source: tspsg/src/settingsdialog.cpp @ aaf2113307

0.1.3.145-beta1-symbian0.1.4.170-beta2-bb10appveyorimgbotreadme
Last change on this file since aaf2113307 was 430bd7f7e9, checked in by Oleksii Serdiuk, 15 years ago

+ 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.

  • Property mode set to 100644
File size: 3.7 KB
RevLine 
[5515c2c2a7]1/*
[430bd7f7e9]2 *  TSPSG: TSP Solver and Generator
[5354a01311]3 *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
[5515c2c2a7]4 *
[bb994a7ff8]5 *  $Id$
6 *  $URL$
[f99964aa0b]7 *
[bb994a7ff8]8 *  This file is part of TSPSG.
[5515c2c2a7]9 *
[bb994a7ff8]10 *  TSPSG is free software: you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License as published by
12 *  the Free Software Foundation, either version 3 of the License, or
13 *  (at your option) any later version.
[5515c2c2a7]14 *
[bb994a7ff8]15 *  TSPSG is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU General Public License for more details.
[5515c2c2a7]19 *
[bb994a7ff8]20 *  You should have received a copy of the GNU General Public License
21 *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
[5515c2c2a7]22 */
23
[7836f136eb]24#include "settingsdialog.h"
[5515c2c2a7]25
26SettingsDialog::SettingsDialog(QWidget *parent)
[430bd7f7e9]27        : QDialog(parent), newFont(false), newColor(false)
[5515c2c2a7]28{
29        setupUi(this);
30        connect(buttonOK,SIGNAL(clicked()),this,SLOT(accept()));
31        connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
32        connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int)));
[5354a01311]33        connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked()));
[aecdf994f9]34        connect(buttonColor,SIGNAL(clicked()),this,SLOT(buttonColorClicked()));
[5515c2c2a7]35//      setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
36        setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
[5354a01311]37#ifndef Q_OS_WINCE
[95eca626aa]38        // Setting initial text of dialog hint label to own status tip
39        // text.
[7836f136eb]40        labelHint->setText(labelHint->statusTip());
[5354a01311]41#endif // Q_OS_WINCE
[665d32434f]42        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
[aecdf994f9]43        spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
44        spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
45#ifndef Q_OS_WINCE
46        cbSaveState->setChecked(settings->value("SavePos",false).toBool());
47#endif // Q_OS_WINCE
[430bd7f7e9]48        settings->beginGroup("Output");
[aecdf994f9]49        font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>();
50        color = settings->value("Color",DEF_FONT_COLOR).value<QColor>();
51        settings->endGroup();
[7836f136eb]52}
53
[430bd7f7e9]54void SettingsDialog::accept()
[7836f136eb]55{
[430bd7f7e9]56#ifndef Q_OS_WINCE
57        settings->setValue("SavePos",cbSaveState->isChecked());
[5354a01311]58#endif // Q_OS_WINCE
[430bd7f7e9]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);
66        settings->endGroup();
67        QDialog::accept();
68}
[5515c2c2a7]69
[5354a01311]70void SettingsDialog::buttonFontClicked()
71{
[aecdf994f9]72bool ok;
73QFont font = QFontDialog::getFont(&ok,this->font,this);
[430bd7f7e9]74        if (ok && (this->font != font)) {
[aecdf994f9]75                this->font = font;
[430bd7f7e9]76                newFont = true;
77        }
[aecdf994f9]78}
79
80void SettingsDialog::buttonColorClicked()
81{
[e7f7d3854d]82QColor color = QColorDialog::getColor(this->color,this);
[430bd7f7e9]83        if (color.isValid() && (this->color != color)) {
[e7f7d3854d]84                this->color = color;
[430bd7f7e9]85                newColor = true;
86        }
[aecdf994f9]87}
88
[430bd7f7e9]89bool SettingsDialog::colorChanged() const
[aecdf994f9]90{
[430bd7f7e9]91        return newColor;
92}
93
94bool SettingsDialog::fontChanged() const
95{
96        return newFont;
97}
98
[aecdf994f9]99#ifndef Q_OS_WINCE
[430bd7f7e9]100bool SettingsDialog::event(QEvent *ev)
101{
102        // Checking for StatusTip event and if tip text is not empty string
103        // setting it as text of the dialog hint label. Otherwise, setting
104        // dialog hint label text to own status tip text.
105        if (ev->type() == QEvent::StatusTip) {
106QString tip = static_cast<QStatusTipEvent *>(ev)->tip();
107                if (tip.length() != 0)
108                        labelHint->setText(tip);
109                else
110                        labelHint->setText(labelHint->statusTip());
111                return true;
112        } else
113                return QDialog::event(ev);
[5354a01311]114}
[430bd7f7e9]115#endif // Q_OS_WINCE
Note: See TracBrowser for help on using the repository browser.