From b657496a0ba326af0688e9935069139c002849cf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Feb 2016 12:41:11 +0100 Subject: QLineEdit: Use High DPI pixmap for clear button. Add a 32x32-pixmap to the style and factor out a function from QStyle::standardIcon() to assemble the icon. The 32x32 pixmap may also be used for the 16x16 case with devicePixelRatio=2. Change QLineEditIconButton to use QStyle::standardIcon() instead of QStyle::standardPixmap passing the QWindow to obtain the correct pixmap from the icon. Task-number: QTBUG-49374 Change-Id: I9895230f66911752cc13b7212609141610df0977 Reviewed-by: Giuseppe D'Angelo --- src/widgets/styles/images/cleartext-32.png | Bin 0 -> 410 bytes src/widgets/styles/qcommonstyle.cpp | 40 ++++++++++++++++++++++------- src/widgets/styles/qstyle.qrc | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 src/widgets/styles/images/cleartext-32.png (limited to 'src/widgets/styles') 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 Binary files /dev/null and b/src/widgets/styles/images/cleartext-32.png differ diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 355a3d2c3f..748cef20c1 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5198,6 +5198,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 @@ -5370,12 +5394,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; @@ -5505,8 +5525,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; @@ -5556,6 +5574,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: @@ -5597,6 +5617,9 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption icon.addPixmap(pixmap); } break; + case SP_LineEditClearButton: + icon = clearTextIcon(rtl); + break; default: break; } @@ -5605,7 +5628,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 @@ images/cleartext-16.png + images/cleartext-32.png images/filelink-16.png images/filelink-32.png images/filelink-128.png -- cgit v1.2.3 From b7022d782abded800e6759ce91bcd13d22ed4854 Mon Sep 17 00:00:00 2001 From: Marko Kangas Date: Wed, 15 Apr 2015 16:29:54 +0300 Subject: Fix Fusion style combobox dirty lines in HiDPI mode. Tuned combobox item highlight outline to avoid dirty lines when painting in HiDPI mode. Task-number: QTBUG-45600 Change-Id: I3c4aab91b2d32733bd2561424052034a3d9c26a3 Reviewed-by: Marko Kangas Reviewed-by: Kai Koehne --- src/widgets/styles/qfusionstyle.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index e4302247f5..8405b5ce97 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1536,13 +1536,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio QRect r = option->rect; painter->fillRect(r, highlight); painter->setPen(QPen(highlightOutline)); - const QLine lines[4] = { - QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), - QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())), - QLine(QPoint(r.left(), r.top()), QPoint(r.left(), r.bottom())), - QLine(QPoint(r.right() , r.top()), QPoint(r.right(), r.bottom())), - }; - painter->drawLines(lines, 4); + painter->drawRect(QRectF(r).adjusted(0.5, 0.5, -0.5, -0.5)); } bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable; bool checked = menuItem->checked; -- cgit v1.2.3 From f64640f44163d868e3d101c3b0ba41d33147a5be Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Tue, 1 Mar 2016 09:07:11 +0100 Subject: Allow to style arrows drawn with drawPrimitive in QCommonStyle. Its currently not possible to style the arrows with QCommonStyle because drawPrimitive from QCommonStyle is called instead from the proxy. Change-Id: I910b13df110601cb18578bc16edfa5ddaa17bbd2 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qcommonstyle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 748cef20c1..4b6e3ac5c4 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1597,7 +1597,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (!hasArrow) { proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm); } else { - drawArrow(this, toolbutton, pr, p, widget); + drawArrow(proxy(), toolbutton, pr, p, widget); } alignment |= Qt::AlignCenter; } else { @@ -1607,7 +1607,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (!hasArrow) { proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm); } else { - drawArrow(this, toolbutton, pr, p, widget); + drawArrow(proxy(), toolbutton, pr, p, widget); } alignment |= Qt::AlignLeft | Qt::AlignVCenter; } @@ -1618,7 +1618,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } else { rect.translate(shiftX, shiftY); if (hasArrow) { - drawArrow(this, toolbutton, rect, p, widget); + drawArrow(proxy(), toolbutton, rect, p, widget); } else { proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm); } -- cgit v1.2.3 From cd46a2daf57dea2e0b661d72f6eb2171079797ba Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Fri, 22 Jan 2016 14:24:00 +0200 Subject: Unify license header usage. Update files using old header.LGPL3 to header.LGPL Update files using old FDL template to use new one Update files using old BSD template to use new one Change-Id: I36a78272516f9953d02956522f285b40adfc8915 Reviewed-by: Lars Knoll --- src/widgets/styles/qmacstyle.qdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qmacstyle.qdoc b/src/widgets/styles/qmacstyle.qdoc index 0800e2d608..5d597b53a4 100644 --- a/src/widgets/styles/qmacstyle.qdoc +++ b/src/widgets/styles/qmacstyle.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v1.2.3 From 72ff2a2f0db1e728d2a53f546021018e076bbfb5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 21 Mar 2016 14:16:09 -0700 Subject: QMacStyle: Return a guess for SE_ProgressBarGroove's rect QMacStyle doesn't know how to accurately compute SE_ProgressBarGroove But, since we only need the progress bar's main dimension, its rect is good enough for QProgressBarPrivate::repaintRequired(). Change-Id: I81e936003b847cc9cc0ddf4fbfc05ddc1c9f6625 Task-number: QTBUG-51120 Reviewed-by: Timur Pocheptsov --- src/widgets/styles/qmacstyle_mac.mm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 092cf4d543..9f241b6e67 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -4978,6 +4978,9 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, break; } case SE_ProgressBarGroove: + // Wrong in the secondary dimension, but accurate enough in the main dimension. + rect = opt->rect; + break; case SE_ProgressBarLabel: break; case SE_ProgressBarContents: -- cgit v1.2.3