1 | /* |
---|
2 | * TSPSG - TSP Solver and Generator |
---|
3 | * Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name> |
---|
4 | * |
---|
5 | * $Id: settingsdialog.cpp 17 2009-06-15 15:10:25Z laleppa $ |
---|
6 | * $URL: https://tspsg.svn.sourceforge.net/svnroot/tspsg/trunk/src/settingsdialog.cpp $ |
---|
7 | * |
---|
8 | * This file is part of TSPSG. |
---|
9 | * |
---|
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. |
---|
14 | * |
---|
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. |
---|
19 | * |
---|
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/>. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <QMessageBox> |
---|
25 | #include <QStatusTipEvent> |
---|
26 | #include <QFontDialog> |
---|
27 | #include "settingsdialog.h" |
---|
28 | |
---|
29 | SettingsDialog::SettingsDialog(QWidget *parent) |
---|
30 | : QDialog(parent) |
---|
31 | { |
---|
32 | setupUi(this); |
---|
33 | connect(buttonOK,SIGNAL(clicked()),this,SLOT(accept())); |
---|
34 | connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject())); |
---|
35 | connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int))); |
---|
36 | connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked())); |
---|
37 | // setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); |
---|
38 | setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); |
---|
39 | layout()->setSizeConstraint(layout()->SetFixedSize); |
---|
40 | #ifndef Q_OS_WINCE |
---|
41 | // Setting initial text of dialog hint label to own status tip |
---|
42 | // text. |
---|
43 | labelHint->setText(labelHint->statusTip()); |
---|
44 | // HACK: Do not resize label hint (and dialog) when text changes |
---|
45 | // from one-line to two-line and vice versa. Any better solution? |
---|
46 | labelHint->setMaximumHeight(labelHint->height()); |
---|
47 | labelHint->setMinimumHeight(labelHint->height()); |
---|
48 | #endif // Q_OS_WINCE |
---|
49 | } |
---|
50 | |
---|
51 | #ifndef Q_OS_WINCE |
---|
52 | bool SettingsDialog::event(QEvent *ev) |
---|
53 | { |
---|
54 | // Checking for StatusTip event and if tip text is not empty string |
---|
55 | // setting it as text of the dialog hint label. Otherwise, setting |
---|
56 | // dialog hint label text to own status tip text. |
---|
57 | if (ev->type() == QEvent::StatusTip) { |
---|
58 | QString tip = static_cast<QStatusTipEvent *>(ev)->tip(); |
---|
59 | if (tip.length() != 0) |
---|
60 | labelHint->setText(tip); |
---|
61 | else |
---|
62 | labelHint->setText(labelHint->statusTip()); |
---|
63 | return true; |
---|
64 | } else |
---|
65 | return QDialog::event(ev); |
---|
66 | } |
---|
67 | #endif // Q_OS_WINCE |
---|
68 | |
---|
69 | void SettingsDialog::buttonFontClicked() |
---|
70 | { |
---|
71 | // TODO: Pass current font to dialog and save selected. |
---|
72 | QFontDialog fd; |
---|
73 | fd.exec(); |
---|
74 | } |
---|