summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/gtksymbols.cpp8
-rw-r--r--src/gui/styles/gtksymbols_p.h1
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp563
-rw-r--r--src/gui/styles/qcleanlooksstyle_p.h2
-rw-r--r--src/gui/styles/qcommonstyle.cpp770
-rw-r--r--src/gui/styles/qcommonstyle_p.h13
-rw-r--r--src/gui/styles/qgtkstyle.cpp96
-rw-r--r--src/gui/styles/qgtkstyle.h4
8 files changed, 272 insertions, 1185 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index f947ac1..c8b4fda 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -60,6 +60,7 @@
#include <QtCore/QHash>
#include <private/qapplication_p.h>
+#include <private/qiconloader_p.h>
#include <QtGui/QMenu>
#include <QtGui/QStyle>
@@ -341,9 +342,9 @@ static bool resolveGConf()
typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
-static QString getGConfString(const QString &value)
+QString QGtk::getGConfString(const QString &value, const QString &fallback)
{
- QString retVal;
+ QString retVal = fallback;
if (resolveGConf()) {
g_type_init();
GConfClient* client = QGtk::gconf_client_get_default();
@@ -393,7 +394,7 @@ static QString getThemeName()
// Fall back to gconf
if (themeName.isEmpty() && resolveGConf())
- themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
+ themeName = QGtk::getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
return themeName;
}
@@ -561,6 +562,7 @@ void QGtkStyleUpdateScheduler::updateTheme()
QApplication::sendEvent(widget, &e);
}
}
+ QIconLoader::instance()->updateSystemTheme();
}
static void add_widget(GtkWidget *widget)
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h
index 18c6dc5..68e970a 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/gtksymbols_p.h
@@ -216,6 +216,7 @@ public:
static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
QString *selectedFilter, QFileDialog::Options options);
+ static QString getGConfString(const QString &key, const QString &fallback = QString());
static Ptr_gtk_container_forall gtk_container_forall;
static Ptr_gtk_init gtk_init;
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index 8f88781..1782e36 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -462,26 +462,6 @@ static const char * const qt_cleanlooks_checkbox_checked[] = {
" ",
" "};
-#ifdef Q_WS_X11
-extern "C" {
- struct GConfClient;
- struct GError;
- typedef void (*Ptr_g_type_init)();
- typedef GConfClient* (*Ptr_gconf_client_get_default)();
- typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
- typedef void (*Ptr_g_object_unref)(void *);
- typedef void (*Ptr_g_error_free)(GError *);
- typedef void (*Ptr_g_free)(void*);
-}
-
-static Ptr_g_type_init p_g_type_init = 0;
-static Ptr_gconf_client_get_default p_gconf_client_get_default = 0;
-static Ptr_gconf_client_get_string p_gconf_client_get_string = 0;
-static Ptr_g_object_unref p_g_object_unref = 0;
-static Ptr_g_error_free p_g_error_free = 0;
-static Ptr_g_free p_g_free = 0;
-#endif
-
static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
const QColor &gradientStop, Direction direction = TopDown, QBrush bgBrush = QBrush())
{
@@ -3848,17 +3828,6 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *
void QCleanlooksStyle::polish(QApplication *app)
{
QWindowsStyle::polish(app);
-#ifdef Q_WS_X11
- Q_D(QCleanlooksStyle);
-
- QString dataDirs = QLatin1String(getenv("XDG_DATA_DIRS"));
-
- if (dataDirs.isEmpty())
- dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
-
- dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
- d->iconDirs = dataDirs.split(QLatin1Char(':'));
-#endif
}
/*!
@@ -4376,44 +4345,6 @@ QRect QCleanlooksStyle::subElementRect(SubElement sr, const QStyleOption *opt, c
return r;
}
-void QCleanlooksStylePrivate::lookupIconTheme() const
-{
-#ifdef Q_WS_X11
-
- if (themeName.isEmpty()) {
- //resolve glib and gconf functions
- p_g_type_init = (Ptr_g_type_init)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_type_init");
- p_gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_default");
- p_gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_string");
- p_g_object_unref = (Ptr_g_object_unref)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_object_unref");
- p_g_error_free = (Ptr_g_error_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_error_free");
- p_g_free = (Ptr_g_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_free");
-
- if (p_g_type_init &&
- p_gconf_client_get_default &&
- p_gconf_client_get_string &&
- p_g_object_unref &&
- p_g_error_free &&
- p_g_free) {
-
- p_g_type_init();
- GConfClient* client = p_gconf_client_get_default();
- GError *err = 0;
- char *str = p_gconf_client_get_string(client, "/desktop/gnome/interface/icon_theme", &err);
- if (!err) {
- themeName = QString::fromUtf8(str);
- p_g_free(str);
- }
- p_g_object_unref(client);
- if (err)
- p_g_error_free (err);
- }
- if (themeName.isEmpty())
- themeName = QLatin1String("gnome");
- }
-#endif
-}
-
/*!
\internal
*/
@@ -4421,165 +4352,6 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon,
const QStyleOption *option,
const QWidget *widget) const
{
-#ifdef Q_WS_X11
- Q_D(const QCleanlooksStyle);
- if (!QApplication::desktopSettingsAware())
- return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
- QIcon icon;
- QPixmap pixmap;
- QPixmap link;
- d->lookupIconTheme();
- switch (standardIcon) {
- case SP_DirIcon: {
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- icon.addPixmap(proxy()->standardPixmap(SP_DirClosedIcon, option, widget),
- QIcon::Normal, QIcon::Off);
- pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png"));
- if (!pixmap.isNull())
- icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
- pixmap = d->findIcon(48, QLatin1String("gnome-fs-directory.png"));
- if (!pixmap.isNull())
- icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
- pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory-accept.png"));
- if (!pixmap.isNull())
- icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
- pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory-accept.png"));
- if (!pixmap.isNull())
- icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);
- }
- break;
- case SP_DirLinkIcon:
- {
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png"));
- if (!link.isNull()) {
- icon.addPixmap(proxy()->standardPixmap(SP_DirLinkIcon, option, widget));
- pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png"));
- if (!pixmap.isNull()) {
- QPainter painter(&pixmap);
- painter.drawPixmap(8, 8, 8, 8, link);
- painter.end();
- icon.addPixmap(pixmap);
- }
- }
- break;
- }
- case SP_FileIcon:
- {
- icon = d->createIcon(QLatin1String("unknown.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("gnome-fs-regular.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("stock_new.png"));
- break;
- }
- case SP_DialogCloseButton:
- {
- icon = d->createIcon(QLatin1String("gtk-close.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("stock-close.png"));
- break;
- }
- case SP_DirHomeIcon:
- {
- icon = d->createIcon(QLatin1String("folder_home.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("gnome_home.png"));
- break;
- }
- case SP_DriveFDIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-dev-floppy.png"));
- break;
- }
- case SP_ComputerIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-fs-client.png"));
- break;
- }
- case SP_DesktopIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-fs-desktop.png"));
- break;
- }
- case SP_TrashIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-fs-trash-empty.png"));
- break;
- }
- case SP_DriveCDIcon:
- case SP_DriveDVDIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-dev-cdrom.png"));
- break;
- }
- case SP_DriveHDIcon:
- {
- icon = d->createIcon(QLatin1String("gnome-dev-harddisk.png"));
- break;
- }
- case SP_ArrowUp:
- {
- icon = d->createIcon(QLatin1String("stock_up.png"));
- break;
- }
- case SP_ArrowDown:
- {
- icon = d->createIcon(QLatin1String("stock_down.png"));
- break;
- }
- case SP_ArrowRight:
- {
- icon = d->createIcon(QLatin1String("stock_right.png"));
- break;
- }
- case SP_ArrowLeft:
- {
- icon = d->createIcon(QLatin1String("stock_left.png"));
- break;
- }
- case SP_BrowserReload:
- {
- icon = d->createIcon(QLatin1String("view-refresh.png"));
- break;
- }
- case SP_BrowserStop:
- {
- pixmap = d->findIcon(24, QLatin1String("stop.png"));
- break;
- }
- case SP_FileLinkIcon:
- {
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png"));
- if (!link.isNull()) {
- icon.addPixmap(proxy()->standardPixmap(SP_FileLinkIcon,option, widget));
- pixmap = d->findIcon(16, QLatin1String("unknown.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("stock_new.png"));
- if (!pixmap.isNull()) {
- QPainter painter(&pixmap);
- painter.drawPixmap(8, 8, 8, 8, link);
- painter.end();
- icon.addPixmap(pixmap);
- }
- }
- break;
- }
- case SP_ArrowForward:
- if (QApplication::layoutDirection() == Qt::RightToLeft)
- return standardIconImplementation(SP_ArrowLeft, option, widget);
- return standardIconImplementation(SP_ArrowRight, option, widget);
- case SP_ArrowBack:
- if (QApplication::layoutDirection() == Qt::RightToLeft)
- return standardIconImplementation(SP_ArrowRight, option, widget);
- return standardIconImplementation(SP_ArrowLeft, option, widget);
- default:
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- }
- if (!icon.isNull())
- return icon;
-#endif // Q_WS_X11
return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);
}
@@ -4589,341 +4361,10 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon,
QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
-#ifdef Q_WS_X11
- Q_D(const QCleanlooksStyle);
QPixmap pixmap;
- if (!QApplication::desktopSettingsAware())
- return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
- d->lookupIconTheme();
+
#ifndef QT_NO_IMAGEFORMAT_XPM
switch (standardPixmap) {
- case SP_MessageBoxInformation:
- {
- pixmap = d->findIcon(48, QLatin1String("dialog-info.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(48, QLatin1String("stock_dialog-info.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MessageBoxWarning:
- {
- pixmap = d->findIcon(48, QLatin1String("dialog-warning.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(48, QLatin1String("stock_dialog-warning.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MessageBoxCritical:
- {
- pixmap = d->findIcon(48, QLatin1String("dialog-error.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(48, QLatin1String("stock_dialog-error.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MessageBoxQuestion:
- {
- pixmap = d->findIcon(48, QLatin1String("dialog-question.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DirHomeIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("folder_home.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("gnome_home.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogOpenButton:
- case SP_DirOpenIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("stock_open.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_FileIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("unknown.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("gnome-fs-regular.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("stock_new.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_FileLinkIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("emblem-symbolic-link.png"));
- if (!pixmap.isNull()) {
- QPixmap fileIcon = d->findIcon(24, QLatin1String("unknown.png"));
- if (fileIcon.isNull())
- fileIcon = d->findIcon(24, QLatin1String("stock_new.png"));
- if (!fileIcon.isNull()) {
- QPainter painter(&fileIcon);
- painter.setRenderHint(QPainter::SmoothPixmapTransform);
- painter.drawPixmap(12, 12, 12, 12, pixmap);
- return fileIcon;
- }
- }
- break;
- }
- case SP_DirClosedIcon:
- case SP_DirIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-fs-directory.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DirLinkIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("emblem-symbolic-link.png"));
- if (!pixmap.isNull()) {
- QPixmap dirIcon = d->findIcon(24, QLatin1String("gnome-fs-directory.png"));
- if (!dirIcon.isNull()) {
- QPainter painter(&dirIcon);
- painter.setRenderHint(QPainter::SmoothPixmapTransform);
- painter.drawPixmap(12, 12, 12, 12, pixmap);
- return dirIcon;
- }
- }
- break;
- }
- case SP_DriveFDIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-dev-floppy.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_ComputerIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-fs-client.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DesktopIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-fs-desktop.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_TrashIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-fs-trash-empty.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DriveCDIcon:
- case SP_DriveDVDIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-dev-cdrom.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DriveHDIcon:
- {
- pixmap = d->findIcon(24, QLatin1String("gnome-dev-harddisk.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_FileDialogToParent:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_up.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_FileDialogNewFolder:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_new-dir.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_ArrowUp:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_up.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_ArrowDown:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_down.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_ArrowRight:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_right.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_ArrowLeft:
- {
- pixmap = d->findIcon(16, QLatin1String("stock_left.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogCloseButton:
- {
- pixmap = d->findIcon(24, QLatin1String("gtk-close.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("stock-close.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogApplyButton:
- {
- pixmap = d->findIcon(24, QLatin1String("dialog-apply.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("stock-apply.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogResetButton:
- {
- pixmap = d->findIcon(24, QLatin1String("gtk-clear.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogHelpButton:
- {
- pixmap = d->findIcon(24, QLatin1String("gtk-help.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogOkButton:
- {
- pixmap = d->findIcon(24, QLatin1String("dialog-ok.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("stock-ok.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogCancelButton:
- {
- pixmap = d->findIcon(24, QLatin1String("dialog-cancel.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("stock-cancel.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(24, QLatin1String("process-stop.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_DialogSaveButton:
- {
- pixmap = d->findIcon(24, QLatin1String("stock_save.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_BrowserStop:
- {
- pixmap = d->findIcon(16, QLatin1String("process-stop.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_BrowserReload:
- {
- pixmap = d->findIcon(16, QLatin1String("view-refresh.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaPlay:
- {
- pixmap = d->findIcon(24, QLatin1String("media-playback-start.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaPause:
- {
- pixmap = d->findIcon(24, QLatin1String("media-playback-pause.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaStop:
- {
- pixmap = d->findIcon(24, QLatin1String("media-playback-stop.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaVolume:
- {
- pixmap = d->findIcon(16, QLatin1String("audio-volume-medium.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaVolumeMuted:
- {
- pixmap = d->findIcon(16, QLatin1String("audio-volume-muted.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaSeekForward:
- {
- pixmap = d->findIcon(24, QLatin1String("media-seek-forward.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaSeekBackward:
- {
- pixmap = d->findIcon(24, QLatin1String("media-seek-backward.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaSkipForward:
- {
- pixmap = d->findIcon(24, QLatin1String("media-skip-forward.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_MediaSkipBackward:
- {
- pixmap = d->findIcon(24, QLatin1String("media-skip-backward.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_TitleBarMenuButton:
- case SP_TitleBarShadeButton:
- case SP_TitleBarUnshadeButton:
- case SP_TitleBarMaxButton:
- case SP_TitleBarContextHelpButton:
- return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
case SP_TitleBarNormalButton:
return QPixmap((const char **)dock_widget_restore_xpm);
case SP_TitleBarMinButton:
@@ -4936,7 +4377,7 @@ QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QS
break;
}
#endif //QT_NO_IMAGEFORMAT_XPM
-#endif //Q_WS_X11
+
return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
}
diff --git a/src/gui/styles/qcleanlooksstyle_p.h b/src/gui/styles/qcleanlooksstyle_p.h
index a26d40d..d325499 100644
--- a/src/gui/styles/qcleanlooksstyle_p.h
+++ b/src/gui/styles/qcleanlooksstyle_p.h
@@ -71,8 +71,6 @@ public:
~QCleanlooksStylePrivate() {
}
-
- void lookupIconTheme() const;
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index c7feb25..3878856 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -840,176 +840,8 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
#endif // QT_NO_TOOLBUTTON
-
#ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec
-void QCommonStylePrivate::lookupIconTheme() const
-{
- if (!themeName.isEmpty())
- return;
-
- QString dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS"));
- if (dataDirs.isEmpty())
- dataDirs = QLatin1String("/usr/local/share/:/usr/share/");
- dataDirs += QLatin1Char(':') + QKde::kdeHome() + QLatin1String("/share");
- dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));
- QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts);
- foreach (const QString &dirName, kdeDirs)
- dataDirs.append(QLatin1Char(':') + dirName + QLatin1String("/share"));
- iconDirs = dataDirs.split(QLatin1Char(':'));
-
- QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
- QDir dir(fileInfo.canonicalFilePath());
- QString kdeDefault = (X11->desktopEnvironment != DE_KDE || X11->desktopVersion >= 4)
- ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");
- QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault;
- QSettings settings(QKde::kdeHome() +
- QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);
- settings.beginGroup(QLatin1String("Icons"));
- themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString();
-}
-
-QIconTheme QCommonStylePrivate::parseIndexFile(const QString &themeName) const
-{
- Q_Q(const QCommonStyle);
- QIconTheme theme;
- QFile themeIndex;
- QStringList parents;
- QHash <int, QString> dirList;
-
- for ( int i = 0 ; i < iconDirs.size() && !themeIndex.exists() ; ++i) {
- QString contentDir = QLatin1String(iconDirs[i].startsWith(QDir::homePath()) ?
- "/.icons/" : "/icons/");
- themeIndex.setFileName(iconDirs[i] + contentDir +
- themeName + QLatin1String("/index.theme"));
- }
-
- if (themeIndex.open(QIODevice::ReadOnly | QIODevice::Text)) {
-
- QTextStream in(&themeIndex);
-
- while (!in.atEnd()) {
-
- QString line = in.readLine();
-
- if (line.startsWith(QLatin1String("Inherits="))) {
- line = line.right(line.length() - 9);
- parents = line.split(QLatin1Char(','));
- }
-
- if (line.startsWith(QLatin1Char('['))) {
- line = line.trimmed();
- line.chop(1);
- QString dirName = line.right(line.length() - 1);
- if (!in.atEnd()) {
- line = in.readLine();
- int size;
- if (line.startsWith(QLatin1String("Size="))) {
- size = line.right(line.length() - 5).toInt();
- if (size)
- dirList.insertMulti(size, dirName);
- }
- }
- }
- }
- }
-
- if (q->inherits("QPlastiqueStyle")) {
- QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));
- QDir dir(fileInfo.canonicalFilePath());
- QString defaultKDETheme = dir.exists() ? dir.dirName() : QString::fromLatin1("crystalsvg");
- if (!parents.contains(defaultKDETheme) && themeName != defaultKDETheme)
- parents.append(defaultKDETheme);
- } else if (parents.isEmpty() && themeName != QLatin1String("hicolor")) {
- parents.append(QLatin1String("hicolor"));
- }
- theme = QIconTheme(dirList, parents);
- return theme;
-}
-
-QPixmap QCommonStylePrivate::findIconHelper(int size,
- const QString &themeName,
- const QString &iconName,
- QStringList &visited) const
-{
- QPixmap pixmap;
-
- if (!themeName.isEmpty()) {
-
- visited << themeName;
- QIconTheme theme = themeList.value(themeName);
-
- if (!theme.isValid()) {
- theme = parseIndexFile(themeName);
- themeList.insert(themeName, theme);
- }
-
- if (!theme.isValid())
- return QPixmap();
-
- QList <QString> subDirs = theme.dirList().values(size);
-
- for ( int i = 0 ; i < iconDirs.size() ; ++i) {
- for ( int j = 0 ; j < subDirs.size() ; ++j) {
- QString contentDir = (iconDirs[i].startsWith(QDir::homePath())) ?
- QLatin1String("/.icons/") : QLatin1String("/icons/");
- QString fileName = iconDirs[i] + contentDir + themeName + QLatin1Char('/') + subDirs[j] + QLatin1Char('/') + iconName;
- QFile file(fileName);
- if (file.exists())
- pixmap.load(fileName);
- if (!pixmap.isNull())
- break;
- }
- }
-
- if (pixmap.isNull()) {
- QStringList parents = theme.parents();
- //search recursively through inherited themes
- for (int i = 0 ; pixmap.isNull() && i < parents.size() ; ++i) {
- QString parentTheme = parents[i].trimmed();
- if (!visited.contains(parentTheme)) //guard against endless recursion
- pixmap = findIconHelper(size, parentTheme, iconName, visited);
- }
- }
- }
- return pixmap;
-}
-
-/*! \internal
- find a pixmap with the given size and name from the freedesktop theme.
-*/
-QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const
-{
- QIcon icon = QKde::kdeIcon(name);
- if (!icon.isNull())
- return icon.pixmap(size);
-
- QPixmap pixmap;
- QString pixmapName = QLatin1String("$qt") + name + QString::number(size);
-
- if (QPixmapCache::find(pixmapName, pixmap))
- return pixmap;
-
- if (!themeName.isEmpty()) {
- QStringList visited;
- pixmap = findIconHelper(size, themeName, name, visited);
- }
- QPixmapCache::insert(pixmapName, pixmap);
- return pixmap;
-}
-/*! \internal
- create an Icon from the freedesktop theme.
- */
-QIcon QCommonStylePrivate::createIcon(const QString &name) const
-{
- QIcon icon = QKde::kdeIcon(name);
- if (icon.isNull()) {
- icon.addPixmap(findIcon(16, name));
- icon.addPixmap(findIcon(24, name));
- icon.addPixmap(findIcon(32, name));
- }
- return icon;
-}
/*!internal
Checks if you are running KDE and looks up the toolbar
@@ -4859,8 +4691,24 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
ret = int(QStyleHelper::dpiScaled(6.));
break;
- case PM_TabBarIconSize:
case PM_ToolBarIconSize:
+#ifdef Q_WS_X11
+ if (X11->desktopVersion >= 4) {
+ static int iconSize = 0;
+ if (!iconSize) {
+ QSettings settings(QKde::kdeHome() +
+ QLatin1String("/share/config/kdeglobals"),
+ QSettings::IniFormat);
+ settings.beginGroup(QLatin1String("ToolbarIcons"));
+ iconSize = settings.value(QLatin1String("Size"), QLatin1String("22")).toInt();
+ }
+ ret = iconSize;
+ } else
+#endif
+ ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
+ break;
+
+ case PM_TabBarIconSize:
case PM_ListViewIconSize:
ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
break;
@@ -5371,293 +5219,161 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
Q_UNUSED(widget);
Q_UNUSED(sp);
#else
-#ifdef Q_WS_X11
- Q_D(const QCommonStyle);
QPixmap pixmap;
- if (QApplication::desktopSettingsAware()) {
- d->lookupIconTheme();
+
+ if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) {
switch (sp) {
case SP_DirHomeIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("folder_home.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("user-home")).pixmap(16);
+ break;
case SP_MessageBoxInformation:
- {
- pixmap = d->findIcon(32, QLatin1String("messagebox_info.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("messagebox_info")).pixmap(16);
+ break;
case SP_MessageBoxWarning:
- {
- pixmap = d->findIcon(32, QLatin1String("messagebox_warning.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("messagebox_warning")).pixmap(16);
+ break;
case SP_MessageBoxCritical:
- {
- pixmap = d->findIcon(32, QLatin1String("messagebox_critical.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("messagebox_critical")).pixmap(16);
+ break;
case SP_MessageBoxQuestion:
- {
- pixmap = d->findIcon(32, QLatin1String("help.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("help")).pixmap(16);
+ break;
case SP_DialogOpenButton:
case SP_DirOpenIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("folder-open.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("folder_open.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("folder-open")).pixmap(16);
+ break;
case SP_FileIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("text-x-generic.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("empty.png"));
- if (!pixmap.isNull())
- return pixmap;
- break;
- }
- case SP_FileLinkIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("link_overlay.png"));
- if (!pixmap.isNull()) {
- QPixmap fileIcon = d->findIcon(16, QLatin1String("text-x-generic.png"));
- if (fileIcon.isNull())
- fileIcon = d->findIcon(16, QLatin1String("empty.png"));
- if (!fileIcon.isNull()) {
- QPainter painter(&fileIcon);
- painter.drawPixmap(0, 0, 16, 16, pixmap);
- return fileIcon;
- }
- }
- break;
- }
+ pixmap = QIcon::fromTheme(QLatin1String("text-x-generic"),
+ QIcon::fromTheme(QLatin1String("empty"))).pixmap(16);
+ break;
case SP_DirClosedIcon:
case SP_DirIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("folder.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("folder")).pixmap(16);
break;
- }
- case SP_DirLinkIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("link_overlay.png"));
- if (!pixmap.isNull()) {
- QPixmap dirIcon = d->findIcon(16, QLatin1String("folder.png"));
- if (!dirIcon.isNull()) {
- QPainter painter(&dirIcon);
- painter.drawPixmap(0, 0, 16, 16, pixmap);
- return dirIcon;
- }
- }
- break;
- }
case SP_DriveFDIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("media-floppy.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("3floppy_unmount.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-floppy"),
+ QIcon::fromTheme(QLatin1String("3floppy_unmount"))).pixmap(16);
break;
- }
case SP_ComputerIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("computer.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("system.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("computer"),
+ QIcon::fromTheme(QLatin1String("system"))).pixmap(16);
break;
- }
case SP_DesktopIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("user-desktop.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("desktop.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("user-desktop"),
+ QIcon::fromTheme(QLatin1String("desktop"))).pixmap(16);
break;
- }
case SP_TrashIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("user-trash.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("trashcan_empty.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("user-trash"),
+ QIcon::fromTheme(QLatin1String("trashcan_empty"))).pixmap(16);
break;
- }
case SP_DriveCDIcon:
case SP_DriveDVDIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("media-optical.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("cdrom_unmount.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-optical"),
+ QIcon::fromTheme(QLatin1String("cdrom_unmount"))).pixmap(16);
break;
- }
case SP_DriveHDIcon:
- {
- pixmap = d->findIcon(16, QLatin1String("drive-harddisk.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(16, QLatin1String("hdd_unmount.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("drive-harddisk"),
+ QIcon::fromTheme(QLatin1String("hdd_unmount"))).pixmap(16);
break;
- }
case SP_FileDialogToParent:
- {
- pixmap = d->findIcon(32, QLatin1String("go-up.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(32, QLatin1String("up.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("go-up"),
+ QIcon::fromTheme(QLatin1String("up"))).pixmap(16);
break;
- }
case SP_FileDialogNewFolder:
- {
- pixmap = d->findIcon(16, QLatin1String("folder_new.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("folder_new")).pixmap(16);
break;
- }
case SP_ArrowUp:
- {
- pixmap = d->findIcon(32, QLatin1String("go-up.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(32, QLatin1String("up.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("go-up"),
+ QIcon::fromTheme(QLatin1String("up"))).pixmap(16);
break;
- }
case SP_ArrowDown:
- {
- pixmap = d->findIcon(32, QLatin1String("go-down.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(32, QLatin1String("down.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("go-down"),
+ QIcon::fromTheme(QLatin1String("down"))).pixmap(16);
break;
- }
case SP_ArrowRight:
- {
- pixmap = d->findIcon(32, QLatin1String("go-next.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(32, QLatin1String("forward.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("go-next"),
+ QIcon::fromTheme(QLatin1String("forward"))).pixmap(16);
break;
- }
case SP_ArrowLeft:
- {
- pixmap = d->findIcon(32, QLatin1String("go-previous.png"));
- if (pixmap.isNull())
- pixmap = d->findIcon(32, QLatin1String("back.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("go-previous"),
+ QIcon::fromTheme(QLatin1String("back"))).pixmap(16);
break;
- }
case SP_FileDialogDetailedView:
- {
- pixmap = d->findIcon(16, QLatin1String("view_detailed.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("view_detailed")).pixmap(16);
break;
- }
-
case SP_FileDialogListView:
- {
- pixmap = d->findIcon(16, QLatin1String("view_icon.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("view_icon")).pixmap(16);
break;
- }
case SP_BrowserReload:
- {
- pixmap = d->findIcon(32, QLatin1String("reload.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("reload")).pixmap(16);
break;
- }
case SP_BrowserStop:
- {
- pixmap = d->findIcon(32, QLatin1String("stop.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("process-stop")).pixmap(16);
break;
- }
case SP_MediaPlay:
- {
- pixmap = d->findIcon(16, QLatin1String("player_play.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-playback-start")).pixmap(16);
break;
- }
case SP_MediaPause:
- {
- pixmap = d->findIcon(16, QLatin1String("player_pause.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-playback-pause")).pixmap(16);
break;
- }
case SP_MediaStop:
- {
- pixmap = d->findIcon(16, QLatin1String("player_stop.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-playback-stop")).pixmap(16);
break;
- }
case SP_MediaSeekForward:
- {
- pixmap = d->findIcon(16, QLatin1String("player_fwd.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-seek-forward")).pixmap(16);
break;
- }
case SP_MediaSeekBackward:
- {
- pixmap = d->findIcon(16, QLatin1String("player_rew.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16);
break;
- }
case SP_MediaSkipForward:
- {
- pixmap = d->findIcon(16, QLatin1String("player_end.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16);
break;
- }
case SP_MediaSkipBackward:
- {
- pixmap = d->findIcon(16, QLatin1String("player_start.png"));
- if (!pixmap.isNull())
- return pixmap;
+ pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16);
+ break;
+ case SP_DialogResetButton:
+ pixmap = QIcon::fromTheme(QLatin1String("edit-clear")).pixmap(24);
+ break;
+ case SP_DialogHelpButton:
+ pixmap = QIcon::fromTheme(QLatin1String("help-contents")).pixmap(24);
+ break;
+ case SP_DialogCancelButton:
+ pixmap = QIcon::fromTheme(QLatin1String("process-stop")).pixmap(24);
+ break;
+ case SP_DialogSaveButton:
+ pixmap = QIcon::fromTheme(QLatin1String("document-save")).pixmap(24);
break;
+ case SP_FileLinkIcon:
+ pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16);
+ if (!pixmap.isNull()) {
+ QPixmap fileIcon = QIcon::fromTheme(QLatin1String("text-x-generic")).pixmap(16);
+ if (fileIcon.isNull())
+ fileIcon = QIcon::fromTheme(QLatin1String("empty")).pixmap(16);
+ if (!fileIcon.isNull()) {
+ QPainter painter(&fileIcon);
+ painter.drawPixmap(0, 0, 16, 16, pixmap);
+ return fileIcon;
+ }
}
-
+ break;
+ case SP_DirLinkIcon:
+ pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16);
+ if (!pixmap.isNull()) {
+ QPixmap dirIcon = QIcon::fromTheme(QLatin1String("folder")).pixmap(16);
+ if (!dirIcon.isNull()) {
+ QPainter painter(&dirIcon);
+ painter.drawPixmap(0, 0, 16, 16, pixmap);
+ return dirIcon;
+ }
+ }
+ break;
default:
break;
}
}
-#endif //Q_WS_X11
+
+ if (!pixmap.isNull())
+ return pixmap;
#endif //QT_NO_IMAGEFORMAT_PNG
switch (sp) {
#ifndef QT_NO_IMAGEFORMAT_XPM
@@ -5793,254 +5509,178 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons
const QWidget *widget) const
{
QIcon icon;
- if (QApplication::desktopSettingsAware()) {
-#ifdef Q_WS_X11
- Q_D(const QCommonStyle);
- d->lookupIconTheme();
- QPixmap pixmap;
+ if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) {
switch (standardIcon) {
case SP_DirHomeIcon:
- {
- icon = d->createIcon(QLatin1String("folder_home.png"));
+ icon = QIcon::fromTheme(QLatin1String("user-home"));
break;
- }
case SP_MessageBoxInformation:
- {
- icon = d->createIcon(QLatin1String("dialog-information.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("messagebox_info.png"));
+ icon = QIcon::fromTheme(QLatin1String("dialog-information"));
break;
- }
case SP_MessageBoxWarning:
- {
- icon = d->createIcon(QLatin1String("dialog-warning.png"));
- icon = d->createIcon(QLatin1String("dialog-warning.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("messagebox_warning.png"));
+ icon = QIcon::fromTheme(QLatin1String("dialog-warning"));
break;
- }
case SP_MessageBoxCritical:
- {
- icon = d->createIcon(QLatin1String("dialog-error.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("messagebox_critical.png"));
+ icon = QIcon::fromTheme(QLatin1String("dialog-error"));
break;
- }
case SP_MessageBoxQuestion:
- {
- icon = d->createIcon(QLatin1String("help.png"));
+ icon = QIcon::fromTheme(QLatin1String("dialog-question"));
break;
- }
case SP_DialogOpenButton:
case SP_DirOpenIcon:
- {
- icon = d->createIcon(QLatin1String("folder-open.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("folder_open.png"));
+ icon = QIcon::fromTheme(QLatin1String("folder-open"));
break;
- }
case SP_FileIcon:
- {
- icon = d->createIcon(QLatin1String("text-x-generic.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("empty.png"));
+ icon = QIcon::fromTheme(QLatin1String("text-x-generic"));
break;
- }
case SP_DirClosedIcon:
case SP_DirIcon:
- {
- icon = d->createIcon(QLatin1String("folder.png"));
+ icon = QIcon::fromTheme(QLatin1String("folder"));
break;
- }
case SP_DriveFDIcon:
- {
- icon = d->createIcon(QLatin1String("floppy_unmount.png"));
+ icon = QIcon::fromTheme(QLatin1String("floppy_unmount"));
break;
- }
case SP_ComputerIcon:
- {
- icon = d->createIcon(QLatin1String("computer.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("system.png"));
+ icon = QIcon::fromTheme(QLatin1String("computer"),
+ QIcon::fromTheme(QLatin1String("system")));
break;
- }
case SP_DesktopIcon:
- {
- icon = d->createIcon(QLatin1String("user-desktop.png"));
+ icon = QIcon::fromTheme(QLatin1String("user-desktop"));
break;
- }
case SP_TrashIcon:
- {
- icon = d->createIcon(QLatin1String("user-trash.png"));
+ icon = QIcon::fromTheme(QLatin1String("user-trash"));
break;
- }
case SP_DriveCDIcon:
case SP_DriveDVDIcon:
- {
- icon = d->createIcon(QLatin1String("media-optical.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("cdrom_unmount.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-optical"));
break;
- }
case SP_DriveHDIcon:
- {
- icon = d->createIcon(QLatin1String("drive-harddisk.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("hdd_unmount.png"));
+ icon = QIcon::fromTheme(QLatin1String("drive-harddisk"));
break;
- }
case SP_FileDialogToParent:
- {
- icon = d->createIcon(QLatin1String("go-up.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("up.png"));
+ icon = QIcon::fromTheme(QLatin1String("go-up"));
break;
- }
case SP_FileDialogNewFolder:
- {
- icon = d->createIcon(QLatin1String("folder_new.png"));
+ icon = QIcon::fromTheme(QLatin1String("folder-new"));
break;
- }
case SP_ArrowUp:
- {
- icon = d->createIcon(QLatin1String("go-up.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("up.png"));
+ icon = QIcon::fromTheme(QLatin1String("go-up"));
break;
- }
case SP_ArrowDown:
- {
- icon = d->createIcon(QLatin1String("go-down.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("down.png"));
+ icon = QIcon::fromTheme(QLatin1String("go-down"));
break;
- }
case SP_ArrowRight:
- {
- icon = d->createIcon(QLatin1String("go-next.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("forward.png"));
+ icon = QIcon::fromTheme(QLatin1String("go-next"));
break;
- }
case SP_ArrowLeft:
- {
- icon = d->createIcon(QLatin1String("go-previous.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("back.png"));
+ icon = QIcon::fromTheme(QLatin1String("go-previous"));
+ break;
+ case SP_DialogHelpButton:
+ icon = QIcon::fromTheme(QLatin1String("help-contents"));
+ break;
+ case SP_DialogCancelButton:
+ icon = QIcon::fromTheme(QLatin1String("process-stop"));
+ break;
+ case SP_DialogCloseButton:
+ icon = QIcon::fromTheme(QLatin1String("window-close"));
+ break;
+ case SP_DialogApplyButton:
+ icon = QIcon::fromTheme(QLatin1String("dialog-ok-apply"));
+ break;
+ case SP_DialogOkButton:
+ icon = QIcon::fromTheme(QLatin1String("dialog-ok"));
break;
- }
case SP_FileDialogDetailedView:
- {
- icon = d->createIcon(QLatin1String("view-list-details.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("view_detailed.png"));
+ icon = QIcon::fromTheme(QLatin1String("view-list-details"));
break;
- }
case SP_FileDialogListView:
- {
- icon = d->createIcon(QLatin1String("view-list-icons.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("view_icon.png"));
+ icon = QIcon::fromTheme(QLatin1String("view-list-icons"));
break;
- }
case SP_BrowserReload:
- {
- icon = d->createIcon(QLatin1String("view-refresh.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("reload.png"));
+ icon = QIcon::fromTheme(QLatin1String("view-refresh"));
break;
- }
case SP_BrowserStop:
- {
- icon = d->createIcon(QLatin1String("process-stop.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("stop.png"));
+ icon = QIcon::fromTheme(QLatin1String("process-stop"));
break;
- }
case SP_MediaPlay:
- {
- icon = d->createIcon(QLatin1String("media-playback-start.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_play.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-playback-start"));
break;
- }
case SP_MediaPause:
- {
- icon = d->createIcon(QLatin1String("media-playback-pause.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_pause.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-playback-pause"));
break;
- }
case SP_MediaStop:
- {
- icon = d->createIcon(QLatin1String("media-playback-stop.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_stop.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-playback-stop"));
break;
- }
case SP_MediaSeekForward:
- {
- icon = d->createIcon(QLatin1String("media-skip-forward.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_fwd.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-seek-forward"));
break;
- }
case SP_MediaSeekBackward:
- {
- icon = d->createIcon(QLatin1String("media-skip-backward.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_rew.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-seek-backward"));
break;
- }
case SP_MediaSkipForward:
- {
- icon = d->createIcon(QLatin1String("media-skip-forward.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_end.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-skip-forward"));
break;
- }
case SP_MediaSkipBackward:
- {
- icon = d->createIcon(QLatin1String("media-skip-backward.png"));
- if (icon.isNull())
- icon = d->createIcon(QLatin1String("player_start.png"));
+ icon = QIcon::fromTheme(QLatin1String("media-skip-backward"));
break;
- }
-
- case SP_FileLinkIcon: {
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png"));
- if (!pixmap.isNull()) {
- QPixmap fileIcon = d->findIcon(32, QLatin1String("text-x-generic.png"));
- if (fileIcon.isNull())
- fileIcon = d->findIcon(32, QLatin1String("empty.png"));
- if (!fileIcon.isNull()) {
- QPainter painter(&fileIcon);
- painter.drawPixmap(0, 0, 32, 32, pixmap);
- icon.addPixmap(fileIcon);
+ case SP_MediaVolume:
+ icon = QIcon::fromTheme(QLatin1String("audio-volume-medium"));
+ break;
+ case SP_MediaVolumeMuted:
+ icon = QIcon::fromTheme(QLatin1String("audio-volume-muted"));
+ break;
+ case SP_DialogResetButton:
+ icon = QIcon::fromTheme(QLatin1String("edit-clear"));
+ break;
+ case SP_ArrowForward:
+ if (QApplication::layoutDirection() == Qt::RightToLeft)
+ return standardIconImplementation(SP_ArrowLeft, option, widget);
+ return standardIconImplementation(SP_ArrowRight, option, widget);
+ case SP_ArrowBack:
+ if (QApplication::layoutDirection() == Qt::RightToLeft)
+ return standardIconImplementation(SP_ArrowRight, option, widget);
+ return standardIconImplementation(SP_ArrowLeft, option, widget);
+ case SP_FileLinkIcon:
+ {
+ QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link"));
+ if (!linkIcon.isNull()) {
+ QIcon baseIcon = standardIconImplementation(SP_FileIcon, option, widget);
+ const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
+ for (int i = 0 ; i < sizes.size() ; ++i) {
+ int size = sizes[i].width();
+ QPixmap basePixmap = baseIcon.pixmap(size);
+ QPixmap linkPixmap = linkIcon.pixmap(size/2);
+ QPainter painter(&basePixmap);
+ painter.drawPixmap(size/2, size/2, linkPixmap);
+ icon.addPixmap(basePixmap);
+ }
}
}
- }
- break;
- case SP_DirLinkIcon: {
- icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget));
- QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png"));
- if (!pixmap.isNull()) {
- QPixmap fileIcon = d->findIcon(32, QLatin1String("folder.png"));
- if (!fileIcon.isNull()) {
- QPainter painter(&fileIcon);
- painter.drawPixmap(0, 0, 32, 32, pixmap);
- icon.addPixmap(fileIcon);
+ break;
+ case SP_DirLinkIcon:
+ {
+ QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link"));
+ if (!linkIcon.isNull()) {
+ QIcon baseIcon = standardIconImplementation(SP_DirIcon, option, widget);
+ const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off);
+ for (int i = 0 ; i < sizes.size() ; ++i) {
+ int size = sizes[i].width();
+ QPixmap basePixmap = baseIcon.pixmap(size);
+ QPixmap linkPixmap = linkIcon.pixmap(size/2);
+ QPainter painter(&basePixmap);
+ painter.drawPixmap(size/2, size/2, linkPixmap);
+ icon.addPixmap(basePixmap);
+ }
}
- }
}
break;
default:
break;
}
+
if (!icon.isNull())
return icon;
-#elif defined(Q_WS_MAC)
+#if defined(Q_WS_MAC)
OSType iconType = 0;
switch (standardIcon) {
case QStyle::SP_MessageBoxQuestion:
@@ -6131,11 +5771,9 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons
ReleaseIconRef(overlayIcon);
return retIcon;
}
-
-#endif //Q_WS_X11 || Q_WS_MAC
+#endif // Q_WS_MAC
}
-
switch (standardIcon) {
#ifndef QT_NO_IMAGEFORMAT_PNG
case SP_FileDialogNewFolder:
diff --git a/src/gui/styles/qcommonstyle_p.h b/src/gui/styles/qcommonstyle_p.h
index f2af5b2..cff46e6 100644
--- a/src/gui/styles/qcommonstyle_p.h
+++ b/src/gui/styles/qcommonstyle_p.h
@@ -122,20 +122,7 @@ public:
}
#endif
mutable QIcon tabBarcloseButtonIcon;
-
-//icon detection on X11
-#ifdef Q_WS_X11
- void lookupIconTheme() const;
int lookupToolButtonStyle() const;
- QIcon createIcon(const QString &) const;
- QPixmap findIcon(int size, const QString &) const;
- QPixmap findIconHelper(int size, const QString &, const QString &, QStringList &visited) const;
- QIconTheme parseIndexFile(const QString &themeName) const;
- mutable QString themeName;
- mutable QStringList iconDirs;
- mutable QHash <QString, QIconTheme> themeList;
-#endif
-
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 660b4c3..f6d8c88 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -3239,6 +3239,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
return newSize;
}
+
/*! \reimp */
QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
const QWidget *widget) const
@@ -3271,65 +3272,80 @@ QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
}
break;
- case SP_DialogDiscardButton: {
+ case SP_DialogDiscardButton:
return QGtkPainter::getIcon(GTK_STOCK_DELETE);
- }
-
- case SP_DialogOkButton: {
+ case SP_DialogOkButton:
return QGtkPainter::getIcon(GTK_STOCK_OK);
- }
-
- case SP_DialogCancelButton: {
+ case SP_DialogCancelButton:
return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
- }
-
- case SP_DialogYesButton: {
+ case SP_DialogYesButton:
return QGtkPainter::getIcon(GTK_STOCK_YES);
- }
-
- case SP_DialogNoButton: {
+ case SP_DialogNoButton:
return QGtkPainter::getIcon(GTK_STOCK_NO);
- }
-
- case SP_DialogOpenButton: {
+ case SP_DialogOpenButton:
return QGtkPainter::getIcon(GTK_STOCK_OPEN);
- }
-
- case SP_DialogCloseButton: {
+ case SP_DialogCloseButton:
return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
- }
-
- case SP_DialogApplyButton: {
+ case SP_DialogApplyButton:
return QGtkPainter::getIcon(GTK_STOCK_APPLY);
- }
-
- case SP_DialogSaveButton: {
+ case SP_DialogSaveButton:
return QGtkPainter::getIcon(GTK_STOCK_SAVE);
- }
-
- case SP_MessageBoxWarning: {
+ case SP_MessageBoxWarning:
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
- }
-
- case SP_MessageBoxQuestion: {
+ case SP_MessageBoxQuestion:
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
- }
-
- case SP_MessageBoxInformation: {
+ case SP_MessageBoxInformation:
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- }
-
- case SP_MessageBoxCritical: {
+ case SP_MessageBoxCritical:
return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
- }
-
default:
return QCleanlooksStyle::standardPixmap(sp, option, widget);
}
+ return pixmap;
+}
- return QPixmap();
+/*!
+ \internal
+*/
+QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ if (!QGtk::isThemeAvailable())
+ return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
+ switch (standardIcon) {
+ case SP_DialogDiscardButton:
+ return QGtkPainter::getIcon(GTK_STOCK_DELETE);
+ case SP_DialogOkButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OK);
+ case SP_DialogCancelButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
+ case SP_DialogYesButton:
+ return QGtkPainter::getIcon(GTK_STOCK_YES);
+ case SP_DialogNoButton:
+ return QGtkPainter::getIcon(GTK_STOCK_NO);
+ case SP_DialogOpenButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OPEN);
+ case SP_DialogCloseButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
+ case SP_DialogApplyButton:
+ return QGtkPainter::getIcon(GTK_STOCK_APPLY);
+ case SP_DialogSaveButton:
+ return QGtkPainter::getIcon(GTK_STOCK_SAVE);
+ case SP_MessageBoxWarning:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxQuestion:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxInformation:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxCritical:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+ default:
+ return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
+ }
}
+
/*! \reimp */
QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
{
diff --git a/src/gui/styles/qgtkstyle.h b/src/gui/styles/qgtkstyle.h
index e12f175..f12de52 100644
--- a/src/gui/styles/qgtkstyle.h
+++ b/src/gui/styles/qgtkstyle.h
@@ -106,6 +106,10 @@ public:
void unpolish(QWidget *widget);
void unpolish(QApplication *app);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
};