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 boxLayout->setMargin(0);
60 boxLayout->addWidget(scroller);
63 boxLayout->addWidget(buttonBox);
68 scroller->setWidget(content);
70 scroller->setWidgetResizable(true);
72 #if defined(Q_OS_SYMBIAN)
73 QAction *closeAction = new QAction(tr("Back"), this);
74 closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
75 connect(closeAction, SIGNAL(triggered()), this, SLOT(reject()));
76 addAction(closeAction);
79 #endif // Q_OS_SYMBIAN
82 void Dyalog::addWidget(QWidget *widget)
84 contentLayout->addWidget(widget);
87 void Dyalog::addStretch(int stretch)
89 contentLayout->addStretch(stretch);
92 void Dyalog::addButton(const QString &label, QObject *receiver,
93 const char *slot, QDialogButtonBox::ButtonRole role)
97 qDebug() << "Ignored: showButtons is false";
103 // Add new action as left softkey
104 leftSoftKey = new QAction(label, this);
105 leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
106 connect(leftSoftKey, SIGNAL(triggered()), receiver, slot);
107 addAction(leftSoftKey);
111 menuBar = new QMenuBar(this);
112 // Add previous LSK to menu bar
113 leftSoftKey->setSoftKeyRole(QAction::NoSoftKey);
114 menuBar->addAction(leftSoftKey);
116 // Add new action to menu bar
117 QAction *action = new QAction(label, this);
118 connect(action, SIGNAL(triggered()), receiver, slot);
119 menuBar->addAction(action);
122 QPushButton *button = new QPushButton(label, this);
123 connect(button, SIGNAL(clicked()), receiver, slot);
124 buttonBox->addButton(button, role);
125 #endif // Q_OS_SYMBIAN
132 foreach (QWidget *w, QApplication::allWidgets()) {
133 w->setContextMenuPolicy(Qt::NoContextMenu);
135 QDialog::showMaximized();
141 return QDialog::exec();
144 #endif // Q_OS_SYMBIAN