Changeset 149 in tspsg-svn for trunk/src/settingsdialog.cpp


Ignore:
Timestamp:
Dec 20, 2010, 9:53:45 PM (14 years ago)
Author:
laleppa
Message:

Converted file formatting to have spaces instead of tabs. No code changes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/settingsdialog.cpp

    r143 r149  
    3131 */
    3232SettingsDialog::SettingsDialog(QWidget *parent)
    33         : QDialog(parent), _newFont(false), _newColor(false), _translucency(0)
    34 {
    35         setupUi(this);
    36 
    37         setWindowIcon(GET_ICON("preferences-system"));
    38 
    39         buttonBox->button(QDialogButtonBox::Ok)->setIcon(GET_ICON("dialog-ok"));
    40 #ifndef QT_NO_STATUSTIP
    41         buttonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Save new preferences"));
     33    : QDialog(parent), _newFont(false), _newColor(false), _translucency(0)
     34{
     35    setupUi(this);
     36
     37    setWindowIcon(GET_ICON("preferences-system"));
     38
     39    buttonBox->button(QDialogButtonBox::Ok)->setIcon(GET_ICON("dialog-ok"));
     40#ifndef QT_NO_STATUSTIP
     41    buttonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Save new preferences"));
    4242#endif
    43         buttonBox->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
    44         buttonBox->button(QDialogButtonBox::Cancel)->setIcon(GET_ICON("dialog-cancel"));
    45 #ifndef QT_NO_STATUSTIP
    46         buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Close without saving preferences"));
     43    buttonBox->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
     44    buttonBox->button(QDialogButtonBox::Cancel)->setIcon(GET_ICON("dialog-cancel"));
     45#ifndef QT_NO_STATUSTIP
     46    buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Close without saving preferences"));
    4747#endif
    48         buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
    49 
    50         buttonColor->setIcon(GET_ICON("format-text-color"));
    51         buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
    52         buttonHelp->setIcon(GET_ICON("help-hint"));
     48    buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
     49
     50    buttonColor->setIcon(GET_ICON("format-text-color"));
     51    buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
     52    buttonHelp->setIcon(GET_ICON("help-hint"));
    5353
    5454QPalette p = bgWhite->palette();
    55         p.setColor(QPalette::Window, p.color(QPalette::Base));
    56         bgWhite->setPalette(p);
    57 
    58         p = lineHorizontal->palette();
    59         p.setColor(QPalette::Window, p.color(QPalette::Text));
    60         lineHorizontal->setPalette(p);
     55    p.setColor(QPalette::Window, p.color(QPalette::Base));
     56    bgWhite->setPalette(p);
     57
     58    p = lineHorizontal->palette();
     59    p.setColor(QPalette::Window, p.color(QPalette::Text));
     60    lineHorizontal->setPalette(p);
    6161
    6262// Layout helpers
     
    6464QHBoxLayout *hbox;
    6565#ifndef QT_NO_PRINTER
    66         cbHQGraph = new QCheckBox(bgWhite);
    67         cbHQGraph->setObjectName("cbHQGraph");
    68 #ifndef QT_NO_STATUSTIP
    69         cbHQGraph->setStatusTip(tr("Higher quality graph looks much better when printing but uglier on the screen"));
    70 #endif // QT_NO_STATUSTIP
    71         cbHQGraph->setText(tr("Draw solution graph in higher quality"));
    72         cbHQGraph->setCursor(QCursor(Qt::PointingHandCursor));
    73 
    74         box = static_cast<QBoxLayout *>(tabOutput->layout());
    75         hbox = new QHBoxLayout();
    76         hbox->addSpacing(10);
    77         hbox->addWidget(cbHQGraph);
    78         box->insertLayout(box->indexOf(cbShowGraph) + 1, hbox);
    79         connect(cbShowGraph, SIGNAL(toggled(bool)), cbHQGraph, SLOT(setEnabled(bool)));
     66    cbHQGraph = new QCheckBox(bgWhite);
     67    cbHQGraph->setObjectName("cbHQGraph");
     68#ifndef QT_NO_STATUSTIP
     69    cbHQGraph->setStatusTip(tr("Higher quality graph looks much better when printing but uglier on the screen"));
     70#endif // QT_NO_STATUSTIP
     71    cbHQGraph->setText(tr("Draw solution graph in higher quality"));
     72    cbHQGraph->setCursor(QCursor(Qt::PointingHandCursor));
     73
     74    box = static_cast<QBoxLayout *>(tabOutput->layout());
     75    hbox = new QHBoxLayout();
     76    hbox->addSpacing(10);
     77    hbox->addWidget(cbHQGraph);
     78    box->insertLayout(box->indexOf(cbShowGraph) + 1, hbox);
     79    connect(cbShowGraph, SIGNAL(toggled(bool)), cbHQGraph, SLOT(setEnabled(bool)));
    8080#endif
    8181
    82         if (hasUpdater()) {
    83                 cbCheck4Updates = new QCheckBox(bgWhite);
    84                 cbCheck4Updates->setObjectName("cbCheck4Updates");
    85 #ifndef QT_NO_STATUSTIP
    86                 cbCheck4Updates->setStatusTip(tr("Automatically check for updates at the given interval"));
    87 #endif // QT_NO_STATUSTIP
    88                 cbCheck4Updates->setText(tr("Check for updates every"));
    89                 cbCheck4Updates->setCursor(QCursor(Qt::PointingHandCursor));
    90 
    91                 spinUpdateCheckInterval = new QSpinBox(bgWhite);
    92                 spinUpdateCheckInterval->setObjectName("spinUpdateCheckInterval");
    93 #ifndef QT_NO_STATUSTIP
    94                 spinUpdateCheckInterval->setStatusTip(tr("Minimal interval at which to check for updates"));
    95 #endif // QT_NO_STATUSTIP
    96                 spinUpdateCheckInterval->setSuffix(tr(" days", "Don't forget a space at the beginning!"));
    97                 spinUpdateCheckInterval->setRange(1, 365);
    98                 spinUpdateCheckInterval->setCursor(QCursor(Qt::PointingHandCursor));
    99 
    100                 connect(cbCheck4Updates, SIGNAL(toggled(bool)), spinUpdateCheckInterval, SLOT(setEnabled(bool)));
    101 
    102                 box = static_cast<QBoxLayout *>(tabGeneral->layout());
    103                 hbox = new QHBoxLayout();
    104                 hbox->setSpacing(0);
    105                 hbox->addWidget(cbCheck4Updates);
    106                 hbox->addWidget(spinUpdateCheckInterval);
    107                 hbox->addStretch();
    108                 box->insertLayout(box->indexOf(cbUseNativeDialogs) + 1, hbox);
    109         } else
    110                 cbCheck4Updates = NULL;
     82    if (hasUpdater()) {
     83        cbCheck4Updates = new QCheckBox(bgWhite);
     84        cbCheck4Updates->setObjectName("cbCheck4Updates");
     85#ifndef QT_NO_STATUSTIP
     86        cbCheck4Updates->setStatusTip(tr("Automatically check for updates at the given interval"));
     87#endif // QT_NO_STATUSTIP
     88        cbCheck4Updates->setText(tr("Check for updates every"));
     89        cbCheck4Updates->setCursor(QCursor(Qt::PointingHandCursor));
     90
     91        spinUpdateCheckInterval = new QSpinBox(bgWhite);
     92        spinUpdateCheckInterval->setObjectName("spinUpdateCheckInterval");
     93#ifndef QT_NO_STATUSTIP
     94        spinUpdateCheckInterval->setStatusTip(tr("Minimal interval at which to check for updates"));
     95#endif // QT_NO_STATUSTIP
     96        spinUpdateCheckInterval->setSuffix(tr(" days", "Don't forget a space at the beginning!"));
     97        spinUpdateCheckInterval->setRange(1, 365);
     98        spinUpdateCheckInterval->setCursor(QCursor(Qt::PointingHandCursor));
     99
     100        connect(cbCheck4Updates, SIGNAL(toggled(bool)), spinUpdateCheckInterval, SLOT(setEnabled(bool)));
     101
     102        box = static_cast<QBoxLayout *>(tabGeneral->layout());
     103        hbox = new QHBoxLayout();
     104        hbox->setSpacing(0);
     105        hbox->addWidget(cbCheck4Updates);
     106        hbox->addWidget(spinUpdateCheckInterval);
     107        hbox->addStretch();
     108        box->insertLayout(box->indexOf(cbUseNativeDialogs) + 1, hbox);
     109    } else
     110        cbCheck4Updates = NULL;
    111111
    112112#ifdef HANDHELD
     
    114114
    115115#ifdef Q_WS_WINCE_WM
    116         // On screens with small height when SIP is shown and the window is resized
    117         // there is not enought space for all elements.
    118         // So we show the scrollbars to be able to access them.
     116    // On screens with small height when SIP is shown and the window is resized
     117    // there is not enought space for all elements.
     118    // So we show the scrollbars to be able to access them.
    119119QScrollArea *scrollArea = new QScrollArea(this);
    120         scrollArea->setFrameShape(QFrame::NoFrame);
    121         scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    122         scrollArea->setWidgetResizable(true);
    123         scrollArea->setWidget(bgWhite);
     120    scrollArea->setFrameShape(QFrame::NoFrame);
     121    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     122    scrollArea->setWidgetResizable(true);
     123    scrollArea->setWidget(bgWhite);
    124124#else
    125         buttons->insertStretch(buttons->indexOf(buttonHelp) + 1);
     125    buttons->insertStretch(buttons->indexOf(buttonHelp) + 1);
    126126#endif // Q_WS_WINCE_WM
    127127
    128         bgWhite->layout()->setMargin(0);
    129 
    130         // Central layout
    131         vbox1 = new QVBoxLayout(this);
    132         vbox1->setMargin(0);
    133         vbox1->setSpacing(0);
     128    bgWhite->layout()->setMargin(0);
     129
     130    // Central layout
     131    vbox1 = new QVBoxLayout(this);
     132    vbox1->setMargin(0);
     133    vbox1->setSpacing(0);
    134134#ifdef Q_WS_WINCE_WM
    135         vbox1->addWidget(scrollArea);
     135    vbox1->addWidget(scrollArea);
    136136#else
    137         vbox1->addWidget(bgWhite);
     137    vbox1->addWidget(bgWhite);
    138138#endif // Q_WS_WINCE_WM
    139         vbox1->addWidget(bgGrey);
    140         setLayout(vbox1);
     139    vbox1->addWidget(bgGrey);
     140    setLayout(vbox1);
    141141#else // HANDHELD
    142142QVBoxLayout *vbox; // Layout helper
    143143
    144144#ifdef Q_WS_WIN32
    145         if (QtWin::isCompositionEnabled()) {
    146                 cbUseTranslucency = new QCheckBox(bgWhite);
    147                 cbUseTranslucency->setObjectName("cbUseTranslucency");
    148 #ifndef QT_NO_STATUSTIP
    149                 cbUseTranslucency->setStatusTip(tr("Use translucent effect on the Main Window under Windows Vista and 7"));
    150 #endif // QT_NO_STATUSTIP
    151                 cbUseTranslucency->setText(tr("Use translucency effects"));
    152                 cbUseTranslucency->setCursor(QCursor(Qt::PointingHandCursor));
    153         }
     145    if (QtWin::isCompositionEnabled()) {
     146        cbUseTranslucency = new QCheckBox(bgWhite);
     147        cbUseTranslucency->setObjectName("cbUseTranslucency");
     148#ifndef QT_NO_STATUSTIP
     149        cbUseTranslucency->setStatusTip(tr("Use translucent effect on the Main Window under Windows Vista and 7"));
     150#endif // QT_NO_STATUSTIP
     151        cbUseTranslucency->setText(tr("Use translucency effects"));
     152        cbUseTranslucency->setCursor(QCursor(Qt::PointingHandCursor));
     153    }
    154154#endif // Q_WS_WIN32
    155155
    156         cbSaveState = new QCheckBox(bgWhite);
    157         cbSaveState->setObjectName("cbSaveState");
    158 #ifndef QT_NO_STATUSTIP
    159         cbSaveState->setStatusTip(tr("Restore main window state and position on application restart"));
    160 #endif // QT_NO_STATUSTIP
    161         cbSaveState->setText(tr("Save main window state and position"));
    162         cbSaveState->setCursor(QCursor(Qt::PointingHandCursor));
    163 
    164         imgIcon = new QLabel(this);
    165         imgIcon->setObjectName("imgIcon");
    166         imgIcon->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
    167         imgIcon->setFrameShape(QFrame::NoFrame);
    168         imgIcon->setPixmap(GET_ICON("preferences-system").pixmap(128, 128));
    169         imgIcon->setStyleSheet("background-color: #0080C0; padding-top: 11px;");
    170         imgIcon->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
    171         imgIcon->setMinimumWidth(150);
    172 
    173         labelHint = new QLabel(bgGrey);
    174         labelHint->setObjectName("labelHint");
    175         labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
     156    cbSaveState = new QCheckBox(bgWhite);
     157    cbSaveState->setObjectName("cbSaveState");
     158#ifndef QT_NO_STATUSTIP
     159    cbSaveState->setStatusTip(tr("Restore main window state and position on application restart"));
     160#endif // QT_NO_STATUSTIP
     161    cbSaveState->setText(tr("Save main window state and position"));
     162    cbSaveState->setCursor(QCursor(Qt::PointingHandCursor));
     163
     164    imgIcon = new QLabel(this);
     165    imgIcon->setObjectName("imgIcon");
     166    imgIcon->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
     167    imgIcon->setFrameShape(QFrame::NoFrame);
     168    imgIcon->setPixmap(GET_ICON("preferences-system").pixmap(128, 128));
     169    imgIcon->setStyleSheet("background-color: #0080C0; padding-top: 11px;");
     170    imgIcon->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
     171    imgIcon->setMinimumWidth(150);
     172
     173    labelHint = new QLabel(bgGrey);
     174    labelHint->setObjectName("labelHint");
     175    labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    176176//      labelHint->setMinimumSize(QSize(190,28));
    177         labelHint->setMinimumSize(QSize(0,28));
    178         labelHint->setMaximumSize(QSize(QWIDGETSIZE_MAX,28));
    179         labelHint->setTextFormat(Qt::PlainText);
     177    labelHint->setMinimumSize(QSize(0,28));
     178    labelHint->setMaximumSize(QSize(QWIDGETSIZE_MAX,28));
     179    labelHint->setTextFormat(Qt::PlainText);
    180180//      labelHint->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    181         labelHint->setWordWrap(true);
    182 #ifndef QT_NO_STATUSTIP
    183         labelHint->setStatusTip(tr("Hover mouse pointer over dialog elements to get additional help"));
    184 #endif // QT_NO_STATUSTIP
    185 
    186         lineVertical = new QFrame(this);
    187         lineVertical->setObjectName("lineVertical");
    188         lineVertical->setFrameShadow(QFrame::Plain);
    189         lineVertical->setFrameShape(QFrame::VLine);
    190         lineVertical->setLineWidth(2);
    191 
    192         // Top line
    193         hbox = new QHBoxLayout();
    194         hbox->addWidget(imgIcon);
    195         hbox->addWidget(lineVertical);
    196         hbox->addWidget(bgWhite);
    197 
    198         box = static_cast<QBoxLayout *>(tabGeneral->layout());
    199         box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbSaveState);
     181    labelHint->setWordWrap(true);
     182#ifndef QT_NO_STATUSTIP
     183    labelHint->setStatusTip(tr("Hover mouse pointer over dialog elements to get additional help"));
     184#endif // QT_NO_STATUSTIP
     185
     186    lineVertical = new QFrame(this);
     187    lineVertical->setObjectName("lineVertical");
     188    lineVertical->setFrameShadow(QFrame::Plain);
     189    lineVertical->setFrameShape(QFrame::VLine);
     190    lineVertical->setLineWidth(2);
     191
     192    // Top line
     193    hbox = new QHBoxLayout();
     194    hbox->addWidget(imgIcon);
     195    hbox->addWidget(lineVertical);
     196    hbox->addWidget(bgWhite);
     197
     198    box = static_cast<QBoxLayout *>(tabGeneral->layout());
     199    box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbSaveState);
    200200#ifdef Q_WS_WIN32
    201         if (QtWin::isCompositionEnabled())
    202                 box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbUseTranslucency);
     201    if (QtWin::isCompositionEnabled())
     202        box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbUseTranslucency);
    203203#endif // Q_WS_WIN32
    204204
    205         // Inserting label for hints to the bottom part (with grey bg)
    206         buttons->insertWidget(buttons->indexOf(buttonHelp) + 1, labelHint, 1);
    207 
    208         // Central layout
    209         vbox = new QVBoxLayout(this);
    210         vbox->setMargin(0);
    211         vbox->setSpacing(0);
    212         vbox->addLayout(hbox);
    213         vbox->addWidget(bgGrey);
    214         setLayout(vbox);
     205    // Inserting label for hints to the bottom part (with grey bg)
     206    buttons->insertWidget(buttons->indexOf(buttonHelp) + 1, labelHint, 1);
     207
     208    // Central layout
     209    vbox = new QVBoxLayout(this);
     210    vbox->setMargin(0);
     211    vbox->setSpacing(0);
     212    vbox->addLayout(hbox);
     213    vbox->addWidget(bgGrey);
     214    setLayout(vbox);
    215215#endif // HANDHELD
    216216
    217217#ifdef Q_WS_WINCE_WM
    218         // We need to react to SIP show/hide and resize the window appropriately
    219         connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(desktopResized(int)));
     218    // We need to react to SIP show/hide and resize the window appropriately
     219    connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(desktopResized(int)));
    220220#endif // Q_WS_WINCE_WM
    221         connect(spinRandMin, SIGNAL(valueChanged(int)), SLOT(spinRandMinValueChanged(int)));
    222         connect(buttonFont, SIGNAL(clicked()), SLOT(buttonFontClicked()));
    223         connect(buttonColor, SIGNAL(clicked()), SLOT(buttonColorClicked()));
    224         setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
     221    connect(spinRandMin, SIGNAL(valueChanged(int)), SLOT(spinRandMinValueChanged(int)));
     222    connect(buttonFont, SIGNAL(clicked()), SLOT(buttonFontClicked()));
     223    connect(buttonColor, SIGNAL(clicked()), SLOT(buttonColorClicked()));
     224    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
    225225#if !defined(QT_NO_STATUSTIP) && !defined(HANDHELD)
    226         // Setting initial text of dialog hint label to own status tip text.
    227         labelHint->setText(labelHint->statusTip());
     226    // Setting initial text of dialog hint label to own status tip text.
     227    labelHint->setText(labelHint->statusTip());
    228228#endif // HANDHELD
    229229
    230         settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
    231         settings->remove("SettingsReset");
    232 
    233         cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool());
    234         cbSaveLastUsed->setChecked(settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool());
    235         cbUseNativeDialogs->setChecked(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool());
     230    settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
     231    settings->remove("SettingsReset");
     232
     233    cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool());
     234    cbSaveLastUsed->setChecked(settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool());
     235    cbUseNativeDialogs->setChecked(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool());
    236236#ifdef Q_WS_WIN32
    237         if (QtWin::isCompositionEnabled())
    238                 cbUseTranslucency->setChecked(settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool());
     237    if (QtWin::isCompositionEnabled())
     238        cbUseTranslucency->setChecked(settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool());
    239239#endif // Q_WS_WIN32
    240240#ifndef HANDHELD
    241         cbSaveState->setChecked(settings->value("SavePos", DEF_SAVEPOS).toBool());
     241    cbSaveState->setChecked(settings->value("SavePos", DEF_SAVEPOS).toBool());
    242242#endif // HANDHELD
    243         if (cbCheck4Updates != NULL) {
    244                 settings->beginGroup("Check4Updates");
    245                 cbCheck4Updates->setChecked(settings->value("Enabled", DEF_CHECK_FOR_UPDATES).toBool());
    246                 spinUpdateCheckInterval->setValue(settings->value("Interval", DEF_UPDATE_CHECK_INTERVAL).toInt());
    247                 settings->endGroup();
    248                 spinUpdateCheckInterval->setEnabled(cbCheck4Updates->isChecked());
    249         }
    250 
    251         settings->beginGroup("Task");
    252         cbSymmetricMode->setChecked(settings->value("SymmetricMode", DEF_SYMMETRIC_MODE).toBool());
    253         spinFractionalAccuracy->setValue(settings->value("FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    254         spinRandMin->setMaximum(MAX_RAND_VALUE);
    255         spinRandMin->setValue(settings->value("RandMin",DEF_RAND_MIN).toInt());
    256         spinRandMax->setMaximum(MAX_RAND_VALUE);
    257         spinRandMax->setValue(settings->value("RandMax",DEF_RAND_MAX).toInt());
    258         cbFractionalRandom->setChecked(settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool());
    259         settings->endGroup();
    260 
    261         settings->beginGroup("Output");
    262         cbShowGraph->setChecked(settings->value("ShowGraph", DEF_SHOW_GRAPH).toBool());
     243    if (cbCheck4Updates != NULL) {
     244        settings->beginGroup("Check4Updates");
     245        cbCheck4Updates->setChecked(settings->value("Enabled", DEF_CHECK_FOR_UPDATES).toBool());
     246        spinUpdateCheckInterval->setValue(settings->value("Interval", DEF_UPDATE_CHECK_INTERVAL).toInt());
     247        settings->endGroup();
     248        spinUpdateCheckInterval->setEnabled(cbCheck4Updates->isChecked());
     249    }
     250
     251    settings->beginGroup("Task");
     252    cbSymmetricMode->setChecked(settings->value("SymmetricMode", DEF_SYMMETRIC_MODE).toBool());
     253    spinFractionalAccuracy->setValue(settings->value("FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
     254    spinRandMin->setMaximum(MAX_RAND_VALUE);
     255    spinRandMin->setValue(settings->value("RandMin",DEF_RAND_MIN).toInt());
     256    spinRandMax->setMaximum(MAX_RAND_VALUE);
     257    spinRandMax->setValue(settings->value("RandMax",DEF_RAND_MAX).toInt());
     258    cbFractionalRandom->setChecked(settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool());
     259    settings->endGroup();
     260
     261    settings->beginGroup("Output");
     262    cbShowGraph->setChecked(settings->value("ShowGraph", DEF_SHOW_GRAPH).toBool());
    263263
    264264#ifndef QT_NO_PRINTER
    265         cbHQGraph->setEnabled(cbShowGraph->isChecked());
    266         cbHQGraph->setChecked(settings->value("HQGraph", DEF_HQ_GRAPH && cbShowGraph->isChecked()).toBool());
     265    cbHQGraph->setEnabled(cbShowGraph->isChecked());
     266    cbHQGraph->setChecked(settings->value("HQGraph", DEF_HQ_GRAPH && cbShowGraph->isChecked()).toBool());
    267267#endif
    268268
    269269#if !defined(NOSVG) && (QT_VERSION >= 0x040500)
    270         comboGraphImageFormat->addItem("svg");
     270    comboGraphImageFormat->addItem("svg");
    271271#endif // NOSVG && QT_VERSION >= 0x040500
    272         // We create whitelist of formats, supported by the most popular web browsers according to
    273         //  http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
    274         //  + TIFF format (there are plugins to support it).
     272    // We create whitelist of formats, supported by the most popular web browsers according to
     273    //  http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
     274    //  + TIFF format (there are plugins to support it).
    275275QStringList whitelist;
    276         whitelist << "bmp" << "jpeg" << "png" << "tiff" << "xbm";
    277         foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
    278                 if (whitelist.contains(format))
    279                         comboGraphImageFormat->addItem(format);
    280         }
    281         comboGraphImageFormat->model()->sort(0);
    282         comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(settings->value("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString(), Qt::MatchFixedString));
    283         if (comboGraphImageFormat->currentIndex() < 0)
    284                 comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(DEF_GRAPH_IMAGE_FORMAT, Qt::MatchFixedString));
    285         labelGraphImageFormat->setEnabled(cbShowGraph->isChecked());
    286         comboGraphImageFormat->setEnabled(cbShowGraph->isChecked());
    287 
    288         cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool());
    289         cbCitiesLimit->setEnabled(cbShowMatrix->isChecked());
    290         cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool());
    291         spinCitiesLimit->setEnabled(cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
    292         spinCitiesLimit->setValue(settings->value("ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt());
    293         spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
    294         cbScrollToEnd->setChecked(settings->value("ScrollToEnd", DEF_SCROLL_TO_END).toBool());
    295 
    296         font = qvariant_cast<QFont>(settings->value("Font", QFont(DEF_FONT_FACE, DEF_FONT_SIZE)));
    297         color = qvariant_cast<QColor>(settings->value("Colors/Text", DEF_TEXT_COLOR));
    298         settings->endGroup();
     276    whitelist << "bmp" << "jpeg" << "png" << "tiff" << "xbm";
     277    foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
     278        if (whitelist.contains(format))
     279            comboGraphImageFormat->addItem(format);
     280    }
     281    comboGraphImageFormat->model()->sort(0);
     282    comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(settings->value("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString(), Qt::MatchFixedString));
     283    if (comboGraphImageFormat->currentIndex() < 0)
     284        comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(DEF_GRAPH_IMAGE_FORMAT, Qt::MatchFixedString));
     285    labelGraphImageFormat->setEnabled(cbShowGraph->isChecked());
     286    comboGraphImageFormat->setEnabled(cbShowGraph->isChecked());
     287
     288    cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool());
     289    cbCitiesLimit->setEnabled(cbShowMatrix->isChecked());
     290    cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool());
     291    spinCitiesLimit->setEnabled(cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
     292    spinCitiesLimit->setValue(settings->value("ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt());
     293    spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
     294    cbScrollToEnd->setChecked(settings->value("ScrollToEnd", DEF_SCROLL_TO_END).toBool());
     295
     296    font = qvariant_cast<QFont>(settings->value("Font", QFont(DEF_FONT_FACE, DEF_FONT_SIZE)));
     297    color = qvariant_cast<QColor>(settings->value("Colors/Text", DEF_TEXT_COLOR));
     298    settings->endGroup();
    299299
    300300#ifdef HANDHELD
    301         setWindowState(Qt::WindowMaximized);
     301    setWindowState(Qt::WindowMaximized);
    302302#else
    303         adjustSize();
     303    adjustSize();
    304304#endif // Q_WS_WINCE_WM
    305305}
     
    311311bool SettingsDialog::colorChanged() const
    312312{
    313         return _newColor;
     313    return _newColor;
    314314}
    315315
     
    320320bool SettingsDialog::fontChanged() const
    321321{
    322         return _newFont;
     322    return _newFont;
    323323}
    324324
     
    331331qint8 SettingsDialog::translucencyChanged() const
    332332{
    333         return _translucency;
     333    return _translucency;
    334334}
    335335
     
    338338void SettingsDialog::accept()
    339339{
    340         if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
    341                 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) {
    342                         _newFont = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
    343                         _newColor = (color != DEF_TEXT_COLOR);
    344                         settings->remove("");
    345                         settings->setValue("SettingsReset", true);
    346                         QDialog::accept();
    347                         QMessageBox::information(this->parentWidget(), tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now."));
    348                         return;
    349                 } else
    350                         return;
    351         }
    352         settings->setValue("Autosize", cbAutosize->isChecked());
    353         settings->setValue("SaveLastUsed", cbSaveLastUsed->isChecked());
    354         settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
     340    if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
     341        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) {
     342            _newFont = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
     343            _newColor = (color != DEF_TEXT_COLOR);
     344            settings->remove("");
     345            settings->setValue("SettingsReset", true);
     346            QDialog::accept();
     347            QMessageBox::information(this->parentWidget(), tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now."));
     348            return;
     349        } else
     350            return;
     351    }
     352    settings->setValue("Autosize", cbAutosize->isChecked());
     353    settings->setValue("SaveLastUsed", cbSaveLastUsed->isChecked());
     354    settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
    355355#ifdef Q_WS_WIN32
    356         if (QtWin::isCompositionEnabled()) {
     356    if (QtWin::isCompositionEnabled()) {
    357357bool old = settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool();
    358                 if ((!old && cbUseTranslucency->isChecked()) || (old && !cbUseTranslucency->isChecked())) {
    359                         _translucency = old ? -1 : 1;
    360                 } else
    361                         _translucency = 0;
    362                 settings->setValue("UseTranslucency", cbUseTranslucency->isChecked());
    363         }
     358        if ((!old && cbUseTranslucency->isChecked()) || (old && !cbUseTranslucency->isChecked())) {
     359            _translucency = old ? -1 : 1;
     360        } else
     361            _translucency = 0;
     362        settings->setValue("UseTranslucency", cbUseTranslucency->isChecked());
     363    }
    364364#endif // Q_WS_WIN32
    365365#ifndef HANDHELD
    366         settings->setValue("SavePos", cbSaveState->isChecked());
     366    settings->setValue("SavePos", cbSaveState->isChecked());
    367367#endif // HANDHELD
    368         if (cbCheck4Updates != NULL) {
    369                 settings->beginGroup("Check4Updates");
    370                 settings->setValue("Enabled", cbCheck4Updates->isChecked());
    371                 if (cbCheck4Updates->isChecked())
    372                         settings->setValue("Interval", spinUpdateCheckInterval->value());
    373                 settings->endGroup();
    374         }
    375 
    376         settings->beginGroup("Task");
    377         settings->setValue("SymmetricMode", cbSymmetricMode->isChecked());
    378         settings->setValue("FractionalAccuracy", spinFractionalAccuracy->value());
    379         settings->setValue("RandMin", spinRandMin->value());
    380         settings->setValue("RandMax", spinRandMax->value());
    381         settings->setValue("FractionalRandom", cbFractionalRandom->isChecked());
    382         settings->endGroup();
    383 
    384         settings->beginGroup("Output");
    385         settings->setValue("ShowGraph", cbShowGraph->isChecked());
     368    if (cbCheck4Updates != NULL) {
     369        settings->beginGroup("Check4Updates");
     370        settings->setValue("Enabled", cbCheck4Updates->isChecked());
     371        if (cbCheck4Updates->isChecked())
     372            settings->setValue("Interval", spinUpdateCheckInterval->value());
     373        settings->endGroup();
     374    }
     375
     376    settings->beginGroup("Task");
     377    settings->setValue("SymmetricMode", cbSymmetricMode->isChecked());
     378    settings->setValue("FractionalAccuracy", spinFractionalAccuracy->value());
     379    settings->setValue("RandMin", spinRandMin->value());
     380    settings->setValue("RandMax", spinRandMax->value());
     381    settings->setValue("FractionalRandom", cbFractionalRandom->isChecked());
     382    settings->endGroup();
     383
     384    settings->beginGroup("Output");
     385    settings->setValue("ShowGraph", cbShowGraph->isChecked());
    386386#ifndef QT_NO_PRINTER
    387         settings->setValue("HQGraph", cbShowGraph->isChecked() && cbHQGraph->isChecked());
     387    settings->setValue("HQGraph", cbShowGraph->isChecked() && cbHQGraph->isChecked());
    388388#endif
    389         if (cbShowGraph->isChecked()) {
    390                 if (comboGraphImageFormat->currentIndex() >= 0)
    391                         settings->setValue("GraphImageFormat", comboGraphImageFormat->currentText());
    392                 else
    393                         settings->setValue("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT);
    394         }
    395         settings->setValue("ShowMatrix", cbShowMatrix->isChecked());
    396         settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
    397         if (cbCitiesLimit->isChecked())
    398                 settings->setValue("ShowMatrixLimit", spinCitiesLimit->value());
    399         settings->setValue("ScrollToEnd", cbScrollToEnd->isChecked());
    400         if (_newFont)
    401                 settings->setValue("Font", font);
    402         if (_newColor)
    403                 settings->setValue("Colors/Text", color);
    404         settings->endGroup();
    405         QDialog::accept();
     389    if (cbShowGraph->isChecked()) {
     390        if (comboGraphImageFormat->currentIndex() >= 0)
     391            settings->setValue("GraphImageFormat", comboGraphImageFormat->currentText());
     392        else
     393            settings->setValue("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT);
     394    }
     395    settings->setValue("ShowMatrix", cbShowMatrix->isChecked());
     396    settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
     397    if (cbCitiesLimit->isChecked())
     398        settings->setValue("ShowMatrixLimit", spinCitiesLimit->value());
     399    settings->setValue("ScrollToEnd", cbScrollToEnd->isChecked());
     400    if (_newFont)
     401        settings->setValue("Font", font);
     402    if (_newColor)
     403        settings->setValue("Colors/Text", color);
     404    settings->endGroup();
     405    QDialog::accept();
    406406}
    407407
     
    409409{
    410410QColor color = QColorDialog::getColor(this->color,this);
    411         if (color.isValid() && (this->color != color)) {
    412                 this->color = color;
    413                 _newColor = true;
    414         }
     411    if (color.isValid() && (this->color != color)) {
     412        this->color = color;
     413        _newColor = true;
     414    }
    415415}
    416416
     
    419419bool ok;
    420420QFont font = QFontDialog::getFont(&ok,this->font,this);
    421         if (ok && (this->font != font)) {
    422                 this->font = font;
    423                 _newFont = true;
    424         }
     421    if (ok && (this->font != font)) {
     422        this->font = font;
     423        _newFont = true;
     424    }
    425425}
    426426
     
    428428void SettingsDialog::desktopResized(int screen)
    429429{
    430         if (screen != 0)
    431                 return;
     430    if (screen != 0)
     431        return;
    432432
    433433QRect availableGeometry = QApplication::desktop()->availableGeometry(0);
    434         if (currentGeometry != availableGeometry) {
    435                 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    436                 /*!
    437                 * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height.
    438                 *  If \c true, the window gets maximized. If we used \c setGeometry() in this case, the bottom of the
    439                 *  window would end up being behind the soft buttons. Is this a bug in Qt or Windows Mobile?
    440                 */
    441                 if ((availableGeometry.top() + availableGeometry.height()) == QApplication::desktop()->screenGeometry().height()) {
    442                         setWindowState(windowState() | Qt::WindowMaximized);
    443                 } else {
    444                         if (windowState() & Qt::WindowMaximized)
    445                                 setWindowState(windowState() ^ Qt::WindowMaximized);
    446                         setGeometry(availableGeometry);
    447                 }
    448                 currentGeometry = availableGeometry;
    449                 QApplication::restoreOverrideCursor();
    450         }
     434    if (currentGeometry != availableGeometry) {
     435        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     436        /*!
     437        * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height.
     438        *  If \c true, the window gets maximized. If we used \c setGeometry() in this case, the bottom of the
     439        *  window would end up being behind the soft buttons. Is this a bug in Qt or Windows Mobile?
     440        */
     441        if ((availableGeometry.top() + availableGeometry.height()) == QApplication::desktop()->screenGeometry().height()) {
     442            setWindowState(windowState() | Qt::WindowMaximized);
     443        } else {
     444            if (windowState() & Qt::WindowMaximized)
     445                setWindowState(windowState() ^ Qt::WindowMaximized);
     446            setGeometry(availableGeometry);
     447        }
     448        currentGeometry = availableGeometry;
     449        QApplication::restoreOverrideCursor();
     450    }
    451451}
    452452
    453453void SettingsDialog::showEvent(QShowEvent *ev)
    454454{
    455         desktopResized(0);
    456 
    457         QWidget::showEvent(ev);
     455    desktopResized(0);
     456
     457    QWidget::showEvent(ev);
    458458}
    459459#endif // Q_WS_WINCE_WM
    460460
    461461void SettingsDialog::spinRandMinValueChanged(int val) {
    462         spinRandMax->setMinimum(val);
     462    spinRandMax->setMinimum(val);
    463463}
    464464
     
    466466bool SettingsDialog::event(QEvent *ev)
    467467{
    468         // Checking for StatusTip event and if tip text is not empty string
    469         // setting it as text of the dialog hint label. Otherwise, setting
    470         // dialog hint label text to own status tip text.
    471         if (ev->type() == QEvent::StatusTip) {
     468    // Checking for StatusTip event and if tip text is not empty string
     469    // setting it as text of the dialog hint label. Otherwise, setting
     470    // dialog hint label text to own status tip text.
     471    if (ev->type() == QEvent::StatusTip) {
    472472QString tip = static_cast<QStatusTipEvent *>(ev)->tip();
    473                 if (tip.length() != 0)
    474                         labelHint->setText(tip);
    475                 else
    476                         labelHint->setText(labelHint->statusTip());
    477                 return true;
    478         } else
    479                 return QDialog::event(ev);
     473        if (tip.length() != 0)
     474            labelHint->setText(tip);
     475        else
     476            labelHint->setText(labelHint->statusTip());
     477        return true;
     478    } else
     479        return QDialog::event(ev);
    480480}
    481481#endif // HANDHELD
Note: See TracChangeset for help on using the changeset viewer.