Qt 4.8
Functions
QKde Namespace Reference

Functions

QString kdeHome ()
 
QPalette kdePalette ()
 
QString kdeStyle ()
 
int kdeToolBarIconSize ()
 
int kdeToolButtonStyle ()
 

Detailed Description

Warning
This function is not part of the public interface. This namespace contains helper function to help KDE integration They are only used if we detect the use of KDE and the KDE platform plugin is not found (old KDE version) Or if the detected KDE version is KDE3

Function Documentation

◆ kdeHome()

QString QKde::kdeHome ( )
Warning
This function is not part of the public interface. Gets the current KDE home path like "/home/troll/.kde"

Definition at line 59 of file qkde.cpp.

Referenced by QGuiPlatformPlugin::iconThemeSearchPaths(), kdePalette(), kdeStyle(), kdeToolBarIconSize(), kdeToolButtonStyle(), QGuiPlatformPlugin::systemIconThemeName(), and QApplicationPrivate::x11_apply_settings().

60 {
61  static QString kdeHomePath;
62  if (kdeHomePath.isEmpty()) {
63  kdeHomePath = QString::fromLocal8Bit(qgetenv("KDEHOME"));
64  if (kdeHomePath.isEmpty()) {
65  QDir homeDir(QDir::homePath());
66  QString kdeConfDir(QLatin1String("/.kde"));
67  if (4 == X11->desktopVersion && homeDir.exists(QLatin1String(".kde4")))
68  kdeConfDir = QLatin1String("/.kde4");
69  kdeHomePath = QDir::homePath() + kdeConfDir;
70  }
71  }
72  return kdeHomePath;
73 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define X11
Definition: qt_x11_p.h:724
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QString homePath()
Returns the absolute path of the user's home directory.
Definition: qdir.cpp:1942

◆ kdePalette()

QPalette QKde::kdePalette ( )
Warning
This function is not part of the public interface. Returns the KDE palette

Definition at line 100 of file qkde.cpp.

Referenced by QGuiPlatformPlugin::palette().

101 {
102  const QSettings theKdeSettings(QKde::kdeHome() +
103  QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
104  QPalette pal;
105 
106  // Setup KDE palette
107  kdeColor(&pal, QPalette::Button, theKdeSettings, QLatin1String("Colors:Button/BackgroundNormal"), QLatin1String("buttonBackground"));
108  kdeColor(&pal, QPalette::Window, theKdeSettings, QLatin1String("Colors:Window/BackgroundNormal"), QLatin1String("background"));
109  kdeColor(&pal, QPalette::Text, theKdeSettings, QLatin1String("Colors:View/ForegroundNormal"), QLatin1String("foreground"));
110  kdeColor(&pal, QPalette::WindowText, theKdeSettings, QLatin1String("Colors:Window/ForegroundNormal"), QLatin1String("windowForeground"));
111  kdeColor(&pal, QPalette::Base, theKdeSettings, QLatin1String("Colors:View/BackgroundNormal"), QLatin1String("windowBackground"));
112  kdeColor(&pal, QPalette::Highlight, theKdeSettings, QLatin1String("Colors:Selection/BackgroundNormal"), QLatin1String("selectBackground"));
113  kdeColor(&pal, QPalette::HighlightedText, theKdeSettings, QLatin1String("Colors:Selection/ForegroundNormal"), QLatin1String("selectForeground"));
114  kdeColor(&pal, QPalette::AlternateBase, theKdeSettings, QLatin1String("Colors:View/BackgroundAlternate"), QLatin1String("alternateBackground"));
115  kdeColor(&pal, QPalette::ButtonText, theKdeSettings, QLatin1String("Colors:Button/ForegroundNormal"), QLatin1String("buttonForeground"));
116  kdeColor(&pal, QPalette::Link, theKdeSettings, QLatin1String("Colors:View/ForegroundLink"), QLatin1String("linkColor"));
117  kdeColor(&pal, QPalette::LinkVisited, theKdeSettings, QLatin1String("Colors:View/ForegroundVisited"), QLatin1String("visitedLinkColor"));
118  //## TODO tooltip color
119 
120  return pal;
121 }
static bool kdeColor(QPalette *pal, QPalette::ColorRole role, const QSettings &kdeSettings, const QString &kde4Key, const QString &kde3Key=QString())
Definition: qkde.cpp:78
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString kdeHome()
Definition: qkde.cpp:59
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ kdeStyle()

QString QKde::kdeStyle ( )
Warning
This function is not part of the public interface. Returns the name of the QStyle to use. (read from the kde config if needed)

Definition at line 127 of file qkde.cpp.

Referenced by QGuiPlatformPlugin::styleName().

128 {
129  if (X11->desktopVersion >= 4) {
130  QSettings kdeSettings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
131  QString style = kdeSettings.value(QLatin1String("widgetStyle"), QLatin1String("Oxygen")).toString();
132 
133  QStringList availableStyles = QStyleFactory::keys();
134  if(availableStyles.contains(style, Qt::CaseInsensitive))
135  return style;
136  }
137 
138  if (X11->use_xrender)
139  return QLatin1String("plastique");
140  else
141  return QLatin1String("windows");
142 }
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define X11
Definition: qt_x11_p.h:724
static QStringList keys()
Returns the list of valid keys, i.e.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QString kdeHome()
Definition: qkde.cpp:59

◆ kdeToolBarIconSize()

int QKde::kdeToolBarIconSize ( )

Definition at line 161 of file qkde.cpp.

Referenced by QGuiPlatformPlugin::platformHint().

162 {
163  static int iconSize = -1;
164  if (iconSize == -1) {
165  QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
167  settings.beginGroup(QLatin1String("ToolbarIcons"));
168  iconSize = settings.value(QLatin1String("Size")).toInt();
169  }
170  return iconSize;
171 }
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString kdeHome()
Definition: qkde.cpp:59

◆ kdeToolButtonStyle()

int QKde::kdeToolButtonStyle ( )

Definition at line 145 of file qkde.cpp.

Referenced by QGuiPlatformPlugin::platformHint().

146 {
147  QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
149  settings.beginGroup(QLatin1String("Toolbar style"));
150  QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString();
151  if (toolbarStyle == QLatin1String("TextBesideIcon"))
153  else if (toolbarStyle == QLatin1String("TextOnly"))
154  return Qt::ToolButtonTextOnly;
155  else if (toolbarStyle == QLatin1String("TextUnderIcon"))
157 
159 }
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString kdeHome()
Definition: qkde.cpp:59