File tree Expand file tree Collapse file tree 4 files changed +21
-39
lines changed
Expand file tree Collapse file tree 4 files changed +21
-39
lines changed Original file line number Diff line number Diff line change 66#include < QPalette>
77#include < QtMath>
88
9- #include < QtGui/qpa/qplatformwindow.h>
10-
119#include < cmath>
1210
1311WindowHelper::WindowHelper ()
@@ -61,6 +59,16 @@ void WindowHelper::changeScheme() {
6159 qApp->setPalette (currentTheme ().palette ());
6260}
6361
62+ void WindowHelper::handleWindowChange () {
63+ if (!m_window) {
64+ return ;
65+ }
66+ if (LithPlatform::instance ()->isDesktop ()) {
67+ bool isLandscape = m_window->width () > m_window->height ();
68+ landscapeModeSet (isLandscape);
69+ }
70+ }
71+
6472const ColorTheme& WindowHelper::currentTheme () const {
6573 if (m_darkTheme) {
6674 if (m_useBlack) {
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class LITHCORE_EXPORT WindowHelper : public QObject {
2121public:
2222 static WindowHelper* instance ();
2323 static WindowHelper* create (QQmlEngine* qmlEngine, QJSEngine* jsEngine) {
24+ Q_UNUSED (qmlEngine);
25+ Q_UNUSED (jsEngine);
2426 return instance ();
2527 }
2628
@@ -31,10 +33,14 @@ class LITHCORE_EXPORT WindowHelper : public QObject {
3133 const ColorTheme& inverseTheme () const ;
3234 QString currentThemeName () const ;
3335
36+ public slots:
37+ void connectToWindow (QQuickWindow* window);
38+
3439private slots:
3540 void init ();
3641 void prepareToChangeScheme ();
3742 void changeScheme ();
43+ void handleWindowChange ();
3844
3945signals:
4046 void themeChanged ();
@@ -43,6 +49,7 @@ private slots:
4349 explicit WindowHelper ();
4450 void detectSystemDarkStyle ();
4551
52+ QPointer<QQuickWindow> m_window = nullptr ;
4653 QTimer* m_changeSchemeTimer = nullptr ;
4754 bool m_systemPrefersDarkStyle = false ;
4855};
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ Item {
1616 implicitWidth: LithPlatform .mobile ? 480 : 1024
1717 implicitHeight: 800
1818
19+ Component .onCompleted : {
20+ WindowHelper .connectToWindow (Window .window )
21+ }
22+
1923 property real topMargin: {
2024 if (LithPlatform .mobile ) {
2125 if (Qt .inputMethod && Qt .inputMethod .keyboardRectangle && Qt .inputMethod .visible ) {
Original file line number Diff line number Diff line change @@ -25,20 +25,6 @@ Window {
2525 PaletteSwitch {
2626 text: " Switch theme"
2727 }
28- TextField {
29- placeholderText: " Set all margins to"
30- implicitWidth: 192
31- validator: IntValidator {
32-
33- }
34- onAccepted: {
35- WindowHelper .safeAreaMargins .left = text
36- WindowHelper .safeAreaMargins .right = text
37- WindowHelper .safeAreaMargins .top = text
38- WindowHelper .safeAreaMargins .bottom = text
39- text = " "
40- }
41- }
4228 TextField {
4329 placeholderText: " Set error string"
4430 implicitWidth: 192
@@ -53,29 +39,6 @@ Window {
5339 onCheckedChanged: mainView .safeAreaBoundaryCovers = checked
5440 }
5541 }
56- RowLayout {
57- Layout .fillWidth : true
58- Label {
59- text: " Safe Area:"
60- }
61- GridLayout {
62- Layout .fillWidth : true
63- columns: 4
64- Repeater {
65- model: [" left" , " right" , " top" , " bottom" ]
66- Label {
67- text: modelData
68- }
69- }
70- Repeater {
71- model: [" left" , " right" , " top" , " bottom" ]
72- SpinBox {
73- value: WindowHelper .safeAreaMargins [modelData]
74- onValueChanged: WindowHelper .safeAreaMargins [modelData] = value
75- }
76- }
77- }
78- }
7942 }
8043 SettingsDialogContents {
8144 id: settings
You can’t perform that action at this time.
0 commit comments