add failsafe theme (#381)
This commit is contained in:
parent
039ec299a6
commit
3552077d5c
|
@ -999,8 +999,23 @@ void MainWindow::applySettings()
|
||||||
themeManager.prepareCustomeTheme();
|
themeManager.prepareCustomeTheme();
|
||||||
}
|
}
|
||||||
themeManager.setUseCustomTheme(pSettings->environment().useCustomTheme());
|
themeManager.setUseCustomTheme(pSettings->environment().useCustomTheme());
|
||||||
|
PAppTheme appTheme;
|
||||||
try {
|
try {
|
||||||
PAppTheme appTheme = themeManager.theme(pSettings->environment().theme());
|
appTheme = themeManager.theme(pSettings->environment().theme());
|
||||||
|
} catch (FileError e) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Load Theme Error"),
|
||||||
|
e.reason());
|
||||||
|
appTheme = AppTheme::fallbackTheme();
|
||||||
|
}
|
||||||
|
#ifdef ENABLE_LUA_ADDON
|
||||||
|
catch (AddOn::LuaError e) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Load Theme Error"),
|
||||||
|
e.reason());
|
||||||
|
appTheme = AppTheme::fallbackTheme();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
const QString& style = appTheme->style();
|
const QString& style = appTheme->style();
|
||||||
if (style == "RedPandaDarkFusion")
|
if (style == "RedPandaDarkFusion")
|
||||||
QApplication::setStyle(new DarkFusionStyle());//app takes the onwership
|
QApplication::setStyle(new DarkFusionStyle());//app takes the onwership
|
||||||
|
@ -1013,18 +1028,6 @@ void MainWindow::applySettings()
|
||||||
mFileEncodingStatus->setPalette(appTheme->palette());
|
mFileEncodingStatus->setPalette(appTheme->palette());
|
||||||
mFileModeStatus->setPalette(appTheme->palette());
|
mFileModeStatus->setPalette(appTheme->palette());
|
||||||
mFileInfoStatus->setPalette(appTheme->palette());
|
mFileInfoStatus->setPalette(appTheme->palette());
|
||||||
} catch (FileError e) {
|
|
||||||
QMessageBox::critical(this,
|
|
||||||
tr("Load Theme Error"),
|
|
||||||
e.reason());
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_LUA_ADDON
|
|
||||||
catch (AddOn::LuaError e) {
|
|
||||||
QMessageBox::critical(this,
|
|
||||||
tr("Load Theme Error"),
|
|
||||||
e.reason());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
updateEditorColorSchemes();
|
updateEditorColorSchemes();
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,8 @@ QList<PAppTheme> ThemeManager::getThemes()
|
||||||
std::sort(result.begin(),result.end(),[](const PAppTheme &theme1, const PAppTheme &theme2){
|
std::sort(result.begin(),result.end(),[](const PAppTheme &theme1, const PAppTheme &theme2){
|
||||||
return QFileInfo(theme1->filename()).baseName() < QFileInfo(theme2->filename()).baseName();
|
return QFileInfo(theme1->filename()).baseName() < QFileInfo(theme2->filename()).baseName();
|
||||||
});
|
});
|
||||||
|
if (result.isEmpty())
|
||||||
|
result.append(AppTheme::fallbackTheme());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,3 +349,18 @@ const QString &AppTheme::style() const
|
||||||
{
|
{
|
||||||
return mStyle;
|
return mStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppTheme::AppTheme() :
|
||||||
|
mName("__failsafe__theme__"),
|
||||||
|
mDisplayName("Fusion [fail-safe hard-coded]"),
|
||||||
|
mStyle("fusion"),
|
||||||
|
mDefaultColorScheme("Adaptive"),
|
||||||
|
mDefaultIconSet("newlook")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PAppTheme AppTheme::fallbackTheme()
|
||||||
|
{
|
||||||
|
static PAppTheme theme = PAppTheme(new AppTheme());
|
||||||
|
return theme;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
class AppTheme;
|
||||||
|
using PAppTheme = std::shared_ptr<AppTheme>;
|
||||||
|
|
||||||
class AppTheme : public QObject{
|
class AppTheme : public QObject{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -102,6 +105,12 @@ public:
|
||||||
|
|
||||||
const QString& filename() const;
|
const QString& filename() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static PAppTheme fallbackTheme();
|
||||||
|
|
||||||
|
private:
|
||||||
|
AppTheme();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QPalette initialPalette();
|
static QPalette initialPalette();
|
||||||
private:
|
private:
|
||||||
|
@ -114,8 +123,6 @@ private:
|
||||||
QString mFilename;
|
QString mFilename;
|
||||||
};
|
};
|
||||||
|
|
||||||
using PAppTheme = std::shared_ptr<AppTheme>;
|
|
||||||
|
|
||||||
class ThemeManager : public QObject
|
class ThemeManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in New Issue