Changeset 95 in tspsg-svn for trunk/src/mainwindow.cpp


Ignore:
Timestamp:
Feb 27, 2010, 2:13:50 PM (15 years ago)
Author:
laleppa
Message:

+ Added Symmetric mode: in this mode the cost of travel from city 1 to city 2 and vice versa is the same.
+ Added the ability to reset all settings to their defaults: hold Shift while clicking Save button in Settings Dialog.

  • Better SIP show/hide handling under wince: no need to resize the Main Window, when it isn't active.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r94 r95  
    7171
    7272#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     73        // Centering main window
     74QRect rect = geometry();
     75        rect.moveCenter(QApplication::desktop()->availableGeometry(this).center());
     76        setGeometry(rect);
    7377        if (settings->value("SavePos", DEF_SAVEPOS).toBool()) {
    7478                // Loading of saved window state
     
    7781                restoreState(settings->value("State").toByteArray());
    7882                settings->endGroup();
    79         } else {
    80                 // Centering main window
    81 QRect rect = geometry();
    82                 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center());
    83                 setGeometry(rect);
    8483        }
    8584#else
     
    500499
    501500#ifdef Q_OS_WINCE
     501void MainWindow::changeEvent(QEvent *ev)
     502{
     503        if ((ev->type() == QEvent::ActivationChange) && isActiveWindow())
     504                desktopResized(0);
     505
     506        QWidget::changeEvent(ev);
     507}
     508
    502509void MainWindow::desktopResized(int screen)
    503510{
    504         if (screen != 0)
     511        if ((screen != 0) || !isActiveWindow())
    505512                return;
    506513
    507514QRect availableGeometry = QApplication::desktop()->availableGeometry(0);
    508515        if (currentGeometry != availableGeometry) {
     516                QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    509517                /*!
    510518                 * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height.
     
    519527                        setGeometry(availableGeometry);
    520528                }
    521         }
    522         currentGeometry = availableGeometry;
     529                currentGeometry = availableGeometry;
     530                QApplication::restoreOverrideCursor();
     531        }
    523532}
    524533#endif // Q_OS_WINCE
     
    557566                return;
    558567        }
    559         settings->setValue("NumCities", spinCities->value());
    560 
    561         // Saving Main Window state
    562         if (settings->value("SavePos", DEF_SAVEPOS).toBool()) {
    563                 settings->beginGroup("MainWindow");
     568        if (!settings->value("SettingsReset", false).toBool()) {
     569                settings->setValue("NumCities", spinCities->value());
     570
     571                // Saving Main Window state
     572                if (settings->value("SavePos", DEF_SAVEPOS).toBool()) {
     573                        settings->beginGroup("MainWindow");
    564574#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
    565                 settings->setValue("Geometry", saveGeometry());
     575                        settings->setValue("Geometry", saveGeometry());
    566576#endif // Q_OS_WINCE
    567                 settings->setValue("State", saveState());
    568                 settings->endGroup();
     577                        settings->setValue("State", saveState());
     578                        settings->endGroup();
     579                }
     580        } else {
     581                settings->remove("SettingsReset");
    569582        }
    570583
Note: See TracChangeset for help on using the changeset viewer.