aboutsummaryrefslogtreecommitdiff
path: root/demos/widgetsgallery/querydialogspage.cpp
diff options
context:
space:
mode:
authorStanislav Ionascu <stanislav.ionascu@nokia.com>2010-05-12 11:14:11 +0300
committerTomas Junnonen <tomas.junnonen@nokia.com>2010-05-28 10:58:49 +0300
commitdaa31018b605208e3c45b02224e014d0e4b3294c (patch)
tree1ceda6322d9a6658dd9926596d18a9a02014c9bc /demos/widgetsgallery/querydialogspage.cpp
parent6d59f110c9a0873100e69434462e708157a45330 (diff)
Changes: Improvements to widgets gallery menu system and page layout.
RevBy: Michal Guminiak, Tomas Junnonen Details: 1) Implementation of the drill-down menu in widgets gallery. 2) New category page for selection of gallery page by category. 3) Added the language settings page to application menu. 4) Some code clean up, and added the language settins page to the application view. 5) Added a content items demonstrantion page. 6) Added separate pages for dialogs and notifications. 7) Includes improved patch from merge request #456 (commits by csklu). 8) Removed dialogs and notifications page due to not being used anymore. 9) Removed image rating possibility from widgets gallery grid page. 10) Implemented pinching zoom of images in widgetsgallery grid page.
Diffstat (limited to 'demos/widgetsgallery/querydialogspage.cpp')
-rw-r--r--demos/widgetsgallery/querydialogspage.cpp193
1 files changed, 193 insertions, 0 deletions
diff --git a/demos/widgetsgallery/querydialogspage.cpp b/demos/widgetsgallery/querydialogspage.cpp
new file mode 100644
index 00000000..2e4a2328
--- /dev/null
+++ b/demos/widgetsgallery/querydialogspage.cpp
@@ -0,0 +1,193 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+#include "querydialogspage.h"
+
+#include <MAbstractCellCreator>
+#include <MButton>
+#include <MContentItem>
+#include <MDialog>
+#include <MLabel>
+#include <MLayout>
+#include <MList>
+#include <MLinearLayoutPolicy>
+#include <MMessageBox>
+#include <MTextEdit>
+
+#include <QGraphicsLinearLayout>
+#include <QStringListModel>
+#include <QTimer>
+
+class QueryDialogsPageCellCreator : public MAbstractCellCreator<MContentItem>
+{
+public:
+ QueryDialogsPageCellCreator() : MAbstractCellCreator<MContentItem>() {
+ }
+
+ MWidget *createCell(const QModelIndex &index, MWidgetRecycler &recycler) const {
+ Q_UNUSED(index);
+
+ MContentItem *cell = dynamic_cast<MContentItem *>(recycler.take(MContentItem::staticMetaObject.className()));
+ if (cell == NULL) {
+ cell = new MContentItem(MContentItem::SingleTextLabel);
+ cell->setObjectName("wgMainPageCategoryItem");
+ }
+ updateCell(index, cell);
+
+ return cell;
+ }
+
+ void updateCell(const QModelIndex &index, MWidget *cell) const {
+ MContentItem *item = qobject_cast<MContentItem*>(cell);
+ if(!item)
+ return;
+
+ item->setTitle(index.data().toString());
+ }
+};
+
+QueryDialogsPage::QueryDialogsPage()
+ : TemplatePage(TemplatePage::DialogsAndBanners)
+{
+}
+
+QString QueryDialogsPage::timedemoTitle()
+{
+ return "QueryDialogsPage";
+}
+
+void QueryDialogsPage::createContent()
+{
+ MApplicationPage::createContent();
+
+ QGraphicsWidget *panel = centralWidget();
+
+ MLayout *layout = new MLayout(panel);
+ layout->setContentsMargins(0, 0, 0, 0);
+ panel->setLayout(layout);
+ policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
+ policy->setContentsMargins(0, 0, 0, 0);
+ policy->setSpacing(0);
+
+ populateLayout();
+}
+
+void QueryDialogsPage::populateLayout()
+{
+ QStringList queryDialogTypes;
+ //% "Entry Dialog"
+ queryDialogTypes << qtTrId("xx_wg_query_dialogs_page_entry_dialog");
+ //% "Long Dialog"
+ queryDialogTypes << qtTrId("xx_wg_query_dialogs_page_long_dialog");
+
+ list = new MList(centralWidget());
+ list->setObjectName("wgList");
+ list->setCellCreator(new QueryDialogsPageCellCreator());
+ list->setItemModel(new QStringListModel(queryDialogTypes));
+ policy->addItem(list, Qt::AlignCenter);
+
+ connect(list, SIGNAL(itemClicked(QModelIndex)), this, SLOT(itemClicked(QModelIndex)));
+}
+
+void QueryDialogsPage::itemClicked(const QModelIndex &index)
+{
+ if (index.row() == 0)
+ openEntryDialog();
+ else if (index.row() == 1)
+ openLongDialog();
+}
+
+void QueryDialogsPage::openEntryDialog()
+{
+ if (dialog)
+ return;
+
+ MWidget *centralWidget = new MWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+ //% "Name"
+ MLabel *label = new MLabel(qtTrId("xx_dialogs_and_notifications_entry_dialog_label"), centralWidget);
+ MTextEdit *textEdit = new MTextEdit(MTextEditModel::SingleLine,
+ QString(),
+ centralWidget);
+ centralWidget->setLayout(layout);
+
+ layout->addItem(label);
+ layout->addItem(textEdit);
+
+ //% "Please enter your name"
+ dialog = new MDialog(qtTrId("xx_dialogs_and_notifications_entry_dialog_title"),
+ M::OkButton | M::ResetButton);
+ dialog->setCentralWidget(centralWidget);
+
+ dialog->appear(MSceneWindow::DestroyWhenDone);
+}
+
+void QueryDialogsPage::openLongDialog()
+{
+ if (dialog)
+ return;
+
+ MWidget *centralWidget = new MWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+
+ //% "Select printer"
+ dialog = new MDialog(qtTrId("xx_dialogs_and_notifications_long_dialog_title"), M::CancelButton);
+ dialog->setCentralWidget(centralWidget);
+ MButton *button = 0;
+
+ centralWidget->setLayout(layout);
+
+#define ADD_PRINTER_BUTTON(NAME) \
+ button = new MButton(NAME, centralWidget); \
+ connect(button, SIGNAL(clicked()), dialog, SLOT(accept())); \
+ layout->addItem(button);
+
+ ADD_PRINTER_BUTTON("Lexmark A");
+ ADD_PRINTER_BUTTON("Lexmark B");
+ ADD_PRINTER_BUTTON("Lexmark C");
+ ADD_PRINTER_BUTTON("Lexmark D");
+ ADD_PRINTER_BUTTON("Canon Alpha");
+ ADD_PRINTER_BUTTON("Canon Beta");
+ ADD_PRINTER_BUTTON("Canon Gama");
+ ADD_PRINTER_BUTTON("Canon Zeta");
+ ADD_PRINTER_BUTTON("Brother 1");
+ ADD_PRINTER_BUTTON("Brother 2");
+ ADD_PRINTER_BUTTON("Brother 3");
+ ADD_PRINTER_BUTTON("Brother 4");
+ ADD_PRINTER_BUTTON("Xerox I");
+ ADD_PRINTER_BUTTON("Xerox II");
+ ADD_PRINTER_BUTTON("Xerox III");
+ ADD_PRINTER_BUTTON("Xerox IV");
+ ADD_PRINTER_BUTTON("Dell Roger");
+ ADD_PRINTER_BUTTON("Dell Charlie");
+ ADD_PRINTER_BUTTON("Dell Bravo");
+ ADD_PRINTER_BUTTON("Dell Tango");
+ ADD_PRINTER_BUTTON("HP X");
+ ADD_PRINTER_BUTTON("HP Y");
+ ADD_PRINTER_BUTTON("HP Z");
+ ADD_PRINTER_BUTTON("HP Plus");
+ ADD_PRINTER_BUTTON("Epson Stylus");
+ ADD_PRINTER_BUTTON("Epson Pro");
+ ADD_PRINTER_BUTTON("Epson Office");
+ ADD_PRINTER_BUTTON("Epson Extra");
+
+#undef ADD_PRINTER_BUTTON
+
+ dialog->appear(MSceneWindow::DestroyWhenDone);
+}