summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2016-03-23 08:29:43 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2016-03-23 08:29:43 +0100
commit8e2d3e3b90d7d35d2c91fc09ab5a9cccac0823e8 (patch)
treefe20315ed91d4babd73df69ece0af1d1550cb40c /src/widgets/styles
parentbf17e30c8e98b311cdee397f1272e70863247ebc (diff)
parentf319b9b43c313dfa306a62c391e767bc6f14bdee (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/images/cleartext-32.pngbin0 -> 410 bytes
-rw-r--r--src/widgets/styles/qcommonstyle.cpp40
-rw-r--r--src/widgets/styles/qstyle.qrc1
3 files changed, 32 insertions, 9 deletions
diff --git a/src/widgets/styles/images/cleartext-32.png b/src/widgets/styles/images/cleartext-32.png
new file mode 100644
index 0000000000..ff5a2b5ec1
--- /dev/null
+++ b/src/widgets/styles/images/cleartext-32.png
Binary files differ
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index c26da68ac9..5ac2293751 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -5237,6 +5237,30 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm)
return result;
}
+static QIcon clearTextIcon(bool rtl)
+{
+ const QString directionalThemeName = rtl
+ ? QStringLiteral("edit-clear-locationbar-ltr") : QStringLiteral("edit-clear-locationbar-rtl");
+ if (QIcon::hasThemeIcon(directionalThemeName))
+ return QIcon::fromTheme(directionalThemeName);
+ const QString themeName = QStringLiteral("edit-clear");
+ if (QIcon::hasThemeIcon(themeName))
+ return QIcon::fromTheme(themeName);
+
+ QIcon icon;
+#ifndef QT_NO_IMAGEFORMAT_PNG
+ QPixmap clearText16(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png"));
+ Q_ASSERT(!clearText16.size().isEmpty());
+ icon.addPixmap(clearText16);
+ QPixmap clearText32(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-32.png"));
+ Q_ASSERT(!clearText32.size().isEmpty());
+ icon.addPixmap(clearText32);
+ clearText32.setDevicePixelRatio(2); // The 32x32 pixmap can also be used for 16x16/devicePixelRatio=2
+ icon.addPixmap(clearText32);
+#endif // !QT_NO_IMAGEFORMAT_PNG
+ return icon;
+}
+
/*! \reimp */
QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
const QWidget *widget) const
@@ -5409,12 +5433,8 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
}
}
break;
- case SP_LineEditClearButton: {
- QString themeName = rtl ? QStringLiteral("edit-clear-locationbar-ltr") : QStringLiteral("edit-clear-locationbar-rtl");
- if (!QIcon::hasThemeIcon(themeName))
- themeName = QStringLiteral("edit-clear");
- pixmap = QIcon::fromTheme(themeName).pixmap(16);
- }
+ case SP_LineEditClearButton:
+ pixmap = clearTextIcon(rtl).pixmap(16);
break;
default:
break;
@@ -5544,8 +5564,6 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-16.png"));
case SP_MediaVolumeMuted:
return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"));
- case SP_LineEditClearButton:
- return QPixmap(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png"));
#endif // QT_NO_IMAGEFORMAT_PNG
default:
break;
@@ -5595,6 +5613,8 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
const QWidget *widget) const
{
QIcon icon;
+ const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
+
#ifdef Q_OS_WIN
switch (standardIcon) {
case SP_DriveCDIcon:
@@ -5634,6 +5654,9 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
}
}
break;
+ case SP_LineEditClearButton:
+ icon = clearTextIcon(rtl);
+ break;
default:
break;
}
@@ -5642,7 +5665,6 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
#endif
- const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) {
switch (standardIcon) {
case SP_DirHomeIcon:
diff --git a/src/widgets/styles/qstyle.qrc b/src/widgets/styles/qstyle.qrc
index c063ec5036..d8c73dd6fa 100644
--- a/src/widgets/styles/qstyle.qrc
+++ b/src/widgets/styles/qstyle.qrc
@@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/qt-project.org/styles/commonstyle">
<file>images/cleartext-16.png</file>
+ <file>images/cleartext-32.png</file>
<file>images/filelink-16.png</file>
<file>images/filelink-32.png</file>
<file>images/filelink-128.png</file>