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

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 {
id: iconText
text: root.appName
font.pixelSize: 14
elide: Text.ElideRight
paletteRole: root.textHighLight ? Palette.HighlightedText : Palette.Text
}

View File

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

View File

@ -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();
}
}

View File

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

View File

@ -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);

View File

@ -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
}
}

View File

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

View File

@ -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;

View File

@ -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() {

View File

@ -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

View File

@ -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;
}
}

View File

@ -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);
}
});
}

View File

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

View File

@ -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;
}

View File

@ -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;
};
}