diff --git a/qt/aux_window.cpp b/qt/aux_window.cpp index a1f8f35..b8f71d6 100644 --- a/qt/aux_window.cpp +++ b/qt/aux_window.cpp @@ -85,7 +85,7 @@ void AuxWindow::closeEvent(QCloseEvent *event) void AuxWindow::writeSettings() const { - QSettings settings(ORGANIZATION, PACKAGE_NAME); + QSettings settings; settings.beginGroup(m_windowName); settings.setValue("size", size()); settings.setValue("pos", pos()); @@ -95,7 +95,7 @@ void AuxWindow::writeSettings() const void AuxWindow::readSettings() { - QSettings settings(ORGANIZATION, PACKAGE_NAME); + QSettings settings; settings.beginGroup(m_windowName); QSize size = settings.value("size").toSize(); if (size.isValid()) diff --git a/qt/history_widget.cpp b/qt/history_widget.cpp index 1a93594..7a690b0 100644 --- a/qt/history_widget.cpp +++ b/qt/history_widget.cpp @@ -124,7 +124,7 @@ void HistoryWidget::updateModel() if (m_history != NULL && m_history->getSize() != 0) { // Should we align the rack with its solution? - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; bool align = qs.value(PrefsDialog::kINTF_ALIGN_HISTORY).toBool(); if (!align) diff --git a/qt/main.cpp b/qt/main.cpp index f94744c..784be25 100644 --- a/qt/main.cpp +++ b/qt/main.cpp @@ -119,6 +119,9 @@ int main(int argc, char **argv) MyApplication app(argc, argv); app.setWindowIcon(QIcon(":/images/eliot.xpm")); + // Used for QSettings + app.setApplicationName(PACKAGE_NAME); + app.setOrganizationName("eliot"); #ifdef ENABLE_NLS // Set the message domain diff --git a/qt/main_window.cpp b/qt/main_window.cpp index 3976318..64aea85 100644 --- a/qt/main_window.cpp +++ b/qt/main_window.cpp @@ -99,7 +99,7 @@ MainWindow::MainWindow(QWidget *iParent) // Make it easier to reproduce bugs LOG_DEBUG("Rand seed: " << val); - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION, 180).toInt(); int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION, 30).toInt(); m_timerModel = new TimerModel(timerTotal, timerAlert); @@ -260,7 +260,7 @@ void MainWindow::linkTrainingAnd7P1() // Reconnect it only if needed if (m_dicToolsWindow != NULL) { - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; if (qs.value(PrefsDialog::kINTF_LINK_TRAINING_7P1, false).toBool()) { QObject::connect(m_trainingWidget, @@ -285,7 +285,7 @@ void MainWindow::prefsUpdated() } // Refresh the timer values - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION).toInt(); int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION).toInt(); m_timerModel->setTotalDuration(timerTotal); @@ -424,7 +424,7 @@ void MainWindow::displayInfoMsg(QString iMsg) void MainWindow::showDefinition(QString iWord) { - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; QString url = qs.value(PrefsDialog::kINTF_DEFINITIONS_SITE_URL, PrefsDialog::kDEFAULT_DEF_SITE).toString(); if (url == "") @@ -477,7 +477,7 @@ void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::writeSettings() const { - QSettings settings(ORGANIZATION, PACKAGE_NAME); + QSettings settings; settings.beginGroup(m_windowName); settings.setValue("size", size()); settings.setValue("pos", pos()); @@ -492,7 +492,7 @@ void MainWindow::writeSettings() const void MainWindow::readSettings() { - QSettings settings(ORGANIZATION, PACKAGE_NAME); + QSettings settings; settings.beginGroup(m_windowName); QSize size = settings.value("size").toSize(); if (size.isValid()) @@ -528,7 +528,7 @@ void MainWindow::changeDictionary(QString iFileName) displayInfoMsg(_q("Loaded dictionary '%1'").arg(iFileName)); // Save the location of the dictionary in the preferences - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; qs.setValue(PrefsDialog::kINTF_DIC_PATH, iFileName); } catch (std::exception &e) @@ -558,7 +558,7 @@ QAction * MainWindow::addMenuAction(QMenu *menu, QString iText, void MainWindow::createMenu() { // Decide whether to show the toolbar - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; bool showToolBar = qs.value(PrefsDialog::kINTF_SHOW_TOOLBAR, true).toBool(); m_ui.toolBar->setVisible(showToolBar); @@ -944,7 +944,7 @@ void MainWindow::onWindowsToolbar() m_ui.toolBar->hide(); else m_ui.toolBar->show(); - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; qs.setValue(PrefsDialog::kINTF_SHOW_TOOLBAR, m_ui.toolBar->isVisible()); } @@ -1161,7 +1161,7 @@ void MainWindow::onHistoryReplayTurn() if (m_game == NULL) return; - QSettings settings(ORGANIZATION, PACKAGE_NAME); + QSettings settings; bool warn = settings.value(PrefsDialog::kINTF_WARN_REPLAY_TURN, true).toBool(); if (warn) { // Ask for a confirmation, because this may lead to data loss diff --git a/qt/new_game.cpp b/qt/new_game.cpp index 49dd16e..763f7b8 100644 --- a/qt/new_game.cpp +++ b/qt/new_game.cpp @@ -125,7 +125,7 @@ NewGame::NewGame(QWidget *iParent) void NewGame::refresh() { // Retrieve the default computer level - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; int defLevel = qs.value(PrefsDialog::kINTF_DEFAULT_AI_LEVEL, 100).toInt(); // Ensure a valid range if (defLevel < 0) diff --git a/qt/prefs_dialog.cpp b/qt/prefs_dialog.cpp index 7b4a53f..d79496d 100644 --- a/qt/prefs_dialog.cpp +++ b/qt/prefs_dialog.cpp @@ -73,7 +73,7 @@ PrefsDialog::PrefsDialog(QWidget *iParent) try { // Interface settings - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; lineEditIntfDicPath->setText(qs.value(kINTF_DIC_PATH, "").toString()); lineEditDefSite->setText(qs.value(kINTF_DEFINITIONS_SITE_URL, kDEFAULT_DEF_SITE).toString()); @@ -133,7 +133,7 @@ void PrefsDialog::updateSettings() try { // Interface settings - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; qs.setValue(kINTF_DIC_PATH, lineEditIntfDicPath->text()); qs.setValue(kINTF_DEFINITIONS_SITE_URL, lineEditDefSite->text()); if (qs.value(kINTF_ALIGN_HISTORY, true).toBool() != checkBoxIntfAlignHistory->isChecked()) diff --git a/qt/qtcommon.h b/qt/qtcommon.h index d6ac98b..d572e61 100644 --- a/qt/qtcommon.h +++ b/qt/qtcommon.h @@ -55,9 +55,6 @@ QString qfw(const wstring &wstr); # define _q(s) QString::fromLocal8Bit(_(s)) #endif -// Used for QSettings -#define ORGANIZATION "eliot" - class QObject; class QWidget; diff --git a/qt/tile_widget.cpp b/qt/tile_widget.cpp index 718cf96..06224bd 100644 --- a/qt/tile_widget.cpp +++ b/qt/tile_widget.cpp @@ -194,7 +194,7 @@ void TileWidget::paintEvent(QPaintEvent *iEvent) painter.setPen(TextNormalColour); // Should we display the tiles points? - QSettings qs(ORGANIZATION, PACKAGE_NAME); + QSettings qs; const bool showPoints = qs.value(PrefsDialog::kINTF_SHOW_TILES_POINTS, true).toBool(); // Draw the points of the tile