diff --git a/modmanager.pro b/modmanager.pro index 7cd6fc9..c59b5a2 100644 --- a/modmanager.pro +++ b/modmanager.pro @@ -123,7 +123,6 @@ win32 { #native blur LIBS += -ldwmapi - QMAKE_CXXFLAGS += $$system($$pkgConfigExecutable() --cflags libaria2) LIBS += $$system($$pkgConfigExecutable() --libs libaria2 | sed 's/\/lib\b/\/bin/' | sed 's/-laria2/-laria2-0/') equals(QT_MAJOR_VERSION, 5){ diff --git a/src/gameversion.cpp b/src/gameversion.cpp index 2397ca3..22e0aaa 100644 --- a/src/gameversion.cpp +++ b/src/gameversion.cpp @@ -8,8 +8,6 @@ #include "curseforge/curseforgeapi.h" #include "util/tutil.hpp" -#include "util/funcutil.h" -#include "config.hpp" GameVersion GameVersion::Any = GameVersion(""); @@ -17,6 +15,7 @@ QList GameVersion::mojangVersionList_; QList GameVersion::curseforgeVersionList_; QList GameVersion::cachedVersionList_{ + GameVersion(1, 21), GameVersion(1, 20, 6), GameVersion(1, 20, 5), GameVersion(1, 20, 4), diff --git a/src/qss/stylesheets.cpp b/src/qss/stylesheets.cpp index 5f2f58e..ec0519e 100644 --- a/src/qss/stylesheets.cpp +++ b/src/qss/stylesheets.cpp @@ -36,20 +36,34 @@ QMap styleSheets() return styleSheets; } -QString styleSheetPath(const QString &name) +QString styleSheetPath(QString name) { - if(!styleSheets().contains(name)) - return QString("file:///:/stylesheet/%1.qss").arg("basic"); - auto fileName = QDir(styleSheetsPath()).absoluteFilePath(name + ".qss"); - 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()); - } + if(!styleSheets().keys().contains(name)) + name = "basic"; + if(builtinStyleSheets().keys().contains(name)){ + QFile f(QString(":/stylesheet/%1.qss").arg(name)); + if(f.open(QIODevice::ReadOnly)) + return f.readAll(); } + auto fileName = QDir(styleSheetsPath()).absoluteFilePath(name + ".qss"); return fileName.prepend("file:///"); } + +QString copyStyleSheet(const QString &name) +{ + QFile oldFile; + if(builtinStyleSheets().keys().contains(name)) + oldFile.setFileName(QString(":/stylesheet/%1.qss").arg(name)); + else + oldFile.setFileName(QString("file:///:/stylesheet/%1.qss").arg(name)); + auto newName = name+"-copy"; + auto fileName = QDir(styleSheetsPath()).absoluteFilePath(newName + ".qss"); + QFile newFile(fileName); + if(!newFile.exists() && oldFile.open(QIODevice::ReadOnly) && newFile.open(QIODevice::WriteOnly)){ + newFile.write("/* This file is auto generated from existed stylesheet\n" + " * you can create you own qss based on this file.\n" + " */\n\n"); + newFile.write(oldFile.readAll()); + } + return newName; +} diff --git a/src/qss/stylesheets.h b/src/qss/stylesheets.h index 9496feb..591c8bf 100644 --- a/src/qss/stylesheets.h +++ b/src/qss/stylesheets.h @@ -7,5 +7,6 @@ const QString &styleSheetsPath(); const QMap &builtinStyleSheets(); QMap styleSheets(); -QString styleSheetPath(const QString &name); +QString styleSheetPath(QString name); +QString copyStyleSheet(const QString &name); #endif // STYLESHEETS_H diff --git a/src/ui/framelesswrapper.cpp b/src/ui/framelesswrapper.cpp index fde11ad..98c1c2e 100644 --- a/src/ui/framelesswrapper.cpp +++ b/src/ui/framelesswrapper.cpp @@ -88,7 +88,6 @@ bool FramelessWrapper::nativeEvent(const QByteArray &eventType, void *message, l switch(msg->message){ case WM_NCCALCSIZE:{ if(msg->wParam == FALSE) return false; - *result = WVR_REDRAW; return true; } diff --git a/src/ui/modmanager.cpp b/src/ui/modmanager.cpp index 49706d2..0a30e8f 100644 --- a/src/ui/modmanager.cpp +++ b/src/ui/modmanager.cpp @@ -223,7 +223,7 @@ void ModManager::paintEvent(QPaintEvent *event[[maybe_unused]]) if(!widget->isVisible()) continue; auto rect = widget->rect(); rect.translate(widget->pos()); - p.fillRect(rect, QBrush(QColor(255, 50, 255, 210))); + p.fillRect(rect, QBrush(QColor(255, 255, 255, 210))); } } #endif //defined (DE_KDE) || defined (Q_OS_WIN) @@ -242,11 +242,12 @@ void ModManager::editLocalPath(int index) void ModManager::on_actionPreferences_triggered() { auto preferences = new Preferences(this); - auto style = config_.getCustomStyle(); - connect(preferences, &Preferences::accepted, this, [=]{ - if(auto afterStyle = config_.getCustomStyle(); afterStyle != style) - qApp->setStyleSheet(styleSheetPath(afterStyle)); - }); + // TODO: mass performance + // auto style = config_.getCustomStyle(); + // connect(preferences, &Preferences::accepted, this, [=]{ + // if(auto afterStyle = config_.getCustomStyle(); afterStyle != style) + // qApp->setStyleSheet(styleSheetPath(afterStyle)); + // }); connect(preferences, &Preferences::accepted, this, &ModManager::updateUi, Qt::UniqueConnection); connect(preferences, &Preferences::accepted, this, &ModManager::setProxy, Qt::UniqueConnection); connect(preferences, &Preferences::accepted, QAria2::qaria2(), &QAria2::updateOptions, Qt::UniqueConnection); diff --git a/src/ui/preferences.cpp b/src/ui/preferences.cpp index 3666a66..aa3ad86 100644 --- a/src/ui/preferences.cpp +++ b/src/ui/preferences.cpp @@ -1,6 +1,7 @@ #include "preferences.h" #include "ui_preferences.h" +#include #include #include "config.hpp" @@ -19,8 +20,7 @@ Preferences::Preferences(QWidget *parent) : #endif auto s = styleSheets(); for(auto it = s.cbegin(); it != s.cend(); it++){ - ui->customStyle->addItem(it.value()); - ui->customStyle->setItemData(ui->customStyle->count() - 1, it.key()); + ui->customStyle->addItem(it.value(), it.key()); } ui->language->addItem(tr("Follow System")); @@ -186,6 +186,13 @@ void Preferences::on_proxyType_currentIndexChanged(int index) ui->proxyPassword->setEnabled(!noProxy); } +void Preferences::on_copyQSSButton_clicked() +{ + auto name = copyStyleSheet(ui->customStyle->currentData().toString()); + ui->customStyle->insertItem(ui->customStyle->currentIndex() + 1, name, name); + ui->customStyle->setCurrentText(name); + QDesktopServices::openUrl(QUrl(styleSheetPath(name))); +} void Preferences::on_useFramelessWindow_toggled(bool checked[[maybe_unused]]) { diff --git a/src/ui/preferences.h b/src/ui/preferences.h index cb57706..5920c15 100644 --- a/src/ui/preferences.h +++ b/src/ui/preferences.h @@ -22,6 +22,8 @@ private slots: void on_proxyType_currentIndexChanged(int index); + void on_copyQSSButton_clicked(); + private: Ui::Preferences *ui; }; diff --git a/src/ui/preferences.ui b/src/ui/preferences.ui index a21d8cc..ce2fe02 100644 --- a/src/ui/preferences.ui +++ b/src/ui/preferences.ui @@ -6,8 +6,8 @@ 0 0 - 600 - 673 + 627 + 772 @@ -69,8 +69,8 @@ 0 0 - 560 - 589 + 599 + 683 @@ -209,26 +209,13 @@ - - - - - - - UI style: - - - - - + + - Language: + Mod Manager update: - - - @@ -248,13 +235,40 @@ - - + + - Mod Manager update: + UI style: + + + + + + + + + + + + Copy + + + + + + + + + + + + Language: + + + @@ -309,8 +323,8 @@ 0 0 - 576 - 580 + 599 + 683 @@ -516,8 +530,8 @@ 0 0 - 560 - 585 + 599 + 683 @@ -834,8 +848,8 @@ 0 0 - 576 - 580 + 599 + 683