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 setAttribute(Qt::WA_DeleteOnClose);
17 scroller = new QScrollArea(this);
19 #if defined(Q_WS_MAEMO_5)
20 scroller->setProperty("FingerScrollable", true);
21 scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
22 #elif defined(Q_OS_SYMBIAN)
23 FlickCharm *charm = new FlickCharm(this);
24 charm->activateOn(scroller);
26 scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
28 scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
29 scroller->setFrameStyle(QFrame::NoFrame);
31 content = new QWidget(scroller);
32 contentLayout = new QVBoxLayout(content);
33 contentLayout->setMargin(0);
34 content->setLayout(contentLayout);
36 QBoxLayout *boxLayout;
37 QRect screenGeometry = QApplication::desktop()->screenGeometry();
38 if (screenGeometry.width() < screenGeometry.height()) {
41 buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
44 boxLayout = new QVBoxLayout(this);
48 buttonBox = new QDialogButtonBox(Qt::Vertical, this);
51 boxLayout = new QHBoxLayout(this);
53 boxLayout->addWidget(scroller);
56 boxLayout->addWidget(buttonBox);
61 scroller->setWidget(content);
63 scroller->setWidgetResizable(true);
65 #if defined(Q_OS_SYMBIAN)
66 QAction *closeAction = new QAction(tr("Back"), this);
67 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
68 connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
69 addAction(closeAction);
72 #endif // Q_OS_SYMBIAN
75 void Dyalog::addWidget(QWidget *widget)
77 contentLayout->addWidget(widget);
80 void Dyalog::addStretch(int stretch)
82 contentLayout->addStretch(stretch);
85 void Dyalog::addButton(const QString &label, QObject *receiver,
86 const char *slot, QDialogButtonBox::ButtonRole role)
90 qDebug() << "Ignored: showButtons is false";
96 // Add new action as left softkey
97 leftSoftKey = new QAction(label, this);
98 leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
99 connect(leftSoftKey, SIGNAL(triggered()), receiver, slot);
100 addAction(leftSoftKey);
104 menuBar = new QMenuBar(this);
105 // Add previous LSK to menu bar
106 leftSoftKey->setSoftKeyRole(QAction::NoSoftKey);
107 menuBar->addAction(leftSoftKey);
109 // Add new action to menu bar
110 QAction *action = new QAction(label, this);
111 connect(action, SIGNAL(triggered()), receiver, slot);
112 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