[5515c2c2a7] | 1 | /* |
---|
[bb994a7ff8] | 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 | |
---|
| 24 | #include <QMessageBox> |
---|
[7836f136eb] | 25 | #include <QStatusTipEvent> |
---|
[5354a01311] | 26 | #include <QFontDialog> |
---|
[7836f136eb] | 27 | #include "settingsdialog.h" |
---|
[5515c2c2a7] | 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))); |
---|
[5354a01311] | 36 | connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked())); |
---|
[5515c2c2a7] | 37 | // setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); |
---|
| 38 | setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); |
---|
| 39 | layout()->setSizeConstraint(layout()->SetFixedSize); |
---|
[5354a01311] | 40 | #ifndef Q_OS_WINCE |
---|
[95eca626aa] | 41 | // Setting initial text of dialog hint label to own status tip |
---|
| 42 | // text. |
---|
[7836f136eb] | 43 | labelHint->setText(labelHint->statusTip()); |
---|
[95eca626aa] | 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()); |
---|
[5354a01311] | 48 | #endif // Q_OS_WINCE |
---|
[7836f136eb] | 49 | } |
---|
| 50 | |
---|
[5354a01311] | 51 | #ifndef Q_OS_WINCE |
---|
[7836f136eb] | 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 |
---|
[95eca626aa] | 56 | // dialog hint label text to own status tip text. |
---|
[7836f136eb] | 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); |
---|
[5515c2c2a7] | 66 | } |
---|
[5354a01311] | 67 | #endif // Q_OS_WINCE |
---|
[5515c2c2a7] | 68 | |
---|
[5354a01311] | 69 | void SettingsDialog::buttonFontClicked() |
---|
| 70 | { |
---|
| 71 | // TODO: Pass current font to dialog and save selected. |
---|
| 72 | QFontDialog fd; |
---|
| 73 | fd.exec(); |
---|
| 74 | } |
---|