添加焦点在鼠标点击情况下清空;添加字体大小跟随主题功能

This commit is contained in:
qiqi 2023-05-15 17:28:48 +08:00 committed by He Sir
parent 7eacbe5a5e
commit d28fbb0487
15 changed files with 68 additions and 23 deletions

View File

@ -66,7 +66,6 @@ Item {
StyleText { StyleText {
id: iconText id: iconText
text: root.appName text: root.appName
font.pixelSize: 14
elide: Text.ElideRight elide: Text.ElideRight
paletteRole: root.textHighLight ? Palette.HighlightedText : Palette.Text paletteRole: root.textHighLight ? Palette.HighlightedText : Palette.Text
} }

View File

@ -30,7 +30,6 @@ MouseArea {
horizontalAlignment: Qt.AlignLeft horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
font.pixelSize: 14
font.bold: true font.bold: true
text: name text: name
} }

View File

@ -3,24 +3,31 @@ import org.ukui.menu.core 1.0
Text { Text {
property int paletteRole: Palette.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() { function updateColor() {
color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha) color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha);
}
function updateFontSize() {
systemFontSize = themePalette.systemFontSize();
} }
Component.onCompleted: { Component.onCompleted: {
updateColor() updateColor();
themePalette.styleColorChanged.connect(updateColor) updateFontSize();
themePalette.styleColorChanged.connect(updateColor);
themePalette.systemFontSizeChanged.connect(updateFontSize);
} }
Component.onDestruction: { Component.onDestruction: {
themePalette.styleColorChanged.disconnect(updateColor) themePalette.styleColorChanged.disconnect(updateColor);
themePalette.systemFontSizeChanged.disconnect(updateFontSize);
} }
onPaletteRoleChanged: { onPaletteRoleChanged: {
updateColor() updateColor();
} }
onAlphaChanged: { onAlphaChanged: {
updateColor() updateColor();
} }
} }

View File

@ -145,6 +145,7 @@ Item {
activeFocusOnTab: true activeFocusOnTab: true
onClicked: { onClicked: {
normalUI.focusToFalse();
searchInputBar.clear(); searchInputBar.clear();
root.state = "normal"; root.state = "normal";
} }

View File

@ -28,6 +28,7 @@ Item {
property bool editStatus: false property bool editStatus: false
property string textEdited: title property string textEdited: title
property bool isFullScreenFolder: false property bool isFullScreenFolder: false
property real textInputSize: 14
Component { Component {
id: unEditText id: unEditText
@ -39,12 +40,15 @@ Item {
text: contain.textEdited text: contain.textEdited
paletteRole: isFullScreenFolder ? Palette.HighlightedText : Palette.Text paletteRole: isFullScreenFolder ? Palette.HighlightedText : Palette.Text
font.bold: !isFullScreenFolder font.bold: !isFullScreenFolder
font.pixelSize: isFullScreenFolder ? 32 : 14 font.pointSize: isFullScreenFolder ? textUltra : systemFontSize
MouseArea { MouseArea {
id: textArea id: textArea
anchors.fill: parent anchors.fill: parent
onDoubleClicked: contain.editStatus = true; onDoubleClicked: {
contain.editStatus = true;
contain.textInputSize = textShow.font.pointSize;
}
} }
} }
} }
@ -74,7 +78,7 @@ Item {
selectByMouse: true selectByMouse: true
maximumLength: 14 maximumLength: 14
font.bold: !isFullScreenFolder font.bold: !isFullScreenFolder
font.pixelSize: isFullScreenFolder ? 32 : 14 font.pointSize: contain.textInputSize
onEditingFinished: { onEditingFinished: {
modelManager.getFolderModel().renameFolder(text); modelManager.getFolderModel().renameFolder(text);

View File

@ -266,7 +266,6 @@ RowLayout {
anchors.bottomMargin: 20 anchors.bottomMargin: 20
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: name text: name
font.pixelSize: 14
elide: Text.ElideRight elide: Text.ElideRight
paletteRole: Palette.HighlightedText paletteRole: Palette.HighlightedText
} }
@ -369,7 +368,6 @@ RowLayout {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
elide: Text.ElideRight elide: Text.ElideRight
text: name text: name
font.pixelSize: 14
paletteRole: Palette.HighlightedText paletteRole: Palette.HighlightedText
} }
} }

View File

@ -268,7 +268,6 @@ Loader {
anchors.topMargin: folderIconBase.iconSpacing anchors.topMargin: folderIconBase.iconSpacing
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: name text: name
font.pixelSize: 14
elide: Text.ElideRight elide: Text.ElideRight
paletteRole: Palette.HighlightedText paletteRole: Palette.HighlightedText
} }

View File

@ -4,6 +4,7 @@ import AppControls2 1.0 as AppControls2
import org.ukui.menu.core 1.0 import org.ukui.menu.core 1.0
FocusScope { FocusScope {
id: normalUI
anchors.fill: parent anchors.fill: parent
function focusToFalse() { function focusToFalse() {
focus = false; focus = false;

View File

@ -28,6 +28,11 @@ RowLayout {
id: pluginSelectMenuRoot id: pluginSelectMenuRoot
property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem) property var model: appPageHeaderUtils.model(PluginGroup.SortMenuItem)
spacing: 2 spacing: 2
function resetFocus() {
if(!mainWindow.isFullScreen) {
normalUI.focusToFalse();
}
}
AppControls2.RoundButton { AppControls2.RoundButton {
id: pluginSelectButton id: pluginSelectButton
@ -39,7 +44,10 @@ RowLayout {
highlight: mainWindow.isFullScreen highlight: mainWindow.isFullScreen
autoHighLight: !mainWindow.isFullScreen autoHighLight: !mainWindow.isFullScreen
buttonIcon: "image://appicon/ukui-selected" buttonIcon: "image://appicon/ukui-selected"
onClicked: pluginSelectMenuRoot.model.autoSwitchProvider() onClicked: {
resetFocus();
pluginSelectMenuRoot.model.autoSwitchProvider();
}
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
pluginSelectMenuRoot.model.autoSwitchProvider(); pluginSelectMenuRoot.model.autoSwitchProvider();
@ -62,6 +70,7 @@ RowLayout {
} }
} }
onClicked: { onClicked: {
resetFocus();
sortMenuClicked(); sortMenuClicked();
} }
function sortMenuClicked() { function sortMenuClicked() {

View File

@ -68,7 +68,6 @@ AppControls2.StyleBackground {
anchors.left: searchIcon.right anchors.left: searchIcon.right
text: qsTr("Search App") text: qsTr("Search App")
visible: textInput.contentWidth === 0 visible: textInput.contentWidth === 0
font.pixelSize: 14
paletteRole: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text paletteRole: mainWindow.isFullScreen ? Palette.HighlightedText : Palette.Text
verticalAlignment: TextInput.AlignVCenter verticalAlignment: TextInput.AlignVCenter
alpha: 0.25 alpha: 0.25
@ -96,7 +95,7 @@ AppControls2.StyleBackground {
height: parent.height height: parent.height
selectByMouse: true selectByMouse: true
verticalAlignment: TextInput.AlignVCenter verticalAlignment: TextInput.AlignVCenter
font.pixelSize: 14 font.pointSize: defaultText.font.pointSize
focus: parent.visible || mainWindow.isFullScreen focus: parent.visible || mainWindow.isFullScreen
KeyNavigation.down: keyDownTarget KeyNavigation.down: keyDownTarget

View File

@ -194,7 +194,6 @@ Item {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
font.bold: parent.ListView.isCurrentItem font.bold: parent.ListView.isCurrentItem
wrapMode: Text.ElideRight
paletteRole: parent.ListView.isCurrentItem ? Palette.Highlight: Palette.Text paletteRole: parent.ListView.isCurrentItem ? Palette.Highlight: Palette.Text
text: model.name text: model.name
@ -203,6 +202,7 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
normalUI.focusToFalse();
parent.ListView.view.currentIndex = model.index; parent.ListView.view.currentIndex = model.index;
} }
} }

View File

@ -30,6 +30,7 @@
#define UKUI_STYLE_SCHEMA "org.ukui.style" #define UKUI_STYLE_SCHEMA "org.ukui.style"
#define UKUI_STYLE_NAME_KEY "styleName" #define UKUI_STYLE_NAME_KEY "styleName"
#define UKUI_STYLE_THEME_COLOR_KEY "themeColor" #define UKUI_STYLE_THEME_COLOR_KEY "themeColor"
#define UKUI_STYLE_SYSTEM_FONT_SIZE "systemFontSize"
namespace UkuiMenu { namespace UkuiMenu {
@ -54,6 +55,7 @@ void GlobalSetting::initStyleSetting()
{ {
m_cache.insert(StyleName, UKUI_STYLE_VALUE_LIGHT); m_cache.insert(StyleName, UKUI_STYLE_VALUE_LIGHT);
m_cache.insert(ThemeColor, UKUI_STYLE_THEME_COLOR_KEY); 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(Transparency, 1);
m_cache.insert(EffectEnabled, false); m_cache.insert(EffectEnabled, false);
@ -67,7 +69,9 @@ void GlobalSetting::initStyleSetting()
if (keys.contains(UKUI_STYLE_THEME_COLOR_KEY)) { if (keys.contains(UKUI_STYLE_THEME_COLOR_KEY)) {
m_cache.insert(ThemeColor,settings->get(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) { connect(settings, &QGSettings::changed, this, [this, settings] (const QString &key) {
if (key == UKUI_STYLE_NAME_KEY) { if (key == UKUI_STYLE_NAME_KEY) {
updateData(StyleName, settings->get(key)); updateData(StyleName, settings->get(key));
@ -75,6 +79,9 @@ void GlobalSetting::initStyleSetting()
} else if (key == UKUI_STYLE_THEME_COLOR_KEY) { } else if (key == UKUI_STYLE_THEME_COLOR_KEY) {
updateData(ThemeColor, settings->get(key)); updateData(ThemeColor, settings->get(key));
Q_EMIT styleChanged(ThemeColor); Q_EMIT styleChanged(ThemeColor);
} else if (key == UKUI_STYLE_SYSTEM_FONT_SIZE) {
updateData(SystemFontSize, settings->get(key));
Q_EMIT styleChanged(SystemFontSize);
} }
}); });
} }

View File

@ -53,7 +53,8 @@ public:
StyleName, StyleName,
ThemeColor, ThemeColor,
Transparency, Transparency,
EffectEnabled EffectEnabled,
SystemFontSize
}; };
Q_ENUM(Key) Q_ENUM(Key)

View File

@ -188,7 +188,9 @@ void ThemePalette::initStyleSetting()
{ {
GlobalSetting *setting = GlobalSetting::instance(); GlobalSetting *setting = GlobalSetting::instance();
m_transparency = setting->get(GlobalSetting::Transparency).toReal(); 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::styleChangedSlot);
connect(setting, &GlobalSetting::styleChanged, this, &ThemePalette::systemFontSizeChangedSlot);
} }
void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key) void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key)
@ -199,3 +201,17 @@ void ThemePalette::styleChangedSlot(const GlobalSetting::Key& key)
Q_EMIT styleColorChanged(); 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;
}

View File

@ -92,11 +92,15 @@ public:
Q_INVOKABLE QColor highlightedText(Palette::ColorGroup colorGroup = Palette::Active) const; Q_INVOKABLE QColor highlightedText(Palette::ColorGroup colorGroup = Palette::Active) const;
Q_INVOKABLE QColor separator(Palette::ColorGroup colorGroup = Palette::Active) const; Q_INVOKABLE QColor separator(Palette::ColorGroup colorGroup = Palette::Active) const;
Q_INVOKABLE qreal systemFontSize() const;
Q_SIGNALS: Q_SIGNALS:
void styleColorChanged(); void styleColorChanged();
void systemFontSizeChanged();
private Q_SLOTS: private Q_SLOTS:
void styleChangedSlot(const GlobalSetting::Key& key); void styleChangedSlot(const GlobalSetting::Key& key);
void systemFontSizeChangedSlot(const GlobalSetting::Key& key);
private: private:
explicit ThemePalette(QObject *parent = nullptr); explicit ThemePalette(QObject *parent = nullptr);
@ -105,6 +109,7 @@ private:
private: private:
qreal m_transparency = 1.0; qreal m_transparency = 1.0;
qreal m_fontSize = 12;
}; };
} }