0
+ − 1
/****************************************************************************
+ − 2
**
18
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
0
+ − 4
** All rights reserved.
+ − 5
** Contact: Nokia Corporation (qt-info@nokia.com)
+ − 6
**
+ − 7
** This file is part of the demonstration applications of the Qt Toolkit.
+ − 8
**
+ − 9
** $QT_BEGIN_LICENSE:LGPL$
+ − 10
** No Commercial Usage
+ − 11
** This file contains pre-release code and may not be distributed.
+ − 12
** You may use this file in accordance with the terms and conditions
+ − 13
** contained in the Technology Preview License Agreement accompanying
+ − 14
** this package.
+ − 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
**
+ − 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.
+ − 27
**
+ − 28
** If you have questions regarding the use of this file, please contact
+ − 29
** Nokia at qt-info@nokia.com.
+ − 30
**
+ − 31
**
+ − 32
**
+ − 33
**
+ − 34
**
+ − 35
**
+ − 36
**
+ − 37
**
+ − 38
** $QT_END_LICENSE$
+ − 39
**
+ − 40
****************************************************************************/
+ − 41
+ − 42
#include "menumanager.h"
+ − 43
#include "colors.h"
+ − 44
#include "menucontent.h"
+ − 45
#include "examplecontent.h"
+ − 46
+ − 47
MenuManager *MenuManager::pInstance = 0;
+ − 48
+ − 49
MenuManager * MenuManager::instance()
+ − 50
{
+ − 51
if (!MenuManager::pInstance)
+ − 52
MenuManager::pInstance = new MenuManager();
+ − 53
return MenuManager::pInstance;
+ − 54
}
+ − 55
+ − 56
MenuManager::MenuManager()
+ − 57
{
+ − 58
this->ticker = 0;
+ − 59
this->tickerInAnim = 0;
+ − 60
this->upButton = 0;
+ − 61
this->downButton = 0;
+ − 62
this->helpEngine = 0;
+ − 63
this->score = new Score();
+ − 64
this->currentMenu = QLatin1String("[no menu visible]");
+ − 65
this->currentCategory = QLatin1String("[no category visible]");
+ − 66
this->currentMenuButtons = QLatin1String("[no menu buttons visible]");
+ − 67
this->currentInfo = QLatin1String("[no info visible]");
+ − 68
this->currentMenuCode = -1;
+ − 69
this->readXmlDocument();
+ − 70
this->initHelpEngine();
+ − 71
}
+ − 72
+ − 73
MenuManager::~MenuManager()
+ − 74
{
+ − 75
delete this->score;
+ − 76
delete this->contentsDoc;
+ − 77
delete this->helpEngine;
+ − 78
}
+ − 79
+ − 80
QByteArray MenuManager::getResource(const QString &name)
+ − 81
{
+ − 82
QByteArray ba = this->helpEngine->fileData(name);
+ − 83
if (Colors::verbose && ba.isEmpty())
+ − 84
qDebug() << " - WARNING: Could not get " << name;
+ − 85
return ba;
+ − 86
}
+ − 87
+ − 88
void MenuManager::readXmlDocument()
+ − 89
{
+ − 90
this->contentsDoc = new QDomDocument();
+ − 91
QString errorStr;
+ − 92
int errorLine;
+ − 93
int errorColumn;
+ − 94
+ − 95
QFile file(":/xml/examples.xml");
+ − 96
bool statusOK = this->contentsDoc->setContent(&file, true, &errorStr, &errorLine, &errorColumn);
+ − 97
if (!statusOK){
+ − 98
QMessageBox::critical(0,
+ − 99
QObject::tr("DOM Parser"),
+ − 100
QObject::tr("Could not read or find the contents document. Error at line %1, column %2:\n%3")
+ − 101
.arg(errorLine).arg(errorColumn).arg(errorStr)
+ − 102
);
+ − 103
exit(-1);
+ − 104
}
+ − 105
}
+ − 106
+ − 107
void MenuManager::initHelpEngine()
+ − 108
{
+ − 109
this->helpRootUrl = QString("qthelp://com.trolltech.qt.%1%2%3/qdoc/")
+ − 110
.arg(QT_VERSION >> 16).arg((QT_VERSION >> 8) & 0xFF)
+ − 111
.arg(QT_VERSION & 0xFF);
+ − 112
+ − 113
// Store help collection file in cache dir of assistant
+ − 114
QString cacheDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+ − 115
+ QLatin1String("/Trolltech/Assistant/");
+ − 116
QString helpDataFile = QString(QLatin1String("qtdemo_%1.qhc")).arg(QLatin1String(QT_VERSION_STR));
+ − 117
+ − 118
QDir dir;
+ − 119
if (!dir.exists(cacheDir))
+ − 120
dir.mkpath(cacheDir);
+ − 121
+ − 122
// Create help engine (and new
+ − 123
// helpDataFile if it does not exist):
+ − 124
this->helpEngine = new QHelpEngineCore(cacheDir + helpDataFile);
+ − 125
this->helpEngine->setupData();
+ − 126
+ − 127
QString qtDocRoot = QLibraryInfo::location(QLibraryInfo::DocumentationPath) + QLatin1String("/qch");
+ − 128
qtDocRoot = QDir(qtDocRoot).absolutePath();
+ − 129
+ − 130
QStringList qchFiles;
+ − 131
qchFiles << QLatin1String("/qt.qch")
+ − 132
<< QLatin1String("/designer.qch")
+ − 133
<< QLatin1String("/linguist.qch");
+ − 134
+ − 135
QString oldDir = helpEngine->customValue(QLatin1String("docDir"), QString()).toString();
+ − 136
if (oldDir != qtDocRoot) {
+ − 137
foreach (const QString &qchFile, qchFiles)
+ − 138
helpEngine->unregisterDocumentation(QHelpEngineCore::namespaceName(qtDocRoot + qchFile));
+ − 139
}
+ − 140
+ − 141
// If the data that the engine will work
+ − 142
// on is not yet registered, do it now:
+ − 143
foreach (const QString &qchFile, qchFiles)
+ − 144
helpEngine->registerDocumentation(qtDocRoot + qchFile);
+ − 145
+ − 146
helpEngine->setCustomValue(QLatin1String("docDir"), qtDocRoot);
+ − 147
}
+ − 148
+ − 149
void MenuManager::itemSelected(int userCode, const QString &menuName)
+ − 150
{
+ − 151
switch (userCode){
+ − 152
case LAUNCH:
+ − 153
this->launchExample(this->currentInfo);
+ − 154
break;
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 155
case LAUNCH_QML:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 156
this->launchQmlExample(this->currentInfo);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 157
break;
0
+ − 158
case DOCUMENTATION:
+ − 159
this->showDocInAssistant(this->currentInfo);
+ − 160
break;
+ − 161
case QUIT:
+ − 162
this->window->loop = false;
+ − 163
QCoreApplication::quit();
+ − 164
break;
+ − 165
case FULLSCREEN:
+ − 166
this->window->toggleFullscreen();
+ − 167
break;
+ − 168
case ROOT:
+ − 169
// out:
+ − 170
this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 171
this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 172
this->score->queueMovie(this->currentInfo + " -out");
+ − 173
this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
+ − 174
this->score->queueMovie("back -out", Score::ONLY_IF_VISIBLE);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 175
if(qmlRoot)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 176
qmlRoot->setProperty("show", QVariant(false));
0
+ − 177
// book-keeping:
+ − 178
this->currentMenuCode = ROOT;
+ − 179
this->currentMenu = menuName + " -menu1";
+ − 180
this->currentMenuButtons = menuName + " -buttons";
+ − 181
this->currentInfo = menuName + " -info";
+ − 182
// in:
+ − 183
this->score->queueMovie("upndown -shake");
+ − 184
this->score->queueMovie(this->currentMenu, Score::FROM_START, Score::UNLOCK_ITEMS);
+ − 185
this->score->queueMovie(this->currentMenuButtons, Score::FROM_START, Score::UNLOCK_ITEMS);
+ − 186
this->score->queueMovie(this->currentInfo);
+ − 187
if (!Colors::noTicker){
+ − 188
this->ticker->doIntroTransitions = true;
+ − 189
this->tickerInAnim->startDelay = 2000;
+ − 190
this->ticker->useGuideQt();
+ − 191
this->score->queueMovie("ticker", Score::NEW_ANIMATION_ONLY);
+ − 192
}
+ − 193
break;
+ − 194
case MENU1:
+ − 195
// out:
+ − 196
this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 197
this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 198
this->score->queueMovie(this->currentInfo + " -out");
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 199
if(qmlRoot)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 200
qmlRoot->setProperty("show", QVariant(false));
0
+ − 201
// book-keeping:
+ − 202
this->currentMenuCode = MENU1;
+ − 203
this->currentCategory = menuName;
+ − 204
this->currentMenu = menuName + " -menu1";
+ − 205
this->currentInfo = menuName + " -info";
+ − 206
// in:
+ − 207
this->score->queueMovie("upndown -shake");
+ − 208
this->score->queueMovie("back -in");
+ − 209
this->score->queueMovie(this->currentMenu, Score::FROM_START, Score::UNLOCK_ITEMS);
+ − 210
this->score->queueMovie(this->currentInfo);
+ − 211
if (!Colors::noTicker)
+ − 212
this->ticker->useGuideTt();
+ − 213
break;
+ − 214
case MENU2:
+ − 215
// out:
+ − 216
this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY);
+ − 217
this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 218
if(qmlRoot)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 219
qmlRoot->setProperty("show", QVariant(false));
0
+ − 220
// book-keeping:
+ − 221
this->currentMenuCode = MENU2;
+ − 222
this->currentInfo = menuName;
+ − 223
// in / shake:
+ − 224
this->score->queueMovie("upndown -shake");
+ − 225
this->score->queueMovie("back -shake");
+ − 226
this->score->queueMovie(this->currentMenu + " -shake");
+ − 227
this->score->queueMovie(this->currentInfo, Score::NEW_ANIMATION_ONLY);
+ − 228
this->score->queueMovie(this->currentInfo + " -buttons", Score::NEW_ANIMATION_ONLY);
+ − 229
if (!Colors::noTicker){
+ − 230
this->score->queueMovie("ticker -out", Score::NEW_ANIMATION_ONLY);
+ − 231
}
+ − 232
break;
+ − 233
case UP:{
+ − 234
QString backMenu = this->info[this->currentMenu]["back"];
+ − 235
if (!backMenu.isNull()){
+ − 236
this->score->queueMovie(this->currentMenu + " -top_out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 237
this->score->queueMovie(backMenu + " -bottom_in", Score::FROM_START, Score::UNLOCK_ITEMS);
+ − 238
this->currentMenu = backMenu;
+ − 239
}
+ − 240
break; }
+ − 241
case DOWN:{
+ − 242
QString moreMenu = this->info[this->currentMenu]["more"];
+ − 243
if (!moreMenu.isNull()){
+ − 244
this->score->queueMovie(this->currentMenu + " -bottom_out", Score::FROM_START, Score::LOCK_ITEMS);
+ − 245
this->score->queueMovie(moreMenu + " -top_in", Score::FROM_START, Score::UNLOCK_ITEMS);
+ − 246
this->currentMenu = moreMenu;
+ − 247
}
+ − 248
break; }
+ − 249
case BACK:{
+ − 250
if (this->currentMenuCode == MENU2){
+ − 251
// out:
+ − 252
this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY);
+ − 253
this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 254
if(qmlRoot)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 255
qmlRoot->setProperty("show", QVariant(false));
0
+ − 256
// book-keeping:
+ − 257
this->currentMenuCode = MENU1;
+ − 258
this->currentMenuButtons = this->currentCategory + " -buttons";
+ − 259
this->currentInfo = this->currentCategory + " -info";
+ − 260
// in / shake:
+ − 261
this->score->queueMovie("upndown -shake");
+ − 262
this->score->queueMovie(this->currentMenu + " -shake");
+ − 263
this->score->queueMovie(this->currentInfo, Score::NEW_ANIMATION_ONLY);
+ − 264
this->score->queueMovie(this->currentInfo + " -buttons", Score::NEW_ANIMATION_ONLY);
+ − 265
if (!Colors::noTicker){
+ − 266
this->ticker->doIntroTransitions = false;
+ − 267
this->tickerInAnim->startDelay = 500;
+ − 268
this->score->queueMovie("ticker", Score::NEW_ANIMATION_ONLY);
+ − 269
}
+ − 270
} else if (this->currentMenuCode != ROOT)
+ − 271
itemSelected(ROOT, Colors::rootMenuName);
+ − 272
break; }
+ − 273
}
+ − 274
+ − 275
// update back- and more buttons
+ − 276
bool noBackMenu = this->info[this->currentMenu]["back"].isNull();
+ − 277
bool noMoreMenu = this->info[this->currentMenu]["more"].isNull();
+ − 278
this->upButton->setState(noBackMenu ? TextButton::DISABLED : TextButton::OFF);
+ − 279
this->downButton->setState(noMoreMenu ? TextButton::DISABLED : TextButton::OFF);
+ − 280
+ − 281
if (this->score->hasQueuedMovies()){
+ − 282
this->score->playQue();
+ − 283
// Playing new movies might include
+ − 284
// loading etc. So ignore the FPS
+ − 285
// at this point
+ − 286
this->window->fpsHistory.clear();
+ − 287
}
+ − 288
}
+ − 289
+ − 290
void MenuManager::showDocInAssistant(const QString &name)
+ − 291
{
+ − 292
QString url = this->resolveDocUrl(name);
+ − 293
if (Colors::verbose)
+ − 294
qDebug() << "Sending URL to Assistant:" << url;
+ − 295
+ − 296
// Start assistant if it's not already running:
+ − 297
if (this->assistantProcess.state() != QProcess::Running){
+ − 298
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
+ − 299
#if !defined(Q_OS_MAC)
+ − 300
app += QLatin1String("assistant");
+ − 301
#else
+ − 302
app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
+ − 303
#endif
+ − 304
QStringList args;
+ − 305
args << QLatin1String("-enableRemoteControl");
+ − 306
this->assistantProcess.start(app, args);
+ − 307
if (!this->assistantProcess.waitForStarted()) {
+ − 308
QMessageBox::critical(0, tr("Qt Demo"), tr("Could not start Qt Assistant.").arg(app));
+ − 309
return;
+ − 310
}
+ − 311
}
+ − 312
+ − 313
// Send command through remote control even if the process
+ − 314
// was started to activate assistant and bring it to front:
+ − 315
QTextStream str(&this->assistantProcess);
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 316
str << "SetSource " << url << QLatin1Char('\n') << endl;
0
+ − 317
}
+ − 318
+ − 319
void MenuManager::launchExample(const QString &name)
+ − 320
{
+ − 321
QString executable = this->resolveExeFile(name);
+ − 322
#ifdef Q_OS_MAC
+ − 323
if (Colors::verbose)
+ − 324
qDebug() << "Launching:" << executable;
+ − 325
bool success = QDesktopServices::openUrl(QUrl::fromLocalFile(executable));
+ − 326
if (!success){
+ − 327
QMessageBox::critical(0, tr("Failed to launch the example"),
+ − 328
tr("Could not launch the example. Ensure that it has been built."),
+ − 329
QMessageBox::Cancel);
+ − 330
}
+ − 331
#else // Not mac. To not break anything regarding dll's etc, keep it the way it was before:
+ − 332
QProcess *process = new QProcess(this);
+ − 333
connect(process, SIGNAL(finished(int)), this, SLOT(exampleFinished()));
+ − 334
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(exampleError(QProcess::ProcessError)));
+ − 335
+ − 336
#ifdef Q_OS_WIN
+ − 337
//make sure it finds the dlls on windows
+ − 338
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ − 339
env.insert(QLatin1String("PATH"), QLibraryInfo::location(QLibraryInfo::BinariesPath)
+ − 340
+ QLatin1Char(';') + env.value(QLatin1String("Path")));
+ − 341
process->setProcessEnvironment(env);
+ − 342
#endif
+ − 343
+ − 344
if (info[name]["changedirectory"] != "false"){
+ − 345
QString workingDirectory = resolveDataDir(name);
+ − 346
process->setWorkingDirectory(workingDirectory);
+ − 347
if (Colors::verbose)
+ − 348
qDebug() << "Setting working directory:" << workingDirectory;
+ − 349
}
+ − 350
+ − 351
if (Colors::verbose)
+ − 352
qDebug() << "Launching:" << executable;
+ − 353
process->start(executable);
+ − 354
#endif
+ − 355
}
+ − 356
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 357
void MenuManager::launchQmlExample(const QString &name)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 358
{
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 359
#ifndef QT_NO_DECLARATIVE
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 360
if(!qmlRoot){
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 361
exampleError(QProcess::UnknownError);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 362
return;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 363
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 364
//resolveQmlFilename - refactor to separate fn?
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 365
QString dirName = this->info[name]["dirname"];
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 366
QString category = this->info[name]["category"];
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 367
QString fileName = this->info[name]["filename"];
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 368
QDir dir;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 369
if (category == "demos")
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 370
dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 371
else
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 372
dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 373
QFile file(dir.path() + "/" + dirName + "/" + fileName + "/" + "main.qml");
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 374
if(!file.exists()){
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 375
//try dirname.qml as well
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 376
file.setFileName(dir.path() + "/" + dirName + "/" + fileName + "/" + fileName.split('/').last() + ".qml");
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 377
if(!file.exists()){
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 378
exampleError(QProcess::UnknownError);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 379
return;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 380
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 381
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 382
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 383
qmlRoot->setProperty("qmlFile", QVariant(""));//unload component
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 384
qmlRoot->setProperty("show", QVariant(true));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 385
qmlRoot->setProperty("qmlFile", QUrl::fromLocalFile(file.fileName()));
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 386
#else
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 387
exampleError(QProcess::UnknownError);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 388
#endif
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 389
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 390
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 391
void MenuManager::quitQML()
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 392
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 393
if(qmlRoot)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 394
qmlRoot->setProperty("show", QVariant(false));
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 395
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 396
0
+ − 397
void MenuManager::exampleFinished()
+ − 398
{
+ − 399
}
+ − 400
+ − 401
void MenuManager::exampleError(QProcess::ProcessError error)
+ − 402
{
+ − 403
if (error != QProcess::Crashed)
+ − 404
QMessageBox::critical(0, tr("Failed to launch the example"),
+ − 405
tr("Could not launch the example. Ensure that it has been built."),
+ − 406
QMessageBox::Cancel);
+ − 407
}
+ − 408
+ − 409
void MenuManager::init(MainWindow *window)
+ − 410
{
+ − 411
this->window = window;
+ − 412
+ − 413
// Create div:
+ − 414
this->createTicker();
+ − 415
this->createUpnDownButtons();
+ − 416
this->createBackButton();
+ − 417
+ − 418
// Create first level menu:
+ − 419
QDomElement rootElement = this->contentsDoc->documentElement();
+ − 420
this->createRootMenu(rootElement);
+ − 421
+ − 422
// Create second level menus:
+ − 423
QDomNode level2MenuNode = rootElement.firstChild();
+ − 424
while (!level2MenuNode.isNull()){
+ − 425
QDomElement level2MenuElement = level2MenuNode.toElement();
+ − 426
this->createSubMenu(level2MenuElement);
+ − 427
+ − 428
// create leaf menu and example info:
+ − 429
QDomNode exampleNode = level2MenuElement.firstChild();
+ − 430
while (!exampleNode.isNull()){
+ − 431
QDomElement exampleElement = exampleNode.toElement();
+ − 432
this->readInfoAboutExample(exampleElement);
+ − 433
this->createLeafMenu(exampleElement);
+ − 434
exampleNode = exampleNode.nextSibling();
+ − 435
}
+ − 436
+ − 437
level2MenuNode = level2MenuNode.nextSibling();
+ − 438
}
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 439
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 440
qmlRoot = 0;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 441
#ifndef QT_NO_DECLARATIVE
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 442
// Create QML Loader
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 443
declarativeEngine = new QDeclarativeEngine(this);
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 444
connect(declarativeEngine, SIGNAL(quit()),
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 445
this, SLOT(quitQML()));
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 446
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 447
QDeclarativeComponent component(declarativeEngine, QUrl("qrc:qml/qmlShell.qml"), this);
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 448
QDeclarativeItem* qmlRootItem = 0;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 449
if(component.isReady()){
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 450
qmlRoot = component.create();
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 451
qmlRootItem = qobject_cast<QDeclarativeItem*>(qmlRoot);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 452
}else{
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 453
qDebug() << component.status() << component.errorString();
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 454
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 455
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 456
if(qmlRootItem){
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 457
qmlRootItem->setHeight(this->window->scene->sceneRect().height());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 458
qmlRootItem->setWidth(this->window->scene->sceneRect().width());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 459
qmlRootItem->setZValue(101);//Above other items
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 460
qmlRootItem->setCursor(Qt::ArrowCursor);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 461
window->scene->addItem(qmlRootItem);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 462
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 463
//Note that QML adds key handling to the app.
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 464
window->viewport()->setFocusPolicy(Qt::NoFocus);//Correct keyboard focus handling
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 465
window->setFocusPolicy(Qt::StrongFocus);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 466
window->scene->setStickyFocus(true);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 467
window->setFocus();
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 468
}else{
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 469
qDebug() << "Error initializing QML subsystem, Declarative examples will not work";
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 470
}
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 471
#endif
0
+ − 472
}
+ − 473
+ − 474
void MenuManager::readInfoAboutExample(const QDomElement &example)
+ − 475
{
+ − 476
QString name = example.attribute("name");
+ − 477
if (this->info.contains(name))
+ − 478
qWarning() << "__WARNING: MenuManager::readInfoAboutExample: Demo/example with name"
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 479
<< name << "appears twice in the xml-file!__";
0
+ − 480
+ − 481
this->info[name]["filename"] = example.attribute("filename");
+ − 482
this->info[name]["category"] = example.parentNode().toElement().tagName();
+ − 483
this->info[name]["dirname"] = example.parentNode().toElement().attribute("dirname");
+ − 484
this->info[name]["changedirectory"] = example.attribute("changedirectory");
+ − 485
this->info[name]["image"] = example.attribute("image");
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 486
this->info[name]["qml"] = example.attribute("qml");
0
+ − 487
}
+ − 488
+ − 489
QString MenuManager::resolveDataDir(const QString &name)
+ − 490
{
+ − 491
QString dirName = this->info[name]["dirname"];
+ − 492
QString category = this->info[name]["category"];
+ − 493
QString fileName = this->info[name]["filename"];
+ − 494
+ − 495
QDir dir;
+ − 496
if (category == "demos")
+ − 497
dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
+ − 498
else
+ − 499
dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
+ − 500
+ − 501
dir.cd(dirName);
+ − 502
dir.cd(fileName);
+ − 503
return dir.absolutePath();
+ − 504
}
+ − 505
+ − 506
QString MenuManager::resolveExeFile(const QString &name)
+ − 507
{
+ − 508
QString dirName = this->info[name]["dirname"];
+ − 509
QString category = this->info[name]["category"];
+ − 510
QString fileName = this->info[name]["filename"];
+ − 511
+ − 512
QDir dir;
+ − 513
if (category == "demos")
+ − 514
dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
+ − 515
else
+ − 516
dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
+ − 517
+ − 518
dir.cd(dirName);
+ − 519
dir.cd(fileName);
+ − 520
+ − 521
QFile unixFile(dir.path() + "/" + fileName);
+ − 522
if (unixFile.exists()) return unixFile.fileName();
+ − 523
QFile winR(dir.path() + "\\release\\" + fileName + ".exe");
+ − 524
if (winR.exists()) return winR.fileName();
+ − 525
QFile winD(dir.path() + "\\debug\\" + fileName + ".exe");
+ − 526
if (winD.exists()) return winD.fileName();
+ − 527
QFile mac(dir.path() + "/" + fileName + ".app");
+ − 528
if (mac.exists()) return mac.fileName();
+ − 529
+ − 530
if (Colors::verbose)
+ − 531
qDebug() << "- WARNING: Could not resolve executable:" << dir.path() << fileName;
+ − 532
return "__executable not found__";
+ − 533
}
+ − 534
+ − 535
QString MenuManager::resolveDocUrl(const QString &name)
+ − 536
{
+ − 537
QString dirName = this->info[name]["dirname"];
+ − 538
QString category = this->info[name]["category"];
+ − 539
QString fileName = this->info[name]["filename"];
+ − 540
+ − 541
if (category == "demos")
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 542
return this->helpRootUrl + "demos-" + fileName.replace("/", "-") + ".html";
0
+ − 543
else
+ − 544
return this->helpRootUrl + dirName.replace("/", "-") + "-" + fileName + ".html";
+ − 545
}
+ − 546
+ − 547
QString MenuManager::resolveImageUrl(const QString &name)
+ − 548
{
+ − 549
return this->helpRootUrl + "images/" + name;
+ − 550
}
+ − 551
+ − 552
QByteArray MenuManager::getHtml(const QString &name)
+ − 553
{
+ − 554
return getResource(this->resolveDocUrl(name));
+ − 555
}
+ − 556
+ − 557
QByteArray MenuManager::getImage(const QString &name)
+ − 558
{
+ − 559
QString imageName = this->info[name]["image"];
+ − 560
QString category = this->info[name]["category"];
+ − 561
QString fileName = this->info[name]["filename"];
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 562
bool qml = (this->info[name]["qml"] == QLatin1String("true"));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 563
if(qml)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 564
fileName = QLatin1String("qml-") + fileName.split('/').last();
0
+ − 565
+ − 566
if (imageName.isEmpty()){
+ − 567
if (category == "demos")
+ − 568
imageName = fileName + "-demo.png";
+ − 569
else
+ − 570
imageName = fileName + "-example.png";
+ − 571
if ((getResource(resolveImageUrl(imageName))).isEmpty())
+ − 572
imageName = fileName + ".png";
+ − 573
if ((getResource(resolveImageUrl(imageName))).isEmpty())
+ − 574
imageName = fileName + "example.png";
+ − 575
}
+ − 576
return getResource(resolveImageUrl(imageName));
+ − 577
}
+ − 578
+ − 579
+ − 580
void MenuManager::createRootMenu(const QDomElement &el)
+ − 581
{
+ − 582
QString name = el.attribute("name");
+ − 583
createMenu(el, MENU1);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 584
createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info");
0
+ − 585
+ − 586
Movie *menuButtonsIn = this->score->insertMovie(name + " -buttons");
+ − 587
Movie *menuButtonsOut = this->score->insertMovie(name + " -buttons -out");
+ − 588
createLowLeftButton(QLatin1String("Quit"), QUIT, menuButtonsIn, menuButtonsOut, 0);
+ − 589
createLowRightButton("Toggle fullscreen", FULLSCREEN, menuButtonsIn, menuButtonsOut, 0);
+ − 590
}
+ − 591
+ − 592
void MenuManager::createSubMenu(const QDomElement &el)
+ − 593
{
+ − 594
QString name = el.attribute("name");
+ − 595
createMenu(el, MENU2);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 596
createInfo(new MenuContentItem(el, this->window->scene, this->window->mainSceneRoot), name + " -info");
0
+ − 597
}
+ − 598
+ − 599
void MenuManager::createLeafMenu(const QDomElement &el)
+ − 600
{
+ − 601
QString name = el.attribute("name");
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 602
createInfo(new ExampleContent(name, this->window->scene, this->window->mainSceneRoot), name);
0
+ − 603
+ − 604
Movie *infoButtonsIn = this->score->insertMovie(name + " -buttons");
+ − 605
Movie *infoButtonsOut = this->score->insertMovie(name + " -buttons -out");
+ − 606
createLowRightLeafButton("Documentation", 600, DOCUMENTATION, infoButtonsIn, infoButtonsOut, 0);
+ − 607
if (el.attribute("executable") != "false")
+ − 608
createLowRightLeafButton("Launch", 405, LAUNCH, infoButtonsIn, infoButtonsOut, 0);
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 609
else if(el.attribute("qml") == "true")
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 610
createLowRightLeafButton("Display", 405, LAUNCH_QML, infoButtonsIn, infoButtonsOut, 0);
0
+ − 611
}
+ − 612
+ − 613
void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type)
+ − 614
{
+ − 615
qreal sw = this->window->scene->sceneRect().width();
+ − 616
int xOffset = 15;
+ − 617
int yOffset = 10;
+ − 618
int maxExamples = Colors::menuCount;
+ − 619
int menuIndex = 1;
+ − 620
QString name = category.attribute("name");
+ − 621
QDomNode currentNode = category.firstChild();
+ − 622
QString currentMenu = name + QLatin1String(" -menu") + QString::number(menuIndex);
+ − 623
+ − 624
while (!currentNode.isNull()){
+ − 625
Movie *movieIn = this->score->insertMovie(currentMenu);
+ − 626
Movie *movieOut = this->score->insertMovie(currentMenu + " -out");
+ − 627
Movie *movieNextTopOut = this->score->insertMovie(currentMenu + " -top_out");
+ − 628
Movie *movieNextBottomOut = this->score->insertMovie(currentMenu + " -bottom_out");
+ − 629
Movie *movieNextTopIn = this->score->insertMovie(currentMenu + " -top_in");
+ − 630
Movie *movieNextBottomIn = this->score->insertMovie(currentMenu + " -bottom_in");
+ − 631
Movie *movieShake = this->score->insertMovie(currentMenu + " -shake");
+ − 632
+ − 633
int i = 0;
+ − 634
while (!currentNode.isNull() && i < maxExamples){
+ − 635
TextButton *item;
+ − 636
+ − 637
// create normal menu button
+ − 638
QString label = currentNode.toElement().attribute("name");
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 639
item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot);
0
+ − 640
currentNode = currentNode.nextSibling();
+ − 641
+ − 642
#ifndef QT_OPENGL_SUPPORT
+ − 643
if (currentNode.toElement().attribute("dirname") == "opengl")
+ − 644
currentNode = currentNode.nextSibling();
+ − 645
#endif
+ − 646
+ − 647
item->setRecursiveVisible(false);
+ − 648
item->setZValue(10);
+ − 649
qreal ih = item->sceneBoundingRect().height();
+ − 650
qreal iw = item->sceneBoundingRect().width();
+ − 651
qreal ihp = ih + 3;
+ − 652
+ − 653
// create in-animation:
+ − 654
DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 655
anim->setDuration(float(1000 + (i * 20)) * Colors::animSpeedButtons);
+ − 656
anim->setStartPos(QPointF(xOffset, -ih));
+ − 657
anim->setPosAt(0.20, QPointF(xOffset, -ih));
+ − 658
anim->setPosAt(0.50, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (10 * float(i / 4.0f))));
+ − 659
anim->setPosAt(0.60, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 660
anim->setPosAt(0.70, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (5 * float(i / 4.0f))));
+ − 661
anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 662
anim->setPosAt(0.90, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (2 * float(i / 4.0f))));
+ − 663
anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 664
movieIn->append(anim);
+ − 665
+ − 666
// create out-animation:
+ − 667
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 668
anim->hideOnFinished = true;
+ − 669
anim->setDuration((700 + (30 * i)) * Colors::animSpeedButtons);
+ − 670
anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 671
anim->setPosAt(0.60, QPointF(xOffset, 600 - ih - ih));
+ − 672
anim->setPosAt(0.65, QPointF(xOffset + 20, 600 - ih));
+ − 673
anim->setPosAt(1.00, QPointF(sw + iw, 600 - ih));
+ − 674
movieOut->append(anim);
+ − 675
+ − 676
// create shake-animation:
+ − 677
anim = new DemoItemAnimation(item);
+ − 678
anim->setDuration(700 * Colors::animSpeedButtons);
+ − 679
anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 680
anim->setPosAt(0.55, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*2.0));
+ − 681
anim->setPosAt(0.70, QPointF(xOffset - 10, (i * ihp) + yOffset + Colors::contentStartY - i*1.5));
+ − 682
anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*1.0));
+ − 683
anim->setPosAt(0.90, QPointF(xOffset - 2, (i * ihp) + yOffset + Colors::contentStartY - i*0.5));
+ − 684
anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 685
movieShake->append(anim);
+ − 686
+ − 687
// create next-menu top-out-animation:
+ − 688
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 689
anim->hideOnFinished = true;
+ − 690
anim->setDuration((200 + (30 * i)) * Colors::animSpeedButtons);
+ − 691
anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 692
anim->setPosAt(0.70, QPointF(xOffset, yOffset + Colors::contentStartY));
+ − 693
anim->setPosAt(1.00, QPointF(-iw, yOffset + Colors::contentStartY));
+ − 694
movieNextTopOut->append(anim);
+ − 695
+ − 696
// create next-menu bottom-out-animation:
+ − 697
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 698
anim->hideOnFinished = true;
+ − 699
anim->setDuration((200 + (30 * i)) * Colors::animSpeedButtons);
+ − 700
anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 701
anim->setPosAt(0.70, QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ − 702
anim->setPosAt(1.00, QPointF(-iw, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ − 703
movieNextBottomOut->append(anim);
+ − 704
+ − 705
// create next-menu top-in-animation:
+ − 706
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 707
anim->setDuration((700 - (30 * i)) * Colors::animSpeedButtons);
+ − 708
anim->setStartPos(QPointF(-iw, yOffset + Colors::contentStartY));
+ − 709
anim->setPosAt(0.30, QPointF(xOffset, yOffset + Colors::contentStartY));
+ − 710
anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 711
movieNextTopIn->append(anim);
+ − 712
+ − 713
// create next-menu bottom-in-animation:
+ − 714
int reverse = maxExamples - i;
+ − 715
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 716
anim->setDuration((1000 - (30 * reverse)) * Colors::animSpeedButtons);
+ − 717
anim->setStartPos(QPointF(-iw, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ − 718
anim->setPosAt(0.30, QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ − 719
anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ − 720
movieNextBottomIn->append(anim);
+ − 721
+ − 722
i++;
+ − 723
}
+ − 724
+ − 725
if (!currentNode.isNull() && i == maxExamples){
+ − 726
// We need another menu, so register for 'more' and 'back' buttons
+ − 727
++menuIndex;
+ − 728
this->info[currentMenu]["more"] = name + QLatin1String(" -menu") + QString::number(menuIndex);
+ − 729
currentMenu = name + QLatin1String(" -menu") + QString::number(menuIndex);
+ − 730
this->info[currentMenu]["back"] = name + QLatin1String(" -menu") + QString::number(menuIndex - 1);
+ − 731
}
+ − 732
}
+ − 733
}
+ − 734
+ − 735
+ − 736
void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type,
+ − 737
Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString)
+ − 738
{
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 739
TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL);
0
+ − 740
if (!menuString.isNull())
+ − 741
button->setMenuString(menuString);
+ − 742
button->setRecursiveVisible(false);
+ − 743
button->setZValue(10);
+ − 744
+ − 745
qreal iw = button->sceneBoundingRect().width();
+ − 746
int xOffset = 15;
+ − 747
+ − 748
// create in-animation:
+ − 749
DemoItemAnimation *buttonIn = new DemoItemAnimation(button, DemoItemAnimation::ANIM_IN);
+ − 750
buttonIn->setDuration(1800 * Colors::animSpeedButtons);
+ − 751
buttonIn->setStartPos(QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 752
buttonIn->setPosAt(0.5, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 753
buttonIn->setPosAt(0.7, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ − 754
buttonIn->setPosAt(1.0, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ − 755
movieIn->append(buttonIn);
+ − 756
+ − 757
// create out-animation:
+ − 758
DemoItemAnimation *buttonOut = new DemoItemAnimation(button, DemoItemAnimation::ANIM_OUT);
+ − 759
buttonOut->hideOnFinished = true;
+ − 760
buttonOut->setDuration(400 * Colors::animSpeedButtons);
+ − 761
buttonOut->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ − 762
buttonOut->setPosAt(1.0, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 26));
+ − 763
movieOut->append(buttonOut);
+ − 764
+ − 765
if (movieShake){
+ − 766
DemoItemAnimation *shakeAnim = new DemoItemAnimation(button, DemoItemAnimation::ANIM_UNSPECIFIED);
+ − 767
shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ − 768
shakeAnim->setDuration(650);
+ − 769
shakeAnim->setStartPos(buttonIn->posAt(1.0f));
+ − 770
shakeAnim->setPosAt(0.60, buttonIn->posAt(1.0f));
+ − 771
shakeAnim->setPosAt(0.70, buttonIn->posAt(1.0f) + QPointF(-3, 0));
+ − 772
shakeAnim->setPosAt(0.80, buttonIn->posAt(1.0f) + QPointF(2, 0));
+ − 773
shakeAnim->setPosAt(0.90, buttonIn->posAt(1.0f) + QPointF(-1, 0));
+ − 774
shakeAnim->setPosAt(1.00, buttonIn->posAt(1.0f));
+ − 775
movieShake->append(shakeAnim);
+ − 776
}
+ − 777
}
+ − 778
+ − 779
void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/)
+ − 780
{
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 781
TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL);
0
+ − 782
item->setRecursiveVisible(false);
+ − 783
item->setZValue(10);
+ − 784
+ − 785
qreal sw = this->window->scene->sceneRect().width();
+ − 786
int xOffset = 70;
+ − 787
+ − 788
// create in-animation:
+ − 789
DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 790
anim->setDuration(1800 * Colors::animSpeedButtons);
+ − 791
anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 792
anim->setPosAt(0.5, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 793
anim->setPosAt(0.7, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 35));
+ − 794
anim->setPosAt(1.0, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26));
+ − 795
movieIn->append(anim);
+ − 796
+ − 797
// create out-animation:
+ − 798
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 799
anim->hideOnFinished = true;
+ − 800
anim->setDuration(400 * Colors::animSpeedButtons);
+ − 801
anim->setStartPos(QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26));
+ − 802
anim->setPosAt(1.0, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 26));
+ − 803
movieOut->append(anim);
+ − 804
}
+ − 805
+ − 806
void MenuManager::createLowRightLeafButton(const QString &label, int xOffset, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/)
+ − 807
{
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 808
TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, this->window->mainSceneRoot, TextButton::PANEL);
0
+ − 809
item->setRecursiveVisible(false);
+ − 810
item->setZValue(10);
+ − 811
+ − 812
qreal sw = this->window->scene->sceneRect().width();
+ − 813
qreal sh = this->window->scene->sceneRect().height();
+ − 814
+ − 815
// create in-animation:
+ − 816
DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 817
anim->setDuration(1050 * Colors::animSpeedButtons);
+ − 818
anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 819
anim->setPosAt(0.10, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ − 820
anim->setPosAt(0.30, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ − 821
anim->setPosAt(0.35, QPointF(xOffset + 30, Colors::contentStartY + Colors::contentHeight - 35));
+ − 822
anim->setPosAt(0.40, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ − 823
anim->setPosAt(0.45, QPointF(xOffset + 5, Colors::contentStartY + Colors::contentHeight - 35));
+ − 824
anim->setPosAt(0.50, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ − 825
anim->setPosAt(1.00, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ − 826
movieIn->append(anim);
+ − 827
+ − 828
// create out-animation:
+ − 829
anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 830
anim->hideOnFinished = true;
+ − 831
anim->setDuration(300 * Colors::animSpeedButtons);
+ − 832
anim->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ − 833
anim->setPosAt(1.0, QPointF(xOffset, sh));
+ − 834
movieOut->append(anim);
+ − 835
}
+ − 836
+ − 837
void MenuManager::createInfo(DemoItem *item, const QString &name)
+ − 838
{
+ − 839
Movie *movie_in = this->score->insertMovie(name);
+ − 840
Movie *movie_out = this->score->insertMovie(name + " -out");
+ − 841
item->setZValue(8);
+ − 842
item->setRecursiveVisible(false);
+ − 843
+ − 844
float xOffset = 230.0f;
+ − 845
DemoItemAnimation *infoIn = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ − 846
infoIn->timeline->setCurveShape(QTimeLine::LinearCurve);
+ − 847
infoIn->setDuration(650);
+ − 848
infoIn->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY));
+ − 849
infoIn->setPosAt(0.60, QPointF(xOffset, Colors::contentStartY));
+ − 850
infoIn->setPosAt(0.70, QPointF(xOffset + 20, Colors::contentStartY));
+ − 851
infoIn->setPosAt(0.80, QPointF(xOffset, Colors::contentStartY));
+ − 852
infoIn->setPosAt(0.90, QPointF(xOffset + 7, Colors::contentStartY));
+ − 853
infoIn->setPosAt(1.00, QPointF(xOffset, Colors::contentStartY));
+ − 854
movie_in->append(infoIn);
+ − 855
+ − 856
DemoItemAnimation *infoOut = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ − 857
infoOut->timeline->setCurveShape(QTimeLine::EaseInCurve);
+ − 858
infoOut->setDuration(300);
+ − 859
infoOut->hideOnFinished = true;
+ − 860
infoOut->setStartPos(QPointF(xOffset, Colors::contentStartY));
+ − 861
infoOut->setPosAt(1.0, QPointF(-600, Colors::contentStartY));
+ − 862
movie_out->append(infoOut);
+ − 863
}
+ − 864
+ − 865
void MenuManager::createTicker()
+ − 866
{
+ − 867
if (!Colors::noTicker){
+ − 868
Movie *movie_in = this->score->insertMovie("ticker");
+ − 869
Movie *movie_out = this->score->insertMovie("ticker -out");
+ − 870
Movie *movie_activate = this->score->insertMovie("ticker -activate");
+ − 871
Movie *movie_deactivate = this->score->insertMovie("ticker -deactivate");
+ − 872
+ − 873
this->ticker = new ItemCircleAnimation(this->window->scene, 0);
+ − 874
this->ticker->setZValue(50);
+ − 875
this->ticker->hide();
+ − 876
+ − 877
// Move ticker in:
+ − 878
int qtendpos = 485;
+ − 879
int qtPosY = 120;
+ − 880
this->tickerInAnim = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_IN);
+ − 881
this->tickerInAnim->setDuration(500);
+ − 882
this->tickerInAnim->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY + qtPosY));
+ − 883
this->tickerInAnim->setPosAt(0.60, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 884
this->tickerInAnim->setPosAt(0.70, QPointF(qtendpos + 30, Colors::contentStartY + qtPosY));
+ − 885
this->tickerInAnim->setPosAt(0.80, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 886
this->tickerInAnim->setPosAt(0.90, QPointF(qtendpos + 5, Colors::contentStartY + qtPosY));
+ − 887
this->tickerInAnim->setPosAt(1.00, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 888
movie_in->append(this->tickerInAnim);
+ − 889
+ − 890
// Move ticker out:
+ − 891
DemoItemAnimation *qtOut = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_OUT);
+ − 892
qtOut->hideOnFinished = true;
+ − 893
qtOut->setDuration(500);
+ − 894
qtOut->setStartPos(QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 895
qtOut->setPosAt(1.00, QPointF(this->window->scene->sceneRect().width() + 700, Colors::contentStartY + qtPosY));
+ − 896
movie_out->append(qtOut);
+ − 897
+ − 898
// Move ticker in on activate:
+ − 899
DemoItemAnimation *qtActivate = new DemoItemAnimation(this->ticker);
+ − 900
qtActivate->setDuration(400);
+ − 901
qtActivate->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY + qtPosY));
+ − 902
qtActivate->setPosAt(0.60, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 903
qtActivate->setPosAt(0.70, QPointF(qtendpos + 30, Colors::contentStartY + qtPosY));
+ − 904
qtActivate->setPosAt(0.80, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 905
qtActivate->setPosAt(0.90, QPointF(qtendpos + 5, Colors::contentStartY + qtPosY));
+ − 906
qtActivate->setPosAt(1.00, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 907
movie_activate->append(qtActivate);
+ − 908
+ − 909
// Move ticker out on deactivate:
+ − 910
DemoItemAnimation *qtDeactivate = new DemoItemAnimation(this->ticker);
+ − 911
qtDeactivate->hideOnFinished = true;
+ − 912
qtDeactivate->setDuration(400);
+ − 913
qtDeactivate->setStartPos(QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ − 914
qtDeactivate->setPosAt(1.00, QPointF(qtendpos, 800));
+ − 915
movie_deactivate->append(qtDeactivate);
+ − 916
}
+ − 917
}
+ − 918
+ − 919
void MenuManager::createUpnDownButtons()
+ − 920
{
+ − 921
float xOffset = 15.0f;
+ − 922
float yOffset = 450.0f;
+ − 923
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 924
this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, this->window->mainSceneRoot, TextButton::UP);
0
+ − 925
this->upButton->prepare();
+ − 926
this->upButton->setPos(xOffset, yOffset);
+ − 927
this->upButton->setState(TextButton::DISABLED);
+ − 928
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 929
this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, this->window->mainSceneRoot, TextButton::DOWN);
0
+ − 930
this->downButton->prepare();
+ − 931
this->downButton->setPos(xOffset + 10 + this->downButton->sceneBoundingRect().width(), yOffset);
+ − 932
+ − 933
Movie *movieShake = this->score->insertMovie("upndown -shake");
+ − 934
+ − 935
DemoItemAnimation *shakeAnim = new DemoItemAnimation(this->upButton, DemoItemAnimation::ANIM_UNSPECIFIED);
+ − 936
shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ − 937
shakeAnim->setDuration(650);
+ − 938
shakeAnim->setStartPos(this->upButton->pos());
+ − 939
shakeAnim->setPosAt(0.60, this->upButton->pos());
+ − 940
shakeAnim->setPosAt(0.70, this->upButton->pos() + QPointF(-2, 0));
+ − 941
shakeAnim->setPosAt(0.80, this->upButton->pos() + QPointF(1, 0));
+ − 942
shakeAnim->setPosAt(0.90, this->upButton->pos() + QPointF(-1, 0));
+ − 943
shakeAnim->setPosAt(1.00, this->upButton->pos());
+ − 944
movieShake->append(shakeAnim);
+ − 945
+ − 946
shakeAnim = new DemoItemAnimation(this->downButton, DemoItemAnimation::ANIM_UNSPECIFIED);
+ − 947
shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ − 948
shakeAnim->setDuration(650);
+ − 949
shakeAnim->setStartPos(this->downButton->pos());
+ − 950
shakeAnim->setPosAt(0.60, this->downButton->pos());
+ − 951
shakeAnim->setPosAt(0.70, this->downButton->pos() + QPointF(-5, 0));
+ − 952
shakeAnim->setPosAt(0.80, this->downButton->pos() + QPointF(-3, 0));
+ − 953
shakeAnim->setPosAt(0.90, this->downButton->pos() + QPointF(-1, 0));
+ − 954
shakeAnim->setPosAt(1.00, this->downButton->pos());
+ − 955
movieShake->append(shakeAnim);
+ − 956
}
+ − 957
+ − 958
void MenuManager::createBackButton()
+ − 959
{
+ − 960
Movie *backIn = this->score->insertMovie("back -in");
+ − 961
Movie *backOut = this->score->insertMovie("back -out");
+ − 962
Movie *backShake = this->score->insertMovie("back -shake");
+ − 963
createLowLeftButton(QLatin1String("Back"), ROOT, backIn, backOut, backShake, Colors::rootMenuName);
+ − 964
}