Changeset 47c811cc09 in tspsg for src/settingsdialog.cpp


Ignore:
Timestamp:
Oct 13, 2012, 9:02:50 PM (12 years ago)
Author:
Oleksii Serdiuk
Branches:
appveyor, imgbot, master, readme
Children:
b96b44b6b7
Parents:
07e43cf61a
Message:

Added a way to change maximum number of cities without recompiling.

Added Tweaks/MaxNumCitites? setting to tspsg.ini. The maximum number of
cities limit can be controlled by setting it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/settingsdialog.cpp

    r07e43cf61a r47c811cc09  
    323323    spinCitiesLimit->setEnabled(cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
    324324    spinCitiesLimit->setValue(settings->value("ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt());
    325     spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
     325    settings->endGroup();
     326    spinCitiesLimit->setMaximum(settings->value("Tweaks/MaxNumCities", MAX_NUM_CITIES).toInt());
     327    settings->beginGroup("Output");
    326328    cbScrollToEnd->setChecked(settings->value("ScrollToEnd", DEF_SCROLL_TO_END).toBool());
    327329
     
    386388{
    387389    if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
    388         if (QMessageBox::question(this, tr("Settings Reset"), tr("Do you really want to <b>reset all application settings to their defaults</b>?"), QMessageBox::RestoreDefaults | QMessageBox::Cancel) == QMessageBox::RestoreDefaults) {
     390        if (QMessageBox::question(this, tr("Settings Reset"),
     391                                  tr("Do you really want to <b>reset all application settings"
     392                                     " to their defaults</b>?<br>"
     393                                     "Please, note that \"Tweaks\" section won't be reset."),
     394                                  QMessageBox::RestoreDefaults | QMessageBox::Cancel)
     395                == QMessageBox::RestoreDefaults) {
    389396            _fontChanged = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
    390397            _colorChanged = (textColor != DEF_TEXT_COLOR);
     398            // Saving Tweaks section as we don't reset it
     399            settings->beginGroup("Tweaks");
     400            QHash<QString, QVariant> values;
     401            foreach (const QString &key, settings->childKeys()) {
     402                values.insert(key, settings->value(key));
     403            }
     404            settings->endGroup();
    391405            settings->remove("");
    392406            settings->setValue("SettingsReset", true);
     407            if (!values.empty()) {
     408                settings->beginGroup("Tweaks");
     409                foreach (const QString &key, values.keys()) {
     410                    settings->setValue(key, values.value(key));
     411                }
     412                settings->endGroup();
     413            }
    393414            QDialog::accept();
    394415            QMessageBox::information(this->parentWidget(), tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now."));
Note: See TracChangeset for help on using the changeset viewer.