Better dialogs on Mac.
[dorian] / devtools.cpp
1 #include <QtGui>
2
3 #include "devtools.h"
4
5 DevTools::DevTools(QWidget *parent):
6         QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
7                 Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
8 {
9     setWindowTitle(tr("Developer"));
10     QScrollArea *scroller = new QScrollArea(this);
11     scroller->setFrameStyle(QFrame::NoFrame);
12 #ifdef Q_WS_MAEMO_5
13     scroller->setProperty("FingerScrollable", true);
14     scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
15 #else
16     scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
17     setSizeGripEnabled(true);
18 #endif // Q_WS_MAEMO_5
19     scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20
21     QWidget *contents = new QWidget(scroller);
22     QVBoxLayout *layout = new QVBoxLayout(contents);
23
24     QPushButton *clearSettings = new QPushButton("Clear persistent data", this);
25     connect(clearSettings, SIGNAL(clicked()), this, SLOT(onClear()));
26     layout->addWidget(clearSettings);
27
28     contents->setLayout(layout);
29     scroller->setWidget(contents);
30
31     QHBoxLayout *dialogLayout = new QHBoxLayout();
32     dialogLayout->addWidget(scroller);
33     setLayout(dialogLayout);
34 }
35
36 void DevTools::onClear()
37 {
38     if (QMessageBox::Yes ==
39         QMessageBox::question(this, "Clear persistent data?",
40                               "Library and settings data will be cleared, "
41                               "application will be restarted. Continue?",
42                               QMessageBox::Yes
43 #ifndef Q_WS_MAEMO_5
44                               , QMessageBox::No
45 #endif
46                               )) {
47         QSettings().clear();
48         QApplication::exit(1000);
49     }
50 }