Generate a customized copy for theme
This commit is contained in:
parent
96c4e95172
commit
d3db8e2b4d
|
@ -18,6 +18,7 @@
|
|||
#include "ui_environmentappearancewidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QStyleFactory>
|
||||
#include "../settings.h"
|
||||
#include "../mainwindow.h"
|
||||
|
@ -109,6 +110,7 @@ void EnvironmentAppearanceWidget::on_cbTheme_currentIndexChanged(int /* index */
|
|||
{
|
||||
ThemeManager themeManager;
|
||||
PAppTheme appTheme = themeManager.theme(ui->cbTheme->currentData().toString());
|
||||
ui->btnCustomize->setVisible(appTheme->category() == AppTheme::ThemeCategory::BuiltIn);
|
||||
if(!appTheme->defaultIconSet().isEmpty()) {
|
||||
for (int i=0; i<ui->cbIconSet->count();i++) {
|
||||
if (ui->cbIconSet->itemData(i) == appTheme->defaultIconSet()) {
|
||||
|
@ -119,3 +121,25 @@ void EnvironmentAppearanceWidget::on_cbTheme_currentIndexChanged(int /* index */
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void EnvironmentAppearanceWidget::on_btnCustomize_clicked()
|
||||
{
|
||||
ThemeManager themeManager;
|
||||
PAppTheme appTheme = themeManager.theme(ui->cbTheme->currentData().toString());
|
||||
QString customThemeFolder = pSettings->dirs().config(Settings::Dirs::DataType::Theme);
|
||||
QDir dir{customThemeFolder};
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(customThemeFolder);
|
||||
}
|
||||
appTheme->copyTo(customThemeFolder);
|
||||
ui->cbTheme->clear();
|
||||
QString currentThemeName = appTheme->name();
|
||||
QList<PAppTheme> appThemes = themeManager.getThemes();
|
||||
for (int i=0; i<appThemes.count();i++) {
|
||||
const PAppTheme& appTheme =appThemes[i];
|
||||
ui->cbTheme->addItem(appTheme->categoryIcon() + " " + appTheme->displayName(), appTheme->name());
|
||||
if (appTheme->name() == currentThemeName)
|
||||
ui->cbTheme->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
void init() override;
|
||||
private slots:
|
||||
void on_cbTheme_currentIndexChanged(int index);
|
||||
void on_btnCustomize_clicked();
|
||||
};
|
||||
|
||||
#endif // ENVIRONMENTAPPEARANCEWIDGET_H
|
||||
|
|
|
@ -135,6 +135,13 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="cbTheme"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCustomize">
|
||||
<property name="text">
|
||||
<string>Create a customized copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -315,6 +322,7 @@
|
|||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>cbTheme</tabstop>
|
||||
<tabstop>btnCustomize</tabstop>
|
||||
<tabstop>cbFont</tabstop>
|
||||
<tabstop>spinFontSize</tabstop>
|
||||
<tabstop>cbIconSet</tabstop>
|
||||
|
|
|
@ -302,6 +302,11 @@ QPalette AppTheme::initialPalette()
|
|||
return palette;
|
||||
}
|
||||
|
||||
AppTheme::ThemeCategory AppTheme::category() const
|
||||
{
|
||||
return mCategory;
|
||||
}
|
||||
|
||||
QString AppTheme::initialStyle()
|
||||
{
|
||||
static QString style = QApplication::style()->objectName();
|
||||
|
@ -329,6 +334,13 @@ const QString AppTheme::categoryIcon() const
|
|||
}
|
||||
}
|
||||
|
||||
bool AppTheme::copyTo(const QString &targetFolder)
|
||||
{
|
||||
QFileInfo fileInfo{mFilename};
|
||||
return QFile::copy(fileInfo.absoluteFilePath(),
|
||||
QDir(targetFolder).absoluteFilePath(fileInfo.fileName()));
|
||||
}
|
||||
|
||||
const QString &AppTheme::defaultIconSet() const
|
||||
{
|
||||
return mDefaultIconSet;
|
||||
|
|
|
@ -116,9 +116,13 @@ public:
|
|||
|
||||
const QString categoryIcon() const;
|
||||
|
||||
bool copyTo(const QString& targetFolder);
|
||||
|
||||
public:
|
||||
static PAppTheme fallbackTheme();
|
||||
|
||||
ThemeCategory category() const;
|
||||
|
||||
private:
|
||||
AppTheme();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
|||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="qsynedit/exporter/exporter.cpp" line="+127"/>
|
||||
<location filename="qsynedit/exporter/exporter.cpp" line="+128"/>
|
||||
<source>Can't open file '%1' to write!</source>
|
||||
<translation>无法写入文件"%1"!</translation>
|
||||
</message>
|
||||
|
@ -4288,7 +4288,7 @@
|
|||
<context>
|
||||
<name>QSynedit::Document</name>
|
||||
<message>
|
||||
<location filename="qsynedit/document.cpp" line="+618"/>
|
||||
<location filename="qsynedit/document.cpp" line="+617"/>
|
||||
<source>Can't open file '%1' for read!</source>
|
||||
<translation>无法读取文件"%1".</translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in New Issue