aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/material/qquickmaterialtheme.cpp18
-rw-r--r--src/imports/controls/material/qquickmaterialtheme_p.h3
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp7
3 files changed, 27 insertions, 1 deletions
diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp
index 63def7a5..3ea41779 100644
--- a/src/imports/controls/material/qquickmaterialtheme.cpp
+++ b/src/imports/controls/material/qquickmaterialtheme.cpp
@@ -36,6 +36,7 @@
#include "qquickmaterialtheme_p.h"
+#include <QtGui/qpa/qplatformdialoghelper.h>
#include <QtGui/qfont.h>
#include <QtGui/qfontinfo.h>
@@ -105,4 +106,21 @@ const QFont *QQuickMaterialTheme::font(QPlatformTheme::Font type) const
}
}
+QVariant QQuickMaterialTheme::themeHint(ThemeHint hint) const
+{
+ switch (hint) {
+ case QPlatformTheme::DialogButtonBoxLayout:
+ // https://material.io/guidelines/components/dialogs.html#dialogs-specs
+ // As per spec, affirmative actions are placed to the right, dismissive
+ // actions are placed directly to the left of affirmative actions.
+ // In the Android sources, there are additional type of actions -
+ // neutral, which are placed to the left.
+ // Rules for macOS seems to be the most suitable here and are also used
+ // in the Android QPA plugin.
+ return QVariant(QPlatformDialogHelper::MacLayout);
+ default:
+ return QQuickProxyTheme::themeHint(hint);
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialtheme_p.h b/src/imports/controls/material/qquickmaterialtheme_p.h
index 828ca83a..d505d4ff 100644
--- a/src/imports/controls/material/qquickmaterialtheme_p.h
+++ b/src/imports/controls/material/qquickmaterialtheme_p.h
@@ -48,6 +48,7 @@
// We mean it.
//
+#include <QtCore/qvariant.h>
#include <QtGui/qfont.h>
#include <QtQuickControls2/private/qquickproxytheme_p.h>
@@ -60,6 +61,8 @@ public:
const QFont *font(Font type = SystemFont) const override;
+ QVariant themeHint(ThemeHint hint) const override;
+
private:
QFont systemFont;
QFont buttonFont;
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index 40b1e2c7..b85e85c8 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -258,7 +258,12 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
return firstRole != QPlatformDialogHelper::InvalidRole;
}
- const int *m_layout = QPlatformDialogHelper::buttonLayout();
+ static const int *themeButtonLayout()
+ {
+ const int hint = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt();
+ return QPlatformDialogHelper::buttonLayout(Qt::Horizontal, static_cast<QPlatformDialogHelper::ButtonLayout>(hint));
+ }
+ const int *m_layout = themeButtonLayout();
};
std::sort(buttons.begin(), buttons.end(), ButtonLayout());