diff --git a/app/ui/Main.qml b/app/ui/Main.qml index 2fbf3da5..e2b9d02a 100644 --- a/app/ui/Main.qml +++ b/app/ui/Main.qml @@ -11,8 +11,8 @@ ApplicationWindow { title: qsTr("GM-Companion") visible: true - width: 1280 - height: 720 + width: SettingsManager.window.width + height: SettingsManager.window.height minimumWidth: 640 minimumHeight: 480 @@ -83,6 +83,11 @@ ApplicationWindow { } } + onClosing: { + SettingsManager.window.width = root.width; + SettingsManager.window.height = root.height; + } + MessageDialog { id: message_dialog width: root.width - 100 @@ -96,7 +101,7 @@ ApplicationWindow { Drawer { id: drawer - width: SettingsManager.showToolNames ? Sizes.sidebarWidth : Sizes.toolbarWidth + width: SettingsManager.window.showToolNames ? Sizes.sidebarWidth : Sizes.toolbarWidth height: parent.height modal: false interactive: false diff --git a/app/ui/main/SideMenuButton.qml b/app/ui/main/SideMenuButton.qml index 57b73d4f..4eb50995 100644 --- a/app/ui/main/SideMenuButton.qml +++ b/app/ui/main/SideMenuButton.qml @@ -24,7 +24,7 @@ Button { font.bold: false ToolTip.delay: 1000 - ToolTip.visible: root.hovered && !SettingsManager.showToolNames + ToolTip.visible: root.hovered && !SettingsManager.window.showToolNames ToolTip.text: root.toolName Row { @@ -50,7 +50,7 @@ Button { Text { text: root.toolName font.pixelSize: 16 - visible: SettingsManager.showToolNames + visible: SettingsManager.window.showToolNames width: parent.width - parent.spacing - parent.padding * 2 - parent.iconWidth clip: true diff --git a/app/ui/tools/settings/GeneralPage.qml b/app/ui/tools/settings/GeneralPage.qml index 52cc7b61..0315c2c9 100644 --- a/app/ui/tools/settings/GeneralPage.qml +++ b/app/ui/tools/settings/GeneralPage.qml @@ -63,8 +63,8 @@ SplitView { // Show Tool Names CheckBox { text: qsTr("Show tool names in menu") - checked: SettingsManager.showToolNames - onClicked: SettingsManager.showToolNames = checked + checked: SettingsManager.window.showToolNames + onClicked: SettingsManager.window.showToolNames = checked } Row { diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index b1ef50db..32a18b49 100755 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -37,6 +37,7 @@ set(SRC_SETTINGS settings/quick/settingsmanager.cpp settings/quick/services.h settings/quick/colors.h + settings/quick/window.h settings/quick/macros.h settings/quick/spotify.h settings/quick/google.h diff --git a/src/common/settings/quick/settingsmanager.h b/src/common/settings/quick/settingsmanager.h index 7099c0b6..fbd839c6 100644 --- a/src/common/settings/quick/settingsmanager.h +++ b/src/common/settings/quick/settingsmanager.h @@ -6,6 +6,7 @@ #include "qmlsingletonfactory.h" #include "services.h" #include "thirdparty/propertyhelper/PropertyHelper.h" +#include "window.h" #include #include #include @@ -26,9 +27,9 @@ class SettingsManager : public QObject Q_PROPERTY(Common::Settings::Quick::Services *services READ services CONSTANT FINAL) Q_PROPERTY(Common::Settings::Quick::Colors *colors READ colors CONSTANT FINAL) + Q_PROPERTY(Common::Settings::Quick::Window *window READ window CONSTANT FINAL) // General Settings - SETTINGS_PROPERTY_VAL(bool, showToolNames, false) SETTINGS_PROPERTY(QString, cloudMode, QStringLiteral("local")) READ_PROPERTY2(QString, languageBcp47, Common::Settings::SettingsManager::instance()->getLanguageBcp47()) @@ -64,6 +65,11 @@ class SettingsManager : public QObject return &m_colors; } + auto window() -> Window * + { + return &m_window; + } + static auto instance() -> SettingsManager *; signals: @@ -74,6 +80,7 @@ class SettingsManager : public QObject Services m_services; Colors m_colors; + Window m_window; inline static SettingsManager *m_instance = nullptr; }; diff --git a/src/common/settings/quick/window.h b/src/common/settings/quick/window.h new file mode 100644 index 00000000..e5dcb286 --- /dev/null +++ b/src/common/settings/quick/window.h @@ -0,0 +1,30 @@ +#pragma once + +#include "../settingsmanager.h" +#include "macros.h" +#include +#include + +namespace Common::Settings::Quick +{ + +class Window : public QObject +{ + Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("") + + SETTINGS_PROPERTY_VAL(int, width, WIDTH_DEFAULT) + SETTINGS_PROPERTY_VAL(int, height, HEIGHT_DEFAULT) + + SETTINGS_PROPERTY_VAL(bool, showToolNames, false) + +public: + using QObject::QObject; + +private: + static constexpr int WIDTH_DEFAULT = 1280; + static constexpr int HEIGHT_DEFAULT = 720; +}; + +} // namespace Common::Settings::Quick