Changeset aecdf994f9 in tspsg for src/settingsdialog.cpp


Ignore:
Timestamp:
Jun 22, 2009, 1:37:12 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:
d5384ee64e
Parents:
799ba1e3f2
Message:

+ Settings are now saved and restored.
+ Font color selection in settings.
+ Primitive about dialog.
+ Automatic resizing of cells to its contents in wince.

  • No "Save window position" checkbox in wince.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/settingsdialog.cpp

    r799ba1e3f2 raecdf994f9  
    2525#include <QStatusTipEvent>
    2626#include <QFontDialog>
     27#include <QColorDialog>
     28#include "defines.h"
    2729#include "settingsdialog.h"
    2830
     
    3537        connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int)));
    3638        connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked()));
     39        connect(buttonColor,SIGNAL(clicked()),this,SLOT(buttonColorClicked()));
    3740//      setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
    3841        setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
     
    4750        labelHint->setMinimumHeight(labelHint->height());
    4851#endif // Q_OS_WINCE
     52        settings = new QSettings(INI_FILE,QSettings::IniFormat);
     53        spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
     54        spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
     55#ifndef Q_OS_WINCE
     56        cbSaveState->setChecked(settings->value("SavePos",false).toBool());
     57#endif // Q_OS_WINCE
     58        settings->beginGroup("Print");
     59        font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>();
     60        color = settings->value("Color",DEF_FONT_COLOR).value<QColor>();
     61#ifndef Q_OS_WINCE
     62        spinLeftMargin->setValue(settings->value("Offset",DEF_OFFSET).toInt());
     63#endif // Q_OS_WINCE
     64        settings->endGroup();
    4965}
    5066
     
    6985void SettingsDialog::buttonFontClicked()
    7086{
    71         // TODO: Pass current font to dialog and save selected.
    72 QFontDialog fd;
    73         fd.exec();
     87bool ok;
     88QFont font = QFontDialog::getFont(&ok,this->font,this);
     89        if (ok)
     90                this->font = font;
    7491}
     92
     93void SettingsDialog::buttonColorClicked()
     94{
     95QColorDialog cd(color,this);
     96        if (cd.exec() == QDialog::Accepted)
     97                color = cd.selectedColor();
     98}
     99
     100void SettingsDialog::accept()
     101{
     102#ifndef Q_OS_WINCE
     103        settings->setValue("SavePos",cbSaveState->isChecked());
     104#endif // Q_OS_WINCE
     105        settings->setValue("MinCost",spinRandMin->value());
     106        settings->setValue("MaxCost",spinRandMax->value());
     107        settings->beginGroup("Print");
     108        settings->setValue("Font",font);
     109        settings->setValue("Color",color);
     110#ifndef Q_OS_WINCE
     111        settings->setValue("Offset",spinLeftMargin->value());
     112#endif // Q_OS_WINCE
     113        settings->endGroup();
     114        QDialog::accept();
     115}
Note: See TracChangeset for help on using the changeset viewer.