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 contentLayout->setMargin(0);
38 content->setLayout(contentLayout);
40 QBoxLayout *boxLayout;
41 QRect screenGeometry = QApplication::desktop()->screenGeometry();
42 if (screenGeometry.width() < screenGeometry.height()) {
45 buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
48 boxLayout = new QVBoxLayout(this);
52 buttonBox = new QDialogButtonBox(Qt::Vertical, this);
55 boxLayout = new QHBoxLayout(this);
57 boxLayout->addWidget(scroller);
60 boxLayout->addWidget(buttonBox);
65 scroller->setWidget(content);
67 scroller->setWidgetResizable(true);
69 #if defined(Q_OS_SYMBIAN)
70 QAction *closeAction = new QAction(tr("Back"), this);
71 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
72 connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
73 addAction(closeAction);
76 #endif // Q_OS_SYMBIAN
79 void Dyalog::addWidget(QWidget *widget)
81 contentLayout->addWidget(widget);
84 void Dyalog::addStretch(int stretch)
86 contentLayout->addStretch(stretch);
89 void Dyalog::addButton(const QString &label, QObject *receiver,
90 const char *slot, QDialogButtonBox::ButtonRole role)
94 qDebug() << "Ignored: showButtons is false";
100 // Add new action as left softkey
101 leftSoftKey = new QAction(label, this);
102 leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
103 connect(leftSoftKey, SIGNAL(triggered()), receiver, slot);
104 addAction(leftSoftKey);
108 menuBar = new QMenuBar(this);
109 // Add previous LSK to menu bar
110 leftSoftKey->setSoftKeyRole(QAction::NoSoftKey);
111 menuBar->addAction(leftSoftKey);
113 // Add new action to menu bar
114 QAction *action = new QAction(label, this);
115 connect(action, SIGNAL(triggered()), receiver, slot);
116 menuBar->addAction(action);
119 QPushButton *button = new QPushButton(label, this);
120 connect(button, SIGNAL(clicked()), receiver, slot);
121 buttonBox->addButton(button, role);
122 #endif // Q_OS_SYMBIAN
129 foreach (QWidget *w, QApplication::allWidgets()) {
130 w->setContextMenuPolicy(Qt::NoContextMenu);
138 return QDialog::exec();
141 #endif // Q_OS_SYMBIAN