css files can be loaded from file

This commit is contained in:
itsmattkc
2019-01-12 02:03:53 +11:00
parent b1bb4b7808
commit 215606772c
6 changed files with 61 additions and 11 deletions
+19 -3
View File
@@ -53,6 +53,7 @@
MainWindow* mainWindow;
#define DEFAULT_CSS "QPushButton::checked { background: rgb(25, 25, 25); }"
#define OLIVE_FILE_FILTER "Olive Project (*.ove)"
QTimer autorecovery_timer;
@@ -106,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) :
// set up style?
qApp->setStyle(QStyleFactory::create("Fusion"));
setStyleSheet("QPushButton::checked { background: rgb(25, 25, 25); }");
setStyleSheet(DEFAULT_CSS);
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
@@ -197,7 +198,11 @@ MainWindow::MainWindow(QWidget *parent, const QString &an) :
config_fn = config_path + "/config.xml";
if (QFileInfo::exists(config_fn)) {
config.load(config_fn);
}
if (!config.css_path.isEmpty()) {
load_css_from_file(config.css_path);
}
}
}
alloc_panels(this);
@@ -330,7 +335,18 @@ void MainWindow::save_shortcuts(const QString& fn) {
shortcut_file_io.close();
} else {
qCritical() << "Failed to save shortcut file";
}
}
}
void MainWindow::load_css_from_file(const QString &fn) {
QFile css_file(fn);
if (css_file.exists() && css_file.open(QFile::ReadOnly)) {
setStyleSheet(css_file.readAll());
css_file.close();
} else {
// set default stylesheet
setStyleSheet(DEFAULT_CSS);
}
}
void MainWindow::show_about() {