Set zoom level in steps. Add icons to some buttons. Adjust dialog box layout accordin...
[dorian] / widgets / dyalog.cpp
1 #include <QtGui>
2
3 #include "dyalog.h"
4
5 Dyalog::Dyalog(QWidget *parent) :
6     QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
7                     Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint)
8 {
9     scroller = new QScrollArea(this);
10
11 #ifdef Q_WS_MAEMO_5
12     scroller->setProperty("FingerScrollable", true);
13     scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
14 #else
15     scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
16 #endif
17     scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
18     scroller->setFrameStyle(QFrame::NoFrame);
19
20     content = new QWidget(scroller);
21     contentLayout = new QVBoxLayout(content);
22     contentLayout->setMargin(0);
23     content->setLayout(contentLayout);
24
25     QBoxLayout *boxLayout;
26     QRect screenGeometry = QApplication::desktop()->screenGeometry();
27     if (screenGeometry.width() < screenGeometry.height()) {
28         buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
29         boxLayout = new QVBoxLayout(this);
30     } else {
31         buttonBox = new QDialogButtonBox(Qt::Vertical, this);
32         boxLayout = new QHBoxLayout(this);
33     }
34     boxLayout->addWidget(scroller);
35     boxLayout->addWidget(buttonBox);
36     setLayout(boxLayout);
37
38     scroller->setWidget(content);
39     content->show();
40     scroller->setWidgetResizable(true);
41 }
42
43 void Dyalog::addWidget(QWidget *widget)
44 {
45     contentLayout->addWidget(widget);
46 }
47
48 void Dyalog::addStretch(int stretch)
49 {
50     contentLayout->addStretch(stretch);
51 }
52
53 void Dyalog::addButton(QPushButton *button, QDialogButtonBox::ButtonRole role)
54 {
55     buttonBox->addButton(button, role);
56 }
57
58 QPushButton *Dyalog::addButton(QDialogButtonBox::StandardButton button)
59 {
60     return buttonBox->addButton(button);
61 }