Skip to content

Commit f2924f1

Browse files
committed
Save Theme in conf file
1 parent f9d1e6e commit f2924f1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

example/mainwindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QFontDialog>
1111
#include <QDragEnterEvent>
1212
#include <QDropEvent>
13+
#include <QStyleFactory>
1314

1415
#include "mainwindow.h"
1516

@@ -206,6 +207,7 @@ void MainWindow::showSearchDialog()
206207
/*****************************************************************************/
207208
void MainWindow::init()
208209
{
210+
QApplication::setStyle(QStyleFactory::create("Fusion"));
209211
hexEdit = new QHexEdit(this);
210212
setCentralWidget(hexEdit);
211213
readSettings();
@@ -388,6 +390,8 @@ void MainWindow::readSettings()
388390
move(pos);
389391
resize(size);
390392

393+
// Note: theme settings is not stored in hexedit, Optionsdialog handles this directly
394+
391395
if (settings.contains("AddressArea"))
392396
hexEdit->setAddressArea(settings.value("AddressArea").toBool());
393397
if (settings.contains("AsciiArea"))
@@ -463,6 +467,8 @@ QString MainWindow::strippedName(const QString &fullFileName)
463467

464468
void MainWindow::writeSettings()
465469
{
470+
// Note: theme settings is not stored in hexedit, Optionsdialog handles this directly
471+
466472
QSettings settings;
467473
settings.setValue("pos", pos());
468474
settings.setValue("size", size());

example/optionsdialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
4141
_darkMode = palette;
4242
_defaultMode = QApplication::palette();
4343

44+
QSettings settings;
45+
if (settings.contains("Theme"))
46+
this->ui->cbPalette->setCurrentIndex(settings.value("Theme").toInt());
4447
}
4548

4649
void OptionsDialog::accept()
@@ -105,6 +108,9 @@ void OptionsDialog::on_pbWidgetFont_clicked()
105108

106109
void OptionsDialog::on_cbPalette_currentIndexChanged(int index)
107110
{
111+
QSettings settings;
112+
settings.setValue("Theme", index);
113+
108114
switch (index)
109115
{
110116
case 1:

0 commit comments

Comments
 (0)