summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/styles')
-rw-r--r--src/plugins/styles/.prev_CMakeLists.txt11
-rw-r--r--src/plugins/styles/CMakeLists.txt11
-rw-r--r--src/plugins/styles/android/qandroidstyle.cpp2
-rw-r--r--src/plugins/styles/mac/CMakeLists.txt23
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm121
-rw-r--r--src/plugins/styles/windowsvista/CMakeLists.txt27
6 files changed, 127 insertions, 68 deletions
diff --git a/src/plugins/styles/.prev_CMakeLists.txt b/src/plugins/styles/.prev_CMakeLists.txt
new file mode 100644
index 0000000000..73329915f6
--- /dev/null
+++ b/src/plugins/styles/.prev_CMakeLists.txt
@@ -0,0 +1,11 @@
+# Generated from styles.pro.
+
+if(QT_FEATURE_style_android)
+ add_subdirectory(android)
+endif()
+if(QT_FEATURE_style_mac)
+ add_subdirectory(mac)
+endif()
+if(QT_FEATURE_style_windowsvista)
+ add_subdirectory(windowsvista)
+endif()
diff --git a/src/plugins/styles/CMakeLists.txt b/src/plugins/styles/CMakeLists.txt
new file mode 100644
index 0000000000..d24e3daff8
--- /dev/null
+++ b/src/plugins/styles/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Generated from styles.pro.
+
+if(QT_FEATURE_style_android)
+ # add_subdirectory(android) # special case TODO
+endif()
+if(QT_FEATURE_style_mac)
+ add_subdirectory(mac)
+endif()
+if(QT_FEATURE_style_windowsvista)
+ add_subdirectory(windowsvista)
+endif()
diff --git a/src/plugins/styles/android/qandroidstyle.cpp b/src/plugins/styles/android/qandroidstyle.cpp
index 086df92322..1d0838daec 100644
--- a/src/plugins/styles/android/qandroidstyle.cpp
+++ b/src/plugins/styles/android/qandroidstyle.cpp
@@ -248,7 +248,7 @@ QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::PrimitiveElement primit
case QStyle::PE_FrameLineEdit:
return QC_EditText;
- case QStyle::PE_IndicatorViewItemCheck:
+ case QStyle::PE_IndicatorItemViewItemCheck:
case QStyle::PE_IndicatorCheckBox:
return QC_Checkbox;
diff --git a/src/plugins/styles/mac/CMakeLists.txt b/src/plugins/styles/mac/CMakeLists.txt
new file mode 100644
index 0000000000..140d4e4c93
--- /dev/null
+++ b/src/plugins/styles/mac/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Generated from mac.pro.
+
+#####################################################################
+## QMacStylePlugin Plugin:
+#####################################################################
+
+qt_add_plugin(QMacStylePlugin
+ OUTPUT_NAME qmacstyle
+ TYPE styles
+ SOURCES
+ main.mm
+ qmacstyle_mac.mm qmacstyle_mac_p.h
+ qmacstyle_mac_p_p.h
+ LIBRARIES
+ ${FWAppKit}
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::WidgetsPrivate
+)
+
+#### Keys ignored in scope 1:.:.:mac.pro:<TRUE>:
+# DISTFILES = "macstyle.json"
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 8e4aaa19c7..70e97b0295 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -855,7 +855,8 @@ static inline int qt_mac_aqua_get_metric(QAquaMetric m)
return qt_mac_aqua_metrics[m];
}
-static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg, QSize szHint,
+static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QStyleOption *opt,
+ const QWidget *widg, QSize szHint,
QStyleHelper::WidgetSizePolicy sz)
{
QSize ret(-1, -1);
@@ -919,12 +920,9 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
switch (ct) {
#if QT_CONFIG(pushbutton)
case QStyle::CT_PushButton: {
- const QPushButton *psh = qobject_cast<const QPushButton *>(widg);
- // If this comparison is false, then the widget was not a push button.
- // This is bad and there's very little we can do since we were requested to find a
- // sensible size for a widget that pretends to be a QPushButton but is not.
- if(psh) {
- QString buttonText = qt_mac_removeMnemonics(psh->text());
+ const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt);
+ if (btn) {
+ QString buttonText = qt_mac_removeMnemonics(btn->text);
if (buttonText.contains(QLatin1Char('\n')))
ret = QSize(-1, -1);
else if (sz == QStyleHelper::SizeLarge)
@@ -934,11 +932,11 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
else if (sz == QStyleHelper::SizeMini)
ret = QSize(-1, qt_mac_aqua_get_metric(MiniPushButtonHeight));
- if (!psh->icon().isNull()){
+ if (!btn->icon.isNull()){
// If the button got an icon, and the icon is larger than the
// button, we can't decide on a default size
ret.setWidth(-1);
- if (ret.height() < psh->iconSize().height())
+ if (ret.height() < btn->iconSize.height())
ret.setHeight(-1);
}
else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){
@@ -952,18 +950,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
// or accept button (i.e., rightmost) and cancel button have the same width.
ret.setWidth(69);
}
- } else {
- // The only sensible thing to do is to return whatever the style suggests...
- if (sz == QStyleHelper::SizeLarge)
- ret = QSize(-1, qt_mac_aqua_get_metric(PushButtonHeight));
- else if (sz == QStyleHelper::SizeSmall)
- ret = QSize(-1, qt_mac_aqua_get_metric(SmallPushButtonHeight));
- else if (sz == QStyleHelper::SizeMini)
- ret = QSize(-1, qt_mac_aqua_get_metric(MiniPushButtonHeight));
- else
- // Since there's no default size we return the large size...
- ret = QSize(-1, qt_mac_aqua_get_metric(PushButtonHeight));
- }
+ }
#endif
#if 0 //Not sure we are applying the rules correctly for RadioButtons/CheckBoxes --Sam
} else if (ct == QStyle::CT_RadioButton) {
@@ -1019,19 +1006,19 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
int width = 0, height = 0;
if (szHint == QSize(-1, -1)) { //just 'guess'..
#if QT_CONFIG(toolbutton)
- const QToolButton *bt = qobject_cast<const QToolButton *>(widg);
+ const QStyleOptionToolButton *bt = qstyleoption_cast<const QStyleOptionToolButton *>(opt);
// If this conversion fails then the widget was not what it claimed to be.
if(bt) {
- if (!bt->icon().isNull()) {
- QSize iconSize = bt->iconSize();
- QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal);
+ if (!bt->icon.isNull()) {
+ QSize iconSize = bt->iconSize;
+ QSize pmSize = bt->icon.actualSize(QSize(32, 32), QIcon::Normal);
width = qMax(width, qMax(iconSize.width(), pmSize.width()));
height = qMax(height, qMax(iconSize.height(), pmSize.height()));
}
- if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) {
- int text_width = bt->fontMetrics().horizontalAdvance(bt->text()),
- text_height = bt->fontMetrics().height();
- if (bt->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) {
+ if (!bt->text.isNull() && bt->toolButtonStyle != Qt::ToolButtonIconOnly) {
+ int text_width = bt->fontMetrics.horizontalAdvance(bt->text),
+ text_height = bt->fontMetrics.height();
+ if (bt->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
width = qMax(width, text_width);
height += text_height;
} else {
@@ -1057,37 +1044,37 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
break;
case QStyle::CT_Slider: {
int w = -1;
- const QSlider *sld = qobject_cast<const QSlider *>(widg);
+ const QStyleOptionSlider *sld = qstyleoption_cast<const QStyleOptionSlider *>(opt);
// If this conversion fails then the widget was not what it claimed to be.
if(sld) {
if (sz == QStyleHelper::SizeLarge) {
- if (sld->orientation() == Qt::Horizontal) {
+ if (sld->orientation == Qt::Horizontal) {
w = qt_mac_aqua_get_metric(HSliderHeight);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(HSliderTickHeight);
} else {
w = qt_mac_aqua_get_metric(VSliderWidth);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(VSliderTickWidth);
}
} else if (sz == QStyleHelper::SizeSmall) {
- if (sld->orientation() == Qt::Horizontal) {
+ if (sld->orientation == Qt::Horizontal) {
w = qt_mac_aqua_get_metric(SmallHSliderHeight);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(SmallHSliderTickHeight);
} else {
w = qt_mac_aqua_get_metric(SmallVSliderWidth);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(SmallVSliderTickWidth);
}
} else if (sz == QStyleHelper::SizeMini) {
- if (sld->orientation() == Qt::Horizontal) {
+ if (sld->orientation == Qt::Horizontal) {
w = qt_mac_aqua_get_metric(MiniHSliderHeight);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(MiniHSliderTickHeight);
} else {
w = qt_mac_aqua_get_metric(MiniVSliderWidth);
- if (sld->tickPosition() != QSlider::NoTicks)
+ if (sld->tickPosition != QSlider::NoTicks)
w += qt_mac_aqua_get_metric(MiniVSliderTickWidth);
}
}
@@ -1099,7 +1086,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
w = qt_mac_aqua_get_metric(HSliderHeight);
w += qt_mac_aqua_get_metric(HSliderTickHeight);
}
- if (sld->orientation() == Qt::Horizontal)
+ if (sld->orientation == Qt::Horizontal)
ret.setHeight(w);
else
ret.setWidth(w);
@@ -1497,9 +1484,9 @@ QStyleHelper::WidgetSizePolicy QMacStylePrivate::aquaSizeConstrain(const QStyleO
return QStyleHelper::SizeDefault;
}
- QSize large = qt_aqua_get_known_size(ct, widg, szHint, QStyleHelper::SizeLarge),
- small = qt_aqua_get_known_size(ct, widg, szHint, QStyleHelper::SizeSmall),
- mini = qt_aqua_get_known_size(ct, widg, szHint, QStyleHelper::SizeMini);
+ QSize large = qt_aqua_get_known_size(ct, option, widg, szHint, QStyleHelper::SizeLarge),
+ small = qt_aqua_get_known_size(ct, option, widg, szHint, QStyleHelper::SizeSmall),
+ mini = qt_aqua_get_known_size(ct, option, widg, szHint, QStyleHelper::SizeMini);
bool guess_size = false;
QStyleHelper::WidgetSizePolicy ret = QStyleHelper::SizeDefault;
QStyleHelper::WidgetSizePolicy wsp = QStyleHelper::widgetSizePolicy(widg);
@@ -1654,24 +1641,24 @@ bool QMacStylePrivate::CocoaControl::getCocoaButtonTypeAndBezelStyle(NSButtonTyp
{
switch (type) {
case Button_CheckBox:
- *buttonType = NSSwitchButton;
- *bezelStyle = NSRegularSquareBezelStyle;
+ *buttonType = NSButtonTypeSwitch;
+ *bezelStyle = NSBezelStyleRegularSquare;
break;
case Button_Disclosure:
- *buttonType = NSOnOffButton;
- *bezelStyle = NSDisclosureBezelStyle;
+ *buttonType = NSButtonTypeOnOff;
+ *bezelStyle = NSBezelStyleDisclosure;
break;
case Button_RadioButton:
- *buttonType = NSRadioButton;
- *bezelStyle = NSRegularSquareBezelStyle;
+ *buttonType = NSButtonTypeRadio;
+ *bezelStyle = NSBezelStyleRegularSquare;
break;
case Button_SquareButton:
- *buttonType = NSPushOnPushOffButton;
- *bezelStyle = NSShadowlessSquareBezelStyle;
+ *buttonType = NSButtonTypePushOnPushOff;
+ *bezelStyle = NSBezelStyleShadowlessSquare;
break;
case Button_PushButton:
- *buttonType = NSPushOnPushOffButton;
- *bezelStyle = NSRoundedBezelStyle;
+ *buttonType = NSButtonTypePushOnPushOff;
+ *bezelStyle = NSBezelStyleRounded;
break;
default:
return false;
@@ -1990,8 +1977,8 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const
break;
case Button_Disclosure: {
NSButtonCell *bc = [[NSButtonCell alloc] init];
- bc.buttonType = NSOnOffButton;
- bc.bezelStyle = NSDisclosureBezelStyle;
+ bc.buttonType = NSButtonTypeOnOff;
+ bc.bezelStyle = NSBezelStyleDisclosure;
cell = bc;
break;
}
@@ -2490,7 +2477,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
aSize = QStyleHelper::SizeSmall;
else
aSize = QStyleHelper::SizeLarge;
- const QSize size = qt_aqua_get_known_size(CT_SizeGrip, widget, QSize(), aSize);
+ const QSize size = qt_aqua_get_known_size(CT_SizeGrip, opt, widget, QSize(), aSize);
ret = size.width();
break; }
case PM_MdiSubWindowFrameWidth:
@@ -2767,12 +2754,12 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
}
const QRgb *sptr = (QRgb*)img.bits(), *srow;
- const int sbpl = img.bytesPerLine();
+ const qsizetype sbpl = img.bytesPerLine();
const int w = sbpl/4, h = img.height();
QImage img_mask(img.width(), img.height(), QImage::Format_ARGB32);
QRgb *dptr = (QRgb*)img_mask.bits(), *drow;
- const int dbpl = img_mask.bytesPerLine();
+ const qsizetype dbpl = img_mask.bytesPerLine();
for (int y = 0; y < h; ++y) {
srow = sptr+((y*sbpl)/4);
@@ -3263,7 +3250,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
CGContextRestoreGState(cg);
break; }
- case PE_IndicatorViewItemCheck:
+ case PE_IndicatorItemViewItemCheck:
case PE_IndicatorRadioButton:
case PE_IndicatorCheckBox: {
const bool isEnabled = opt->state & State_Enabled;
@@ -3274,8 +3261,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *tb = static_cast<NSButton *>(d->cocoaControl(cw));
tb.enabled = isEnabled;
- tb.state = (opt->state & State_NoChange) ? NSMixedState :
- (opt->state & State_On) ? NSOnState : NSOffState;
+ tb.state = (opt->state & State_NoChange) ? NSControlStateValueMixed :
+ (opt->state & State_On) ? NSControlStateValueOn : NSControlStateValueOff;
[tb highlight:isPressed];
const auto vOffset = [=] {
// As measured
@@ -3297,7 +3284,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
break;
const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Button_Disclosure, QStyleHelper::SizeLarge);
NSButtonCell *triangleCell = static_cast<NSButtonCell *>(d->cocoaCell(cw));
- [triangleCell setState:(opt->state & State_Open) ? NSOnState : NSOffState];
+ [triangleCell setState:(opt->state & State_Open) ? NSControlStateValueOn : NSControlStateValueOff];
bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus);
[triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleDark : NSBackgroundStyleLight];
@@ -3716,7 +3703,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pb.enabled = isEnabled;
[pb highlight:isPressed];
- pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
+ pb.state = isHighlighted && !isPressed ? NSControlStateValueOn : NSControlStateValueOff;
d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) {
[pb.cell drawBezelWithFrame:r inView:pb.superview];
});
@@ -3941,7 +3928,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pb.enabled = isEnabled;
[pb highlight:isPressed];
// Set off state when inactive. See needsInactiveHack for when it's selected
- pb.state = (isActive && isSelected && !isPressed) ? NSOnState : NSOffState;
+ pb.state = (isActive && isSelected && !isPressed) ? NSControlStateValueOn : NSControlStateValueOff;
const auto drawBezelBlock = ^(CGContextRef ctx, const CGRect &r) {
CGContextClipToRect(ctx, opt->rect.toCGRect());
@@ -5706,12 +5693,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *pb = static_cast<NSButton *>(d->cocoaControl(cw));
- pb.bezelStyle = NSShadowlessSquareBezelStyle; // TODO Use NSTexturedRoundedBezelStyle in the future.
+ pb.bezelStyle = NSBezelStyleShadowlessSquare; // TODO Use NSTexturedRoundedBezelStyle in the future.
pb.frame = opt->rect.toCGRect();
- pb.buttonType = NSPushOnPushOffButton;
+ pb.buttonType = NSButtonTypePushOnPushOff;
pb.enabled = isEnabled;
[pb highlight:isPressed];
- pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
+ pb.state = isHighlighted && !isPressed ? NSControlStateValueOn : NSControlStateValueOff;
const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton, widget);
d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef, const CGRect &rect) {
[pb.cell drawBezelWithFrame:rect inView:pb];
diff --git a/src/plugins/styles/windowsvista/CMakeLists.txt b/src/plugins/styles/windowsvista/CMakeLists.txt
new file mode 100644
index 0000000000..008fa624fe
--- /dev/null
+++ b/src/plugins/styles/windowsvista/CMakeLists.txt
@@ -0,0 +1,27 @@
+# Generated from windowsvista.pro.
+
+#####################################################################
+## QWindowsVistaStylePlugin Plugin:
+#####################################################################
+
+qt_add_plugin(QWindowsVistaStylePlugin
+ OUTPUT_NAME qwindowsvistastyle
+ TYPE styles
+ SOURCES
+ main.cpp
+ qwindowsvistastyle.cpp qwindowsvistastyle_p.h
+ qwindowsvistastyle_p_p.h
+ qwindowsxpstyle.cpp qwindowsxpstyle_p.h
+ qwindowsxpstyle_p_p.h
+ LIBRARIES
+ gdi32
+ user32
+ uxtheme
+ PUBLIC_LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::WidgetsPrivate
+)
+
+#### Keys ignored in scope 1:.:.:windowsvista.pro:<TRUE>:
+# DISTFILES = "windowsvistastyle.json"