Changeset 665d32434f in tspsg for src


Ignore:
Timestamp:
Jun 22, 2009, 9:44:00 AM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
e7f7d3854d
Parents:
d5384ee64e
Message:

Settings saving tweaks.

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/defines.h

    rd5384ee64e r665d32434f  
    2222 */
    2323
    24 #ifndef DEFAULTS_H
    25 #define DEFAULTS_H
    26 
    27 // Ini file name
    28 #define INI_FILE "tspsg.ini"
     24#ifndef DEFINES_H
     25#define DEFINES_H
    2926
    3027// Default values
     
    3633#define DEF_FONT_COLOR Qt::black
    3734
    38 #endif // DEFAULTS_H
     35#endif // DEFINES_H
  • src/mainwindow.cpp

    rd5384ee64e r665d32434f  
    3333{
    3434        setupUi(this);
    35 QSettings settings(INI_FILE,QSettings::IniFormat);
    36         spinCities->setValue(settings.value("NumCities",5).toInt());
     35        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
     36        spinCities->setValue(settings->value("NumCities",5).toInt());
    3737        connect(actionSettingsSettings,SIGNAL(triggered()),this,SLOT(ChangeSettings()));
    3838        connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
     
    5050        tabWidget->resize(rect.width(),rect.height() - toolBar->size().height());
    5151#else
    52         if (settings.value("SavePos",false).toBool()) {
     52        if (settings->value("SavePos",false).toBool()) {
    5353                // Loading of saved window state
    54                 settings.beginGroup("MainWindow");
    55                 resize(settings.value("Size",size()).toSize());
    56                 move(settings.value("Position",pos()).toPoint());
    57                 if (settings.value("Maximized",false).toBool())
     54                settings->beginGroup("MainWindow");
     55                resize(settings->value("Size",size()).toSize());
     56                move(settings->value("Position",pos()).toPoint());
     57                if (settings->value("Maximized",false).toBool())
    5858                        setWindowState(windowState() | Qt::WindowMaximized);
    59                 settings.endGroup();
     59                settings->endGroup();
    6060        } else {
    6161                // Centering main window
     
    154154{
    155155        // Saving windows state
    156 QSettings settings(INI_FILE,QSettings::IniFormat);
    157         settings.setValue("NumCities",spinCities->value());
    158         if (settings.value("SavePos",false).toBool()) {
    159                 settings.beginGroup("MainWindow");
    160                 settings.setValue("Maximized",isMaximized());
     156        settings->setValue("NumCities",spinCities->value());
     157        if (settings->value("SavePos",false).toBool()) {
     158                settings->beginGroup("MainWindow");
     159                settings->setValue("Maximized",isMaximized());
    161160                if (!isMaximized()) {
    162                         settings.setValue("Size",size());
    163                         settings.setValue("Position",pos());
     161                        settings->setValue("Size",size());
     162                        settings->setValue("Position",pos());
    164163                }
    165                 settings.endGroup();
     164                settings->endGroup();
    166165        }
    167166        QMainWindow::closeEvent(event);
  • src/mainwindow.h

    rd5384ee64e r665d32434f  
    2626
    2727#include <QMainWindow>
     28#include <QSettings>
    2829#ifdef Q_OS_WINCE
    2930        #include "ui_mainwindow.ce.h"
     
    5354        void CitiesNumberChanged(int n);
    5455private:
     56        QSettings *settings;
    5557        CTSPModel *tspmodel;
    5658};
  • src/settingsdialog.cpp

    rd5384ee64e r665d32434f  
    5050        labelHint->setMinimumHeight(labelHint->height());
    5151#endif // Q_OS_WINCE
    52         settings = new QSettings(INI_FILE,QSettings::IniFormat);
     52        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
    5353        spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
    5454        spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
  • src/tspmodel.cpp

    rd5384ee64e r665d32434f  
    2929        : QAbstractTableModel(parent), nCities(0)
    3030{
    31         settings = new QSettings(INI_FILE,QSettings::IniFormat);
     31        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
    3232}
    3333
Note: See TracChangeset for help on using the changeset viewer.