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);
30 #if defined(Q_OS_SYMBIAN)
31 // setStyleSheet("QFrame {margin:0; border:0; padding:0}");
32 setStyleSheet("QScrollArea {margin:0; border:0; padding:0}");
35 content = new QWidget(scroller);
36 contentLayout = new QVBoxLayout(content);
37 #if !defined(Q_OS_SYMBIAN)
38 contentLayout->setMargin(0);
40 content->setLayout(contentLayout);
42 QBoxLayout *boxLayout;
43 QRect screenGeometry = QApplication::desktop()->screenGeometry();
44 if (screenGeometry.width() < screenGeometry.height()) {
47 buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
50 boxLayout = new QVBoxLayout(this);
54 buttonBox = new QDialogButtonBox(Qt::Vertical, this);
57 boxLayout = new QHBoxLayout(this);
59 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
60 boxLayout->setMargin(0);
62 boxLayout->addWidget(scroller);
65 boxLayout->addWidget(buttonBox);
70 scroller->setWidget(content);
72 scroller->setWidgetResizable(true);
74 #if defined(Q_OS_SYMBIAN)
75 QAction *closeAction = new QAction(tr("Back"), this);
76 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
77 connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
78 addAction(closeAction);
81 #endif // Q_OS_SYMBIAN
84 void Dyalog::addWidget(QWidget *widget)
86 contentLayout->addWidget(widget);
89 void Dyalog::addStretch(int stretch)
91 contentLayout->addStretch(stretch);
94 void Dyalog::addButton(const QString &label, QObject *receiver,
95 const char *slot, QDialogButtonBox::ButtonRole role)
99 qDebug() << "Ignored: showButtons is false";
105 // Add new action as left softkey
106 leftSoftKey = new QAction(label, this);
107 leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
108 connect(leftSoftKey, SIGNAL(triggered()), receiver, slot);
109 addAction(leftSoftKey);
113 menuBar = new QMenuBar(this);
114 // Add previous LSK to menu bar
115 leftSoftKey->setSoftKeyRole(QAction::NoSoftKey);
116 menuBar->addAction(leftSoftKey);
118 // Add new action to menu bar
119 QAction *action = new QAction(label, this);
120 connect(action, SIGNAL(triggered()), receiver, slot);
121 menuBar->addAction(action);
124 QPushButton *button = new QPushButton(label, this);
125 connect(button, SIGNAL(clicked()), receiver, slot);
126 buttonBox->addButton(button, role);
127 #endif // Q_OS_SYMBIAN
134 foreach (QWidget *w, QApplication::allWidgets()) {
135 w->setContextMenuPolicy(Qt::NoContextMenu);
137 QDialog::showMaximized();
143 return QDialog::exec();
146 #endif // Q_OS_SYMBIAN