Skip to content

Commit

Permalink
Fixed functionality for changing the theme (custom or standard)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nighty3098 committed Jul 17, 2024
1 parent f73238a commit 9b15a73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/CodeKeeper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ bool loadApp(QSplashScreen *psplash)

int main(int argc, char *argv[])
{
QFile file(":/stylesheet/custom_stylesheet.qss");
file.open(QFile::ReadOnly);
// QFile file(":/stylesheet/custom_stylesheet.qss");
// file.open(QFile::ReadOnly);

QApplication a(argc, argv);

// QSplashScreen splash(QPixmap(":/icon.png"));
// splash.show();

MainWindow keeper;
a.setStyleSheet(file.readAll());
// a.setStyleSheet(file.readAll());

keeper.setWindowIcon(QIcon(":/icon.png"));

Expand Down
31 changes: 18 additions & 13 deletions src/CodeKeeper/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,26 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)

getSettingsData();

if(isCustomTheme == true) {
if (isCustomTheme) {
QFile custom_theme(":/stylesheet/custom_stylesheet.qss");
custom_theme.open(QFile::ReadOnly);

qDebug() << "Loading custom stylesheet..." << custom_theme.readAll();

setStyleSheet(custom_theme.readAll());
}
else {
if (custom_theme.open(QFile::ReadOnly)) {
QString customStyleSheet = custom_theme.readAll();
qDebug() << "Loading custom stylesheet:" << customStyleSheet;
setStyleSheet(customStyleSheet);
custom_theme.close();
} else {
qDebug() << "Failed to open custom stylesheet file";
}
} else {
QFile theme_file(":/stylesheet/stylesheet.qss");
theme_file.open(QFile::ReadOnly);

qDebug() << "Loading default stylesheet..." << theme_file.readAll();

setStyleSheet(theme_file.readAll());
if (theme_file.open(QFile::ReadOnly)) {
QString defaultStyleSheet = theme_file.readAll();
qDebug() << "Loading default stylesheet:" << defaultStyleSheet;
setStyleSheet(defaultStyleSheet);
theme_file.close();
} else {
qDebug() << "Failed to open default stylesheet file";
}
}

closeBtn = new QPushButton();
Expand Down

0 comments on commit 9b15a73

Please sign in to comment.