Merge branch 'master' of github.com:royqh1979/RedPanda-CPP
This commit is contained in:
commit
935c2d2eb7
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
|
||||
- enhancement: custom icon set ( in the configuration folder)
|
||||
- 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();
|
||||
//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)
|
||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,false);
|
||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorScheme),false,false);
|
||||
//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)
|
||||
|
@ -731,9 +731,9 @@ QString ColorManager::generateFullPathname(const QString &name, bool isBundled,
|
|||
{
|
||||
QString filename = generateFilename(name,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 {
|
||||
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()
|
||||
{
|
||||
ThemeManager themeManager;
|
||||
PAppTheme appTheme = themeManager.theme(pSettings->environment().theme());
|
||||
if (appTheme->isDark())
|
||||
QApplication::setStyle(new DarkFusionStyle());
|
||||
else
|
||||
QApplication::setStyle(new LightFusionStyle());
|
||||
qApp->setPalette(appTheme->palette());
|
||||
//fix for qstatusbar bug
|
||||
mFileEncodingStatus->setPalette(appTheme->palette());
|
||||
mFileModeStatus->setPalette(appTheme->palette());
|
||||
mFileInfoStatus->setPalette(appTheme->palette());
|
||||
if (pSettings->environment().useCustomTheme()) {
|
||||
themeManager.prepareCustomeTheme();
|
||||
}
|
||||
themeManager.setUseCustomTheme(pSettings->environment().useCustomTheme());
|
||||
try {
|
||||
PAppTheme appTheme = themeManager.theme(pSettings->environment().theme());
|
||||
if (appTheme->isDark())
|
||||
QApplication::setStyle(new DarkFusionStyle());
|
||||
else
|
||||
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();
|
||||
|
||||
QFont font(pSettings->environment().interfaceFont());
|
||||
|
@ -1182,6 +1193,7 @@ void MainWindow::updateActionIcons()
|
|||
ui->actionNew->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_NEW));
|
||||
ui->actionNew_Project->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROJECT_NEW));
|
||||
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->actionSaveAs->setIcon(pIconsManager->getIcon(IconsManager::ACTION_FILE_SAVE_AS));
|
||||
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) {
|
||||
case DataType::None:
|
||||
return dataDir;
|
||||
case DataType::ColorSheme:
|
||||
case DataType::ColorScheme:
|
||||
return ":/colorschemes/colorschemes";
|
||||
case DataType::IconSet:
|
||||
return ":/resources/iconsets";
|
||||
case DataType::Theme:
|
||||
return ":/themes";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -224,10 +226,12 @@ QString Settings::Dirs::config(Settings::Dirs::DataType dataType) const
|
|||
switch (dataType) {
|
||||
case DataType::None:
|
||||
return configDir;
|
||||
case DataType::ColorSheme:
|
||||
case DataType::ColorScheme:
|
||||
return includeTrailingPathDelimiter(configDir)+"scheme";
|
||||
case DataType::IconSet:
|
||||
return includeTrailingPathDelimiter(configDir)+"iconsets";
|
||||
case DataType::Theme:
|
||||
return includeTrailingPathDelimiter(configDir)+"themes";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -2900,6 +2904,7 @@ void Settings::Environment::doLoad()
|
|||
mLanguage = stringValue("language", QLocale::system().name());
|
||||
mIconSet = stringValue("icon_set","newlook");
|
||||
mUseCustomIconSet = boolValue("use_custom_icon_set", false);
|
||||
mUseCustomTheme = boolValue("use_custom_theme", false);
|
||||
|
||||
|
||||
mCurrentFolder = stringValue("current_folder",QDir::currentPath());
|
||||
|
@ -3001,6 +3006,16 @@ void Settings::Environment::setUseCustomIconSet(bool newUseCustomIconSet)
|
|||
mUseCustomIconSet = newUseCustomIconSet;
|
||||
}
|
||||
|
||||
bool Settings::Environment::useCustomTheme() const
|
||||
{
|
||||
return mUseCustomTheme;
|
||||
}
|
||||
|
||||
void Settings::Environment::setUseCustomTheme(bool newUseCustomTheme)
|
||||
{
|
||||
mUseCustomTheme = newUseCustomTheme;
|
||||
}
|
||||
|
||||
void Settings::Environment::doSave()
|
||||
{
|
||||
//Appearence
|
||||
|
@ -3010,6 +3025,7 @@ void Settings::Environment::doSave()
|
|||
saveValue("language", mLanguage);
|
||||
saveValue("icon_set",mIconSet);
|
||||
saveValue("use_custom_icon_set", mUseCustomIconSet);
|
||||
saveValue("use_custom_theme", mUseCustomTheme);
|
||||
|
||||
saveValue("current_folder",mCurrentFolder);
|
||||
saveValue("default_open_folder",mDefaultOpenFolder);
|
||||
|
|
|
@ -102,8 +102,9 @@ public:
|
|||
public:
|
||||
enum class DataType {
|
||||
None,
|
||||
ColorSheme,
|
||||
IconSet
|
||||
ColorScheme,
|
||||
IconSet,
|
||||
Theme
|
||||
};
|
||||
explicit Dirs(Settings * settings);
|
||||
QString appDir() const;
|
||||
|
@ -523,6 +524,9 @@ public:
|
|||
bool useCustomIconSet() const;
|
||||
void setUseCustomIconSet(bool newUseCustomIconSet);
|
||||
|
||||
bool useCustomTheme() const;
|
||||
void setUseCustomTheme(bool newUseCustomTheme);
|
||||
|
||||
private:
|
||||
|
||||
//Appearence
|
||||
|
@ -533,6 +537,7 @@ public:
|
|||
QString mCurrentFolder;
|
||||
QString mIconSet;
|
||||
bool mUseCustomIconSet;
|
||||
bool mUseCustomTheme;
|
||||
|
||||
QString mDefaultOpenFolder;
|
||||
QString mTerminalPath;
|
||||
|
|
|
@ -53,6 +53,7 @@ void EnvironmentAppearenceWidget::doLoad()
|
|||
ui->spinFontSize->setValue(pSettings->environment().interfaceFontSize());
|
||||
ui->cbIconSet->setCurrentText(pSettings->environment().iconSet());
|
||||
ui->chkUseCustomIconSet->setChecked(pSettings->environment().useCustomIconSet());
|
||||
ui->chkUseCustomTheme->setChecked(pSettings->environment().useCustomTheme());
|
||||
|
||||
for (int i=0;i<ui->cbLanguage->count();i++) {
|
||||
if (ui->cbLanguage->itemData(i) == pSettings->environment().language()) {
|
||||
|
@ -78,6 +79,7 @@ void EnvironmentAppearenceWidget::doSave()
|
|||
pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString());
|
||||
pSettings->environment().setIconSet(ui->cbIconSet->currentText());
|
||||
pSettings->environment().setUseCustomIconSet(ui->chkUseCustomIconSet->isChecked());
|
||||
pSettings->environment().setUseCustomTheme(ui->chkUseCustomTheme->isChecked());
|
||||
|
||||
pSettings->editor().save();
|
||||
pSettings->environment().save();
|
||||
|
|
|
@ -152,6 +152,13 @@
|
|||
<item>
|
||||
<widget class="QComboBox" name="cbTheme"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkUseCustomTheme">
|
||||
<property name="text">
|
||||
<string>Use custom theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -23,8 +23,10 @@
|
|||
#include <QMetaEnum>
|
||||
#include <QMetaObject>
|
||||
#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 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
|
@ -116,8 +141,10 @@ QPalette AppTheme::palette() const
|
|||
void AppTheme::load(const QString &filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (!file.exists())
|
||||
return;
|
||||
if (!file.exists()) {
|
||||
throw FileError(tr("Theme file '%1' doesn't exist!")
|
||||
.arg(filename));
|
||||
}
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QByteArray content = file.readAll();
|
||||
QJsonParseError error;
|
||||
|
@ -144,7 +171,7 @@ void AppTheme::load(const QString &filename)
|
|||
}
|
||||
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,12 @@ class ThemeManager : public QObject
|
|||
public:
|
||||
explicit ThemeManager(QObject *parent = nullptr);
|
||||
PAppTheme theme(const QString& themeName);
|
||||
bool useCustomTheme() const;
|
||||
void setUseCustomTheme(bool newUseCustomTheme);
|
||||
void prepareCustomeTheme();
|
||||
|
||||
private:
|
||||
bool mUseCustomTheme;
|
||||
};
|
||||
|
||||
#endif // THEMEMANAGER_H
|
||||
|
|
|
@ -1120,7 +1120,6 @@ void copyFolder(const QString &fromDir, const QString &toDir)
|
|||
if(!fileInfo.isHidden()) { //filters dot and dotdot
|
||||
const QString subPathStructure = fileInfo.absoluteFilePath().mid(absSourcePathLength);
|
||||
const QString constructedAbsolutePath = targetDir.absolutePath() + subPathStructure;
|
||||
qDebug()<<fileInfo.absoluteFilePath()<<constructedAbsolutePath;
|
||||
if(fileInfo.isDir()){
|
||||
//Create directory in target folder
|
||||
dir.mkpath(constructedAbsolutePath);
|
||||
|
|
Loading…
Reference in New Issue