From 0748751c9f097d9d866605306bbdd4b96e2a5c4e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 27 Apr 2011 19:16:41 +0200 Subject: Squashed commit of the changes from the mobile-examples repository (4.7-generated-declarative branch). --- examples/dialogs/extension/finddialog.cpp | 45 ++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'examples/dialogs/extension/finddialog.cpp') diff --git a/examples/dialogs/extension/finddialog.cpp b/examples/dialogs/extension/finddialog.cpp index 313e8e4201..2ce0391d3c 100644 --- a/examples/dialogs/extension/finddialog.cpp +++ b/examples/dialogs/extension/finddialog.cpp @@ -63,9 +63,6 @@ FindDialog::FindDialog(QWidget *parent) //! [0] moreButton->setAutoDefault(false); - buttonBox = new QDialogButtonBox(Qt::Vertical); - buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); //! [1] //! [2] @@ -77,7 +74,42 @@ FindDialog::FindDialog(QWidget *parent) //! [2] //! [3] +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) + // Create menu + QMenu *menu = new QMenu(this); + + // Create Find menu item + menu->addAction(tr("Find")); + + // Create More menu item + QAction *moreAction = menu->addAction(tr("More")); + moreAction->setCheckable(true); + + // Create Options CBA + QAction *optionAction = new QAction(tr("Options"), this); + + // Set defined menu into Options button + optionAction->setMenu(menu); + optionAction->setSoftKeyRole(QAction::PositiveSoftKey); + addAction(optionAction); + + // Connect More menu item to setVisible slot + connect(moreAction, SIGNAL(triggered(bool)), extension, SLOT(setVisible(bool))); + + // Create Exit CBA + QAction *backSoftKeyAction = new QAction(QString(tr("Exit")), this); + backSoftKeyAction->setSoftKeyRole(QAction::NegativeSoftKey); + + // Exit button closes the application + connect(backSoftKeyAction, SIGNAL(triggered()), qApp, SLOT(quit())); + addAction(backSoftKeyAction); +#else + buttonBox = new QDialogButtonBox(Qt::Vertical); + buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); + connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool))); +#endif QVBoxLayout *extensionLayout = new QVBoxLayout; extensionLayout->setMargin(0); @@ -96,13 +128,18 @@ FindDialog::FindDialog(QWidget *parent) leftLayout->addLayout(topLeftLayout); leftLayout->addWidget(caseCheckBox); leftLayout->addWidget(fromStartCheckBox); - leftLayout->addStretch(1); QGridLayout *mainLayout = new QGridLayout; +#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR) mainLayout->setSizeConstraint(QLayout::SetFixedSize); +#endif mainLayout->addLayout(leftLayout, 0, 0); +#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_SIMULATOR) mainLayout->addWidget(buttonBox, 0, 1); +#endif mainLayout->addWidget(extension, 1, 0, 1, 2); + mainLayout->setRowStretch(2, 1); + setLayout(mainLayout); setWindowTitle(tr("Extension")); -- cgit v1.2.3