代码拉取完成,页面将自动刷新
#include "mainwindow.h"
#include <QApplication>
#include <QSettings>
static QMap<QString, QPalette::ColorGroup> GROUP_NAME_MAP({
{"Active", QPalette::Active},
{"Disabled", QPalette::Disabled},
{"Inactive", QPalette::Inactive}
});
static QMap<QString, QPalette::ColorRole> ROLE_NAME_MAP({
{"WindowText", QPalette::WindowText},
{"Button", QPalette::Button},
{"Light", QPalette::Light},
{"Midlight", QPalette::Midlight},
{"Dark", QPalette::Dark},
{"Mid", QPalette::Mid},
{"Text", QPalette::Text},
{"BrightText", QPalette::BrightText},
{"ButtonText", QPalette::ButtonText},
{"Base", QPalette::Base},
{"Window", QPalette::Window},
{"Shadow", QPalette::Shadow},
{"Highlight", QPalette::Highlight},
{"HighlightedText", QPalette::HighlightedText},
{"Link", QPalette::Link},
{"LinkVisited", QPalette::LinkVisited},
{"AlternateBase", QPalette::AlternateBase},
{"NoRole", QPalette::NoRole},
{"ToolTipBase", QPalette::ToolTipBase},
{"ToolTipText", QPalette::ToolTipText}
});
int main(int argc, char *argv[])
{
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QApplication a(argc, argv);
{
QPalette palette;
QSettings baseColorSettings(":/res/Darkstyle.ini", QSettings::IniFormat);
baseColorSettings.beginGroup("StyleColors");
for(const QString& groupKey : GROUP_NAME_MAP.keys()) {
for(const QString& roleKey : ROLE_NAME_MAP.keys()) {
QString key(groupKey + "_" + roleKey);
if(baseColorSettings.contains(key)) {
palette.setColor(GROUP_NAME_MAP.value(groupKey),
ROLE_NAME_MAP.value(roleKey),
QColor(baseColorSettings.value(key).toString()));
}
}
}
a.setPalette(palette);
}
MainWindow w;
w.show();
return a.exec();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。