First try getting cursor theme from environment variable

If XCURSOR_THEME and XCURSOR_SIZE are set they are preferred over
reading the values from kcminputrc.

REVIEW: 121923
BUG: 334954
FIXED-IN: 5.2.0
This commit is contained in:
Martin Gräßlin 2015-01-08 15:09:23 +01:00
parent d173ff7412
commit ab4b1ba25a
2 changed files with 24 additions and 6 deletions

View file

@ -76,14 +76,31 @@ Cursor::~Cursor()
void Cursor::loadThemeSettings() void Cursor::loadThemeSettings()
{ {
KConfigGroup mousecfg(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Mouse"); QString themeName = QString::fromUtf8(qgetenv("XCURSOR_THEME"));
m_themeName = mousecfg.readEntry("cursorTheme", "default");
bool ok = false; bool ok = false;
m_themeSize = mousecfg.readEntry("cursorSize", QString("24")).toUInt(&ok); uint themeSize = qgetenv("XCURSOR_SIZE").toUInt(&ok);
if (!ok) { if (!themeName.isEmpty() && ok) {
m_themeSize = 24; updateTheme(themeName, themeSize);
return;
}
// didn't get from environment variables, read from config file
KConfigGroup mousecfg(KSharedConfig::openConfig("kcminputrc", KConfig::NoGlobals), "Mouse");
themeName = mousecfg.readEntry("cursorTheme", "default");
ok = false;
themeSize = mousecfg.readEntry("cursorSize", QString("24")).toUInt(&ok);
if (!ok) {
themeSize = 24;
}
updateTheme(themeName, themeSize);
}
void Cursor::updateTheme(const QString &name, int size)
{
if (m_themeName != name || m_themeSize != size) {
m_themeName = name;
m_themeSize = size;
emit themeChanged();
} }
emit themeChanged();
} }
QPoint Cursor::pos() QPoint Cursor::pos()

View file

@ -192,6 +192,7 @@ private Q_SLOTS:
void loadThemeSettings(); void loadThemeSettings();
private: private:
void updateTheme(const QString &name, int size);
QPoint m_pos; QPoint m_pos;
int m_mousePollingCounter; int m_mousePollingCounter;
int m_cursorTrackingCounter; int m_cursorTrackingCounter;