source: tspsg/src/settingsdialog.cpp @ 95c1897bf1

appveyorimgbotreadme
Last change on this file since 95c1897bf1 was a09f31733a, checked in by Oleksii Serdiuk, 12 years ago

Added all configurable colors to Settings Dialog.

Only display ATM. Editing and saving will follow soon...

  • Property mode set to 100644
File size: 20.8 KB
Line 
1/*
2 *  TSPSG: TSP Solver and Generator
3 *  Copyright (C) 2007-2012 Oleksii Serdiuk <contacts[at]oleksii[dot]name>
4 *
5 *  $Id: $Format:%h %ai %an$ $
6 *  $URL: http://tspsg.info/ $
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 "settingsdialog.h"
25
26/*!
27 * \brief Class constructor.
28 * \param parent Settings Dialog parent widget.
29 *
30 * Initializes Settings Dialog and creates its layout based on target OS.
31 */
32SettingsDialog::SettingsDialog(QWidget *parent)
33    : QDialog(parent), _fontChanged(false), _colorChanged(false), _translucency(0)
34{
35    setupUi(this);
36
37    setWindowIcon(GET_ICON("preferences-system"));
38
39    buttonBox->button(QDialogButtonBox::Ok)->setIcon(GET_ICON("dialog-ok"));
40#ifndef QT_NO_STATUSTIP
41    buttonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Save new preferences"));
42#endif
43    buttonBox->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
44    buttonBox->button(QDialogButtonBox::Cancel)->setIcon(GET_ICON("dialog-cancel"));
45#ifndef QT_NO_STATUSTIP
46    buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Close without saving preferences"));
47#endif
48    buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
49
50    buttonTextColor->setIcon(GET_ICON("format-text-color"));
51    buttonSelectedColor->setIcon(GET_ICON("format-text-color"));
52    buttonAlternateColor->setIcon(GET_ICON("format-text-color"));
53    buttonBorderColor->setIcon(GET_ICON("format-stroke-color"));
54    buttonBgColor->setIcon(GET_ICON("format-fill-color"));
55    buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
56    buttonHelp->setIcon(GET_ICON("help-hint"));
57
58QPalette p = bgWhite->palette();
59    p.setColor(QPalette::Window, p.color(QPalette::Base));
60    bgWhite->setPalette(p);
61
62    p = lineHorizontal->palette();
63    p.setColor(QPalette::Window, p.color(QPalette::Text));
64    lineHorizontal->setPalette(p);
65
66// Layout helpers
67QBoxLayout *box;
68QHBoxLayout *hbox;
69#ifndef QT_NO_PRINTER
70    cbHQGraph = new QCheckBox(bgWhite);
71    cbHQGraph->setObjectName("cbHQGraph");
72#ifndef QT_NO_STATUSTIP
73    cbHQGraph->setStatusTip(tr("Higher quality graph looks much better when printing but uglier on the screen"));
74#endif // QT_NO_STATUSTIP
75    cbHQGraph->setText(tr("Draw solution graph in higher quality"));
76    cbHQGraph->setCursor(QCursor(Qt::PointingHandCursor));
77
78    box = static_cast<QBoxLayout *>(tabOutputGeneral->layout());
79    hbox = new QHBoxLayout();
80    hbox->addSpacing(10);
81    hbox->addWidget(cbHQGraph);
82    box->insertLayout(box->indexOf(cbGenerateGraph) + 2, hbox);
83    connect(cbGenerateGraph, SIGNAL(toggled(bool)), cbHQGraph, SLOT(setEnabled(bool)));
84#endif
85
86    if (hasUpdater()) {
87        cbCheck4Updates = new QCheckBox(bgWhite);
88        cbCheck4Updates->setObjectName("cbCheck4Updates");
89#ifndef QT_NO_STATUSTIP
90        cbCheck4Updates->setStatusTip(tr("Automatically check for updates at the given interval"));
91#endif // QT_NO_STATUSTIP
92        cbCheck4Updates->setText(tr("Check for updates every"));
93        cbCheck4Updates->setCursor(QCursor(Qt::PointingHandCursor));
94
95        spinUpdateCheckInterval = new QSpinBox(bgWhite);
96        spinUpdateCheckInterval->setObjectName("spinUpdateCheckInterval");
97#ifndef QT_NO_STATUSTIP
98        spinUpdateCheckInterval->setStatusTip(tr("Minimal interval at which to check for updates"));
99#endif // QT_NO_STATUSTIP
100        spinUpdateCheckInterval->setSuffix(tr(" days", "Don't forget a space at the beginning!"));
101        spinUpdateCheckInterval->setRange(1, 365);
102        spinUpdateCheckInterval->setCursor(QCursor(Qt::PointingHandCursor));
103
104        connect(cbCheck4Updates, SIGNAL(toggled(bool)), spinUpdateCheckInterval, SLOT(setEnabled(bool)));
105
106        box = static_cast<QBoxLayout *>(tabGeneral->layout());
107        hbox = new QHBoxLayout();
108        hbox->setSpacing(0);
109        hbox->addWidget(cbCheck4Updates);
110        hbox->addWidget(spinUpdateCheckInterval);
111        hbox->addStretch();
112        box->insertLayout(box->indexOf(cbUseNativeDialogs) + 1, hbox);
113    } else
114        cbCheck4Updates = NULL;
115
116#ifdef HANDHELD
117QVBoxLayout *vbox1; // Layout helper
118
119    // On screens with small height when SIP is shown and the window is resized
120    // there is not enought space for all elements.
121    // So we show the scrollbars to be able to access them.
122QScrollArea *scrollArea = new QScrollArea(this);
123    scrollArea->setFrameShape(QFrame::NoFrame);
124    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
125    scrollArea->setWidgetResizable(true);
126    scrollArea->setWidget(bgWhite);
127
128    bgWhite->layout()->setMargin(0);
129
130    // Central layout
131    vbox1 = new QVBoxLayout(this);
132    vbox1->setMargin(0);
133    vbox1->setSpacing(0);
134    vbox1->addWidget(scrollArea);
135    vbox1->addWidget(bgGrey);
136    setLayout(vbox1);
137#else // HANDHELD
138QVBoxLayout *vbox; // Layout helper
139
140#ifndef HANDHELD
141    if (QtWin::isCompositionEnabled()) {
142        cbUseTranslucency = new QCheckBox(bgWhite);
143        cbUseTranslucency->setObjectName("cbUseTranslucency");
144#ifndef QT_NO_STATUSTIP
145        cbUseTranslucency->setStatusTip(tr("Make Main Window background translucent"));
146#endif // QT_NO_STATUSTIP
147        cbUseTranslucency->setText(tr("Use translucency effects"));
148        cbUseTranslucency->setCursor(QCursor(Qt::PointingHandCursor));
149    }
150#endif // HANDHELD
151
152    cbSaveState = new QCheckBox(bgWhite);
153    cbSaveState->setObjectName("cbSaveState");
154#ifndef QT_NO_STATUSTIP
155    cbSaveState->setStatusTip(tr("Restore main window state and position on application restart"));
156#endif // QT_NO_STATUSTIP
157    cbSaveState->setText(tr("Save main window state and position"));
158    cbSaveState->setCursor(QCursor(Qt::PointingHandCursor));
159
160    imgIcon = new QLabel(this);
161    imgIcon->setObjectName("imgIcon");
162    imgIcon->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
163    imgIcon->setFrameShape(QFrame::NoFrame);
164    imgIcon->setPixmap(GET_ICON("preferences-system").pixmap(128, 128));
165    imgIcon->setStyleSheet("background-color: #0080C0; padding-top: 11px;");
166    imgIcon->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
167    imgIcon->setMinimumWidth(150);
168
169    labelHint = new QLabel(bgGrey);
170    labelHint->setObjectName("labelHint");
171    labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
172    labelHint->setMinimumSize(QSize(250, 28));
173    labelHint->setMaximumSize(QSize(QWIDGETSIZE_MAX, 28));
174    labelHint->setTextFormat(Qt::PlainText);
175//      labelHint->setAlignment(Qt::AlignLeft | Qt::AlignTop);
176    labelHint->setWordWrap(true);
177#ifndef QT_NO_STATUSTIP
178    labelHint->setStatusTip(tr("Hover mouse pointer over dialog elements to get additional help"));
179#endif // QT_NO_STATUSTIP
180
181    lineVertical = new QFrame(this);
182    lineVertical->setObjectName("lineVertical");
183    lineVertical->setFrameShadow(QFrame::Plain);
184    lineVertical->setFrameShape(QFrame::VLine);
185    lineVertical->setLineWidth(2);
186
187    // Top line
188    hbox = new QHBoxLayout();
189    hbox->addWidget(imgIcon);
190    hbox->addWidget(lineVertical);
191    hbox->addWidget(bgWhite);
192
193    box = static_cast<QBoxLayout *>(tabGeneral->layout());
194    box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbSaveState);
195#ifndef HANDHELD
196    if (QtWin::isCompositionEnabled())
197        box->insertWidget(box->indexOf(cbUseNativeDialogs) + 1, cbUseTranslucency);
198#endif // HANDHELD
199
200    // Inserting label for hints to the bottom part (with grey bg)
201    buttons->insertWidget(buttons->indexOf(buttonHelp) + 1, labelHint, 1);
202
203    // Central layout
204    vbox = new QVBoxLayout(this);
205    vbox->setMargin(0);
206    vbox->setSpacing(0);
207    vbox->addLayout(hbox);
208    vbox->addWidget(bgGrey);
209    setLayout(vbox);
210#endif // HANDHELD
211
212#ifdef Q_WS_WINCE_WM
213    // We need to react to SIP show/hide and resize the window appropriately
214    connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(desktopResized(int)));
215#endif // Q_WS_WINCE_WM
216    connect(spinRandMin, SIGNAL(valueChanged(int)), SLOT(spinRandMinValueChanged(int)));
217    connect(buttonFont, SIGNAL(clicked()), SLOT(buttonFontClicked()));
218    connect(buttonTextColor, SIGNAL(clicked()), SLOT(buttonTextColorClicked()));
219    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
220#if !defined(QT_NO_STATUSTIP) && !defined(HANDHELD)
221    // Setting initial text of dialog hint label to own status tip text.
222    labelHint->setText(labelHint->statusTip());
223#endif // HANDHELD
224
225    settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
226    settings->remove("SettingsReset");
227
228    cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool());
229    cbSaveLastUsed->setChecked(settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool());
230    cbUseNativeDialogs->setChecked(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool());
231#ifndef HANDHELD
232    if (QtWin::isCompositionEnabled())
233        cbUseTranslucency->setChecked(settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool());
234#endif // HANDHELD
235#ifndef HANDHELD
236    cbSaveState->setChecked(settings->value("SavePos", DEF_SAVEPOS).toBool());
237#endif // HANDHELD
238    if (cbCheck4Updates != NULL) {
239        settings->beginGroup("Check4Updates");
240        cbCheck4Updates->setChecked(settings->value("Enabled", DEF_CHECK_FOR_UPDATES).toBool());
241        spinUpdateCheckInterval->setValue(settings->value("Interval", DEF_UPDATE_CHECK_INTERVAL).toInt());
242        settings->endGroup();
243        spinUpdateCheckInterval->setEnabled(cbCheck4Updates->isChecked());
244    }
245
246    settings->beginGroup("Task");
247    cbSymmetricMode->setChecked(settings->value("SymmetricMode", DEF_SYMMETRIC_MODE).toBool());
248    spinFractionalAccuracy->setValue(settings->value("FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
249    spinRandMin->setMaximum(MAX_RAND_VALUE);
250    spinRandMin->setValue(settings->value("RandMin",DEF_RAND_MIN).toInt());
251    spinRandMax->setMaximum(MAX_RAND_VALUE);
252    spinRandMax->setValue(settings->value("RandMax",DEF_RAND_MAX).toInt());
253    cbFractionalRandom->setChecked(settings->value("FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool());
254    settings->endGroup();
255
256    settings->beginGroup("Output");
257    cbGenerateGraph->setChecked(settings->value("GenerateGraph", DEF_GENERATE_GRAPH).toBool());
258
259#ifndef QT_NO_PRINTER
260    cbHQGraph->setEnabled(cbGenerateGraph->isChecked());
261    cbHQGraph->setChecked(settings->value("HQGraph", DEF_HQ_GRAPH).toBool());
262#endif
263
264#if !defined(NOSVG) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
265    comboGraphImageFormat->addItem("svg");
266#endif
267    // We create whitelist of formats, supported by the most popular web browsers according to
268    //  http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
269    //  + TIFF format (there are plugins to support it).
270QStringList whitelist;
271    whitelist << "bmp" << "jpeg" << "png" << "tiff" << "xbm";
272    foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
273        if (whitelist.contains(format))
274            comboGraphImageFormat->addItem(format);
275    }
276    comboGraphImageFormat->model()->sort(0);
277    comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(settings->value("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString(), Qt::MatchFixedString));
278    if (comboGraphImageFormat->currentIndex() < 0)
279        comboGraphImageFormat->setCurrentIndex(comboGraphImageFormat->findText(DEF_GRAPH_IMAGE_FORMAT, Qt::MatchFixedString));
280    labelGraphImageFormat->setEnabled(cbGenerateGraph->isChecked());
281    comboGraphImageFormat->setEnabled(cbGenerateGraph->isChecked());
282    cbEmbedGraphIntoHTML->setChecked(settings->value("EmbedGraphIntoHTML", DEF_EMBED_GRAPH_INTO_HTML).toBool());
283    cbEmbedGraphIntoHTML->setEnabled(cbGenerateGraph->isChecked());
284
285    cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool());
286    cbCitiesLimit->setEnabled(cbShowMatrix->isChecked());
287    cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool());
288    spinCitiesLimit->setEnabled(cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
289    spinCitiesLimit->setValue(settings->value("ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt());
290    spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
291    cbScrollToEnd->setChecked(settings->value("ScrollToEnd", DEF_SCROLL_TO_END).toBool());
292
293    font = qvariant_cast<QFont>(settings->value("Font", QFont(DEF_FONT_FACE, DEF_FONT_SIZE)));
294    textColor = QColor(settings->value("Colors/Text", DEF_TEXT_COLOR).toString());
295    selColor = QColor(settings->value("Colors/Selected", DEF_SELECTED_COLOR).toString());
296    altColor = QColor(settings->value("Colors/Alternate", DEF_ALTERNATE_COLOR).toString());
297    borderColor = QColor(settings->value("Colors/Border", DEF_TABLE_COLOR).toString());
298    bgColor = QColor(settings->value("Colors/Background", DEF_BACKGROUND_COLOR).toString());
299    settings->endGroup();
300
301    QFont f = font;
302    f.setPointSize(labelFontExample->font().pointSize());
303    labelFontExample->setFont(f);
304    labelFontExample->setText(font.family());
305
306    p = boxTextColor->palette();
307    p.setColor(QPalette::Window, textColor);
308    boxTextColor->setPalette(p);
309
310    p = boxSelectedColor->palette();
311    p.setColor(QPalette::Window, selColor);
312    boxSelectedColor->setPalette(p);
313
314    p = boxAlternateColor->palette();
315    p.setColor(QPalette::Window, altColor);
316    boxAlternateColor->setPalette(p);
317
318    p = boxBorderColor->palette();
319    p.setColor(QPalette::Window, borderColor);
320    boxBorderColor->setPalette(p);
321
322    p = boxBgColor->palette();
323    p.setColor(QPalette::Window, bgColor);
324    boxBgColor->setPalette(p);
325
326#ifdef HANDHELD
327    setWindowState(Qt::WindowMaximized);
328#else
329    adjustSize();
330#endif // Q_WS_WINCE_WM
331}
332
333/*!
334 * \brief Indicates whether or not the font color has been changed.
335 * \return \c true if font color changed, otherwise \c false.
336 */
337bool SettingsDialog::colorChanged() const
338{
339    return _colorChanged;
340}
341
342/*!
343 * \brief Indicates whether or not the font properties have been changed.
344 * \return \c true if font properties changed, otherwise \c false.
345 */
346bool SettingsDialog::fontChanged() const
347{
348    return _fontChanged;
349}
350
351/*!
352 * \brief Indicates whether and how the translucency setting was changed
353 * \retval -1 the translucency was \em disabled.
354 * \retval  0 the translucency <em>didn't change</em>.
355 * \retval  1 the translucency was \em enabled.
356 */
357qint8 SettingsDialog::translucencyChanged() const
358{
359    return _translucency;
360}
361
362/* Privates **********************************************************/
363
364void SettingsDialog::accept()
365{
366    if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
367        if (QMessageBox::question(this, tr("Settings Reset"), tr("Do you really want to <b>reset all application settings to their defaults</b>?"), QMessageBox::RestoreDefaults | QMessageBox::Cancel) == QMessageBox::RestoreDefaults) {
368            _fontChanged = (font != QFont(DEF_FONT_FACE, DEF_FONT_SIZE));
369            _colorChanged = (textColor != DEF_TEXT_COLOR);
370            settings->remove("");
371            settings->setValue("SettingsReset", true);
372            QDialog::accept();
373            QMessageBox::information(this->parentWidget(), tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now."));
374            return;
375        } else
376            return;
377    }
378    settings->setValue("Autosize", cbAutosize->isChecked());
379    settings->setValue("SaveLastUsed", cbSaveLastUsed->isChecked());
380    settings->setValue("UseNativeDialogs", cbUseNativeDialogs->isChecked());
381#ifndef HANDHELD
382    if (QtWin::isCompositionEnabled()) {
383bool old = settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool();
384        if ((!old && cbUseTranslucency->isChecked()) || (old && !cbUseTranslucency->isChecked())) {
385            _translucency = old ? -1 : 1;
386        } else
387            _translucency = 0;
388        settings->setValue("UseTranslucency", cbUseTranslucency->isChecked());
389    }
390    settings->setValue("SavePos", cbSaveState->isChecked());
391#endif // HANDHELD
392    if (cbCheck4Updates != NULL) {
393        settings->beginGroup("Check4Updates");
394        settings->setValue("Enabled", cbCheck4Updates->isChecked());
395        if (cbCheck4Updates->isChecked())
396            settings->setValue("Interval", spinUpdateCheckInterval->value());
397        settings->endGroup();
398    }
399
400    settings->beginGroup("Task");
401    settings->setValue("SymmetricMode", cbSymmetricMode->isChecked());
402    settings->setValue("FractionalAccuracy", spinFractionalAccuracy->value());
403    settings->setValue("RandMin", spinRandMin->value());
404    settings->setValue("RandMax", spinRandMax->value());
405    settings->setValue("FractionalRandom", cbFractionalRandom->isChecked());
406    settings->endGroup();
407
408    settings->beginGroup("Output");
409    settings->setValue("GenerateGraph", cbGenerateGraph->isChecked());
410    if (cbGenerateGraph->isChecked()) {
411#ifndef QT_NO_PRINTER
412        settings->setValue("HQGraph", cbHQGraph->isChecked());
413#endif
414        if (cbGenerateGraph->isChecked()) {
415            if (comboGraphImageFormat->currentIndex() >= 0)
416                settings->setValue("GraphImageFormat", comboGraphImageFormat->currentText());
417            else
418                settings->setValue("GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT);
419        }
420        settings->setValue("EmbedGraphIntoHTML", cbEmbedGraphIntoHTML->isChecked());
421    }
422    settings->setValue("ShowMatrix", cbShowMatrix->isChecked());
423    settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
424    if (cbCitiesLimit->isChecked())
425        settings->setValue("ShowMatrixLimit", spinCitiesLimit->value());
426    settings->setValue("ScrollToEnd", cbScrollToEnd->isChecked());
427    if (_fontChanged)
428        settings->setValue("Font", font);
429    if (_colorChanged)
430        settings->setValue("Colors/Text", textColor.name());
431    settings->endGroup();
432    QDialog::accept();
433}
434
435void SettingsDialog::buttonTextColorClicked()
436{
437QColor color = QColorDialog::getColor(this->textColor,this);
438    if (color.isValid() && (this->textColor != color)) {
439        this->textColor = color;
440        _colorChanged = true;
441    }
442}
443
444void SettingsDialog::buttonFontClicked()
445{
446bool ok;
447QFont font = QFontDialog::getFont(&ok, this->font, this);
448    if (ok && (this->font != font)) {
449        this->font = font;
450        QFont f = font;
451        f.setPointSize(labelFontExample->font().pointSize());
452        labelFontExample->setFont(f);
453        labelFontExample->setText(font.family());
454        _fontChanged = true;
455    }
456}
457
458#ifdef Q_WS_WINCE_WM
459void SettingsDialog::desktopResized(int screen)
460{
461    if (screen != 0)
462        return;
463
464QRect availableGeometry = QApplication::desktop()->availableGeometry(0);
465    if (currentGeometry != availableGeometry) {
466        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
467        /*!
468         * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height.
469         *  If \c true, the window gets maximized. If we used \c setGeometry() in this case, the bottom of the
470         *  window would end up being behind the soft buttons. Is this a bug in Qt or Windows Mobile?
471         */
472        if ((availableGeometry.top() + availableGeometry.height()) == QApplication::desktop()->screenGeometry().height()) {
473            setWindowState(windowState() | Qt::WindowMaximized);
474        } else {
475            if (windowState() & Qt::WindowMaximized)
476                setWindowState(windowState() ^ Qt::WindowMaximized);
477            setGeometry(availableGeometry);
478        }
479        currentGeometry = availableGeometry;
480        QApplication::restoreOverrideCursor();
481    }
482}
483
484void SettingsDialog::showEvent(QShowEvent *ev)
485{
486    desktopResized(0);
487
488    QWidget::showEvent(ev);
489}
490#endif // Q_WS_WINCE_WM
491
492void SettingsDialog::spinRandMinValueChanged(int val) {
493    spinRandMax->setMinimum(val);
494}
495
496#if !defined(QT_NO_STATUSTIP) && !defined(HANDHELD)
497bool SettingsDialog::event(QEvent *ev)
498{
499    // Checking for StatusTip event and if tip text is not empty string
500    // setting it as text of the dialog hint label. Otherwise, setting
501    // dialog hint label text to own status tip text.
502    if (ev->type() == QEvent::StatusTip) {
503QString tip = static_cast<QStatusTipEvent *>(ev)->tip();
504        if (tip.length() != 0)
505            labelHint->setText(tip);
506        else
507            labelHint->setText(labelHint->statusTip());
508        return true;
509    } else
510        return QDialog::event(ev);
511}
512#endif // HANDHELD
Note: See TracBrowser for help on using the repository browser.