Changeset 1fbf016a09 in tspsg for src/settingsdialog.cpp


Ignore:
Timestamp:
Dec 18, 2009, 1:57:39 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:
3bcb7e8910
Parents:
140109febb
Message:

+ Added an ability to disable showing of the solution steps' matrices in solution output.

  • Replaced Ok and Cancel buttons in SettingsDialog? with QButtonBox. Now the buttons conform the interface guidelines of the target platform.
  • Increased the allowed maximum number of cities to 50. Solution steps' matrices aren't shown by default if the number of cities in task is more than 15.
  • For WinCE the size of the toolbar buttons is now determined based on the device DPI instead of its resolution.
  • Open and save file dialogs are now using native dialogs where supported.
  • Reworked About dialog a little bit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/settingsdialog.cpp

    r140109febb r1fbf016a09  
    3535        setupUi(this);
    3636        // Laying out elements
     37        layoutCitiesLimit = new QHBoxLayout();
     38        layoutCitiesLimit->setMargin(0);
     39        layoutCitiesLimit->setSpacing(0);
     40        layoutCitiesLimit->addSpacing(10);
     41        layoutCitiesLimit->addWidget(cbCitiesLimit);
     42        layoutCitiesLimit->addWidget(spinCitiesLimit);
     43        layoutCitiesLimit->addStretch();
     44
     45        buttonBox->button(QDialogButtonBox::Save)->setIcon(QIcon(":/images/icons/button_ok.png"));
     46        buttonBox->button(QDialogButtonBox::Save)->setStatusTip(trUtf8("Save new preferences"));
     47        buttonBox->button(QDialogButtonBox::Save)->setCursor(QCursor(Qt::PointingHandCursor));
     48        buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":/images/icons/button_cancel.png"));
     49        buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(trUtf8("Close without saving preferences"));
     50        buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
     51
    3752#ifdef Q_OS_WINCE
    3853        // Layout helper elements
    3954QVBoxLayout *vbox1, *vbox2;
    4055QHBoxLayout *hbox1, *hbox2;
    41 QSpacerItem *spacer;
    4256
    4357        labelRandMin->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
     
    4862        vbox2->addWidget(groupRandomSettings);
    4963        vbox2->addWidget(groupOutputSettings);
    50         spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
    51         vbox2->addItem(spacer);
     64        vbox2->addStretch();
     65        vbox2->addWidget(cbShowMatrix);
     66        vbox2->addLayout(layoutCitiesLimit);
    5267        vbox2->addWidget(cbAutosize);
    5368
     
    6277        hbox2->setSpacing(6);
    6378        hbox2->addWidget(buttonHelp);
    64         spacer = new QSpacerItem(0,0,QSizePolicy::Expanding);
    65         hbox2->addItem(spacer);
    66         hbox2->addWidget(buttonOK);
    67         hbox2->addWidget(buttonCancel);
     79        hbox2->addStretch();
     80        hbox2->addWidget(buttonBox);
    6881
    6982        // Central layout
     
    7891QVBoxLayout *vbox1, *vbox2, *vbox3;
    7992QHBoxLayout *hbox1, *hbox2, *hbox3;
    80 QSpacerItem *spacer;
    8193
    8294        cbSaveState = new QCheckBox(bgWhite);
     
    93105        imgIcon->setFrameShape(QFrame::Panel);
    94106        imgIcon->setLineWidth(0);
    95         imgIcon->setPixmap(QPixmap(QString::fromUtf8(":/images/icons/preferences_system.png")));
     107        imgIcon->setPixmap(QPixmap(":/images/icons/preferences_system.png"));
    96108        imgIcon->setStyleSheet("background-color: #0080C0;");
    97109        imgIcon->setAlignment(Qt::AlignCenter);
     110        imgIcon->setMinimumWidth(150);
    98111
    99112        labelHint = new QLabel(bgGrey);
     
    131144        hbox2->addWidget(groupRandomSettings);
    132145        hbox2->addWidget(groupOutputSettings);
    133         spacer = new QSpacerItem(0,0,QSizePolicy::Expanding);
    134         hbox2->addItem(spacer);
     146        hbox2->addStretch();
    135147
    136148        // Top right part (with white bg)
    137149        vbox2 = new QVBoxLayout(bgWhite);
    138         spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
    139         vbox2->addItem(spacer);
     150        vbox2->addStretch();
    140151        vbox2->addLayout(hbox2);
     152        vbox2->addWidget(cbShowMatrix);
     153        vbox2->addLayout(layoutCitiesLimit);
    141154        vbox2->addWidget(cbAutosize);
    142155        vbox2->addWidget(cbSaveState);
    143         spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
    144         vbox2->addItem(spacer);
     156        vbox2->addStretch();
    145157
    146158        // Bottom part (with grey bg)
     
    150162        hbox3->addWidget(buttonHelp);
    151163        hbox3->addWidget(labelHint);
    152         hbox3->addWidget(buttonOK);
    153         hbox3->addWidget(buttonCancel);
     164        hbox3->addWidget(buttonBox);
    154165
    155166        // Central layout
     
    161172        vbox1->addWidget(bgGrey);
    162173#endif // Q_OS_WINCE
    163         connect(buttonOK,SIGNAL(clicked()),this,SLOT(accept()));
    164         connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
    165174        connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int)));
    166175        connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked()));
     
    169178        setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
    170179#ifndef Q_OS_WINCE
    171         // Setting initial text of dialog hint label to own status tip
    172         // text.
     180        // Setting initial text of dialog hint label to own status tip text.
    173181        labelHint->setText(labelHint->statusTip());
    174182#endif // Q_OS_WINCE
     
    182190        cbSaveState->setChecked(settings->value("SavePos",false).toBool());
    183191#endif // Q_OS_WINCE
     192
    184193        settings->beginGroup("Output");
     194        cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool());
     195        cbCitiesLimit->setEnabled(cbShowMatrix->isChecked());
     196        cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool());
     197        spinCitiesLimit->setEnabled(cbShowMatrix->isChecked());
     198        spinCitiesLimit->setValue(settings->value("ShowMatrixCitiesLimit", DEF_SHOW_MATRIX_CITY_LIMIT).toInt());
     199        spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
     200
    185201        font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>();
    186202        color = settings->value("Color",DEF_FONT_COLOR).value<QColor>();
    187203        settings->endGroup();
     204
     205        adjustSize();
    188206}
    189207
     
    211229{
    212230#ifndef Q_OS_WINCE
    213         settings->setValue("SavePos",cbSaveState->isChecked());
    214 #endif // Q_OS_WINCE
    215         settings->setValue("Autosize",cbAutosize->isChecked());
    216         settings->setValue("MinCost",spinRandMin->value());
    217         settings->setValue("MaxCost",spinRandMax->value());
     231        settings->setValue("SavePos", cbSaveState->isChecked());
     232#endif // Q_OS_WINCE
     233        settings->setValue("Autosize", cbAutosize->isChecked());
     234        settings->setValue("MinCost", spinRandMin->value());
     235        settings->setValue("MaxCost", spinRandMax->value());
     236
    218237        settings->beginGroup("Output");
     238        settings->setValue("ShowMatrix", cbShowMatrix->isChecked());
     239        settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
     240        if (cbCitiesLimit->isChecked())
     241                settings->setValue("ShowMatrixCitiesLimit", spinCitiesLimit->value());
    219242        if (newFont)
    220                 settings->setValue("Font",font);
     243                settings->setValue("Font", font);
    221244        if (newColor)
    222                 settings->setValue("Color",color);
     245                settings->setValue("Color", color);
    223246        settings->endGroup();
    224247        QDialog::accept();
     
    261284                        labelHint->setText(labelHint->statusTip());
    262285                return true;
    263         // Making imgIcon square.
    264         } else if (ev->type() == QEvent::Show) {
    265 bool result = QDialog::event(ev);
    266                 if (result)
    267                         imgIcon->setMinimumWidth(imgIcon->height());
    268                 return result;
    269286        } else
    270287                return QDialog::event(ev);
Note: See TracChangeset for help on using the changeset viewer.