- enhancement: custom theme
This commit is contained in:
parent
af4a872024
commit
aeb1c36f07
3
NEWS.md
3
NEWS.md
|
@ -1,3 +1,6 @@
|
||||||
|
Red Panda C++ Version 0.14.1
|
||||||
|
- enhancement: custom theme
|
||||||
|
|
||||||
Red Panda C++ Version 0.14.0
|
Red Panda C++ Version 0.14.0
|
||||||
- enhancement: custom icon set ( in the configuration folder)
|
- enhancement: custom icon set ( in the configuration folder)
|
||||||
- enhancement: show custom icon set folder in options -> enviroment -> folders
|
- enhancement: show custom icon set folder in options -> enviroment -> folders
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -275,11 +275,11 @@ void ColorManager::reload()
|
||||||
{
|
{
|
||||||
mSchemes.clear();
|
mSchemes.clear();
|
||||||
//bundled schemes ( the lowest priority)
|
//bundled schemes ( the lowest priority)
|
||||||
loadSchemesInDir(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme),true,false);
|
loadSchemesInDir(pSettings->dirs().data(Settings::Dirs::DataType::ColorScheme),true,false);
|
||||||
//config schemes ( higher priority)
|
//config schemes ( higher priority)
|
||||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,false);
|
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorScheme),false,false);
|
||||||
//customed schemes ( highest priority)
|
//customed schemes ( highest priority)
|
||||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,true);
|
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorScheme),false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ColorManager::getSchemes(const QString &themeType)
|
QStringList ColorManager::getSchemes(const QString &themeType)
|
||||||
|
@ -731,9 +731,9 @@ QString ColorManager::generateFullPathname(const QString &name, bool isBundled,
|
||||||
{
|
{
|
||||||
QString filename = generateFilename(name,isCustomed);
|
QString filename = generateFilename(name,isCustomed);
|
||||||
if (isBundled && !isCustomed) {
|
if (isBundled && !isCustomed) {
|
||||||
return includeTrailingPathDelimiter(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme))+filename;
|
return includeTrailingPathDelimiter(pSettings->dirs().data(Settings::Dirs::DataType::ColorScheme))+filename;
|
||||||
} else {
|
} else {
|
||||||
return includeTrailingPathDelimiter(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme))+filename;
|
return includeTrailingPathDelimiter(pSettings->dirs().config(Settings::Dirs::DataType::ColorScheme))+filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -567,16 +567,27 @@ void MainWindow::updateEditorColorSchemes()
|
||||||
void MainWindow::applySettings()
|
void MainWindow::applySettings()
|
||||||
{
|
{
|
||||||
ThemeManager themeManager;
|
ThemeManager themeManager;
|
||||||
PAppTheme appTheme = themeManager.theme(pSettings->environment().theme());
|
if (pSettings->environment().useCustomTheme()) {
|
||||||
if (appTheme->isDark())
|
themeManager.prepareCustomeTheme();
|
||||||
QApplication::setStyle(new DarkFusionStyle());
|
}
|
||||||
else
|
themeManager.setUseCustomTheme(pSettings->environment().useCustomTheme());
|
||||||
QApplication::setStyle(new LightFusionStyle());
|
try {
|
||||||
qApp->setPalette(appTheme->palette());
|
PAppTheme appTheme = themeManager.theme(pSettings->environment().theme());
|
||||||
//fix for qstatusbar bug
|
if (appTheme->isDark())
|
||||||
mFileEncodingStatus->setPalette(appTheme->palette());
|
QApplication::setStyle(new DarkFusionStyle());
|
||||||
mFileModeStatus->setPalette(appTheme->palette());
|
else
|
||||||
mFileInfoStatus->setPalette(appTheme->palette());
|
QApplication::setStyle(new LightFusionStyle());
|
||||||
|
qApp->setPalette(appTheme->palette());
|
||||||
|
//fix for qstatusbar bug
|
||||||
|
mFileEncodingStatus->setPalette(appTheme->palette());
|
||||||
|
mFileModeStatus->setPalette(appTheme->palette());
|
||||||
|
mFileInfoStatus->setPalette(appTheme->palette());
|
||||||
|
} catch (FileError e) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Load Theme Error"),
|
||||||
|
e.reason());
|
||||||
|
}
|
||||||
|
|
||||||
updateEditorColorSchemes();
|
updateEditorColorSchemes();
|
||||||
|
|
||||||
QFont font(pSettings->environment().interfaceFont());
|
QFont font(pSettings->environment().interfaceFont());
|
||||||
|
@ -1182,6 +1193,7 @@ void MainWindow::updateActionIcons()
|
||||||
ui->actionNew->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_NEW));
|
ui->actionNew->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_NEW));
|
||||||
ui->actionNew_Project->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW));
|
ui->actionNew_Project->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW));
|
||||||
ui->actionOpen->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_OPEN));
|
ui->actionOpen->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_OPEN));
|
||||||
|
ui->actionOpen_Folder->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_OPEN_FOLDER));
|
||||||
ui->actionSave->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE));
|
ui->actionSave->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE));
|
||||||
ui->actionSaveAs->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE_AS));
|
ui->actionSaveAs->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE_AS));
|
||||||
ui->actionSaveAll->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE_ALL));
|
ui->actionSaveAll->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE_ALL));
|
||||||
|
|
|
@ -208,10 +208,12 @@ QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
case DataType::None:
|
case DataType::None:
|
||||||
return dataDir;
|
return dataDir;
|
||||||
case DataType::ColorSheme:
|
case DataType::ColorScheme:
|
||||||
return ":/colorschemes/colorschemes";
|
return ":/colorschemes/colorschemes";
|
||||||
case DataType::IconSet:
|
case DataType::IconSet:
|
||||||
return ":/resources/iconsets";
|
return ":/resources/iconsets";
|
||||||
|
case DataType::Theme:
|
||||||
|
return ":/themes";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -224,10 +226,12 @@ QString Settings::Dirs::config(Settings::Dirs::DataType dataType) const
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
case DataType::None:
|
case DataType::None:
|
||||||
return configDir;
|
return configDir;
|
||||||
case DataType::ColorSheme:
|
case DataType::ColorScheme:
|
||||||
return includeTrailingPathDelimiter(configDir)+"scheme";
|
return includeTrailingPathDelimiter(configDir)+"scheme";
|
||||||
case DataType::IconSet:
|
case DataType::IconSet:
|
||||||
return includeTrailingPathDelimiter(configDir)+"iconsets";
|
return includeTrailingPathDelimiter(configDir)+"iconsets";
|
||||||
|
case DataType::Theme:
|
||||||
|
return includeTrailingPathDelimiter(configDir)+"themes";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -2900,6 +2904,7 @@ void Settings::Environment::doLoad()
|
||||||
mLanguage = stringValue("language", QLocale::system().name());
|
mLanguage = stringValue("language", QLocale::system().name());
|
||||||
mIconSet = stringValue("icon_set","newlook");
|
mIconSet = stringValue("icon_set","newlook");
|
||||||
mUseCustomIconSet = boolValue("use_custom_icon_set", false);
|
mUseCustomIconSet = boolValue("use_custom_icon_set", false);
|
||||||
|
mUseCustomTheme = boolValue("use_custom_theme", false);
|
||||||
|
|
||||||
|
|
||||||
mCurrentFolder = stringValue("current_folder",QDir::currentPath());
|
mCurrentFolder = stringValue("current_folder",QDir::currentPath());
|
||||||
|
@ -3001,6 +3006,16 @@ void Settings::Environment::setUseCustomIconSet(bool newUseCustomIconSet)
|
||||||
mUseCustomIconSet = newUseCustomIconSet;
|
mUseCustomIconSet = newUseCustomIconSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::Environment::useCustomTheme() const
|
||||||
|
{
|
||||||
|
return mUseCustomTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::Environment::setUseCustomTheme(bool newUseCustomTheme)
|
||||||
|
{
|
||||||
|
mUseCustomTheme = newUseCustomTheme;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::Environment::doSave()
|
void Settings::Environment::doSave()
|
||||||
{
|
{
|
||||||
//Appearence
|
//Appearence
|
||||||
|
@ -3010,6 +3025,7 @@ void Settings::Environment::doSave()
|
||||||
saveValue("language", mLanguage);
|
saveValue("language", mLanguage);
|
||||||
saveValue("icon_set",mIconSet);
|
saveValue("icon_set",mIconSet);
|
||||||
saveValue("use_custom_icon_set", mUseCustomIconSet);
|
saveValue("use_custom_icon_set", mUseCustomIconSet);
|
||||||
|
saveValue("use_custom_theme", mUseCustomTheme);
|
||||||
|
|
||||||
saveValue("current_folder",mCurrentFolder);
|
saveValue("current_folder",mCurrentFolder);
|
||||||
saveValue("default_open_folder",mDefaultOpenFolder);
|
saveValue("default_open_folder",mDefaultOpenFolder);
|
||||||
|
|
|
@ -102,8 +102,9 @@ public:
|
||||||
public:
|
public:
|
||||||
enum class DataType {
|
enum class DataType {
|
||||||
None,
|
None,
|
||||||
ColorSheme,
|
ColorScheme,
|
||||||
IconSet
|
IconSet,
|
||||||
|
Theme
|
||||||
};
|
};
|
||||||
explicit Dirs(Settings * settings);
|
explicit Dirs(Settings * settings);
|
||||||
QString appDir() const;
|
QString appDir() const;
|
||||||
|
@ -523,6 +524,9 @@ public:
|
||||||
bool useCustomIconSet() const;
|
bool useCustomIconSet() const;
|
||||||
void setUseCustomIconSet(bool newUseCustomIconSet);
|
void setUseCustomIconSet(bool newUseCustomIconSet);
|
||||||
|
|
||||||
|
bool useCustomTheme() const;
|
||||||
|
void setUseCustomTheme(bool newUseCustomTheme);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Appearence
|
//Appearence
|
||||||
|
@ -533,6 +537,7 @@ public:
|
||||||
QString mCurrentFolder;
|
QString mCurrentFolder;
|
||||||
QString mIconSet;
|
QString mIconSet;
|
||||||
bool mUseCustomIconSet;
|
bool mUseCustomIconSet;
|
||||||
|
bool mUseCustomTheme;
|
||||||
|
|
||||||
QString mDefaultOpenFolder;
|
QString mDefaultOpenFolder;
|
||||||
QString mTerminalPath;
|
QString mTerminalPath;
|
||||||
|
|
|
@ -53,6 +53,7 @@ void EnvironmentAppearenceWidget::doLoad()
|
||||||
ui->spinFontSize->setValue(pSettings->environment().interfaceFontSize());
|
ui->spinFontSize->setValue(pSettings->environment().interfaceFontSize());
|
||||||
ui->cbIconSet->setCurrentText(pSettings->environment().iconSet());
|
ui->cbIconSet->setCurrentText(pSettings->environment().iconSet());
|
||||||
ui->chkUseCustomIconSet->setChecked(pSettings->environment().useCustomIconSet());
|
ui->chkUseCustomIconSet->setChecked(pSettings->environment().useCustomIconSet());
|
||||||
|
ui->chkUseCustomTheme->setChecked(pSettings->environment().useCustomTheme());
|
||||||
|
|
||||||
for (int i=0;i<ui->cbLanguage->count();i++) {
|
for (int i=0;i<ui->cbLanguage->count();i++) {
|
||||||
if (ui->cbLanguage->itemData(i) == pSettings->environment().language()) {
|
if (ui->cbLanguage->itemData(i) == pSettings->environment().language()) {
|
||||||
|
@ -78,6 +79,7 @@ void EnvironmentAppearenceWidget::doSave()
|
||||||
pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString());
|
pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString());
|
||||||
pSettings->environment().setIconSet(ui->cbIconSet->currentText());
|
pSettings->environment().setIconSet(ui->cbIconSet->currentText());
|
||||||
pSettings->environment().setUseCustomIconSet(ui->chkUseCustomIconSet->isChecked());
|
pSettings->environment().setUseCustomIconSet(ui->chkUseCustomIconSet->isChecked());
|
||||||
|
pSettings->environment().setUseCustomTheme(ui->chkUseCustomTheme->isChecked());
|
||||||
|
|
||||||
pSettings->editor().save();
|
pSettings->editor().save();
|
||||||
pSettings->environment().save();
|
pSettings->environment().save();
|
||||||
|
|
|
@ -152,6 +152,13 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="cbTheme"/>
|
<widget class="QComboBox" name="cbTheme"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chkUseCustomTheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use custom theme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -23,8 +23,10 @@
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
ThemeManager::ThemeManager(QObject *parent) : QObject(parent),
|
||||||
|
mUseCustomTheme(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,10 +34,33 @@ ThemeManager::ThemeManager(QObject *parent) : QObject(parent)
|
||||||
PAppTheme ThemeManager::theme(const QString &themeName)
|
PAppTheme ThemeManager::theme(const QString &themeName)
|
||||||
{
|
{
|
||||||
PAppTheme appTheme = std::make_shared<AppTheme>();
|
PAppTheme appTheme = std::make_shared<AppTheme>();
|
||||||
appTheme->load(QString(":/themes/%1.json").arg(themeName));
|
QString themeDir;
|
||||||
|
if (mUseCustomTheme)
|
||||||
|
themeDir = pSettings->dirs().config(Settings::Dirs::DataType::Theme);
|
||||||
|
else
|
||||||
|
themeDir = pSettings->dirs().data(Settings::Dirs::DataType::Theme);
|
||||||
|
appTheme->load(QString("%1/%2.json").arg(themeDir, themeName));
|
||||||
return appTheme;
|
return appTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ThemeManager::useCustomTheme() const
|
||||||
|
{
|
||||||
|
return mUseCustomTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemeManager::setUseCustomTheme(bool newUseCustomTheme)
|
||||||
|
{
|
||||||
|
mUseCustomTheme = newUseCustomTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemeManager::prepareCustomeTheme()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (QFile(pSettings->dirs().config(Settings::Dirs::DataType::Theme)).exists())
|
||||||
|
return;
|
||||||
|
copyFolder(pSettings->dirs().data(Settings::Dirs::DataType::Theme),pSettings->dirs().config(Settings::Dirs::DataType::Theme));
|
||||||
|
}
|
||||||
|
|
||||||
AppTheme::AppTheme(QObject *parent):QObject(parent)
|
AppTheme::AppTheme(QObject *parent):QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -116,8 +141,10 @@ QPalette AppTheme::palette() const
|
||||||
void AppTheme::load(const QString &filename)
|
void AppTheme::load(const QString &filename)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.exists())
|
if (!file.exists()) {
|
||||||
return;
|
throw FileError(tr("Theme file '%1' doesn't exist!")
|
||||||
|
.arg(filename));
|
||||||
|
}
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
QByteArray content = file.readAll();
|
QByteArray content = file.readAll();
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
|
@ -144,7 +171,7 @@ void AppTheme::load(const QString &filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw FileError(tr("Can't open file '%1' for read.")
|
throw FileError(tr("Can't open the theme file '%1' for read.")
|
||||||
.arg(filename));
|
.arg(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,12 @@ class ThemeManager : public QObject
|
||||||
public:
|
public:
|
||||||
explicit ThemeManager(QObject *parent = nullptr);
|
explicit ThemeManager(QObject *parent = nullptr);
|
||||||
PAppTheme theme(const QString& themeName);
|
PAppTheme theme(const QString& themeName);
|
||||||
|
bool useCustomTheme() const;
|
||||||
|
void setUseCustomTheme(bool newUseCustomTheme);
|
||||||
|
void prepareCustomeTheme();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool mUseCustomTheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // THEMEMANAGER_H
|
#endif // THEMEMANAGER_H
|
||||||
|
|
|
@ -1120,7 +1120,6 @@ void copyFolder(const QString &fromDir, const QString &toDir)
|
||||||
if(!fileInfo.isHidden()) { //filters dot and dotdot
|
if(!fileInfo.isHidden()) { //filters dot and dotdot
|
||||||
const QString subPathStructure = fileInfo.absoluteFilePath().mid(absSourcePathLength);
|
const QString subPathStructure = fileInfo.absoluteFilePath().mid(absSourcePathLength);
|
||||||
const QString constructedAbsolutePath = targetDir.absolutePath() + subPathStructure;
|
const QString constructedAbsolutePath = targetDir.absolutePath() + subPathStructure;
|
||||||
qDebug()<<fileInfo.absoluteFilePath()<<constructedAbsolutePath;
|
|
||||||
if(fileInfo.isDir()){
|
if(fileInfo.isDir()){
|
||||||
//Create directory in target folder
|
//Create directory in target folder
|
||||||
dir.mkpath(constructedAbsolutePath);
|
dir.mkpath(constructedAbsolutePath);
|
||||||
|
|
Loading…
Reference in New Issue