[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the demonstration applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef MENU_MANAGER_H
|
---|
| 43 | #define MENU_MANAGER_H
|
---|
| 44 |
|
---|
| 45 | #include <QtGui>
|
---|
| 46 | #include <QtXml>
|
---|
| 47 | #include <QtHelp/QHelpEngineCore>
|
---|
[846] | 48 | #ifndef QT_NO_DECLARATIVE
|
---|
| 49 | #include <QtDeclarative>
|
---|
| 50 | #endif
|
---|
[2] | 51 |
|
---|
| 52 | #include "score.h"
|
---|
| 53 | #include "textbutton.h"
|
---|
| 54 | #include "mainwindow.h"
|
---|
| 55 | #include "itemcircleanimation.h"
|
---|
| 56 |
|
---|
| 57 | typedef QHash<QString, QString> StringHash;
|
---|
| 58 | typedef QHash<QString, StringHash> HashHash;
|
---|
| 59 |
|
---|
| 60 | class TextButton;
|
---|
| 61 |
|
---|
| 62 | class MenuManager : public QObject
|
---|
| 63 | {
|
---|
| 64 | Q_OBJECT
|
---|
| 65 |
|
---|
| 66 | public:
|
---|
[846] | 67 | enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK, LAUNCH_QML};
|
---|
[2] | 68 |
|
---|
| 69 | // singleton pattern:
|
---|
| 70 | static MenuManager *instance();
|
---|
| 71 | virtual ~MenuManager();
|
---|
| 72 |
|
---|
| 73 | void init(MainWindow *window);
|
---|
| 74 | void itemSelected(int userCode, const QString &menuName = "");
|
---|
| 75 |
|
---|
| 76 | QByteArray getHtml(const QString &name);
|
---|
| 77 | QByteArray getImage(const QString &name);
|
---|
| 78 | QString resolveExeFile(const QString &name);
|
---|
| 79 | QString resolveDocUrl(const QString &name);
|
---|
| 80 | QString resolveImageUrl(const QString &name);
|
---|
| 81 | QString resolveDataDir(const QString &name);
|
---|
| 82 |
|
---|
| 83 | HashHash info;
|
---|
| 84 | ItemCircleAnimation *ticker;
|
---|
| 85 | MainWindow *window;
|
---|
| 86 | Score *score;
|
---|
| 87 | int currentMenuCode;
|
---|
| 88 |
|
---|
[846] | 89 | QObject *qmlRoot;
|
---|
| 90 | #ifndef QT_NO_DECLARATIVE
|
---|
| 91 | QDeclarativeEngine* declarativeEngine;
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
[2] | 94 | private slots:
|
---|
| 95 | void exampleFinished();
|
---|
| 96 | void exampleError(QProcess::ProcessError error);
|
---|
| 97 |
|
---|
[846] | 98 | void quitQML();
|
---|
| 99 |
|
---|
[2] | 100 | private:
|
---|
| 101 | // singleton pattern:
|
---|
| 102 | MenuManager();
|
---|
| 103 | static MenuManager *pInstance;
|
---|
| 104 |
|
---|
| 105 | QByteArray getResource(const QString &name);
|
---|
| 106 |
|
---|
| 107 | void readXmlDocument();
|
---|
| 108 | void initHelpEngine();
|
---|
| 109 | void getDocumentationDir();
|
---|
| 110 | void readInfoAboutExample(const QDomElement &example);
|
---|
| 111 | void showDocInAssistant(const QString &docFile);
|
---|
| 112 | void launchExample(const QString &uniqueName);
|
---|
[846] | 113 | void launchQmlExample(const QString &uniqueName);
|
---|
[2] | 114 |
|
---|
| 115 | void createMenu(const QDomElement &category, BUTTON_TYPE type);
|
---|
| 116 | void createLowLeftButton(const QString &label, BUTTON_TYPE type,
|
---|
| 117 | Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString = QString());
|
---|
| 118 | void createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie *movieShake);
|
---|
| 119 | void createLowRightLeafButton(const QString &label, int pos, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/);
|
---|
| 120 | void createRootMenu(const QDomElement &el);
|
---|
| 121 | void createSubMenu(const QDomElement &el);
|
---|
| 122 | void createLeafMenu(const QDomElement &el);
|
---|
| 123 | void createInfo(DemoItem *item, const QString &name);
|
---|
| 124 | void createTicker();
|
---|
| 125 | void createUpnDownButtons();
|
---|
| 126 | void createBackButton();
|
---|
| 127 |
|
---|
| 128 | QDomDocument *contentsDoc;
|
---|
| 129 | QProcess assistantProcess;
|
---|
| 130 | QString currentMenu;
|
---|
| 131 | QString currentCategory;
|
---|
| 132 | QString currentMenuButtons;
|
---|
| 133 | QString currentInfo;
|
---|
| 134 | QString helpRootUrl;
|
---|
| 135 | DemoItemAnimation *tickerInAnim;
|
---|
| 136 | QDir docDir;
|
---|
| 137 | QDir imgDir;
|
---|
| 138 | QHelpEngineCore *helpEngine;
|
---|
| 139 |
|
---|
| 140 | TextButton *upButton;
|
---|
| 141 | TextButton *downButton;
|
---|
[846] | 142 |
|
---|
[2] | 143 | };
|
---|
| 144 |
|
---|
| 145 | #endif // MENU_MANAGER_H
|
---|
| 146 |
|
---|