Brush up the Windows styles
- use range-based for loops where possible - use nullptr - use member initialization - remove a lot of C-style casts - use override - fix some signedness warnings - add some missing break statements Task-number: QTBUG-76493 Change-Id: Ica6ed65ec29e958406e54d816b8a679ed81bd177 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
e2431b619d
commit
7252251768
@ -48,7 +48,7 @@ class QWindowsVistaStylePlugin : public QStylePlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "windowsvistastyle.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "windowsvistastyle.json")
|
||||||
public:
|
public:
|
||||||
QStyle *create(const QString &key);
|
QStyle *create(const QString &key) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
QStyle *QWindowsVistaStylePlugin::create(const QString &key)
|
QStyle *QWindowsVistaStylePlugin::create(const QString &key)
|
||||||
@ -56,7 +56,7 @@ QStyle *QWindowsVistaStylePlugin::create(const QString &key)
|
|||||||
if (key.compare(QLatin1String("windowsvista"), Qt::CaseInsensitive) == 0)
|
if (key.compare(QLatin1String("windowsvista"), Qt::CaseInsensitive) == 0)
|
||||||
return new QWindowsVistaStyle();
|
return new QWindowsVistaStyle();
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include <qwindow.h>
|
#include <qwindow.h>
|
||||||
#include <private/qstyleanimation_p.h>
|
#include <private/qstyleanimation_p.h>
|
||||||
#include <private/qstylehelper_p.h>
|
#include <private/qstylehelper_p.h>
|
||||||
#include <private/qapplication_p.h>
|
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -91,7 +90,7 @@ bool QWindowsVistaStylePrivate::useVista()
|
|||||||
Checks and returns the style object
|
Checks and returns the style object
|
||||||
*/
|
*/
|
||||||
inline QObject *styleObject(const QStyleOption *option) {
|
inline QObject *styleObject(const QStyleOption *option) {
|
||||||
return option ? option->styleObject : 0;
|
return option ? option->styleObject : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \internal
|
/* \internal
|
||||||
@ -116,7 +115,7 @@ static inline QImage createAnimationBuffer(const QStyleOption *option, const QWi
|
|||||||
Used by animations to clone a styleoption and shift its offset
|
Used by animations to clone a styleoption and shift its offset
|
||||||
*/
|
*/
|
||||||
QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) {
|
QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) {
|
||||||
QStyleOption *styleOption = 0;
|
QStyleOption *styleOption = nullptr;
|
||||||
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option))
|
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option))
|
||||||
styleOption = new QStyleOptionSlider(*slider);
|
styleOption = new QStyleOptionSlider(*slider);
|
||||||
else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option))
|
else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option))
|
||||||
@ -297,7 +296,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
int oldState = styleObject->property("_q_stylestate").toInt();
|
int oldState = styleObject->property("_q_stylestate").toInt();
|
||||||
oldRect = styleObject->property("_q_stylerect").toRect();
|
oldRect = styleObject->property("_q_stylerect").toRect();
|
||||||
newRect = option->rect;
|
newRect = option->rect;
|
||||||
styleObject->setProperty("_q_stylestate", (int)option->state);
|
styleObject->setProperty("_q_stylestate", int(option->state));
|
||||||
styleObject->setProperty("_q_stylerect", option->rect);
|
styleObject->setProperty("_q_stylerect", option->rect);
|
||||||
|
|
||||||
bool doTransition = oldState &&
|
bool doTransition = oldState &&
|
||||||
@ -315,7 +314,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
|
|
||||||
if (doTransition) {
|
if (doTransition) {
|
||||||
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
||||||
styleOption->state = (QStyle::State)oldState;
|
styleOption->state = QStyle::State(oldState);
|
||||||
|
|
||||||
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
||||||
QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
|
QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
|
||||||
@ -340,7 +339,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
|
|
||||||
// The end state of the transition is simply the result we would have painted
|
// The end state of the transition is simply the result we would have painted
|
||||||
// if the style was not animated.
|
// if the style was not animated.
|
||||||
styleOption->styleObject = 0;
|
styleOption->styleObject = nullptr;
|
||||||
styleOption->state = option->state;
|
styleOption->state = option->state;
|
||||||
proxy()->drawPrimitive(element, styleOption, &endPainter, widget);
|
proxy()->drawPrimitive(element, styleOption, &endPainter, widget);
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
|
|
||||||
//translate state flags to UXTHEME states :
|
//translate state flags to UXTHEME states :
|
||||||
if (element == PE_FrameLineEdit) {
|
if (element == PE_FrameLineEdit) {
|
||||||
theme = OpenThemeData(0, L"Edit");
|
theme = OpenThemeData(nullptr, L"Edit");
|
||||||
partId = EP_EDITBORDER_NOSCROLL;
|
partId = EP_EDITBORDER_NOSCROLL;
|
||||||
|
|
||||||
if (oldState & State_MouseOver)
|
if (oldState & State_MouseOver)
|
||||||
@ -373,7 +372,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
toState = ETS_NORMAL;
|
toState = ETS_NORMAL;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
theme = OpenThemeData(0, L"Button");
|
theme = OpenThemeData(nullptr, L"Button");
|
||||||
if (element == PE_IndicatorRadioButton)
|
if (element == PE_IndicatorRadioButton)
|
||||||
partId = BP_RADIOBUTTON;
|
partId = BP_RADIOBUTTON;
|
||||||
else if (element == PE_IndicatorCheckBox)
|
else if (element == PE_IndicatorCheckBox)
|
||||||
@ -389,7 +388,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
if (theme
|
if (theme
|
||||||
&& SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
|
&& SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
|
||||||
TMT_TRANSITIONDURATIONS, &duration))) {
|
TMT_TRANSITIONDURATIONS, &duration))) {
|
||||||
t->setDuration(duration);
|
t->setDuration(int(duration));
|
||||||
}
|
}
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(QTime::currentTime());
|
||||||
|
|
||||||
@ -534,7 +533,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
else if (state & State_MouseOver)
|
else if (state & State_MouseOver)
|
||||||
stateId = EBS_HOT;
|
stateId = EBS_HOT;
|
||||||
|
|
||||||
XPThemeData theme(0, painter, QWindowsXPStylePrivate::EditTheme,
|
XPThemeData theme(nullptr, painter, QWindowsXPStylePrivate::EditTheme,
|
||||||
partId, stateId, rect);
|
partId, stateId, rect);
|
||||||
if (!theme.isValid()) {
|
if (!theme.isValid()) {
|
||||||
QWindowsStyle::drawPrimitive(element, option, painter, widget);
|
QWindowsStyle::drawPrimitive(element, option, painter, widget);
|
||||||
@ -581,27 +580,26 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
p->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
p->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
||||||
p->setPen(oldPen);
|
p->setPen(oldPen);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
int stateId = ETS_NORMAL;
|
|
||||||
if (!(state & State_Enabled))
|
|
||||||
stateId = ETS_DISABLED;
|
|
||||||
else if (state & State_ReadOnly)
|
|
||||||
stateId = ETS_READONLY;
|
|
||||||
else if (state & State_MouseOver)
|
|
||||||
stateId = ETS_HOT;
|
|
||||||
else if (state & State_HasFocus)
|
|
||||||
stateId = ETS_SELECTED;
|
|
||||||
XPThemeData theme(widget, painter,
|
|
||||||
QWindowsXPStylePrivate::EditTheme,
|
|
||||||
EP_EDITBORDER_NOSCROLL, stateId, option->rect);
|
|
||||||
theme.noContent = true;
|
|
||||||
painter->save();
|
|
||||||
QRegion clipRegion = option->rect;
|
|
||||||
clipRegion -= option->rect.adjusted(2, 2, -2, -2);
|
|
||||||
painter->setClipRegion(clipRegion);
|
|
||||||
d->drawBackground(theme);
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
int stateId = ETS_NORMAL;
|
||||||
|
if (!(state & State_Enabled))
|
||||||
|
stateId = ETS_DISABLED;
|
||||||
|
else if (state & State_ReadOnly)
|
||||||
|
stateId = ETS_READONLY;
|
||||||
|
else if (state & State_MouseOver)
|
||||||
|
stateId = ETS_HOT;
|
||||||
|
else if (state & State_HasFocus)
|
||||||
|
stateId = ETS_SELECTED;
|
||||||
|
XPThemeData theme(widget, painter,
|
||||||
|
QWindowsXPStylePrivate::EditTheme,
|
||||||
|
EP_EDITBORDER_NOSCROLL, stateId, option->rect);
|
||||||
|
theme.noContent = true;
|
||||||
|
painter->save();
|
||||||
|
QRegion clipRegion = option->rect;
|
||||||
|
clipRegion -= option->rect.adjusted(2, 2, -2, -2);
|
||||||
|
painter->setClipRegion(clipRegion);
|
||||||
|
d->drawBackground(theme);
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -724,7 +722,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
d->drawBackground(theme);
|
d->drawBackground(theme);
|
||||||
} else {
|
} else {
|
||||||
QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
|
QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
|
||||||
break;;
|
break;
|
||||||
}
|
}
|
||||||
QPixmapCache::insert(key, pixmap);
|
QPixmapCache::insert(key, pixmap);
|
||||||
}
|
}
|
||||||
@ -770,7 +768,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
case PE_Widget:
|
case PE_Widget:
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(dialogbuttonbox)
|
#if QT_CONFIG(dialogbuttonbox)
|
||||||
const QDialogButtonBox *buttonBox = 0;
|
const QDialogButtonBox *buttonBox = nullptr;
|
||||||
|
|
||||||
if (qobject_cast<const QMessageBox *> (widget))
|
if (qobject_cast<const QMessageBox *> (widget))
|
||||||
buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
|
buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
|
||||||
@ -844,7 +842,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
int oldState = styleObject->property("_q_stylestate").toInt();
|
int oldState = styleObject->property("_q_stylestate").toInt();
|
||||||
oldRect = styleObject->property("_q_stylerect").toRect();
|
oldRect = styleObject->property("_q_stylerect").toRect();
|
||||||
newRect = option->rect;
|
newRect = option->rect;
|
||||||
styleObject->setProperty("_q_stylestate", (int)option->state);
|
styleObject->setProperty("_q_stylestate", int(option->state));
|
||||||
styleObject->setProperty("_q_stylerect", option->rect);
|
styleObject->setProperty("_q_stylerect", option->rect);
|
||||||
|
|
||||||
bool wasDefault = false;
|
bool wasDefault = false;
|
||||||
@ -870,7 +868,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
|
QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
|
||||||
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
||||||
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
||||||
styleOption->state = (QStyle::State)oldState;
|
styleOption->state = QStyle::State(oldState);
|
||||||
|
|
||||||
QImage startImage = createAnimationBuffer(option, widget);
|
QImage startImage = createAnimationBuffer(option, widget);
|
||||||
QPainter startPainter(&startImage);
|
QPainter startPainter(&startImage);
|
||||||
@ -892,12 +890,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
|
|
||||||
|
|
||||||
DWORD duration = 0;
|
DWORD duration = 0;
|
||||||
const HTHEME theme = OpenThemeData(0, L"Button");
|
const HTHEME theme = OpenThemeData(nullptr, L"Button");
|
||||||
|
|
||||||
int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
|
int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
|
||||||
int toState = buttonStateId(option->state, BP_PUSHBUTTON);
|
int toState = buttonStateId(option->state, BP_PUSHBUTTON);
|
||||||
if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
|
if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
|
||||||
t->setDuration(duration);
|
t->setDuration(int(duration));
|
||||||
else
|
else
|
||||||
t->setDuration(0);
|
t->setDuration(0);
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(QTime::currentTime());
|
||||||
@ -983,7 +981,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
|
|
||||||
if (btn->features & QStyleOptionButton::HasMenu) {
|
if (btn->features & QStyleOptionButton::HasMenu) {
|
||||||
int mbiw = 0, mbih = 0;
|
int mbiw = 0, mbih = 0;
|
||||||
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ToolBarTheme,
|
XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::ToolBarTheme,
|
||||||
TP_DROPDOWNBUTTON);
|
TP_DROPDOWNBUTTON);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSizeF size = theme.size() * QStyleHelper::dpiScaled(1, option);
|
const QSizeF size = theme.size() * QStyleHelper::dpiScaled(1, option);
|
||||||
@ -992,7 +990,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
mbih = qRound(size.height());
|
mbih = qRound(size.height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QRect ir = subElementRect(SE_PushButtonContents, option, 0);
|
QRect ir = subElementRect(SE_PushButtonContents, option, nullptr);
|
||||||
QStyleOptionButton newBtn = *btn;
|
QStyleOptionButton newBtn = *btn;
|
||||||
newBtn.rect = QStyle::visualRect(option->direction, option->rect,
|
newBtn.rect = QStyle::visualRect(option->direction, option->rect,
|
||||||
QRect(ir.right() - mbiw - 2,
|
QRect(ir.right() - mbiw - 2,
|
||||||
@ -1137,7 +1135,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
|
QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
|
||||||
QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
|
QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
|
||||||
|
|
||||||
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||||
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
||||||
alignment |= Qt::TextHideMnemonic;
|
alignment |= Qt::TextHideMnemonic;
|
||||||
|
|
||||||
@ -1177,7 +1175,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
int checkcol = qRound(qreal(25) * factor);
|
int checkcol = qRound(qreal(25) * factor);
|
||||||
const int gutterWidth = qRound(qreal(3) * factor);
|
const int gutterWidth = qRound(qreal(3) * factor);
|
||||||
{
|
{
|
||||||
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme,
|
XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::MenuTheme,
|
||||||
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
||||||
XPThemeData themeSize = theme;
|
XPThemeData themeSize = theme;
|
||||||
themeSize.partId = MENU_POPUPCHECK;
|
themeSize.partId = MENU_POPUPCHECK;
|
||||||
@ -1394,7 +1392,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
|
int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
|
||||||
int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
|
int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
|
||||||
const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
|
const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
|
||||||
bool isFloating = dw != 0 && dw->isFloating();
|
bool isFloating = dw && dw->isFloating();
|
||||||
|
|
||||||
QRect r = option->rect.adjusted(0, 2, -1, -3);
|
QRect r = option->rect.adjusted(0, 2, -1, -3);
|
||||||
QRect titleRect = r;
|
QRect titleRect = r;
|
||||||
@ -1411,7 +1409,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
|
|
||||||
if (isFloating) {
|
if (isFloating) {
|
||||||
titleRect.adjust(0, -fw, 0, 0);
|
titleRect.adjust(0, -fw, 0, 0);
|
||||||
if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
|
if (widget && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
|
||||||
titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
|
titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
titleRect.adjust(mw, 0, 0, 0);
|
titleRect.adjust(mw, 0, 0, 0);
|
||||||
@ -1517,8 +1515,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
int oldActiveControls = styleObject->property("_q_stylecontrols").toInt();
|
int oldActiveControls = styleObject->property("_q_stylecontrols").toInt();
|
||||||
|
|
||||||
QRect oldRect = styleObject->property("_q_stylerect").toRect();
|
QRect oldRect = styleObject->property("_q_stylerect").toRect();
|
||||||
styleObject->setProperty("_q_stylestate", (int)option->state);
|
styleObject->setProperty("_q_stylestate", int(option->state));
|
||||||
styleObject->setProperty("_q_stylecontrols", (int)option->activeSubControls);
|
styleObject->setProperty("_q_stylecontrols", int(option->activeSubControls));
|
||||||
styleObject->setProperty("_q_stylerect", option->rect);
|
styleObject->setProperty("_q_stylerect", option->rect);
|
||||||
|
|
||||||
bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
|
bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
|
||||||
@ -1562,8 +1560,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
|
|
||||||
// Draw transition source
|
// Draw transition source
|
||||||
if (!anim) {
|
if (!anim) {
|
||||||
styleOption->state = (QStyle::State)oldState;
|
styleOption->state = QStyle::State(oldState);
|
||||||
styleOption->activeSubControls = (QStyle::SubControl)oldActiveControls;
|
styleOption->activeSubControls = QStyle::SubControl(oldActiveControls);
|
||||||
proxy()->drawComplexControl(control, styleOption, &startPainter, widget);
|
proxy()->drawComplexControl(control, styleOption, &startPainter, widget);
|
||||||
} else {
|
} else {
|
||||||
anim->paint(&startPainter, option);
|
anim->paint(&startPainter, option);
|
||||||
@ -1814,7 +1812,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
// That however breaks with QtQuickControls where this results in transparent
|
// That however breaks with QtQuickControls where this results in transparent
|
||||||
// spinbox background, so if there's no "widget" passed (QtQuickControls case),
|
// spinbox background, so if there's no "widget" passed (QtQuickControls case),
|
||||||
// let ftheme.noContent be false, which fixes the spinbox rendering in QQC
|
// let ftheme.noContent be false, which fixes the spinbox rendering in QQC
|
||||||
ftheme.noContent = (widget != NULL);
|
ftheme.noContent = (widget != nullptr);
|
||||||
d->drawBackground(ftheme);
|
d->drawBackground(ftheme);
|
||||||
}
|
}
|
||||||
if (sub & SC_SpinBoxUp) {
|
if (sub & SC_SpinBoxUp) {
|
||||||
@ -1871,7 +1869,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
|
|||||||
sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
|
sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
|
||||||
int minimumHeight;
|
int minimumHeight;
|
||||||
{
|
{
|
||||||
XPThemeData theme(widget, 0,
|
XPThemeData theme(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::MenuTheme,
|
QWindowsXPStylePrivate::MenuTheme,
|
||||||
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
MENU_POPUPCHECKBACKGROUND, MBI_HOT);
|
||||||
XPThemeData themeSize = theme;
|
XPThemeData themeSize = theme;
|
||||||
@ -1939,7 +1937,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
|
|||||||
case SE_PushButtonContents:
|
case SE_PushButtonContents:
|
||||||
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
||||||
MARGINS borderSize;
|
MARGINS borderSize;
|
||||||
const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
|
const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : nullptr, L"Button");
|
||||||
if (theme) {
|
if (theme) {
|
||||||
int stateId = PBS_NORMAL;
|
int stateId = PBS_NORMAL;
|
||||||
if (!(option->state & State_Enabled))
|
if (!(option->state & State_Enabled))
|
||||||
@ -1954,7 +1952,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
|
|||||||
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
|
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
|
||||||
rect = option->rect.adjusted(border, border, -border, -border);
|
rect = option->rect.adjusted(border, border, -border, -border);
|
||||||
|
|
||||||
if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
|
if (SUCCEEDED(GetThemeMargins(theme, nullptr, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, nullptr, &borderSize))) {
|
||||||
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
|
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
|
||||||
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
|
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
|
||||||
rect = visualRect(option->direction, option->rect, rect);
|
rect = visualRect(option->direction, option->rect, rect);
|
||||||
@ -1972,7 +1970,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
|
|||||||
int y = option->rect.y();
|
int y = option->rect.y();
|
||||||
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
|
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
|
||||||
|
|
||||||
XPThemeData theme(widget, 0,
|
XPThemeData theme(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::HeaderTheme,
|
QWindowsXPStylePrivate::HeaderTheme,
|
||||||
HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
|
HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
|
||||||
|
|
||||||
@ -2045,7 +2043,7 @@ static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBa
|
|||||||
|
|
||||||
bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
|
bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
|
||||||
bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
|
bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
|
||||||
const uint flags = tb->titleBarFlags;
|
const auto flags = tb->titleBarFlags;
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
switch (sc) {
|
switch (sc) {
|
||||||
case QStyle::SC_TitleBarContextHelpButton:
|
case QStyle::SC_TitleBarContextHelpButton:
|
||||||
@ -2103,7 +2101,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co
|
|||||||
if (option) {
|
if (option) {
|
||||||
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
|
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
XPThemeData themeData(widget, 0,
|
XPThemeData themeData(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::ToolTipTheme,
|
QWindowsXPStylePrivate::ToolTipTheme,
|
||||||
TTP_STANDARD, TTSS_NORMAL, option->rect);
|
TTP_STANDARD, TTSS_NORMAL, option->rect);
|
||||||
mask->region = d->region(themeData);
|
mask->region = d->region(themeData);
|
||||||
@ -2112,7 +2110,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co
|
|||||||
break;
|
break;
|
||||||
case SH_Table_GridLineColor:
|
case SH_Table_GridLineColor:
|
||||||
if (option)
|
if (option)
|
||||||
ret = option->palette.color(QPalette::Base).darker(118).rgb();
|
ret = int(option->palette.color(QPalette::Base).darker(118).rgb());
|
||||||
else
|
else
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
@ -2323,7 +2321,7 @@ void QWindowsVistaStyle::polish(QWidget *widget)
|
|||||||
//we do not have to care about unpolishing
|
//we do not have to care about unpolishing
|
||||||
widget->setContentsMargins(3, 0, 4, 0);
|
widget->setContentsMargins(3, 0, 4, 0);
|
||||||
COLORREF bgRef;
|
COLORREF bgRef;
|
||||||
HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
|
HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : nullptr, L"TOOLTIP");
|
||||||
if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
|
if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
|
||||||
QColor textColor = QColor::fromRgb(bgRef);
|
QColor textColor = QColor::fromRgb(bgRef);
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
@ -2463,7 +2461,7 @@ QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon,
|
|||||||
switch(standardIcon) {
|
switch(standardIcon) {
|
||||||
case SP_CommandLink:
|
case SP_CommandLink:
|
||||||
{
|
{
|
||||||
XPThemeData theme(0, 0,
|
XPThemeData theme(nullptr, nullptr,
|
||||||
QWindowsXPStylePrivate::ButtonTheme,
|
QWindowsXPStylePrivate::ButtonTheme,
|
||||||
BP_COMMANDLINKGLYPH, CMDLGS_NORMAL);
|
BP_COMMANDLINKGLYPH, CMDLGS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
|
@ -162,7 +162,7 @@ class QWindowsVistaAnimation : public QBlendStyleAnimation
|
|||||||
public:
|
public:
|
||||||
QWindowsVistaAnimation(Type type, QObject *target) : QBlendStyleAnimation(type, target) { }
|
QWindowsVistaAnimation(Type type, QObject *target) : QBlendStyleAnimation(type, target) { }
|
||||||
|
|
||||||
virtual bool isUpdateNeeded() const;
|
bool isUpdateNeeded() const override;
|
||||||
void paint(QPainter *painter, const QStyleOption *option);
|
void paint(QPainter *painter, const QStyleOption *option);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ static inline QBackingStore *backingStoreForWidget(const QWidget *widget)
|
|||||||
if (const QWidget *topLevel = widget->nativeParentWidget())
|
if (const QWidget *topLevel = widget->nativeParentWidget())
|
||||||
if (QBackingStore *topLevelBackingStore = topLevel->backingStore())
|
if (QBackingStore *topLevelBackingStore = topLevel->backingStore())
|
||||||
return topLevelBackingStore;
|
return topLevelBackingStore;
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HDC hdcForWidgetBackingStore(const QWidget *widget)
|
static inline HDC hdcForWidgetBackingStore(const QWidget *widget)
|
||||||
@ -127,7 +127,7 @@ static inline HDC hdcForWidgetBackingStore(const QWidget *widget)
|
|||||||
if (nativeInterface)
|
if (nativeInterface)
|
||||||
return static_cast<HDC>(nativeInterface->nativeResourceForBackingStore(QByteArrayLiteral("getDC"), backingStore));
|
return static_cast<HDC>(nativeInterface->nativeResourceForBackingStore(QByteArrayLiteral("getDC"), backingStore));
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Theme data helper ------------------------------------------------------------------------------
|
// Theme data helper ------------------------------------------------------------------------------
|
||||||
@ -148,7 +148,7 @@ bool XPThemeData::isValid()
|
|||||||
HTHEME XPThemeData::handle()
|
HTHEME XPThemeData::handle()
|
||||||
{
|
{
|
||||||
if (!QWindowsXPStylePrivate::useXP())
|
if (!QWindowsXPStylePrivate::useXP())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
if (!htheme)
|
if (!htheme)
|
||||||
htheme = QWindowsXPStylePrivate::createTheme(theme, QWindowsXPStylePrivate::winId(widget));
|
htheme = QWindowsXPStylePrivate::createTheme(theme, QWindowsXPStylePrivate::winId(widget));
|
||||||
@ -175,10 +175,10 @@ RECT XPThemeData::toRECT(const QRect &qr)
|
|||||||
HRGN XPThemeData::mask(QWidget *widget)
|
HRGN XPThemeData::mask(QWidget *widget)
|
||||||
{
|
{
|
||||||
if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
|
if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
HRGN hrgn;
|
HRGN hrgn;
|
||||||
HDC dc = 0;
|
HDC dc = nullptr;
|
||||||
if (widget)
|
if (widget)
|
||||||
dc = hdcForWidgetBackingStore(widget);
|
dc = hdcForWidgetBackingStore(widget);
|
||||||
RECT nativeRect = toRECT(rect);
|
RECT nativeRect = toRECT(rect);
|
||||||
@ -188,7 +188,7 @@ HRGN XPThemeData::mask(QWidget *widget)
|
|||||||
|
|
||||||
// QWindowsXPStylePrivate -------------------------------------------------------------------------
|
// QWindowsXPStylePrivate -------------------------------------------------------------------------
|
||||||
// Static initializations
|
// Static initializations
|
||||||
HWND QWindowsXPStylePrivate::m_vistaTreeViewHelper = 0;
|
HWND QWindowsXPStylePrivate::m_vistaTreeViewHelper = nullptr;
|
||||||
HTHEME QWindowsXPStylePrivate::m_themes[NThemes];
|
HTHEME QWindowsXPStylePrivate::m_themes[NThemes];
|
||||||
bool QWindowsXPStylePrivate::use_xp = false;
|
bool QWindowsXPStylePrivate::use_xp = false;
|
||||||
QBasicAtomicInt QWindowsXPStylePrivate::ref = Q_BASIC_ATOMIC_INITIALIZER(-1); // -1 based refcounting
|
QBasicAtomicInt QWindowsXPStylePrivate::ref = Q_BASIC_ATOMIC_INITIALIZER(-1); // -1 based refcounting
|
||||||
@ -227,7 +227,7 @@ bool QWindowsXPStylePrivate::useXP(bool update)
|
|||||||
{
|
{
|
||||||
if (!update)
|
if (!update)
|
||||||
return use_xp;
|
return use_xp;
|
||||||
return use_xp = IsThemeActive() && (IsAppThemed() || !QApplication::instance());
|
return use_xp = IsThemeActive() && (IsAppThemed() || !QCoreApplication::instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \internal
|
/* \internal
|
||||||
@ -241,7 +241,7 @@ void QWindowsXPStylePrivate::init(bool force)
|
|||||||
ref.ref();
|
ref.ref();
|
||||||
|
|
||||||
useXP(true);
|
useXP(true);
|
||||||
std::fill(m_themes, m_themes + NThemes, HTHEME(0));
|
std::fill(m_themes, m_themes + NThemes, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* \internal
|
/* \internal
|
||||||
@ -253,12 +253,12 @@ void QWindowsXPStylePrivate::cleanup(bool force)
|
|||||||
if (bufferDC && nullBitmap)
|
if (bufferDC && nullBitmap)
|
||||||
SelectObject(bufferDC, nullBitmap);
|
SelectObject(bufferDC, nullBitmap);
|
||||||
DeleteObject(bufferBitmap);
|
DeleteObject(bufferBitmap);
|
||||||
bufferBitmap = 0;
|
bufferBitmap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bufferDC)
|
if(bufferDC)
|
||||||
DeleteDC(bufferDC);
|
DeleteDC(bufferDC);
|
||||||
bufferDC = 0;
|
bufferDC = nullptr;
|
||||||
|
|
||||||
if (ref.deref() && !force)
|
if (ref.deref() && !force)
|
||||||
return;
|
return;
|
||||||
@ -282,7 +282,7 @@ void QWindowsXPStylePrivate::cleanup(bool force)
|
|||||||
static inline HWND createTreeViewHelperWindow()
|
static inline HWND createTreeViewHelperWindow()
|
||||||
{
|
{
|
||||||
if (QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface()) {
|
if (QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface()) {
|
||||||
void *hwnd = 0;
|
void *hwnd = nullptr;
|
||||||
void *wndProc = reinterpret_cast<void *>(DefWindowProc);
|
void *wndProc = reinterpret_cast<void *>(DefWindowProc);
|
||||||
if (QMetaObject::invokeMethod(ni, "createMessageWindow", Qt::DirectConnection,
|
if (QMetaObject::invokeMethod(ni, "createMessageWindow", Qt::DirectConnection,
|
||||||
Q_RETURN_ARG(void*, hwnd),
|
Q_RETURN_ARG(void*, hwnd),
|
||||||
@ -292,7 +292,7 @@ static inline HWND createTreeViewHelperWindow()
|
|||||||
return reinterpret_cast<HWND>(hwnd);
|
return reinterpret_cast<HWND>(hwnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
|
bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
|
||||||
@ -305,7 +305,7 @@ bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
|
|||||||
qWarning("Unable to create the treeview helper window.");
|
qWarning("Unable to create the treeview helper window.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
|
if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", nullptr))) {
|
||||||
qErrnoWarning("SetWindowTheme() failed.");
|
qErrnoWarning("SetWindowTheme() failed.");
|
||||||
cleanupVistaTreeViewTheming();
|
cleanupVistaTreeViewTheming();
|
||||||
return false;
|
return false;
|
||||||
@ -317,7 +317,7 @@ void QWindowsXPStylePrivate::cleanupVistaTreeViewTheming()
|
|||||||
{
|
{
|
||||||
if (m_vistaTreeViewHelper) {
|
if (m_vistaTreeViewHelper) {
|
||||||
DestroyWindow(m_vistaTreeViewHelper);
|
DestroyWindow(m_vistaTreeViewHelper);
|
||||||
m_vistaTreeViewHelper = 0;
|
m_vistaTreeViewHelper = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,11 +328,12 @@ void QWindowsXPStylePrivate::cleanupVistaTreeViewTheming()
|
|||||||
*/
|
*/
|
||||||
void QWindowsXPStylePrivate::cleanupHandleMap()
|
void QWindowsXPStylePrivate::cleanupHandleMap()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NThemes; ++i)
|
for (auto &theme : m_themes) {
|
||||||
if (m_themes[i]) {
|
if (theme) {
|
||||||
CloseThemeData(m_themes[i]);
|
CloseThemeData(theme);
|
||||||
m_themes[i] = 0;
|
theme = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
QWindowsXPStylePrivate::cleanupVistaTreeViewTheming();
|
QWindowsXPStylePrivate::cleanupVistaTreeViewTheming();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +341,7 @@ HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd)
|
|||||||
{
|
{
|
||||||
if (Q_UNLIKELY(theme < 0 || theme >= NThemes || !hwnd)) {
|
if (Q_UNLIKELY(theme < 0 || theme >= NThemes || !hwnd)) {
|
||||||
qWarning("Invalid parameters #%d, %p", theme, hwnd);
|
qWarning("Invalid parameters #%d, %p", theme, hwnd);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!m_themes[theme]) {
|
if (!m_themes[theme]) {
|
||||||
const wchar_t *name = themeNames[theme];
|
const wchar_t *name = themeNames[theme];
|
||||||
@ -427,16 +428,16 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
|
|||||||
if (bufferDC && nullBitmap)
|
if (bufferDC && nullBitmap)
|
||||||
SelectObject(bufferDC, nullBitmap);
|
SelectObject(bufferDC, nullBitmap);
|
||||||
DeleteObject(bufferBitmap);
|
DeleteObject(bufferBitmap);
|
||||||
bufferBitmap = 0;
|
bufferBitmap = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = qMax(bufferW, w);
|
w = qMax(bufferW, w);
|
||||||
h = qMax(bufferH, h);
|
h = qMax(bufferH, h);
|
||||||
|
|
||||||
if (!bufferDC) {
|
if (!bufferDC) {
|
||||||
HDC displayDC = GetDC(0);
|
HDC displayDC = GetDC(nullptr);
|
||||||
bufferDC = CreateCompatibleDC(displayDC);
|
bufferDC = CreateCompatibleDC(displayDC);
|
||||||
ReleaseDC(0, displayDC);
|
ReleaseDC(nullptr, displayDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the header
|
// Define the header
|
||||||
@ -450,22 +451,22 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
|
|||||||
bmi.bmiHeader.biCompression = BI_RGB;
|
bmi.bmiHeader.biCompression = BI_RGB;
|
||||||
|
|
||||||
// Create the pixmap
|
// Create the pixmap
|
||||||
bufferPixels = 0;
|
bufferPixels = nullptr;
|
||||||
bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS, (void **) &bufferPixels, 0, 0);
|
bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS, reinterpret_cast<void **>(&bufferPixels), nullptr, 0);
|
||||||
GdiFlush();
|
GdiFlush();
|
||||||
nullBitmap = (HBITMAP)SelectObject(bufferDC, bufferBitmap);
|
nullBitmap = static_cast<HBITMAP>(SelectObject(bufferDC, bufferBitmap));
|
||||||
|
|
||||||
if (Q_UNLIKELY(!bufferBitmap)) {
|
if (Q_UNLIKELY(!bufferBitmap)) {
|
||||||
qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h);
|
qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h);
|
||||||
bufferW = 0;
|
bufferW = 0;
|
||||||
bufferH = 0;
|
bufferH = 0;
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (Q_UNLIKELY(!bufferPixels)) {
|
if (Q_UNLIKELY(!bufferPixels)) {
|
||||||
qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h);
|
qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h);
|
||||||
bufferW = 0;
|
bufferW = 0;
|
||||||
bufferH = 0;
|
bufferH = 0;
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
bufferW = w;
|
bufferW = w;
|
||||||
bufferH = h;
|
bufferH = h;
|
||||||
@ -493,7 +494,7 @@ bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData)
|
|||||||
*/
|
*/
|
||||||
QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
|
QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
|
||||||
{
|
{
|
||||||
HRGN hRgn = 0;
|
HRGN hRgn = nullptr;
|
||||||
const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(themeData.widget);
|
const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(themeData.widget);
|
||||||
RECT rect = themeData.toRECT(QRect(themeData.rect.topLeft() / factor, themeData.rect.size() / factor));
|
RECT rect = themeData.toRECT(QRect(themeData.rect.topLeft() / factor, themeData.rect.size() / factor));
|
||||||
if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
|
if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
|
||||||
@ -502,12 +503,12 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
HRGN dest = CreateRectRgn(0, 0, 0, 0);
|
HRGN dest = CreateRectRgn(0, 0, 0, 0);
|
||||||
const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR;
|
const bool success = CombineRgn(dest, hRgn, nullptr, RGN_COPY) != ERROR;
|
||||||
|
|
||||||
QRegion region;
|
QRegion region;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
int numBytes = GetRegionData(dest, 0, 0);
|
const auto numBytes = GetRegionData(dest, 0, nullptr);
|
||||||
if (numBytes == 0)
|
if (numBytes == 0)
|
||||||
return QRegion();
|
return QRegion();
|
||||||
|
|
||||||
@ -551,7 +552,7 @@ bool QWindowsXPStylePrivate::hasAlphaChannel(const QRect &rect)
|
|||||||
|
|
||||||
int firstAlpha = -1;
|
int firstAlpha = -1;
|
||||||
for (int y = startY; y < h/2; ++y) {
|
for (int y = startY; y < h/2; ++y) {
|
||||||
DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
|
auto buffer = reinterpret_cast<const DWORD *>(bufferPixels) + (y * bufferW);
|
||||||
for (int x = startX; x < w; ++x, ++buffer) {
|
for (int x = startX; x < w; ++x, ++buffer) {
|
||||||
int alpha = (*buffer) >> 24;
|
int alpha = (*buffer) >> 24;
|
||||||
if (firstAlpha == -1)
|
if (firstAlpha == -1)
|
||||||
@ -580,7 +581,7 @@ bool QWindowsXPStylePrivate::fixAlphaChannel(const QRect &rect)
|
|||||||
bool hasFixedAlphaValue = false;
|
bool hasFixedAlphaValue = false;
|
||||||
|
|
||||||
for (int y = startY; y < h; ++y) {
|
for (int y = startY; y < h; ++y) {
|
||||||
DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
|
auto buffer = reinterpret_cast<DWORD *>(bufferPixels) + (y * bufferW);
|
||||||
for (int x = startX; x < w; ++x, ++buffer) {
|
for (int x = startX; x < w; ++x, ++buffer) {
|
||||||
uint pixel = *buffer;
|
uint pixel = *buffer;
|
||||||
int alpha = qAlpha(pixel);
|
int alpha = qAlpha(pixel);
|
||||||
@ -612,7 +613,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
|
|||||||
|
|
||||||
// Flip the alphas, so that 255-alpha pixels are 0, and 0-alpha are 255.
|
// Flip the alphas, so that 255-alpha pixels are 0, and 0-alpha are 255.
|
||||||
for (int y = startY; y < h; ++y) {
|
for (int y = startY; y < h; ++y) {
|
||||||
DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
|
auto buffer = reinterpret_cast<DWORD *>(bufferPixels) + (y * bufferW);
|
||||||
for (int x = startX; x < w; ++x, ++buffer) {
|
for (int x = startX; x < w; ++x, ++buffer) {
|
||||||
if (allPixels) {
|
if (allPixels) {
|
||||||
*buffer |= 0xFF000000;
|
*buffer |= 0xFF000000;
|
||||||
@ -668,7 +669,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
QPainter *painter = themeData.painter;
|
QPainter *painter = themeData.painter;
|
||||||
Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
|
Q_ASSERT_X(painter != nullptr, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
|
||||||
if (!painter || !painter->isActive())
|
if (!painter || !painter->isActive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -706,7 +707,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0);
|
const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : nullptr;
|
||||||
const bool result = dc
|
const bool result = dc
|
||||||
? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio)
|
? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio)
|
||||||
: drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio);
|
: drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio);
|
||||||
@ -740,7 +741,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
|
|||||||
{
|
{
|
||||||
QPainter *painter = themeData.painter;
|
QPainter *painter = themeData.painter;
|
||||||
|
|
||||||
const auto deviceTransform = painter->deviceTransform();
|
const auto &deviceTransform = painter->deviceTransform();
|
||||||
const QPointF redirectionDelta(deviceTransform.dx(), deviceTransform.dy());
|
const QPointF redirectionDelta(deviceTransform.dx(), deviceTransform.dy());
|
||||||
const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
|
const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
|
||||||
|
|
||||||
@ -771,7 +772,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
|
|||||||
| (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
|
| (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
|
||||||
|
|
||||||
const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
|
const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
|
||||||
SelectClipRgn(dc, 0);
|
SelectClipRgn(dc, nullptr);
|
||||||
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
||||||
return SUCCEEDED(result);
|
return SUCCEEDED(result);
|
||||||
}
|
}
|
||||||
@ -1099,9 +1100,7 @@ QWindowsXPStyle::QWindowsXPStyle()
|
|||||||
/*!
|
/*!
|
||||||
Destroys the style.
|
Destroys the style.
|
||||||
*/
|
*/
|
||||||
QWindowsXPStyle::~QWindowsXPStyle()
|
QWindowsXPStyle::~QWindowsXPStyle() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
void QWindowsXPStyle::unpolish(QApplication *app)
|
void QWindowsXPStyle::unpolish(QApplication *app)
|
||||||
@ -1157,7 +1156,7 @@ void QWindowsXPStyle::polish(QWidget *widget)
|
|||||||
if (!d->hasInitColors) {
|
if (!d->hasInitColors) {
|
||||||
// Get text color for group box labels
|
// Get text color for group box labels
|
||||||
COLORREF cref;
|
COLORREF cref;
|
||||||
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0);
|
XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, 0, 0);
|
||||||
GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
|
GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
|
||||||
d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
|
d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
|
||||||
GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
|
GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
|
||||||
@ -1270,7 +1269,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option,
|
|||||||
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
||||||
MARGINS borderSize;
|
MARGINS borderSize;
|
||||||
if (widget) {
|
if (widget) {
|
||||||
XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme);
|
XPThemeData buttontheme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme);
|
||||||
HTHEME theme = buttontheme.handle();
|
HTHEME theme = buttontheme.handle();
|
||||||
if (theme) {
|
if (theme) {
|
||||||
int stateId;
|
int stateId;
|
||||||
@ -1288,7 +1287,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option,
|
|||||||
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
|
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
|
||||||
rect = option->rect.adjusted(border, border, -border, -border);
|
rect = option->rect.adjusted(border, border, -border, -border);
|
||||||
|
|
||||||
if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
|
if (SUCCEEDED(GetThemeMargins(theme, nullptr, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, nullptr, &borderSize))) {
|
||||||
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
|
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
|
||||||
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
|
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
|
||||||
rect = visualRect(option->direction, option->rect, rect);
|
rect = visualRect(option->direction, option->rect, rect);
|
||||||
@ -1468,7 +1467,7 @@ case PE_Frame:
|
|||||||
return;
|
return;
|
||||||
themeNumber = QWindowsXPStylePrivate::ListViewTheme;
|
themeNumber = QWindowsXPStylePrivate::ListViewTheme;
|
||||||
partId = LVP_LISTGROUP;
|
partId = LVP_LISTGROUP;
|
||||||
XPThemeData theme(widget, 0, themeNumber, partId, 0);
|
XPThemeData theme(widget, nullptr, themeNumber, partId);
|
||||||
|
|
||||||
if (!(flags & State_Enabled))
|
if (!(flags & State_Enabled))
|
||||||
stateId = ETS_DISABLED;
|
stateId = ETS_DISABLED;
|
||||||
@ -1496,9 +1495,9 @@ case PE_Frame:
|
|||||||
p->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment));
|
p->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment));
|
||||||
p->setPen(oldPen);
|
p->setPen(oldPen);
|
||||||
return;
|
return;
|
||||||
} else if (fillType == BT_NONE) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (fillType == BT_NONE)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1514,7 +1513,8 @@ case PE_Frame:
|
|||||||
p->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
p->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
||||||
p->setPen(oldPen);
|
p->setPen(oldPen);
|
||||||
return;
|
return;
|
||||||
} else if (qstyleoption_cast<const QStyleOptionFrame *>(option)) {
|
}
|
||||||
|
if (qstyleoption_cast<const QStyleOptionFrame *>(option)) {
|
||||||
themeNumber = QWindowsXPStylePrivate::EditTheme;
|
themeNumber = QWindowsXPStylePrivate::EditTheme;
|
||||||
partId = EP_EDITTEXT;
|
partId = EP_EDITTEXT;
|
||||||
noContent = true;
|
noContent = true;
|
||||||
@ -1538,7 +1538,7 @@ case PE_Frame:
|
|||||||
if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) {
|
if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) {
|
||||||
p->fillRect(panel->rect, panel->palette.brush(QPalette::Base));
|
p->fillRect(panel->rect, panel->palette.brush(QPalette::Base));
|
||||||
} else {
|
} else {
|
||||||
XPThemeData theme(0, p, themeNumber, partId, stateId, rect);
|
XPThemeData theme(nullptr, p, themeNumber, partId, stateId, rect);
|
||||||
if (!theme.isValid()) {
|
if (!theme.isValid()) {
|
||||||
QWindowsStyle::drawPrimitive(pe, option, p, widget);
|
QWindowsStyle::drawPrimitive(pe, option, p, widget);
|
||||||
return;
|
return;
|
||||||
@ -1587,9 +1587,9 @@ case PE_Frame:
|
|||||||
wchar_t themeFileName[maxlength];
|
wchar_t themeFileName[maxlength];
|
||||||
wchar_t themeColor[maxlength];
|
wchar_t themeColor[maxlength];
|
||||||
// Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
|
// Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
|
||||||
if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
|
if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, nullptr, 0) == S_OK) {
|
||||||
wchar_t *offset = 0;
|
wchar_t *offset = nullptr;
|
||||||
if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) {
|
if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != nullptr) {
|
||||||
offset++;
|
offset++;
|
||||||
if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) {
|
if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) {
|
||||||
useGradient = false;
|
useGradient = false;
|
||||||
@ -1820,7 +1820,7 @@ case PE_Frame:
|
|||||||
bef_v -= delta;
|
bef_v -= delta;
|
||||||
aft_h += delta;
|
aft_h += delta;
|
||||||
aft_v += delta;
|
aft_v += delta;
|
||||||
XPThemeData theme(0, p, QWindowsXPStylePrivate::XpTreeViewTheme);
|
XPThemeData theme(nullptr, p, QWindowsXPStylePrivate::XpTreeViewTheme);
|
||||||
theme.rect = QRect(bef_h, bef_v, decoration_size, decoration_size);
|
theme.rect = QRect(bef_h, bef_v, decoration_size, decoration_size);
|
||||||
theme.partId = TVP_GLYPH;
|
theme.partId = TVP_GLYPH;
|
||||||
theme.stateId = flags & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
|
theme.stateId = flags & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
|
||||||
@ -1912,7 +1912,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
{
|
{
|
||||||
themeNumber = QWindowsXPStylePrivate::StatusTheme;
|
themeNumber = QWindowsXPStylePrivate::StatusTheme;
|
||||||
partId = SP_GRIPPER;
|
partId = SP_GRIPPER;
|
||||||
XPThemeData theme(0, p, themeNumber, partId, 0);
|
XPThemeData theme(nullptr, p, themeNumber, partId);
|
||||||
QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
size.rheight()--;
|
size.rheight()--;
|
||||||
if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
|
if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
|
||||||
@ -1980,7 +1980,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
|
|
||||||
if (btn->features & QStyleOptionButton::HasMenu) {
|
if (btn->features & QStyleOptionButton::HasMenu) {
|
||||||
int mbiw = 0, mbih = 0;
|
int mbiw = 0, mbih = 0;
|
||||||
XPThemeData theme(widget, 0,
|
XPThemeData theme(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::ToolBarTheme,
|
QWindowsXPStylePrivate::ToolBarTheme,
|
||||||
TP_SPLITBUTTONDROPDOWN);
|
TP_SPLITBUTTONDROPDOWN);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
@ -2309,7 +2309,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
|
|
||||||
if (isFloating) {
|
if (isFloating) {
|
||||||
titleRect.adjust(0, -fw, 0, 0);
|
titleRect.adjust(0, -fw, 0, 0);
|
||||||
if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
|
if (widget != nullptr && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
|
||||||
titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
|
titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
titleRect.adjust(mw, 0, 0, 0);
|
titleRect.adjust(mw, 0, 0, 0);
|
||||||
@ -2775,7 +2775,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
|
|||||||
break;
|
break;
|
||||||
v = nextInterval;
|
v = nextInterval;
|
||||||
}
|
}
|
||||||
if (lines.size() > 0) {
|
if (!lines.isEmpty()) {
|
||||||
p->save();
|
p->save();
|
||||||
p->translate(slrect.topLeft());
|
p->translate(slrect.topLeft());
|
||||||
p->drawLines(lines.constData(), lines.size());
|
p->drawLines(lines.constData(), lines.size());
|
||||||
@ -2923,7 +2923,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
|
|||||||
p->save();
|
p->save();
|
||||||
p->setClipRect(menuarea);
|
p->setClipRect(menuarea);
|
||||||
tool.rect = option->rect;
|
tool.rect = option->rect;
|
||||||
proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0);
|
proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, nullptr);
|
||||||
p->restore();
|
p->restore();
|
||||||
}
|
}
|
||||||
// Draw arrow
|
// Draw arrow
|
||||||
@ -3223,7 +3223,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = 0)
|
static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = nullptr)
|
||||||
{
|
{
|
||||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
|
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
|
||||||
return pb->orientation;
|
return pb->orientation;
|
||||||
@ -3234,27 +3234,27 @@ int QWindowsXPStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, cons
|
|||||||
{
|
{
|
||||||
switch (pm) {
|
switch (pm) {
|
||||||
case QStyle::PM_IndicatorWidth:
|
case QStyle::PM_IndicatorWidth:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).width();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).width();
|
||||||
case QStyle::PM_IndicatorHeight:
|
case QStyle::PM_IndicatorHeight:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).height();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).height();
|
||||||
case QStyle::PM_ExclusiveIndicatorWidth:
|
case QStyle::PM_ExclusiveIndicatorWidth:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).width();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).width();
|
||||||
case QStyle::PM_ExclusiveIndicatorHeight:
|
case QStyle::PM_ExclusiveIndicatorHeight:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).height();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).height();
|
||||||
case QStyle::PM_ProgressBarChunkWidth:
|
case QStyle::PM_ProgressBarChunkWidth:
|
||||||
return progressBarOrientation(option) == Qt::Horizontal
|
return progressBarOrientation(option) == Qt::Horizontal
|
||||||
? XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNK).width()
|
? XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNK).width()
|
||||||
: XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNKVERT).height();
|
: XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNKVERT).height();
|
||||||
case QStyle::PM_SliderThickness:
|
case QStyle::PM_SliderThickness:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::TrackBarTheme, TKP_THUMB).height();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::TrackBarTheme, TKP_THUMB).height();
|
||||||
case QStyle::PM_TitleBarHeight:
|
case QStyle::PM_TitleBarHeight:
|
||||||
return widget && (widget->windowType() == Qt::Tool)
|
return widget && (widget->windowType() == Qt::Tool)
|
||||||
? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME)
|
? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME)
|
||||||
: GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME);
|
: GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
case QStyle::PM_MdiSubWindowFrameWidth:
|
case QStyle::PM_MdiSubWindowFrameWidth:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width();
|
||||||
case QStyle::PM_DockWidgetFrameWidth:
|
case QStyle::PM_DockWidgetFrameWidth:
|
||||||
return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLFRAMERIGHT, FS_ACTIVE).width();
|
return XPThemeData::themeSize(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLFRAMERIGHT, FS_ACTIVE).width();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3620,7 +3620,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
|
|||||||
case CT_LineEdit:
|
case CT_LineEdit:
|
||||||
case CT_ComboBox:
|
case CT_ComboBox:
|
||||||
{
|
{
|
||||||
XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
|
XPThemeData buttontheme(widget, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
|
||||||
if (buttontheme.isValid()) {
|
if (buttontheme.isValid()) {
|
||||||
const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
|
const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
|
||||||
const QMarginsF borderSize = buttontheme.margins() * factor;
|
const QMarginsF borderSize = buttontheme.margins() * factor;
|
||||||
@ -3741,11 +3741,11 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const
|
|||||||
titleBarRect.setHeight(tbHeight);
|
titleBarRect.setHeight(tbHeight);
|
||||||
XPThemeData themeData;
|
XPThemeData themeData;
|
||||||
if (titlebar->titleBarState & Qt::WindowMinimized) {
|
if (titlebar->titleBarState & Qt::WindowMinimized) {
|
||||||
themeData = XPThemeData(widget, 0,
|
themeData = XPThemeData(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::WindowTheme,
|
QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_MINCAPTION, CS_ACTIVE, titleBarRect);
|
WP_MINCAPTION, CS_ACTIVE, titleBarRect);
|
||||||
} else
|
} else
|
||||||
themeData = XPThemeData(widget, 0,
|
themeData = XPThemeData(widget, nullptr,
|
||||||
QWindowsXPStylePrivate::WindowTheme,
|
QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_CAPTION, CS_ACTIVE, titleBarRect);
|
WP_CAPTION, CS_ACTIVE, titleBarRect);
|
||||||
mask->region = d->region(themeData) +
|
mask->region = d->region(themeData) +
|
||||||
@ -3774,10 +3774,8 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const
|
|||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QPalette QWindowsXPStyle::standardPalette() const
|
QPalette QWindowsXPStyle::standardPalette() const
|
||||||
{
|
{
|
||||||
if (QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal)
|
return QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal
|
||||||
return *QApplicationPrivate::sys_pal;
|
? *QApplicationPrivate::sys_pal : QWindowsStyle::standardPalette();
|
||||||
else
|
|
||||||
return QWindowsStyle::standardPalette();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -3795,7 +3793,7 @@ QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QSt
|
|||||||
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
||||||
{
|
{
|
||||||
if (widget && widget->isWindow()) {
|
if (widget && widget->isWindow()) {
|
||||||
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
XPThemeData theme(widget, nullptr, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
return QIcon(QWindowsStyle::standardPixmap(standardPixmap, option, widget)).pixmap(size);
|
return QIcon(QWindowsStyle::standardPixmap(standardPixmap, option, widget)).pixmap(size);
|
||||||
@ -3826,9 +3824,9 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon,
|
|||||||
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
||||||
{
|
{
|
||||||
if (d->dockFloat.isNull()) {
|
if (d->dockFloat.isNull()) {
|
||||||
XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData themeSize(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
||||||
XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_MAXBUTTON, MAXBS_NORMAL);
|
WP_MAXBUTTON, MAXBS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
@ -3862,7 +3860,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon,
|
|||||||
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
||||||
{
|
{
|
||||||
if (d->dockClose.isNull()) {
|
if (d->dockClose.isNull()) {
|
||||||
XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
@ -3896,9 +3894,9 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon,
|
|||||||
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
|
||||||
{
|
{
|
||||||
if (d->dockFloat.isNull()) {
|
if (d->dockFloat.isNull()) {
|
||||||
XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData themeSize(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
WP_SMALLCLOSEBUTTON, CBS_NORMAL);
|
||||||
XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
|
XPThemeData theme(nullptr, nullptr, QWindowsXPStylePrivate::WindowTheme,
|
||||||
WP_RESTOREBUTTON, RBS_NORMAL);
|
WP_RESTOREBUTTON, RBS_NORMAL);
|
||||||
if (theme.isValid()) {
|
if (theme.isValid()) {
|
||||||
const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
|
||||||
|
@ -100,11 +100,11 @@ class QDebug;
|
|||||||
class XPThemeData
|
class XPThemeData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit XPThemeData(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
|
explicit XPThemeData(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1,
|
||||||
int part = 0, int state = 0, const QRect &r = QRect())
|
int part = 0, int state = 0, const QRect &r = QRect())
|
||||||
: widget(w), painter(p), theme(themeIn), htheme(0), partId(part), stateId(state),
|
: widget(w), painter(p), theme(themeIn), partId(part), stateId(state),
|
||||||
mirrorHorizontally(false), mirrorVertically(false), noBorder(false),
|
mirrorHorizontally(false), mirrorVertically(false), noBorder(false),
|
||||||
noContent(false), rotate(0), rect(r)
|
noContent(false), rect(r)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
HRGN mask(QWidget *widget);
|
HRGN mask(QWidget *widget);
|
||||||
@ -117,17 +117,17 @@ public:
|
|||||||
QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS);
|
QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS);
|
||||||
QMarginsF margins(int propId = TMT_CONTENTMARGINS);
|
QMarginsF margins(int propId = TMT_CONTENTMARGINS);
|
||||||
|
|
||||||
static QSizeF themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0);
|
static QSizeF themeSize(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1, int part = 0, int state = 0);
|
||||||
static QMarginsF themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
|
static QMarginsF themeMargins(const QRect &rect, const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1,
|
||||||
int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
|
int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
|
||||||
static QMarginsF themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
|
static QMarginsF themeMargins(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1,
|
||||||
int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
|
int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
|
||||||
|
|
||||||
const QWidget *widget;
|
const QWidget *widget;
|
||||||
QPainter *painter;
|
QPainter *painter;
|
||||||
|
|
||||||
int theme;
|
int theme;
|
||||||
HTHEME htheme;
|
HTHEME htheme = nullptr;
|
||||||
int partId;
|
int partId;
|
||||||
int stateId;
|
int stateId;
|
||||||
|
|
||||||
@ -135,18 +135,18 @@ public:
|
|||||||
uint mirrorVertically : 1;
|
uint mirrorVertically : 1;
|
||||||
uint noBorder : 1;
|
uint noBorder : 1;
|
||||||
uint noContent : 1;
|
uint noContent : 1;
|
||||||
uint rotate;
|
uint rotate = 0;
|
||||||
QRect rect;
|
QRect rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ThemeMapKey {
|
struct ThemeMapKey {
|
||||||
int theme;
|
int theme = 0;
|
||||||
int partId;
|
int partId = -1;
|
||||||
int stateId;
|
int stateId = -1;
|
||||||
bool noBorder;
|
bool noBorder = false;
|
||||||
bool noContent;
|
bool noContent = false;
|
||||||
|
|
||||||
ThemeMapKey() : partId(-1), stateId(-1) {}
|
ThemeMapKey() = default;
|
||||||
ThemeMapKey(const XPThemeData &data)
|
ThemeMapKey(const XPThemeData &data)
|
||||||
: theme(data.theme), partId(data.partId), stateId(data.stateId),
|
: theme(data.theme), partId(data.partId), stateId(data.stateId),
|
||||||
noBorder(data.noBorder), noContent(data.noContent) {}
|
noBorder(data.noBorder), noContent(data.noContent) {}
|
||||||
@ -171,7 +171,7 @@ enum AlphaChannelType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ThemeMapData {
|
struct ThemeMapData {
|
||||||
AlphaChannelType alphaType; // Which type of alpha on part & state
|
AlphaChannelType alphaType = UnknownAlpha; // Which type of alpha on part & state
|
||||||
|
|
||||||
bool dataValid : 1; // Only used to detect if hash value is ok
|
bool dataValid : 1; // Only used to detect if hash value is ok
|
||||||
bool partIsTransparent : 1;
|
bool partIsTransparent : 1;
|
||||||
@ -217,15 +217,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
QWindowsXPStylePrivate()
|
QWindowsXPStylePrivate()
|
||||||
: QWindowsStylePrivate(), hasInitColors(false), bufferDC(0), bufferBitmap(0), nullBitmap(0),
|
|
||||||
bufferPixels(0), bufferW(0), bufferH(0)
|
|
||||||
{ init(); }
|
{ init(); }
|
||||||
|
|
||||||
~QWindowsXPStylePrivate()
|
~QWindowsXPStylePrivate()
|
||||||
{ cleanup(); }
|
{ cleanup(); }
|
||||||
|
|
||||||
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
|
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr);
|
||||||
static int fixedPixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
|
static int fixedPixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr);
|
||||||
|
|
||||||
static HWND winId(const QWidget *widget);
|
static HWND winId(const QWidget *widget);
|
||||||
|
|
||||||
@ -251,10 +249,10 @@ public:
|
|||||||
bool fixAlphaChannel(const QRect &rect);
|
bool fixAlphaChannel(const QRect &rect);
|
||||||
bool swapAlphaChannel(const QRect &rect, bool allPixels = false);
|
bool swapAlphaChannel(const QRect &rect, bool allPixels = false);
|
||||||
|
|
||||||
QRgb groupBoxTextColor;
|
QRgb groupBoxTextColor = 0;
|
||||||
QRgb groupBoxTextColorDisabled;
|
QRgb groupBoxTextColorDisabled = 0;
|
||||||
QRgb sliderTickColor;
|
QRgb sliderTickColor = 0;
|
||||||
bool hasInitColors;
|
bool hasInitColors = false;
|
||||||
|
|
||||||
static HTHEME createTheme(int theme, HWND hwnd);
|
static HTHEME createTheme(int theme, HWND hwnd);
|
||||||
static QString themeName(int theme);
|
static QString themeName(int theme);
|
||||||
@ -277,11 +275,12 @@ private:
|
|||||||
static bool use_xp;
|
static bool use_xp;
|
||||||
|
|
||||||
QHash<ThemeMapKey, ThemeMapData> alphaCache;
|
QHash<ThemeMapKey, ThemeMapData> alphaCache;
|
||||||
HDC bufferDC;
|
HDC bufferDC = nullptr;
|
||||||
HBITMAP bufferBitmap;
|
HBITMAP bufferBitmap = nullptr;
|
||||||
HBITMAP nullBitmap;
|
HBITMAP nullBitmap = nullptr;
|
||||||
uchar *bufferPixels;
|
uchar *bufferPixels = nullptr;
|
||||||
int bufferW, bufferH;
|
int bufferW = 0;
|
||||||
|
int bufferH = 0;
|
||||||
|
|
||||||
static HWND m_vistaTreeViewHelper;
|
static HWND m_vistaTreeViewHelper;
|
||||||
static HTHEME m_themes[NThemes];
|
static HTHEME m_themes[NThemes];
|
||||||
@ -292,7 +291,7 @@ inline QSizeF XPThemeData::size()
|
|||||||
QSizeF result(0, 0);
|
QSizeF result(0, 0);
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
SIZE size;
|
SIZE size;
|
||||||
if (SUCCEEDED(GetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
|
if (SUCCEEDED(GetThemePartSize(handle(), nullptr, partId, stateId, nullptr, TS_TRUE, &size)))
|
||||||
result = QSize(size.cx, size.cy);
|
result = QSize(size.cx, size.cy);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -304,7 +303,7 @@ inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId)
|
|||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
MARGINS margins;
|
MARGINS margins;
|
||||||
RECT rect = XPThemeData::toRECT(qRect);
|
RECT rect = XPThemeData::toRECT(qRect);
|
||||||
if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
|
if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, &rect, &margins)))
|
||||||
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
|
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -315,7 +314,7 @@ inline QMarginsF XPThemeData::margins(int propId)
|
|||||||
QMarginsF result(0, 0, 0 ,0);
|
QMarginsF result(0, 0, 0 ,0);
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
MARGINS margins;
|
MARGINS margins;
|
||||||
if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
|
if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, nullptr, &margins)))
|
||||||
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
|
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -120,10 +120,7 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
|
|||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QWindowsStylePrivate::QWindowsStylePrivate()
|
QWindowsStylePrivate::QWindowsStylePrivate() = default;
|
||||||
: alt_down(false), menuBarTimer(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal QWindowsStylePrivate::appDevicePixelRatio()
|
qreal QWindowsStylePrivate::appDevicePixelRatio()
|
||||||
{
|
{
|
||||||
@ -157,7 +154,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
|
|||||||
QList<QWidget *> l = widget->findChildren<QWidget *>();
|
QList<QWidget *> l = widget->findChildren<QWidget *>();
|
||||||
auto ignorable = [](QWidget *w) {
|
auto ignorable = [](QWidget *w) {
|
||||||
return w->isWindow() || !w->isVisible()
|
return w->isWindow() || !w->isVisible()
|
||||||
|| w->style()->styleHint(SH_UnderlineShortcut, 0, w);
|
|| w->style()->styleHint(SH_UnderlineShortcut, nullptr, w);
|
||||||
};
|
};
|
||||||
l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end());
|
l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end());
|
||||||
// Update states before repainting
|
// Update states before repainting
|
||||||
@ -242,7 +239,7 @@ void QWindowsStyle::polish(QApplication *app)
|
|||||||
QCommonStyle::polish(app);
|
QCommonStyle::polish(app);
|
||||||
QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
|
QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func());
|
||||||
// We only need the overhead when shortcuts are sometimes hidden
|
// We only need the overhead when shortcuts are sometimes hidden
|
||||||
if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app)
|
if (!proxy()->styleHint(SH_UnderlineShortcut, nullptr) && app)
|
||||||
app->installEventFilter(this);
|
app->installEventFilter(this);
|
||||||
|
|
||||||
const auto &palette = QGuiApplication::palette();
|
const auto &palette = QGuiApplication::palette();
|
||||||
@ -343,7 +340,6 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm)
|
|||||||
case QStyle::PM_MenuVMargin:
|
case QStyle::PM_MenuVMargin:
|
||||||
case QStyle::PM_ToolBarItemMargin:
|
case QStyle::PM_ToolBarItemMargin:
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
|
||||||
case QStyle::PM_DockWidgetSeparatorExtent:
|
case QStyle::PM_DockWidgetSeparatorExtent:
|
||||||
return 4;
|
return 4;
|
||||||
#if QT_CONFIG(tabbar)
|
#if QT_CONFIG(tabbar)
|
||||||
@ -698,17 +694,17 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
x -= 2;
|
x -= 2;
|
||||||
if (opt->rect.height() > 4) {
|
if (opt->rect.height() > 4) {
|
||||||
qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
|
qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4,
|
||||||
opt->palette, false, 1, 0);
|
opt->palette, false, 1, nullptr);
|
||||||
qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
|
qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4,
|
||||||
opt->palette, false, 1, 0);
|
opt->palette, false, 1, nullptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (opt->rect.width() > 4) {
|
if (opt->rect.width() > 4) {
|
||||||
int y = opt->rect.height() / 2 - 4;
|
int y = opt->rect.height() / 2 - 4;
|
||||||
qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
|
qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3,
|
||||||
opt->palette, false, 1, 0);
|
opt->palette, false, 1, nullptr);
|
||||||
qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
|
qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3,
|
||||||
opt->palette, false, 1, 0);
|
opt->palette, false, 1, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p->restore();
|
p->restore();
|
||||||
@ -759,7 +755,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDrawWinButton(p, opt->rect, opt->palette,
|
qDrawWinButton(p, opt->rect, opt->palette,
|
||||||
opt->state & (State_Sunken | State_On), panel ? &fill : 0);
|
opt->state & (State_Sunken | State_On), panel ? &fill : nullptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p->fillRect(opt->rect, fill);
|
p->fillRect(opt->rect, fill);
|
||||||
@ -980,7 +976,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
|
|
||||||
if (opt->state & (State_Raised | State_On | State_Sunken)) {
|
if (opt->state & (State_Raised | State_On | State_Sunken)) {
|
||||||
qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
|
qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On),
|
||||||
panel ? &fill : 0);
|
panel ? &fill : nullptr);
|
||||||
} else {
|
} else {
|
||||||
if (panel)
|
if (panel)
|
||||||
p->fillRect(opt->rect, fill);
|
p->fillRect(opt->rect, fill);
|
||||||
@ -1005,7 +1001,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
#endif // QT_CONFIG(dockwidget)
|
#endif // QT_CONFIG(dockwidget)
|
||||||
|
|
||||||
case PE_FrameStatusBarItem:
|
case PE_FrameStatusBarItem:
|
||||||
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
|
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, nullptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PE_IndicatorProgressChunk:
|
case PE_IndicatorProgressChunk:
|
||||||
@ -1043,7 +1039,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PE_FrameTabWidget: {
|
case PE_FrameTabWidget: {
|
||||||
qDrawWinButton(p, opt->rect, opt->palette, false, 0);
|
qDrawWinButton(p, opt->rect, opt->palette, false, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1585,6 +1581,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||||||
case QStyleOptionToolBar::Beginning:
|
case QStyleOptionToolBar::Beginning:
|
||||||
case QStyleOptionToolBar::OnlyOne:
|
case QStyleOptionToolBar::OnlyOne:
|
||||||
paintBottomBorder = false;
|
paintBottomBorder = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1600,6 +1597,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||||||
case QStyleOptionToolBar::OnlyOne:
|
case QStyleOptionToolBar::OnlyOne:
|
||||||
paintRightBorder = false;
|
paintRightBorder = false;
|
||||||
paintLeftBorder = false;
|
paintLeftBorder = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,9 @@ public:
|
|||||||
|
|
||||||
bool hasSeenAlt(const QWidget *widget) const;
|
bool hasSeenAlt(const QWidget *widget) const;
|
||||||
bool altDown() const { return alt_down; }
|
bool altDown() const { return alt_down; }
|
||||||
bool alt_down;
|
bool alt_down = false;
|
||||||
QList<const QWidget *> seenAlt;
|
QList<const QWidget *> seenAlt;
|
||||||
int menuBarTimer;
|
int menuBarTimer = 0;
|
||||||
|
|
||||||
QColor inactiveCaptionText;
|
QColor inactiveCaptionText;
|
||||||
QColor activeCaptionColor;
|
QColor activeCaptionColor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user