diff --git a/companion/src/burnconfigdialog.cpp b/companion/src/burnconfigdialog.cpp index 61c0df423..b09a7318a 100644 --- a/companion/src/burnconfigdialog.cpp +++ b/companion/src/burnconfigdialog.cpp @@ -279,17 +279,7 @@ void burnConfigDialog::listProgrammers() QStringList arguments; arguments << "-c?"; avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon Icon; populate_icon(&Icon,Theme,"list.png"); ad->setWindowIcon(Icon); @@ -309,17 +299,7 @@ void burnConfigDialog::on_pushButton_4_clicked() arguments << "-?"; avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon Icon; populate_icon(&Icon,Theme,"configure.png"); ad->setWindowIcon(Icon); @@ -339,17 +319,7 @@ void burnConfigDialog::readFuses() arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str; avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon Icon; populate_icon(&Icon,Theme,"fuses.png"); ad->setWindowIcon(Icon); @@ -364,6 +334,7 @@ void burnConfigDialog::restFuses(bool eeProtect) //avrdude -c usbasp -p m64 -U efuse:w:<0xFF>:m QMessageBox::StandardButton ret = QMessageBox::No; + QString Theme=getTheme(); ret = QMessageBox::warning(this, tr("Companion"), tr("WARNING!
This will reset the fuses of %1 to the factory settings.
Writing fuses can mess up your radio.
Do this only if you are sure they are wrong!
Are you sure you want to continue?").arg(avrMCU), @@ -386,17 +357,6 @@ void burnConfigDialog::restFuses(bool eeProtect) QStringList argread; argread << "-c" << avrProgrammer << "-p" << avrMCU << args <<"-U" << "lfuse:r:"+tempFile+":r" ; avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, argread, "Reset Fuses",AVR_DIALOG_CLOSE_IF_SUCCESSFUL,FALSE); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } QIcon Icon; populate_icon(&Icon,Theme,"fuses.png"); ad->setWindowIcon(Icon); @@ -428,17 +388,6 @@ void burnConfigDialog::restFuses(bool eeProtect) arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str; } avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } QIcon Icon; populate_icon(&Icon,Theme,"fuses.png"); ad->setWindowIcon(Icon); diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp index df87455e9..7da0896ed 100644 --- a/companion/src/burndialog.cpp +++ b/companion/src/burndialog.cpp @@ -16,17 +16,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac hexType(Type) { ui->setupUi(this); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon LibraryIcon; populate_icon(&LibraryIcon,Theme,"library.png"); ui->libraryButton->setIcon(LibraryIcon); diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 88c338859..92c3a54e1 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -11,17 +11,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) : QDialog(parent), ui(new Ui::customizeSplashDialog) { ui->setupUi(this); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon LibraryIcon; populate_icon(&LibraryIcon,Theme,"library.png"); ui->libraryButton->setIcon(LibraryIcon); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 8c70f8805..f5a509359 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -1485,9 +1485,26 @@ QString getCenterBeep(ModelData * g_model) return strl.join(", "); } -void populate_icon(QIcon *Icon, QString usedtheme, QString baseimage) { +void populate_icon(QIcon *Icon, QString usedtheme, QString baseimage) +{ Icon->addFile(":/themes/"+usedtheme+"/16/"+baseimage,QSize(16,16)); Icon->addFile(":/themes/"+usedtheme+"/24/"+baseimage,QSize(24,24)); Icon->addFile(":/themes/"+usedtheme+"/32/"+baseimage,QSize(32,32)); Icon->addFile(":/themes/"+usedtheme+"/48/"+baseimage,QSize(48,48)); } + +QString getTheme() +{ + QSettings settings("companion", "companion"); + int theme_set=settings.value("theme", 1).toInt(); + QString Theme; + switch(theme_set) { + case 0: + Theme="classic"; + break; + default: + Theme="monochrome"; + break; + } + return Theme; +} \ No newline at end of file diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 1cb564340..4e720e629 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -29,6 +29,7 @@ void populateTTraceCB(QComboBox *b, int value); void populateRotEncCB(QComboBox *b, int value, int renumber); void populateBacklightCB(QComboBox *b, const uint8_t value); void populate_icon(QIcon *Icon, QString usedtheme, QString baseimage); +QString getTheme(); class GVarGroup : public QObject { diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 4f0cad108..5d8bdf237 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -96,16 +96,8 @@ downloadDialog_forWait(NULL) this, SLOT(setActiveSubWindow(QWidget*))); MaxRecentFiles=MAX_RECENT; + Theme=getTheme(); QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } int icon_size=settings.value("icon_size", 1).toInt(); switch (icon_size) { case 0: diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index e17594540..b3ecb4a72 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -68,17 +68,7 @@ MdiChild::MdiChild(): isUntitled(true), fileChanged(false) { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon SimulateIcon; populate_icon(&SimulateIcon,Theme,"simulate.png"); @@ -522,17 +512,8 @@ QString MdiChild::strippedName(const QString &fullFileName) void MdiChild::burnTo() // write to Tx { + QString Theme=getTheme(); QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } bool backupEnable=settings.value("backupEnable", true).toBool(); QString backupPath=settings.value("backupPath", "").toString(); if (!backupPath.isEmpty()) { diff --git a/companion/src/modeledit/curves.cpp b/companion/src/modeledit/curves.cpp index 21c3fec32..b997a964c 100644 --- a/companion/src/modeledit/curves.cpp +++ b/companion/src/modeledit/curves.cpp @@ -84,18 +84,7 @@ Curves::Curves(QWidget * parent, ModelData & model): QGraphicsScene *scene = new QGraphicsScene(ui->curvePreview); scene->setItemIndexMethod(QGraphicsScene::NoIndex); ui->curvePreview->setScene(scene); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } - + QString Theme=getTheme(); QIcon ClearIcon; populate_icon(&ClearIcon,Theme,"clear.png"); diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 7bb1a2b76..ebccf06c8 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -123,17 +123,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, connect(fswtchParamArmT[i], SIGNAL(editTextChanged ( const QString)), this, SLOT(customFunctionEdited())); #ifdef PHONON - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon PlayIcon; populate_icon(&PlayIcon,Theme,"play.png"); playBT[i] = new QPushButton(this); @@ -173,17 +163,7 @@ void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::Sta { if (phononLock) return; - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon PlayIcon; populate_icon(&PlayIcon,Theme,"play.png"); @@ -216,17 +196,8 @@ void CustomFunctionsPanel::playMusic() QPushButton *playButton = qobject_cast(sender()); int index=playButton->objectName().mid(5,2).toInt(); QString function=playButton->objectName().left(4); + QString Theme=getTheme(); QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } QIcon PlayIcon; populate_icon(&PlayIcon,Theme,"play.png"); QIcon StopIcon; @@ -499,17 +470,7 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedFunction = label->property("index").toInt(); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon ClearIcon; populate_icon(&ClearIcon,Theme,"clear.png"); QIcon CopyIcon; diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index 487cd68cc..8c2adf2c5 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -382,17 +382,7 @@ void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedSwitch = label->property("index").toInt(); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon ClearIcon; populate_icon(&ClearIcon,Theme,"clear.png"); QIcon CopyIcon; diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index fce9166e2..c8ac71c59 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -8,17 +8,7 @@ InputsPanel::InputsPanel(QWidget *parent, ModelData & model, GeneralSettings & g generalSettings(generalSettings), expoInserted(false) { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QGridLayout * exposLayout = new QGridLayout(this); @@ -358,17 +348,7 @@ void InputsPanel::expoAdd() void InputsPanel::expolistWidget_customContextMenuRequested(QPoint pos) { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon AddIcon; populate_icon(&AddIcon,Theme,"add.png"); QIcon EditIcon; diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 132cfc00e..5f6cc74a6 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -8,17 +8,6 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen generalSettings(generalSettings), mixInserted(false) { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } QGridLayout * mixesLayout = new QGridLayout(this); MixerlistWidget = new MixersList(this, false); // TODO enum @@ -26,6 +15,7 @@ MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & gen QPushButton * qbDown = new QPushButton(this); QPushButton * qbClear = new QPushButton(this); + QString Theme=getTheme(); QIcon qbUpIcon; populate_icon(&qbUpIcon,Theme,"moveup.png"); qbUp->setText(tr("Move Up")); @@ -423,17 +413,7 @@ void MixesPanel::mixerAdd() void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos) { - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon AddIcon; populate_icon(&AddIcon,Theme,"add.png"); QIcon EditIcon; diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 8cf90bece..ec6d76ab8 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -21,18 +21,9 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i generalSettings(generalSettings) { ui->setupUi(this); + QString Theme=getTheme(); QSettings settings("companion", "companion"); restoreGeometry(settings.value("modelEditGeometry").toByteArray()); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } QIcon SimulateIcon; populate_icon(&SimulateIcon,Theme,"simulate.png"); ui->pushButton->setIcon(SimulateIcon); diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index a2984c02c..b96925020 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -83,17 +83,7 @@ void ModelsListWidget::ShowContextMenu(const QPoint& pos) const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); bool hasData = mimeData->hasFormat("application/x-companion9x"); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon AddIcon; populate_icon(&AddIcon,Theme,"add.png"); QIcon EditIcon; diff --git a/companion/src/preferencesdialog.cpp b/companion/src/preferencesdialog.cpp index 839c554a3..625934292 100644 --- a/companion/src/preferencesdialog.cpp +++ b/companion/src/preferencesdialog.cpp @@ -17,19 +17,8 @@ preferencesDialog::preferencesDialog(QWidget *parent) : updateLock(false) { ui->setupUi(this); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); + QString Theme=getTheme(); QIcon Icon; - - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } populate_icon(&Icon, Theme, "preferences.png"); this->setWindowIcon(Icon); QIcon LibraryIcon; diff --git a/companion/src/splashlibrary.cpp b/companion/src/splashlibrary.cpp index 8749f7587..4d0c0b111 100644 --- a/companion/src/splashlibrary.cpp +++ b/companion/src/splashlibrary.cpp @@ -9,17 +9,7 @@ splashLibrary::splashLibrary(QWidget *parent, QString * fileName) : QDialog(parent), ui(new Ui::splashLibrary) { splashFileName = fileName; ui->setupUi(this); - QSettings settings("companion", "companion"); - int theme_set=settings.value("theme", 1).toInt(); - QString Theme; - switch(theme_set) { - case 0: - Theme="classic"; - break; - default: - Theme="monochrome"; - break; - } + QString Theme=getTheme(); QIcon NextIcon; populate_icon(&NextIcon,Theme,"arrow-right.png"); QIcon PrevIcon;