From d28fbb048704536cefb090dcaf1de4363cb29538 Mon Sep 17 00:00:00 2001 From: qiqi Date: Mon, 15 May 2023 17:28:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=84=A6=E7=82=B9=E5=9C=A8?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=82=B9=E5=87=BB=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=EF=BC=9B=E6=B7=BB=E5=8A=A0=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E8=B7=9F=E9=9A=8F=E4=B8=BB=E9=A2=98=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml/AppControls2/IconLabel.qml | 1 - qml/AppControls2/LabelItem.qml | 1 - qml/AppControls2/StyleText.qml | 25 ++++++++++++++++--------- qml/AppUI/AppPageHeader.qml | 1 + qml/AppUI/EditText.qml | 10 +++++++--- qml/AppUI/FullScreenContent.qml | 2 -- qml/AppUI/FullScreenFolder.qml | 1 - qml/AppUI/NormalUI.qml | 1 + qml/AppUI/PluginSelectMenu.qml | 11 ++++++++++- qml/AppUI/SearchInputBar.qml | 3 +-- qml/AppUI/Sidebar.qml | 2 +- src/settings/settings.cpp | 9 ++++++++- src/settings/settings.h | 3 ++- src/uiconfig/theme-palette.cpp | 16 ++++++++++++++++ src/uiconfig/theme-palette.h | 5 +++++ 15 files changed, 68 insertions(+), 23 deletions(-) diff --git a/qml/AppControls2/IconLabel.qml b/qml/AppControls2/IconLabel.qml index b9ed242..3c6fc7d 100644 --- a/qml/AppControls2/IconLabel.qml +++ b/qml/AppControls2/IconLabel.qml @@ -66,7 +66,6 @@ Item { StyleText { id: iconText text: root.appName - font.pixelSize: 14 elide: Text.ElideRight paletteRole: root.textHighLight ? Palette.HighlightedText : Palette.Text } diff --git a/qml/AppControls2/LabelItem.qml b/qml/AppControls2/LabelItem.qml index dcbfc72..436bddb 100644 --- a/qml/AppControls2/LabelItem.qml +++ b/qml/AppControls2/LabelItem.qml @@ -30,7 +30,6 @@ MouseArea { horizontalAlignment: Qt.AlignLeft verticalAlignment: Qt.AlignVCenter - font.pixelSize: 14 font.bold: true text: name } diff --git a/qml/AppControls2/StyleText.qml b/qml/AppControls2/StyleText.qml index 8f23661..de4b127 100644 --- a/qml/AppControls2/StyleText.qml +++ b/qml/AppControls2/StyleText.qml @@ -3,24 +3,31 @@ import org.ukui.menu.core 1.0 Text { property int paletteRole: Palette.Text - property real alpha: 1.0 + property real alpha: 1 + property real systemFontSize: 10 + property real textUltra: 2*systemFontSize + font.pointSize: systemFontSize function updateColor() { - color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha) + color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha); + } + function updateFontSize() { + systemFontSize = themePalette.systemFontSize(); } - Component.onCompleted: { - updateColor() - themePalette.styleColorChanged.connect(updateColor) + updateColor(); + updateFontSize(); + themePalette.styleColorChanged.connect(updateColor); + themePalette.systemFontSizeChanged.connect(updateFontSize); } Component.onDestruction: { - themePalette.styleColorChanged.disconnect(updateColor) + themePalette.styleColorChanged.disconnect(updateColor); + themePalette.systemFontSizeChanged.disconnect(updateFontSize); } - onPaletteRoleChanged: { - updateColor() + updateColor(); } onAlphaChanged: { - updateColor() + updateColor(); } } diff --git a/qml/AppUI/AppPageHeader.qml b/qml/AppUI/AppPageHeader.qml index 970ed71..34e8c28 100644 --- a/qml/AppUI/AppPageHeader.qml +++ b/qml/AppUI/AppPageHeader.qml @@ -145,6 +145,7 @@ Item { activeFocusOnTab: true onClicked: { + normalUI.focusToFalse(); searchInputBar.clear(); root.state = "normal"; } diff --git a/qml/AppUI/EditText.qml b/qml/AppUI/EditText.qml index 740a0de..8fa96c5 100644 --- a/qml/AppUI/EditText.qml +++ b/qml/AppUI/EditText.qml @@ -28,6 +28,7 @@ Item { property bool editStatus: false property string textEdited: title property bool isFullScreenFolder: false + property real textInputSize: 14 Component { id: unEditText @@ -39,12 +40,15 @@ Item { text: contain.textEdited paletteRole: isFullScreenFolder ? Palette.HighlightedText : Palette.Text font.bold: !isFullScreenFolder - font.pixelSize: isFullScreenFolder ? 32 : 14 + font.pointSize: isFullScreenFolder ? textUltra : systemFontSize MouseArea { id: textArea anchors.fill: parent - onDoubleClicked: contain.editStatus = true; + onDoubleClicked: { + contain.editStatus = true; + contain.textInputSize = textShow.font.pointSize; + } } } } @@ -74,7 +78,7 @@ Item { selectByMouse: true maximumLength: 14 font.bold: !isFullScreenFolder - font.pixelSize: isFullScreenFolder ? 32 : 14 + font.pointSize: contain.textInputSize onEditingFinished: { modelManager.getFolderModel().renameFolder(text); diff --git a/qml/AppUI/FullScreenContent.qml b/qml/AppUI/FullScreenContent.qml index c56736b..1942c33 100644 --- a/qml/AppUI/FullScreenContent.qml +++ b/qml/AppUI/FullScreenContent.qml @@ -266,7 +266,6 @@ RowLayout { anchors.bottomMargin: 20 anchors.horizontalCenter: parent.horizontalCenter text: name - font.pixelSize: 14 elide: Text.ElideRight paletteRole: Palette.HighlightedText } @@ -369,7 +368,6 @@ RowLayout { anchors.horizontalCenter: parent.horizontalCenter elide: Text.ElideRight text: name - font.pixelSize: 14 paletteRole: Palette.HighlightedText } } diff --git a/qml/AppUI/FullScreenFolder.qml b/qml/AppUI/FullScreenFolder.qml index 4b1c40a..a6faa27 100644 --- a/qml/AppUI/FullScreenFolder.qml +++ b/qml/AppUI/FullScreenFolder.qml @@ -268,7 +268,6 @@ Loader { anchors.topMargin: folderIconBase.iconSpacing anchors.horizontalCenter: parent.horizontalCenter text: name - font.pixelSize: 14 elide: Text.ElideRight paletteRole: Palette.HighlightedText } diff --git a/qml/AppUI/NormalUI.qml b/qml/AppUI/NormalUI.qml index 17b0630..40323c3 100644 --- a/qml/AppUI/NormalUI.qml +++ b/qml/AppUI/NormalUI.qml @@ -4,6 +4,7 @@ import AppControls2 1.0 as AppControls2 import org.ukui.menu.core 1.0 FocusScope { + id: normalUI anchors.fill: parent function focusToFalse() { focus = false; diff --git a/qml/AppUI/PluginSelectMenu.qml b/qml/AppUI/PluginSelectMenu.qml index 16ba4f8..01cdfec 100644 --- a/qml/AppUI/PluginSelectMenu.qml +++ b/qml/AppUI/PluginSelectMenu.qml @@ -28,6 +28,11 @@ RowLayout { id: pluginSelectMenuRoot property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem) spacing: 2 + function resetFocus() { + if(!mainWindow.isFullScreen) { + normalUI.focusToFalse(); + } + } AppControls2.RoundButton { id: pluginSelectButton @@ -39,7 +44,10 @@ RowLayout { highlight: mainWindow.isFullScreen autoHighLight: !mainWindow.isFullScreen buttonIcon: "image://appicon/ukui-selected" - onClicked: pluginSelectMenuRoot.model.autoSwitchProvider() + onClicked: { + resetFocus(); + pluginSelectMenuRoot.model.autoSwitchProvider(); + } Keys.onPressed: { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { pluginSelectMenuRoot.model.autoSwitchProvider(); @@ -62,6 +70,7 @@ RowLayout { } } onClicked: { + resetFocus(); sortMenuClicked(); } function sortMenuClicked() { diff --git a/qml/AppUI/SearchInputBar.qml b/qml/AppUI/SearchInputBar.qml index a47a2ef..74658ef 100644 --- a/qml/AppUI/SearchInputBar.qml +++ b/qml/AppUI/SearchInputBar.qml @@ -68,7 +68,6 @@ AppControls2.StyleBackground { anchors.left: searchIcon.right text: qsTr("Search App") visible: textInput.contentWidth === 0 - font.pixelSize: 14 paletteRole: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text verticalAlignment: TextInput.AlignVCenter alpha: 0.25 @@ -96,7 +95,7 @@ AppControls2.StyleBackground { height: parent.height selectByMouse: true verticalAlignment: TextInput.AlignVCenter - font.pixelSize: 14 + font.pointSize: defaultText.font.pointSize focus: parent.visible || mainWindow.isFullScreen KeyNavigation.down: keyDownTarget diff --git a/qml/AppUI/Sidebar.qml b/qml/AppUI/Sidebar.qml index c4fa80a..b92edf1 100644 --- a/qml/AppUI/Sidebar.qml +++ b/qml/AppUI/Sidebar.qml @@ -194,7 +194,6 @@ Item { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter font.bold: parent.ListView.isCurrentItem - wrapMode: Text.ElideRight paletteRole: parent.ListView.isCurrentItem ? Palette.Highlight: Palette.Text text: model.name @@ -203,6 +202,7 @@ Item { MouseArea { anchors.fill: parent onClicked: { + normalUI.focusToFalse(); parent.ListView.view.currentIndex = model.index; } } diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp index 5290be4..02a90b4 100644 --- a/src/settings/settings.cpp +++ b/src/settings/settings.cpp @@ -30,6 +30,7 @@ #define UKUI_STYLE_SCHEMA "org.ukui.style" #define UKUI_STYLE_NAME_KEY "styleName" #define UKUI_STYLE_THEME_COLOR_KEY "themeColor" +#define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize" namespace UkuiMenu { @@ -54,6 +55,7 @@ void GlobalSetting::initStyleSetting() { m_cache.insert(StyleName, UKUI_STYLE_VALUE_LIGHT); m_cache.insert(ThemeColor, UKUI_STYLE_THEME_COLOR_KEY); + m_cache.insert(SystemFontSize, UKUI_STYLE_SYSTEM_FONT_SIZE); m_cache.insert(Transparency, 1); m_cache.insert(EffectEnabled, false); @@ -67,7 +69,9 @@ void GlobalSetting::initStyleSetting() if (keys.contains(UKUI_STYLE_THEME_COLOR_KEY)) { m_cache.insert(ThemeColor,settings->get(UKUI_STYLE_THEME_COLOR_KEY)); } - + if (keys.contains(UKUI_STYLE_SYSTEM_FONT_SIZE)) { + m_cache.insert(SystemFontSize,settings->get(UKUI_STYLE_SYSTEM_FONT_SIZE)); + } connect(settings, &QGSettings::changed, this, [this, settings] (const QString &key) { if (key == UKUI_STYLE_NAME_KEY) { updateData(StyleName, settings->get(key)); @@ -75,6 +79,9 @@ void GlobalSetting::initStyleSetting() } else if (key == UKUI_STYLE_THEME_COLOR_KEY) { updateData(ThemeColor, settings->get(key)); Q_EMIT styleChanged(ThemeColor); + } else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) { + updateData(SystemFontSize, settings->get(key)); + Q_EMIT styleChanged(SystemFontSize); } }); } diff --git a/src/settings/settings.h b/src/settings/settings.h index 30994f2..3768faa 100644 --- a/src/settings/settings.h +++ b/src/settings/settings.h @@ -53,7 +53,8 @@ public: StyleName, ThemeColor, Transparency, - EffectEnabled + EffectEnabled, + SystemFontSize }; Q_ENUM(Key) diff --git a/src/uiconfig/theme-palette.cpp b/src/uiconfig/theme-palette.cpp index e436ec8..05bb1a9 100644 --- a/src/uiconfig/theme-palette.cpp +++ b/src/uiconfig/theme-palette.cpp @@ -188,7 +188,9 @@ void ThemePalette::initStyleSetting() { GlobalSetting *setting = GlobalSetting::instance(); m_transparency = setting->get(GlobalSetting::Transparency).toReal(); + m_fontSize = setting->get(GlobalSetting::SystemFontSize).toReal(); connect(setting, &GlobalSetting::styleChanged, this, &ThemePalette::styleChangedSlot); + connect(setting, &GlobalSetting::styleChanged, this, &ThemePalette::systemFontSizeChangedSlot); } void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key) @@ -199,3 +201,17 @@ void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key) Q_EMIT styleColorChanged(); } + +void ThemePalette::systemFontSizeChangedSlot(const GlobalSetting::Key &key) +{ + if (key & GlobalSetting::SystemFontSize) { + m_fontSize = GlobalSetting::instance()->get(GlobalSetting::SystemFontSize).toReal(); + } + + Q_EMIT systemFontSizeChanged(); +} + +qreal ThemePalette::systemFontSize() const +{ + return m_fontSize; +} diff --git a/src/uiconfig/theme-palette.h b/src/uiconfig/theme-palette.h index d26c7d0..a558546 100644 --- a/src/uiconfig/theme-palette.h +++ b/src/uiconfig/theme-palette.h @@ -92,11 +92,15 @@ public: Q_INVOKABLE QColor highlightedText(Palette::ColorGroup colorGroup = Palette::Active) const; Q_INVOKABLE QColor separator(Palette::ColorGroup colorGroup = Palette::Active) const; + Q_INVOKABLE qreal systemFontSize() const; + Q_SIGNALS: void styleColorChanged(); + void systemFontSizeChanged(); private Q_SLOTS: void styleChangedSlot(const GlobalSetting::Key& key); + void systemFontSizeChangedSlot(const GlobalSetting::Key& key); private: explicit ThemePalette(QObject *parent = nullptr); @@ -105,6 +109,7 @@ private: private: qreal m_transparency = 1.0; + qreal m_fontSize = 12; }; }