7 #include "flickcharm.h"
10 Dyalog::Dyalog(QWidget *parent, bool showButtons_):
11 QDialog(parent, Qt::Dialog | Qt::WindowTitleHint |
12 Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint),
13 showButtons(showButtons_)
15 scroller = new QScrollArea(this);
17 #if defined(Q_WS_MAEMO_5)
18 scroller->setProperty("FingerScrollable", true);
19 scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 #elif defined(Q_OS_SYMBIAN)
21 FlickCharm *charm = new FlickCharm(this);
22 charm->activateOn(scroller);
24 scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
26 scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
27 scroller->setFrameStyle(QFrame::NoFrame);
29 content = new QWidget(scroller);
30 contentLayout = new QVBoxLayout(content);
31 contentLayout->setMargin(0);
32 content->setLayout(contentLayout);
34 QBoxLayout *boxLayout;
35 QRect screenGeometry = QApplication::desktop()->screenGeometry();
36 if (screenGeometry.width() < screenGeometry.height()) {
39 buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
42 boxLayout = new QVBoxLayout(this);
46 buttonBox = new QDialogButtonBox(Qt::Vertical, this);
49 boxLayout = new QHBoxLayout(this);
51 boxLayout->addWidget(scroller);
54 boxLayout->addWidget(buttonBox);
59 scroller->setWidget(content);
61 scroller->setWidgetResizable(true);
63 #if defined(Q_OS_SYMBIAN)
64 QAction *closeAction = new QAction(tr("Back"), this);
65 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
66 connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
67 addAction(closeAction);
70 #endif // Q_OS_SYMBIAN
73 void Dyalog::addWidget(QWidget *widget)
75 contentLayout->addWidget(widget);
78 void Dyalog::addStretch(int stretch)
80 contentLayout->addStretch(stretch);
83 void Dyalog::addButton(const QString &label, QObject *receiver,
84 const char *slot, QDialogButtonBox::ButtonRole role)
88 qDebug() << "Ignored: showButtons is false";
95 qDebug() << "Adding left soft key";
96 leftSoftKey = new QAction(label, this);
97 leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
98 connect(leftSoftKey, SIGNAL(triggered()), receiver, slot);
99 addAction(leftSoftKey);
103 qDebug() << "Creating menu bar";
104 menuBar = new QMenuBar(this);
105 menuBar->addAction(leftSoftKey);
107 qDebug() << "Adding to menu bar";
108 QAction *action = new QAction(label, this);
109 connect(action, SIGNAL(triggered()), receiver, slot);
110 menuBar->addAction(action);
115 QPushButton *button = new QPushButton(label, this);
116 connect(button, SIGNAL(clicked()), receiver, slot);
117 buttonBox->addButton(button, role);
118 #endif // Q_OS_SYMBIAN
125 foreach (QWidget *w, QApplication::allWidgets()) {
126 w->setContextMenuPolicy(Qt::NoContextMenu);
134 return QDialog::exec();
137 #endif // Q_OS_SYMBIAN