Changeset View
Changeset View
Standalone View
Standalone View
kcms/lookandfeel/kcm.cpp
Show All 14 Lines | 1 | /* This file is part of the KDE Project | |||
---|---|---|---|---|---|
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "kcm.h" | 21 | #include "kcm.h" | ||
22 | #include "../krdb/krdb.h" | 22 | #include "../krdb/krdb.h" | ||
23 | #include "../cursortheme/xcursor/xcursortheme.h" | | |||
24 | #include "config-kcm.h" | 23 | #include "config-kcm.h" | ||
25 | #include "config-workspace.h" | 24 | #include "config-workspace.h" | ||
26 | #include <klauncher_iface.h> | 25 | #include <klauncher_iface.h> | ||
27 | 26 | | |||
28 | #include <KAboutData> | 27 | #include <KAboutData> | ||
29 | #include <KSharedConfig> | 28 | #include <KSharedConfig> | ||
30 | #include <KGlobalSettings> | 29 | #include <KGlobalSettings> | ||
31 | #include <KIconLoader> | 30 | #include <KIconLoader> | ||
32 | #include <KAutostart> | 31 | #include <KAutostart> | ||
33 | #include <KRun> | 32 | #include <KRun> | ||
34 | #include <KService> | 33 | #include <KService> | ||
35 | 34 | | |||
36 | #include <QDebug> | 35 | #include <QDebug> | ||
37 | #include <QQuickItem> | 36 | #include <QQuickItem> | ||
38 | #include <QQuickWindow> | 37 | #include <QQuickWindow> | ||
39 | #include <QStandardPaths> | 38 | #include <QStandardPaths> | ||
40 | #include <QProcess> | 39 | #include <QProcess> | ||
41 | #include <QStandardItemModel> | 40 | #include <QStandardItemModel> | ||
42 | #include <QX11Info> | 41 | #include <QX11Info> | ||
43 | 42 | | |||
44 | #include <KLocalizedString> | 43 | #include <KLocalizedString> | ||
45 | #include <KPackage/PackageLoader> | 44 | #include <KPackage/PackageLoader> | ||
46 | 45 | | |||
47 | #include <X11/Xlib.h> | 46 | #include <X11/Xlib.h> | ||
48 | #include <X11/Xcursor/Xcursor.h> | | |||
49 | 47 | | |||
50 | #include "lookandfeelsettings.h" | 48 | #include "lookandfeelsettings.h" | ||
51 | 49 | | |||
50 | #ifdef HAVE_XCURSOR | ||||
51 | # include "../cursortheme/xcursor/xcursortheme.h" | ||||
52 | # include <X11/Xcursor/Xcursor.h> | ||||
53 | #endif | ||||
54 | | ||||
52 | #ifdef HAVE_XFIXES | 55 | #ifdef HAVE_XFIXES | ||
53 | # include <X11/extensions/Xfixes.h> | 56 | # include <X11/extensions/Xfixes.h> | ||
54 | #endif | 57 | #endif | ||
55 | 58 | | |||
56 | KCMLookandFeel::KCMLookandFeel(QObject *parent, const QVariantList &args) | 59 | KCMLookandFeel::KCMLookandFeel(QObject *parent, const QVariantList &args) | ||
57 | : KQuickAddons::ManagedConfigModule(parent, args) | 60 | : KQuickAddons::ManagedConfigModule(parent, args) | ||
58 | , m_settings(new LookAndFeelSettings(this)) | 61 | , m_settings(new LookAndFeelSettings(this)) | ||
59 | , m_config(QStringLiteral("kdeglobals")) | 62 | , m_config(QStringLiteral("kdeglobals")) | ||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Line(s) | 464 | if (themeName.isEmpty()) { | |||
462 | return; | 465 | return; | ||
463 | } | 466 | } | ||
464 | 467 | | |||
465 | KConfig config(QStringLiteral("kcminputrc")); | 468 | KConfig config(QStringLiteral("kcminputrc")); | ||
466 | KConfigGroup cg(&config, "Mouse"); | 469 | KConfigGroup cg(&config, "Mouse"); | ||
467 | cg.writeEntry("cursorTheme", themeName); | 470 | cg.writeEntry("cursorTheme", themeName); | ||
468 | cg.sync(); | 471 | cg.sync(); | ||
469 | 472 | | |||
473 | #ifdef HAVE_XCURSOR | ||||
470 | // Require the Xcursor version that shipped with X11R6.9 or greater, since | 474 | // Require the Xcursor version that shipped with X11R6.9 or greater, since | ||
471 | // in previous versions the Xfixes code wasn't enabled due to a bug in the | 475 | // in previous versions the Xfixes code wasn't enabled due to a bug in the | ||
472 | // build system (freedesktop bug #975). | 476 | // build system (freedesktop bug #975). | ||
473 | #if HAVE_XFIXES && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | 477 | #if defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2 && XCURSOR_LIB_VERSION >= 10105 | ||
474 | const int cursorSize = cg.readEntry("cursorSize", 0); | 478 | const int cursorSize = cg.readEntry("cursorSize", 0); | ||
475 | 479 | | |||
476 | QDir themeDir = cursorThemeDir(themeName, 0); | 480 | QDir themeDir = cursorThemeDir(themeName, 0); | ||
477 | 481 | | |||
478 | if (!themeDir.exists()) { | 482 | if (!themeDir.exists()) { | ||
479 | return; | 483 | return; | ||
480 | } | 484 | } | ||
481 | 485 | | |||
Show All 39 Lines | 524 | foreach (const QString &name, names) { | |||
521 | XFixesChangeCursorByName(QX11Info::display(), theme.loadCursor(name, cursorSize), QFile::encodeName(name)); | 525 | XFixesChangeCursorByName(QX11Info::display(), theme.loadCursor(name, cursorSize), QFile::encodeName(name)); | ||
522 | } | 526 | } | ||
523 | 527 | | |||
524 | #else | 528 | #else | ||
525 | KMessageBox::information(this, | 529 | KMessageBox::information(this, | ||
526 | i18n("You have to restart the Plasma session for these changes to take effect."), | 530 | i18n("You have to restart the Plasma session for these changes to take effect."), | ||
527 | i18n("Cursor Settings Changed"), "CursorSettingsChanged"); | 531 | i18n("Cursor Settings Changed"), "CursorSettingsChanged"); | ||
528 | #endif | 532 | #endif | ||
533 | #endif | ||||
529 | } | 534 | } | ||
530 | 535 | | |||
531 | QDir KCMLookandFeel::cursorThemeDir(const QString &theme, const int depth) | 536 | QDir KCMLookandFeel::cursorThemeDir(const QString &theme, const int depth) | ||
532 | { | 537 | { | ||
533 | // Prevent infinite recursion | 538 | // Prevent infinite recursion | ||
534 | if (depth > 10) { | 539 | if (depth > 10) { | ||
535 | return QDir(); | 540 | return QDir(); | ||
536 | } | 541 | } | ||
Show All 37 Lines | |||||
574 | return QDir(); | 579 | return QDir(); | ||
575 | } | 580 | } | ||
576 | 581 | | |||
577 | const QStringList KCMLookandFeel::cursorSearchPaths() | 582 | const QStringList KCMLookandFeel::cursorSearchPaths() | ||
578 | { | 583 | { | ||
579 | if (!m_cursorSearchPaths.isEmpty()) | 584 | if (!m_cursorSearchPaths.isEmpty()) | ||
580 | return m_cursorSearchPaths; | 585 | return m_cursorSearchPaths; | ||
581 | 586 | | |||
587 | #ifdef HAVE_XCURSOR | ||||
582 | #if XCURSOR_LIB_MAJOR == 1 && XCURSOR_LIB_MINOR < 1 | 588 | #if XCURSOR_LIB_MAJOR == 1 && XCURSOR_LIB_MINOR < 1 | ||
583 | // These are the default paths Xcursor will scan for cursor themes | 589 | // These are the default paths Xcursor will scan for cursor themes | ||
584 | QString path("~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons"); | 590 | QString path("~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons"); | ||
585 | 591 | | |||
586 | // If XCURSOR_PATH is set, use that instead of the default path | 592 | // If XCURSOR_PATH is set, use that instead of the default path | ||
587 | char *xcursorPath = std::getenv("XCURSOR_PATH"); | 593 | char *xcursorPath = std::getenv("XCURSOR_PATH"); | ||
588 | if (xcursorPath) | 594 | if (xcursorPath) | ||
589 | path = xcursorPath; | 595 | path = xcursorPath; | ||
Show All 14 Lines | 607 | { | |||
604 | while (j.hasNext()) | 610 | while (j.hasNext()) | ||
605 | if (j.next() == path) | 611 | if (j.next() == path) | ||
606 | j.remove(); | 612 | j.remove(); | ||
607 | } | 613 | } | ||
608 | 614 | | |||
609 | // Expand all occurrences of ~/ to the home dir | 615 | // Expand all occurrences of ~/ to the home dir | ||
610 | m_cursorSearchPaths.replaceInStrings(QRegExp(QStringLiteral("^~\\/")), QDir::home().path() + QLatin1Char('/')); | 616 | m_cursorSearchPaths.replaceInStrings(QRegExp(QStringLiteral("^~\\/")), QDir::home().path() + QLatin1Char('/')); | ||
611 | return m_cursorSearchPaths; | 617 | return m_cursorSearchPaths; | ||
618 | #else | ||||
619 | return QStringList(); | ||||
620 | #endif | ||||
612 | } | 621 | } | ||
613 | 622 | | |||
614 | void KCMLookandFeel::setSplashScreen(const QString &theme) | 623 | void KCMLookandFeel::setSplashScreen(const QString &theme) | ||
615 | { | 624 | { | ||
616 | if (theme.isEmpty()) { | 625 | if (theme.isEmpty()) { | ||
617 | return; | 626 | return; | ||
618 | } | 627 | } | ||
619 | 628 | | |||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |