fix: 修复不跟随系统字体问题
This commit is contained in:
parent
868da6151e
commit
9cd32605c0
|
@ -1,8 +1,9 @@
|
||||||
ukui-menu (4.0.0.9-ok0.1) yangtze; urgency=medium
|
ukui-menu (4.0.0.9-ok0.1build1) yangtze; urgency=medium
|
||||||
|
|
||||||
* issue: #I72IIJ
|
* issue: #I72IIJ
|
||||||
|
* rebuild: 4.0.0.9-ok0.1
|
||||||
|
|
||||||
-- hewenfei <hewenfei@kylinos.cn> Tue, 07 Nov 2023 16:43:13 +0800
|
-- hewenfei <hewenfei@kylinos.cn> Fri, 08 Mar 2024 09:56:46 +0800
|
||||||
|
|
||||||
ukui-menu (4.0.0.9-ok0) yangtze; urgency=medium
|
ukui-menu (4.0.0.9-ok0) yangtze; urgency=medium
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,18 @@ Text {
|
||||||
function updateColor() {
|
function updateColor() {
|
||||||
color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha);
|
color = themePalette.paletteColorWithCustomTransparency(paletteRole, Palette.Active, alpha);
|
||||||
}
|
}
|
||||||
function updateFontSize() {
|
function updateFont() {
|
||||||
systemFontSize = themePalette.systemFontSize();
|
font = themePalette.systemFont();
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
updateColor();
|
updateColor();
|
||||||
updateFontSize();
|
updateFont();
|
||||||
themePalette.styleColorChanged.connect(updateColor);
|
themePalette.styleColorChanged.connect(updateColor);
|
||||||
themePalette.systemFontSizeChanged.connect(updateFontSize);
|
themePalette.systemFontChanged.connect(updateFont);
|
||||||
}
|
}
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
themePalette.styleColorChanged.disconnect(updateColor);
|
themePalette.styleColorChanged.disconnect(updateColor);
|
||||||
themePalette.systemFontSizeChanged.disconnect(updateFontSize);
|
themePalette.systemFontChanged.disconnect(updateFont);
|
||||||
}
|
}
|
||||||
onPaletteRoleChanged: {
|
onPaletteRoleChanged: {
|
||||||
updateColor();
|
updateColor();
|
||||||
|
|
|
@ -42,6 +42,9 @@ ThemePalette::ThemePalette(QObject *parent) : QObject(parent)
|
||||||
connect(qGuiApp, &QGuiApplication::paletteChanged, this, [=] {
|
connect(qGuiApp, &QGuiApplication::paletteChanged, this, [=] {
|
||||||
Q_EMIT styleColorChanged();
|
Q_EMIT styleColorChanged();
|
||||||
});
|
});
|
||||||
|
connect(qGuiApp, &QGuiApplication::fontChanged, this, [=] {
|
||||||
|
Q_EMIT systemFontChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ThemePalette::paletteColor(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup) const
|
QColor ThemePalette::paletteColor(Palette::ColorRole colorRole, Palette::ColorGroup colorGroup) const
|
||||||
|
@ -222,3 +225,8 @@ qreal ThemePalette::systemFontSize() const
|
||||||
{
|
{
|
||||||
return m_fontSize;
|
return m_fontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFont ThemePalette::systemFont()
|
||||||
|
{
|
||||||
|
return QGuiApplication::font();
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
#include <QFont>
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
@ -94,9 +95,11 @@ public:
|
||||||
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_INVOKABLE qreal systemFontSize() const;
|
||||||
|
Q_INVOKABLE QFont systemFont();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void styleColorChanged();
|
void styleColorChanged();
|
||||||
|
void systemFontChanged();
|
||||||
void systemFontSizeChanged();
|
void systemFontSizeChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
Loading…
Reference in New Issue