X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=widgets%2Fdyalog.cpp;h=addef7033cf43edd76fc680e247d35752aa12e26;hb=482bb4e19882aab891836a780f2584387e9abc10;hp=06db69047d78d832ba8e43b4d4536c61af6b53a6;hpb=2cd5dacabee31add2369542fc21f34a81dd50294;p=dorian diff --git a/widgets/dyalog.cpp b/widgets/dyalog.cpp index 06db690..addef70 100644 --- a/widgets/dyalog.cpp +++ b/widgets/dyalog.cpp @@ -1,16 +1,27 @@ #include #include "dyalog.h" +#include "trace.h" -Dyalog::Dyalog(QWidget *parent, bool showButtons): +#ifdef Q_OS_SYMBIAN +#include "flickcharm.h" +#endif + +Dyalog::Dyalog(QWidget *parent, bool showButtons_): QDialog(parent, Qt::Dialog | Qt::WindowTitleHint | - Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint) + 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 @@ -25,31 +36,39 @@ Dyalog::Dyalog(QWidget *parent, bool showButtons): QBoxLayout *boxLayout; QRect screenGeometry = QApplication::desktop()->screenGeometry(); if (screenGeometry.width() < screenGeometry.height()) { - buttonBox = new QDialogButtonBox(Qt::Horizontal, this); +#ifndef Q_OS_SYMBIAN + if (showButtons) { + buttonBox = new QDialogButtonBox(Qt::Horizontal, this); + } +#endif boxLayout = new QVBoxLayout(this); } else { - buttonBox = new QDialogButtonBox(Qt::Vertical, this); +#ifndef Q_OS_SYMBIAN + if (showButtons) { + buttonBox = new QDialogButtonBox(Qt::Vertical, this); + } +#endif boxLayout = new QHBoxLayout(this); } boxLayout->addWidget(scroller); +#ifndef Q_OS_SYMBIAN if (showButtons) { boxLayout->addWidget(buttonBox); - } else { - buttonBox->hide(); } +#endif setLayout(boxLayout); scroller->setWidget(content); content->show(); scroller->setWidgetResizable(true); -#ifdef Q_OS_SYMBIAN - QAction *closeAction = new QAction(tr("Close"), this); - closeAction->setSoftKeyRole(QAction::CancelSoftKey); +#if defined(Q_OS_SYMBIAN) + QAction *closeAction = new QAction(tr("Back"), this); + closeAction->setSoftKeyRole(QAction::NegativeSoftKey); connect(closeAction, SIGNAL(triggered()), this, SLOT(reject())); - QList softKeys; - softKeys.append(closeAction); - setSoftKeys(softKeys); + addAction(closeAction); + leftSoftKey = 0; + menuBar = 0; #endif // Q_OS_SYMBIAN } @@ -63,12 +82,56 @@ void Dyalog::addStretch(int stretch) contentLayout->addStretch(stretch); } -void Dyalog::addButton(QPushButton *button, QDialogButtonBox::ButtonRole role) +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 (!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); + } +#else + QPushButton *button = new QPushButton(label, this); + connect(button, SIGNAL(clicked()), receiver, slot); buttonBox->addButton(button, role); +#endif // Q_OS_SYMBIAN } -QPushButton *Dyalog::addButton(QDialogButtonBox::StandardButton button) +#ifdef Q_OS_SYMBIAN + +void Dyalog::show() { - return buttonBox->addButton(button); + foreach (QWidget *w, QApplication::allWidgets()) { + w->setContextMenuPolicy(Qt::NoContextMenu); + } + showMaximized(); } + +int Dyalog::exec() +{ + show(); + return QDialog::exec(); +} + +#endif // Q_OS_SYMBIAN