summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp23
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp98
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style_p.h1
4 files changed, 89 insertions, 35 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index e0ef6cec794..4c4e5fac962 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -491,7 +491,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
return;
if (m_panel.visible) {
- const QString selection = QString::fromNSString(m_panel.URL.path);
+ const QString selection = QString::fromNSString(m_panel.URL.path).normalized(QString::NormalizationForm_C);
if (selection != m_currentSelection) {
m_currentSelection = selection;
emit m_helper->currentChanged(QUrl::fromLocalFile(selection));
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 8e3ab67ced5..72daffb56b1 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -466,15 +466,17 @@ static bool applyBlurBehindWindow(HWND hwnd)
return result;
}
+static bool shouldShowTitlebarButton(Qt::WindowFlags flags, Qt::WindowFlags button)
+{
+ return !flags.testFlag(Qt::CustomizeWindowHint) || flags.testFlags(Qt::CustomizeWindowHint | button);
+}
+
// from qwidget_win.cpp, pass flags separately in case they have been "autofixed".
static bool shouldShowMaximizeButton(const QWindow *w, Qt::WindowFlags flags)
{
- if ((flags & Qt::MSWindowsFixedSizeDialogHint) || !(flags & Qt::WindowMaximizeButtonHint))
- return false;
- // if the user explicitly asked for the maximize button, we try to add
- // it even if the window has fixed size.
- return (flags & Qt::CustomizeWindowHint) ||
- w->maximumSize() == QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX);
+ return !flags.testFlag(Qt::MSWindowsFixedSizeDialogHint) &&
+ (shouldShowTitlebarButton(flags, Qt::WindowMaximizeButtonHint) ||
+ w->maximumSize() == QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
}
bool QWindowsWindow::hasNoNativeFrame(HWND hwnd, Qt::WindowFlags flags)
@@ -805,6 +807,7 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
if (topLevel) {
if ((type == Qt::Window || dialog || tool)) {
+ const bool defaultTitlebar = !flags.testFlag(Qt::CustomizeWindowHint);
if (!(flags & Qt::FramelessWindowHint)) {
style |= WS_POPUP;
if (flags & Qt::MSWindowsFixedSizeDialogHint) {
@@ -812,16 +815,16 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
} else {
style |= WS_THICKFRAME;
}
- if (flags & Qt::WindowTitleHint)
+ if (defaultTitlebar || flags.testFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint))
style |= WS_CAPTION; // Contains WS_DLGFRAME
}
- if (flags & Qt::WindowSystemMenuHint)
+ if (defaultTitlebar || flags.testFlags(Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint))
style |= WS_SYSMENU;
- else if (dialog && (flags & Qt::WindowCloseButtonHint) && !(flags & Qt::FramelessWindowHint)) {
+ else if (dialog && (defaultTitlebar || flags.testFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)) && !(flags & Qt::FramelessWindowHint)) {
style |= WS_SYSMENU | WS_BORDER; // QTBUG-2027, dialogs without system menu.
exStyle |= WS_EX_DLGMODALFRAME;
}
- const bool showMinimizeButton = flags & Qt::WindowMinimizeButtonHint;
+ const bool showMinimizeButton = shouldShowTitlebarButton(flags, Qt::WindowMinimizeButtonHint);
if (showMinimizeButton)
style |= WS_MINIMIZEBOX;
const bool showMaximizeButton = shouldShowMaximizeButton(w, flags);
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index 2944c02fd79..410750d941d 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -109,6 +109,7 @@ inline ControlState calcControlState(const QStyleOption *option)
#define More u"\uE712"_s
#define Help u"\uE897"_s
+#define Clear u"\uE894"_s
template <typename R, typename P, typename B>
static inline void drawRoundedRect(QPainter *p, R &&rect, P &&pen, B &&brush)
@@ -1720,9 +1721,10 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
case CE_ItemViewItem: {
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
- QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget);
- QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
+ const auto p = proxy();
+ QRect checkRect = p->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
+ QRect iconRect = p->subElementRect(SE_ItemViewItemDecoration, vopt, widget);
+ QRect textRect = p->subElementRect(SE_ItemViewItemText, vopt, widget);
// draw the background
proxy()->drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
@@ -1823,16 +1825,17 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
d->viewItemDrawText(painter, vopt, textRect);
// paint a vertical marker for QListView
- if (vopt->state & State_Selected) {
+ if (vopt->state & State_Selected && !highContrastTheme) {
if (const QListView *lv = qobject_cast<const QListView *>(widget);
- lv && lv->viewMode() != QListView::IconMode && !highContrastTheme) {
- painter->setPen(vopt->palette.accent().color());
- const auto xPos = isRtl ? rect.right() - 1 : rect.left();
- const QLineF lines[2] = {
- QLineF(xPos, rect.y() + 2, xPos, rect.y() + rect.height() - 2),
- QLineF(xPos + 1, rect.y() + 2, xPos + 1, rect.y() + rect.height() - 2),
- };
- painter->drawLines(lines, 2);
+ lv && lv->viewMode() != QListView::IconMode) {
+ const auto col = vopt->palette.accent().color();
+ painter->setBrush(col);
+ painter->setPen(col);
+ const auto xPos = isRtl ? rect.right() - 4.5f : rect.left() + 3.5f;
+ const auto yOfs = rect.height() / 4.;
+ QRectF r(QPointF(xPos, rect.y() + yOfs),
+ QPointF(xPos + 1, rect.y() + rect.height() - yOfs));
+ painter->drawRoundedRect(r, 1, 1);
}
}
}
@@ -1883,22 +1886,29 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
case QStyle::SE_LineEditContents:
ret = option->rect.adjusted(4,0,-4,0);
break;
- case QStyle::SE_ItemViewItemText:
- if (const auto *item = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- const int decorationOffset = item->features.testFlag(QStyleOptionViewItem::HasDecoration) ? item->decorationSize.width() : 0;
- const int checkboxOffset = item->features.testFlag(QStyleOptionViewItem::HasCheckIndicator) ? 16 : 0;
- if (widget && qobject_cast<QComboBoxPrivateContainer *>(widget->parentWidget())) {
- if (option->direction == Qt::LeftToRight)
- ret = option->rect.adjusted(decorationOffset + checkboxOffset + 5, 0, -5, 0);
- else
- ret = option->rect.adjusted(5, 0, decorationOffset - checkboxOffset - 5, 0);
+ case SE_ItemViewItemCheckIndicator:
+ case SE_ItemViewItemDecoration:
+ case SE_ItemViewItemText: {
+ ret = QWindowsVistaStyle::subElementRect(element, option, widget);
+ if (!ret.isValid() || highContrastTheme)
+ return ret;
+
+ if (const QListView *lv = qobject_cast<const QListView *>(widget);
+ lv && lv->viewMode() != QListView::IconMode) {
+ const int xOfs = contentHMargin;
+ const bool isRtl = option->direction == Qt::RightToLeft;
+ if (isRtl) {
+ ret.moveRight(ret.right() - xOfs);
+ if (ret.left() < option->rect.left())
+ ret.setLeft(option->rect.left());
} else {
- ret = QWindowsVistaStyle::subElementRect(element, option, widget);
+ ret.moveLeft(ret.left() + xOfs);
+ if (ret.right() > option->rect.right())
+ ret.setRight(option->rect.right());
}
- } else {
- ret = QWindowsVistaStyle::subElementRect(element, option, widget);
}
break;
+ }
#if QT_CONFIG(progressbar)
case SE_ProgressBarGroove:
case SE_ProgressBarContents:
@@ -2091,6 +2101,19 @@ QRect QWindows11Style::subControlRect(ComplexControl control, const QStyleOption
}
break;
}
+#if QT_CONFIG(groupbox)
+ case CC_GroupBox: {
+ ret = QWindowsVistaStyle::subControlRect(control, option, subControl, widget);
+ switch (subControl) {
+ case SC_GroupBoxCheckBox:
+ ret.moveTop(1);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+#endif // QT_CONFIG(groupbox)
default:
ret = QWindowsVistaStyle::subControlRect(control, option, subControl, widget);
}
@@ -2234,6 +2257,25 @@ QSize QWindows11Style::sizeFromContents(ContentsType type, const QStyleOption *o
contentSize.rwidth() += 2 * contentHMargin - oldMargin;
break;
}
+ case CT_ItemViewItem: {
+ if (const auto *viewItemOpt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
+ if (const QListView *lv = qobject_cast<const QListView *>(widget);
+ lv && lv->viewMode() != QListView::IconMode) {
+ QStyleOptionViewItem vOpt(*viewItemOpt);
+ // viewItemSize only takes PM_FocusFrameHMargin into account but no additional
+ // margin, therefore adjust it here for a correct width during layouting when
+ // WrapText is enabled
+ vOpt.rect.setRight(vOpt.rect.right() - contentHMargin);
+ contentSize = QWindowsVistaStyle::sizeFromContents(type, &vOpt, size, widget);
+ contentSize.rwidth() += contentHMargin;
+ contentSize.rheight() += 2 * contentHMargin;
+
+ } else {
+ contentSize = QWindowsVistaStyle::sizeFromContents(type, option, size, widget);
+ }
+ }
+ break;
+ }
default:
contentSize = QWindowsVistaStyle::sizeFromContents(type, option, size, widget);
break;
@@ -2544,6 +2586,7 @@ void QWindows11Style::polish(QPalette& result)
d->m_titleBarCloseIcon = QIcon();
d->m_titleBarNormalIcon = QIcon();
d->m_toolbarExtensionButton = QIcon();
+ d->m_lineEditClearButton = QIcon();
}
QPixmap QWindows11Style::standardPixmap(StandardPixmap standardPixmap,
@@ -2568,6 +2611,13 @@ QIcon QWindows11Style::standardIcon(StandardPixmap standardIcon,
{
auto *d = const_cast<QWindows11StylePrivate*>(d_func());
switch (standardIcon) {
+ case SP_LineEditClearButton: {
+ if (d->m_lineEditClearButton.isNull()) {
+ auto e = new WinFontIconEngine(Clear.at(0), d->assetFont);
+ d->m_lineEditClearButton = QIcon(e);
+ }
+ return d->m_lineEditClearButton;
+ }
case SP_ToolBarHorizontalExtensionButton:
case SP_ToolBarVerticalExtensionButton: {
if (d->m_toolbarExtensionButton.isNull()) {
diff --git a/src/plugins/styles/modernwindows/qwindows11style_p.h b/src/plugins/styles/modernwindows/qwindows11style_p.h
index 736caae956c..a51a93ddd9b 100644
--- a/src/plugins/styles/modernwindows/qwindows11style_p.h
+++ b/src/plugins/styles/modernwindows/qwindows11style_p.h
@@ -123,6 +123,7 @@ class QWindows11StylePrivate : public QWindowsVistaStylePrivate {
protected:
QIcon m_toolbarExtensionButton;
+ QIcon m_lineEditClearButton;
};
QT_END_NAMESPACE