Changeset 47c811cc09 in tspsg for src


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.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    r07e43cf61a r47c811cc09  
    129129{
    130130    settings = initSettings(this);
     131
     132    // Sanity check
     133    int m = settings->value("Tweaks/MaxNumCities", MAX_NUM_CITIES).toInt();
     134    if (m < 3)
     135        settings->setValue("Tweaks/MaxNumCities", 3);
    131136
    132137    if (settings->contains("Style")) {
     
    19661971        actionHelpCheck4Updates = NULL;
    19671972
    1968     spinCities->setMaximum(MAX_NUM_CITIES);
     1973    spinCities->setMaximum(settings->value("Tweaks/MaxNumCities", MAX_NUM_CITIES).toInt());
    19691974
    19701975#ifndef HANDHELD
  • 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."));
  • src/tspmodel.cpp

    r07e43cf61a r47c811cc09  
    432432        return false;
    433433    }
    434     if (size > MAX_NUM_CITIES) {
    435         QApplication::restoreOverrideCursor();
    436         QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
    437         QMessageBox::critical(QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n"
    438             + tr("The task contains more cities (%1) than this version of %3 supports (%2).\n"
    439                  "You might be using an old version of the application or the file could be corrupted.")
    440                  .arg(size).arg(MAX_NUM_CITIES).arg(QApplication::applicationName()));
     434    if (size > settings->value("Tweaks/MaxNumCities", MAX_NUM_CITIES).toInt()) {
     435        QApplication::restoreOverrideCursor();
     436        QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
     437        if (settings->contains("Tweaks/MaxNumCities")) {
     438            QMessageBox::critical(
     439                        QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n"
     440                        + tr("Your Tweaks/MaxNumCities setting in tspsg.ini is currently set to %1"
     441                             " but the task you're trying to load contains %2 cities.\n"
     442                             "Please, set Tweaks/MaxNumCities setting to at least %2"
     443                             " to be able to load this task.")
     444                        .arg(settings->value("Tweaks/MaxNumCities").toInt()).arg(size));
     445        } else {
     446            QMessageBox::critical(
     447                        QApplication::activeWindow(), tr("Task Load"), tr("Unable to load task:") + "\n"
     448                        + tr("The maximum number of cities this version of %1 supports is %2"
     449                             " but the task you're trying to load contains %3.\n"
     450                             "You might be using an old version of the application or the file"
     451                             " could be corrupted.")
     452                        .arg(QApplication::applicationName()).arg(MAX_NUM_CITIES).arg(size));
     453        }
    441454        QApplication::restoreOverrideCursor();
    442455        return false;
Note: See TracChangeset for help on using the changeset viewer.