🐞 fix(投屏窗口): 添加标题栏字体字号变化
180469 【多端协同】修改字体大小或样式,投屏窗口的标题栏名称不会跟随变化
This commit is contained in:
parent
5251c87368
commit
c3ab595c85
|
@ -3,6 +3,9 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <KF5/KWindowSystem/KWindowSystem>
|
||||
#include <QMouseEvent>
|
||||
#include <gsettingmonitor.h>
|
||||
|
||||
#define UKUI_STYLE_GSETTING_PATH "org.ukui.style"
|
||||
|
||||
VideoTitle::VideoTitle(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -11,6 +14,29 @@ VideoTitle::VideoTitle(QWidget *parent) : QWidget(parent)
|
|||
initMenu();
|
||||
// 信号连接槽
|
||||
connectInit();
|
||||
|
||||
double fontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
|
||||
QFont font;
|
||||
font.setPointSizeF(fontSize);
|
||||
m_titleNameLab->setFont(font);
|
||||
connect(kdk::GsettingMonitor::getInstance(), &kdk::GsettingMonitor::systemFontSizeChange, this, [=]() {
|
||||
double fontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
|
||||
QFont font;
|
||||
font.setPointSizeF(fontSize);
|
||||
m_titleNameLab->setFont(font);
|
||||
});
|
||||
if (QGSettings::isSchemaInstalled(UKUI_STYLE_GSETTING_PATH)) {
|
||||
m_fontData = new QGSettings(UKUI_STYLE_GSETTING_PATH);
|
||||
connect(m_fontData, &QGSettings::changed, this, [=](const QString &key) {
|
||||
if (key == "systemFont") {
|
||||
qDebug() << "The font changes...";
|
||||
double fontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
|
||||
QFont font;
|
||||
font.setPointSizeF(fontSize);
|
||||
m_titleNameLab->setFont(font);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
VideoTitle::~VideoTitle()
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QAction>
|
||||
#include <QMouseEvent>
|
||||
#include <tablemodelistener.h>
|
||||
#include <QGSettings>
|
||||
|
||||
class VideoTitle : public QWidget
|
||||
{
|
||||
|
@ -65,6 +66,7 @@ private:
|
|||
bool isStayOnTop = false;
|
||||
bool m_isTable = false;
|
||||
Qt::WindowStates m_oldState = Qt::WindowState::WindowNoState;
|
||||
QGSettings *m_fontData = nullptr; // 字体变化
|
||||
};
|
||||
|
||||
#endif // VIDEOTITLE_H
|
||||
|
|
Loading…
Reference in New Issue