Home · All Classes · Main Classes · Deprecated |
This is the easiest navigation pattern to implement. Since escapeMode() of a page is by default set to MApplicationPageModel::EscapeAuto, MeeGo Touch either shows a Back button or a Close button when a new page appears, according to the page navigation history (MSceneManager::pageHistory()). When the Back button is clicked, MeeGo Touch automatically dismisses the current page and displays the previous page (in other words, the most recent page in the page navigation history).
To implement this navigation pattern, create the required pages, and MeeGo Touch takes care of the rest.
All files can be found at:
libmeegotouch/examples/pagenavigation_drilldown
main.cpp:
/*************************************************************************** ** ** Copyright (C) 2010, 2011 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 <MApplication> #include <MApplicationWindow> #include "samplepage.h" int main(int argc, char **argv) { MApplication app(argc, argv); MApplicationWindow window; SamplePage *page = new SamplePage(1); page->appear(&window); window.show(); return app.exec(); }
samplepage.cpp:
/*************************************************************************** ** ** Copyright (C) 2010, 2011 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 "samplepage.h" #include <MSceneManager> #include <MButton> SamplePage::SamplePage(int level) : MApplicationPage(0), level(level) { QString title; if (level == 1) { title = "Root level"; } else { title = QString("Level %1").arg(level); } setTitle(title); QString buttonTitle = QString("Open page level %1").arg(level + 1); MButton *button = new MButton(buttonTitle); connect(button, SIGNAL(clicked()), SLOT(openNextPage())); setCentralWidget(button); } void SamplePage::openNextPage() { SamplePage *nextPage = new SamplePage(level + 1); nextPage->appear(scene(), MSceneWindow::DestroyWhenDismissed); }
samplepage.h:
/*************************************************************************** ** ** Copyright (C) 2010, 2011 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. ** ****************************************************************************/ #ifndef SAMPLEPAGE_H #define SAMPLEPAGE_H #include <MApplicationPage> class SamplePage : public MApplicationPage { Q_OBJECT public: SamplePage(int level); private slots: void openNextPage(); private: int level; }; #endif
Copyright © 2010 Nokia Corporation | MeeGo Touch |