feat(mainwindow): Get transparency by GlobalSettings' interface.

Description: 使用GlobalSettings类提供的接口获取透明度

Log: 使用GlobalSettings类提供的接口获取透明度
This commit is contained in:
zhangjiaping 2021-01-06 14:40:48 +08:00
parent 33608a71ab
commit 2d6d41b05f
2 changed files with 17 additions and 16 deletions

View File

@ -75,6 +75,11 @@ MainWindow::MainWindow(QWidget *parent) :
if (QGSettings::isSchemaInstalled(id)) { if (QGSettings::isSchemaInstalled(id)) {
m_transparency_gsettings = new QGSettings(id); m_transparency_gsettings = new QGSettings(id);
} }
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) {
this->setPalette(pal);
this->update();
});
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -325,22 +330,18 @@ void MainWindow::searchContent(QString searchcontent){
//使用GSetting获取当前窗口应该使用的透明度 //使用GSetting获取当前窗口应该使用的透明度
double MainWindow::getTransparentData() double MainWindow::getTransparentData()
{ {
//todo modify here!!!!!!!!!!!!!!!!!!!!!!!!!!!! return GlobalSettings::getInstance()->getValue(TRANSPARENCY_KEY).toDouble();
//todo modify here!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (!m_transparency_gsettings) {
//todo modify here!!!!!!!!!!!!!!!!!!!!!!!!!!!! // return 0.7;
//if you have questions, please ask iaom or MouseZhangZh // }
// return GlobalSettings::getInstance()->getValue(TRANSPARENCY_KEY).toDouble();
if (!m_transparency_gsettings) {
return 0.7;
}
QStringList keys = m_transparency_gsettings->keys(); // QStringList keys = m_transparency_gsettings->keys();
if (keys.contains("transparency")) { // if (keys.contains("transparency")) {
double tp = m_transparency_gsettings->get("transparency").toDouble(); // double tp = m_transparency_gsettings->get("transparency").toDouble();
return tp; // return tp;
} else { // } else {
return 0.7; // return 0.7;
} // }
} }
/** /**

View File

@ -57,7 +57,7 @@ qm_files.files = $$OUT_PWD/res/translations/*.qm
INSTALLS += \ INSTALLS += \
qm_files \ qm_files \
LIBS += -L$$PWD/../libsearch -lukui-search -L$$PWD/../libchinese-segmentation/ -lchinese-segmentation LIBS += -L$$OUT_PWD/../libsearch -lukui-search -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
INCLUDEPATH += $$PWD/../libsearch INCLUDEPATH += $$PWD/../libsearch
DEPENDPATH += $$PWD/../libsearch DEPENDPATH += $$PWD/../libsearch