summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-06-24 15:14:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-24 15:14:55 +0200
commit88211af86c3fe447041cfa1aa7be27da86dc84af (patch)
treede1e4f9bb41432bc3dadc7ed82429fd02bf39a3c /src/widgets/styles
parent687f002352a02f190591c10fded61b2e566f521e (diff)
parent6213b8145772d3dc584907a544f6c46b8cef74e2 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm30
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h2
-rw-r--r--src/widgets/styles/qstyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp12
-rw-r--r--src/widgets/styles/styles.pri25
5 files changed, 40 insertions, 31 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index a8fba4fb68..f8905b1b1a 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -119,9 +119,12 @@ QMacStylePrivate *mPrivate;
{
Q_UNUSED(notification);
QEvent event(QEvent::StyleChange);
- foreach (QWidget *widget, QApplication::allWidgets()) {
- if (QScrollBar *scrollBar = qobject_cast<QScrollBar *>(widget))
- QCoreApplication::sendEvent(scrollBar, &event);
+ QMutableSetIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars);
+ while (it.hasNext()) {
+ if (!it.next())
+ it.remove();
+ else
+ QCoreApplication::sendEvent(it.value(), &event);
}
}
@end
@@ -142,6 +145,13 @@ const int QMacStylePrivate::PushButtonContentPadding = 6;
const qreal QMacStylePrivate::ScrollBarFadeOutDuration = 200.0;
const qreal QMacStylePrivate::ScrollBarFadeOutDelay = 450.0;
+QSet<QPointer<QObject> > QMacStylePrivate::scrollBars;
+
+static uint qHash(const QPointer<QObject> &ptr)
+{
+ return qHash(ptr.data());
+}
+
// These colors specify the titlebar gradient colors on
// Leopard. Ideally we should get them from the system.
static const QColor titlebarGradientActiveBegin(220, 220, 220);
@@ -4934,6 +4944,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
// no longer possible to move it, second the up/down buttons are removed when
// there is not enough space for them.
if (cc == CC_ScrollBar) {
+ if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject))
+ QMacStylePrivate::scrollBars.insert(QPointer<QObject>(opt->styleObject));
const int scrollBarLength = (slider->orientation == Qt::Horizontal)
? slider->rect.width() : slider->rect.height();
const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt);
@@ -6021,10 +6033,14 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
bool useAquaGuideline = true;
switch (ct) {
- case QStyle::CT_SpinBox:
- // hack to work around horrible sizeHint() code in QAbstractSpinBox
- sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
- sz.setHeight(sz.height() - 3);
+
+ case CT_SpinBox:
+ if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ // Add button + frame widths
+ int buttonWidth = 20;
+ int fw = proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget);
+ sz += QSize(buttonWidth + 2*fw, 2*fw - 3);
+ }
break;
case QStyle::CT_TabWidget:
// the size between the pane and the "contentsRect" (+4,+4)
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index c424ff0c3c..bf42087fcb 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -93,6 +93,7 @@
#include <qlibrary.h>
#include <qdatetimeedit.h>
#include <qmath.h>
+#include <qset.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicsview.h>
@@ -197,6 +198,7 @@ public:
mutable QPointer<QObject> pressedButton;
mutable QPointer<QObject> defaultButton;
mutable QPointer<QObject> autoDefaultButton;
+ static QSet<QPointer<QObject> > scrollBars;
struct ButtonState {
int frame;
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 7ab5734eed..c6c71845eb 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -351,7 +351,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
\section1 Styles in Item Views
The painting of items in views is performed by a delegate. Qt's
- default delegate, QStyledItemDelegate, is also used for for calculating bounding
+ default delegate, QStyledItemDelegate, is also used for calculating bounding
rectangles of items, and their sub-elements for the various kind
of item \l{Qt::ItemDataRole}{data roles}
QStyledItemDelegate supports. See the QStyledItemDelegate class
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 31cf329262..3b3c27f6cb 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -582,7 +582,7 @@ bool QWindowsXPStylePrivate::hasAlphaChannel(const QRect &rect)
int firstAlpha = -1;
for (int y = startY; y < h/2; ++y) {
- register DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
+ DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
for (int x = startX; x < w; ++x, ++buffer) {
int alpha = (*buffer) >> 24;
if (firstAlpha == -1)
@@ -611,8 +611,8 @@ bool QWindowsXPStylePrivate::fixAlphaChannel(const QRect &rect)
bool hasFixedAlphaValue = false;
for (int y = startY; y < h; ++y) {
- register DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (register int x = startX; x < w; ++x, ++buffer) {
+ DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
+ for (int x = startX; x < w; ++x, ++buffer) {
uint pixel = *buffer;
int alpha = qAlpha(pixel);
if (qRed(pixel) > alpha || qGreen(pixel) > alpha || qBlue(pixel) > alpha) {
@@ -643,13 +643,13 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
// Flip the alphas, so that 255-alpha pixels are 0, and 0-alpha are 255.
for (int y = startY; y < h; ++y) {
- register DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (register int x = startX; x < w; ++x, ++buffer) {
+ DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
+ for (int x = startX; x < w; ++x, ++buffer) {
if (allPixels) {
*buffer |= 0xFF000000;
continue;
}
- register unsigned int alphaValue = (*buffer) & 0xFF000000;
+ unsigned int alphaValue = (*buffer) & 0xFF000000;
if (alphaValue == 0xFF000000) {
*buffer = 0;
valueChange = true;
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index b39b17fd86..3707090c4c 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -54,25 +54,10 @@ contains( styles, mac ) {
styles/qmacstyle_mac_p.h \
styles/qmacstyle_mac_p_p.h
OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm
-
- !contains( styles, windows ) {
- message( mac requires windows )
- styles += windows
- DEFINES+= QT_STYLE_WINDOWS
- }
} else {
DEFINES += QT_NO_STYLE_MAC
}
-contains( styles, windows ) {
- HEADERS += styles/qwindowsstyle_p.h
- HEADERS += styles/qwindowsstyle_p_p.h
- SOURCES += styles/qwindowsstyle.cpp
- DEFINES += QT_STYLE_WINDOWS
-} else {
- DEFINES += QT_NO_STYLE_WINDOWS
-}
-
contains( styles, windowsvista ) {
HEADERS += styles/qwindowsvistastyle_p.h
HEADERS += styles/qwindowsvistastyle_p_p.h
@@ -80,7 +65,6 @@ contains( styles, windowsvista ) {
!contains( styles, windowsxp ) {
message( windowsvista requires windowsxp )
styles += windowsxp
- DEFINES += QT_STYLE_WINDOWSXP
}
} else {
DEFINES += QT_NO_STYLE_WINDOWSVISTA
@@ -93,12 +77,19 @@ contains( styles, windowsxp ) {
!contains( styles, windows ) {
message( windowsxp requires windows )
styles += windows
- DEFINES += QT_STYLE_WINDOWS
}
} else {
DEFINES += QT_NO_STYLE_WINDOWSXP
}
+contains( styles, windows ) {
+ HEADERS += styles/qwindowsstyle_p.h
+ HEADERS += styles/qwindowsstyle_p_p.h
+ SOURCES += styles/qwindowsstyle.cpp
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWS
+}
+
contains( styles, gtk ) {
HEADERS += styles/qgtkglobal_p.h
HEADERS += styles/qgtkstyle_p.h