X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=widgets%2Fdyalog.cpp;h=fc8d3374207a1ac33f8a2a112b1952c6e7eb42c9;hb=0a0ae933b4a226c53a03e67886b0da44cc68ca50;hp=0e4d295aa421245cbf7ed1e4877511c60d152e4d;hpb=3ce29c18fb643d34b86baab846bce2804479db48;p=dorian diff --git a/widgets/dyalog.cpp b/widgets/dyalog.cpp index 0e4d295..fc8d337 100644 --- a/widgets/dyalog.cpp +++ b/widgets/dyalog.cpp @@ -1,22 +1,36 @@ #include #include "dyalog.h" +#include "trace.h" + +#ifdef Q_OS_SYMBIAN +#include "flickcharm.h" +#endif Dyalog::Dyalog(QWidget *parent, bool showButtons_): QDialog(parent, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint), showButtons(showButtons_) { + setAttribute(Qt::WA_DeleteOnClose); + scroller = new QScrollArea(this); -#ifdef Q_WS_MAEMO_5 +#if defined(Q_WS_MAEMO_5) scroller->setProperty("FingerScrollable", true); scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +#elif defined(Q_OS_SYMBIAN) + FlickCharm *charm = new FlickCharm(this); + charm->activateOn(scroller); #else scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); #endif scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scroller->setFrameStyle(QFrame::NoFrame); +#if defined(Q_OS_SYMBIAN) + setStyleSheet("QFrame {margin:0; border:0; padding:0}"); + setStyleSheet("QScrollArea {margin:0; border:0; padding:0}"); +#endif content = new QWidget(scroller); contentLayout = new QVBoxLayout(content); @@ -52,12 +66,13 @@ Dyalog::Dyalog(QWidget *parent, bool showButtons_): content->show(); scroller->setWidgetResizable(true); -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) QAction *closeAction = new QAction(tr("Back"), this); closeAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(closeAction, SIGNAL(triggered()), this, SLOT(reject())); addAction(closeAction); - menu = 0; + leftSoftKey = 0; + menuBar = 0; #endif // Q_OS_SYMBIAN } @@ -74,20 +89,32 @@ void Dyalog::addStretch(int stretch) void Dyalog::addButton(const QString &label, QObject *receiver, const char *slot, QDialogButtonBox::ButtonRole role) { + TRACE; if (!showButtons) { + qDebug() << "Ignored: showButtons is false"; return; } #ifdef Q_OS_SYMBIAN Q_UNUSED(role); - if (!menu) { - QAction *menuAction = new QAction(tr("Options"), this); - menuAction->setSoftKeyRole(QAction::PositiveSoftKey); - menu = new QMenu(this); - menuAction->setMenu(menu); + if (!leftSoftKey) { + // Add new action as left softkey + leftSoftKey = new QAction(label, this); + leftSoftKey->setSoftKeyRole(QAction::PositiveSoftKey); + connect(leftSoftKey, SIGNAL(triggered()), receiver, slot); + addAction(leftSoftKey); + } else { + if (!menuBar) { + // Create menu bar + menuBar = new QMenuBar(this); + // Add previous LSK to menu bar + leftSoftKey->setSoftKeyRole(QAction::NoSoftKey); + menuBar->addAction(leftSoftKey); + } + // Add new action to menu bar + QAction *action = new QAction(label, this); + connect(action, SIGNAL(triggered()), receiver, slot); + menuBar->addAction(action); } - QAction *action = new QAction(label, this); - connect(action, SIGNAL(triggered()), receiver, slot); - menu->addAction(action); #else QPushButton *button = new QPushButton(label, this); connect(button, SIGNAL(clicked()), receiver, slot); @@ -99,12 +126,15 @@ void Dyalog::addButton(const QString &label, QObject *receiver, void Dyalog::show() { + foreach (QWidget *w, QApplication::allWidgets()) { + w->setContextMenuPolicy(Qt::NoContextMenu); + } showMaximized(); } int Dyalog::exec() { - showMaximized(); + show(); return QDialog::exec(); }