From 4c88ad2cfa9854fc0e4419668bd9eee74c16f56a Mon Sep 17 00:00:00 2001 From: kaniol-lck <375520360@qq.com> Date: Wed, 2 Mar 2022 10:36:54 +0800 Subject: [PATCH] customize qss --- src/qss/dark.qss | 2 +- src/qss/stylesheets.cpp | 18 ++++++++++++++---- src/ui/local/batchrenamedialog.ui | 25 ++++++++----------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/qss/dark.qss b/src/qss/dark.qss index 9e4363cc..da62b017 100644 --- a/src/qss/dark.qss +++ b/src/qss/dark.qss @@ -41,7 +41,7 @@ QTextBrowser, QScrollArea, QScrollArea .QWidget { } .Title { - color: black; + color: #fff; font-weight: bold; font-size: 13pt; background: transparent; diff --git a/src/qss/stylesheets.cpp b/src/qss/stylesheets.cpp index 4aeac6c6..5f2f58e0 100644 --- a/src/qss/stylesheets.cpp +++ b/src/qss/stylesheets.cpp @@ -9,6 +9,7 @@ const QString &styleSheetsPath() { static auto path = QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)) .absoluteFilePath("stylesheets"); + QDir().mkpath(path); return path; } @@ -25,7 +26,8 @@ const QMap &builtinStyleSheets() QMap styleSheets() { auto styleSheets = builtinStyleSheets(); - for(auto &&fileInfo : QDir(styleSheetsPath()).entryInfoList()) + auto &&fileInfoList = QDir(styleSheetsPath()).entryInfoList(); + for(auto &&fileInfo : fileInfoList) if(fileInfo.suffix() == "qss"){ auto name = fileInfo.baseName(); if(!styleSheets.contains(name)) @@ -39,7 +41,15 @@ QString styleSheetPath(const QString &name) if(!styleSheets().contains(name)) return QString("file:///:/stylesheet/%1.qss").arg("basic"); auto fileName = QDir(styleSheetsPath()).absoluteFilePath(name + ".qss"); - if(!QFileInfo(fileName).exists() && builtinStyleSheets().contains(name)) - return QString("file:///:/stylesheet/%1.qss").arg(name); - return fileName; + if(!QFileInfo::exists(fileName) && builtinStyleSheets().contains(name)){ + QFile builtinFile(QString(":/stylesheet/%1.qss").arg(name)); + QFile newFile(fileName); + if(builtinFile.open(QIODevice::ReadOnly) && newFile.open(QIODevice::WriteOnly)){ + newFile.write("/* This file is auto generated from built-in stylesheet\n" + " * you can create you own qss based on this file.\n" + " */\n\n"); + newFile.write(builtinFile.readAll()); + } + } + return fileName.prepend("file:///"); } diff --git a/src/ui/local/batchrenamedialog.ui b/src/ui/local/batchrenamedialog.ui index d316b7db..06c01654 100644 --- a/src/ui/local/batchrenamedialog.ui +++ b/src/ui/local/batchrenamedialog.ui @@ -6,7 +6,7 @@ 0 0 - 1080 + 726 720 @@ -46,9 +46,7 @@ - - Consolas ligaturized v2 - + <filename> @@ -89,9 +87,7 @@ - - Consolas ligaturized v2 - + <id> @@ -132,9 +128,7 @@ - - Consolas ligaturized v2 - + <name> @@ -179,9 +173,7 @@ - - Consolas ligaturized v2 - + <version> @@ -222,9 +214,7 @@ - - Consolas ligaturized v2 - + <tags|...|...> @@ -330,7 +320,8 @@ - + + .. QToolButton::InstantPopup