Changeset 430bd7f7e9 in tspsg for src/settingsdialog.cpp


Ignore:
Timestamp:
Jul 31, 2009, 8:23:07 PM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
ec54b4490b
Parents:
b5c9bcb585
Message:

+ Finished solving algorithm (needs thorough testing).
+ Solution can be saved to HTML or OpenDocument? format.
+ Added VERSIONINFO resource for windows builds.

  • Updated translations to have unified terminology everywhere.

NB: This will be the first public alpha build.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/settingsdialog.cpp

    rb5c9bcb585 r430bd7f7e9  
    11/*
    2  *  TSPSG - TSP Solver and Generator
     2 *  TSPSG: TSP Solver and Generator
    33 *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
    44 *
     
    2525
    2626SettingsDialog::SettingsDialog(QWidget *parent)
    27         : QDialog(parent)
     27        : QDialog(parent), newFont(false), newColor(false)
    2828{
    2929        setupUi(this);
     
    3535//      setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
    3636        setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
    37         layout()->setSizeConstraint(layout()->SetFixedSize);
    3837#ifndef Q_OS_WINCE
    3938        // Setting initial text of dialog hint label to own status tip
    4039        // text.
    4140        labelHint->setText(labelHint->statusTip());
    42         // HACK: Do not resize label hint (and dialog) when text changes
    43         // from one-line to two-line and vice versa. Any better solution?
    44         labelHint->setMaximumHeight(labelHint->height());
    45         labelHint->setMinimumHeight(labelHint->height());
    4641#endif // Q_OS_WINCE
    4742        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
     
    5146        cbSaveState->setChecked(settings->value("SavePos",false).toBool());
    5247#endif // Q_OS_WINCE
    53         settings->beginGroup("Print");
     48        settings->beginGroup("Output");
    5449        font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>();
    5550        color = settings->value("Color",DEF_FONT_COLOR).value<QColor>();
     51        settings->endGroup();
     52}
     53
     54void SettingsDialog::accept()
     55{
    5656#ifndef Q_OS_WINCE
    57         spinLeftMargin->setValue(settings->value("Offset",DEF_OFFSET).toInt());
     57        settings->setValue("SavePos",cbSaveState->isChecked());
    5858#endif // Q_OS_WINCE
     59        settings->setValue("MinCost",spinRandMin->value());
     60        settings->setValue("MaxCost",spinRandMax->value());
     61        settings->beginGroup("Output");
     62        if (newFont)
     63                settings->setValue("Font",font);
     64        if (newColor)
     65                settings->setValue("Color",color);
    5966        settings->endGroup();
     67        QDialog::accept();
     68}
     69
     70void SettingsDialog::buttonFontClicked()
     71{
     72bool ok;
     73QFont font = QFontDialog::getFont(&ok,this->font,this);
     74        if (ok && (this->font != font)) {
     75                this->font = font;
     76                newFont = true;
     77        }
     78}
     79
     80void SettingsDialog::buttonColorClicked()
     81{
     82QColor color = QColorDialog::getColor(this->color,this);
     83        if (color.isValid() && (this->color != color)) {
     84                this->color = color;
     85                newColor = true;
     86        }
     87}
     88
     89bool SettingsDialog::colorChanged() const
     90{
     91        return newColor;
     92}
     93
     94bool SettingsDialog::fontChanged() const
     95{
     96        return newFont;
    6097}
    6198
     
    77114}
    78115#endif // Q_OS_WINCE
    79 
    80 void SettingsDialog::buttonFontClicked()
    81 {
    82 bool ok;
    83 QFont font = QFontDialog::getFont(&ok,this->font,this);
    84         if (ok)
    85                 this->font = font;
    86 }
    87 
    88 void SettingsDialog::buttonColorClicked()
    89 {
    90 QColor color = QColorDialog::getColor(this->color,this);
    91         if (color.isValid())
    92                 this->color = color;
    93 }
    94 
    95 void SettingsDialog::accept()
    96 {
    97 #ifndef Q_OS_WINCE
    98         settings->setValue("SavePos",cbSaveState->isChecked());
    99 #endif // Q_OS_WINCE
    100         settings->setValue("MinCost",spinRandMin->value());
    101         settings->setValue("MaxCost",spinRandMax->value());
    102         settings->beginGroup("Print");
    103         settings->setValue("Font",font);
    104         settings->setValue("Color",color);
    105 #ifndef Q_OS_WINCE
    106         settings->setValue("Offset",spinLeftMargin->value());
    107 #endif // Q_OS_WINCE
    108         settings->endGroup();
    109         QDialog::accept();
    110 }
Note: See TracChangeset for help on using the changeset viewer.