1 |
#include "soundwizard.h" |
2 |
|
3 |
SoundWizard::SoundWizard(QString appLocation, QString workspaceWizardLocation, Logger *myLogger, QHash<QString, QString> *commandMap) |
4 |
{ |
5 |
this->appLocation=appLocation; |
6 |
this->workspaceWizardLocation=workspaceWizardLocation; |
7 |
this->myLogger=myLogger; |
8 |
this->soundsLocation=this->workspaceWizardLocation+"/Sounds"; |
9 |
this->commandMap=commandMap; |
10 |
} |
11 |
|
12 |
int SoundWizard::exec(){ |
13 |
this->myWizard = new QWizard(); |
14 |
|
15 |
QPushButton *restartButton = new QPushButton("Restart"); |
16 |
this->myWizard->setButton(QWizard::CustomButton1,restartButton); |
17 |
this->myWizard->setOption(QWizard::HaveCustomButton1, true); |
18 |
|
19 |
connect(this->myWizard, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(int))); |
20 |
connect(restartButton, SIGNAL(clicked(bool)), this, SLOT(restartWizard())); |
21 |
|
22 |
this->myWizard->setWindowIcon(QIcon(":/new/icons/sound.png")); |
23 |
|
24 |
//Center and resize QWizard (http://www.thedazzlersinc.com/source/2012/06/04/qt-center-window-in-screen/) |
25 |
#ifdef Q_WS_WIN |
26 |
this->myWizard->resize(640,480); |
27 |
#else |
28 |
this->myWizard->resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better |
29 |
// because the components on mac use more space |
30 |
#endif |
31 |
QRect position = this->myWizard->frameGeometry(); |
32 |
position.moveCenter(QDesktopWidget().availableGeometry().center()); |
33 |
this->myWizard->move(position.topLeft()); |
34 |
// |
35 |
|
36 |
SoundPage2 *page2 = new SoundPage2(this->appLocation); |
37 |
SoundPage3 *page3 = new SoundPage3(); |
38 |
SoundPage4 *page4 = new SoundPage4(); |
39 |
SoundPageFinal *pageFinal = new SoundPageFinal(this->soundsLocation,page2->soundTable,this->myLogger, this->commandMap); |
40 |
|
41 |
this->myWizard->addPage(createIntroPage()); |
42 |
this->myWizard->addPage(page2); |
43 |
this->myWizard->addPage(page3); |
44 |
this->myWizard->addPage(page4); |
45 |
this->myWizard->addPage(pageFinal); |
46 |
|
47 |
this->myWizard->setWindowTitle("Sound wizard"); |
48 |
|
49 |
//If wizard finished with sucess |
50 |
if(this->myWizard->exec()){ //modal and wait for finalization |
51 |
//createPackage(this->myWizard, page4); |
52 |
} |
53 |
|
54 |
delete this->myWizard; // not needed anymore |
55 |
|
56 |
return 0; |
57 |
} |
58 |
|
59 |
QWizardPage* SoundWizard::createIntroPage() { |
60 |
QWizardPage *page = new QWizardPage; |
61 |
page->setTitle("Introduction"); |
62 |
|
63 |
QLabel *label = new QLabel("Welcome to the Oni Sound wizard.\n" |
64 |
"This wizard will allow you to convert in a few and simple steps sounds to oni format."); |
65 |
label->setWordWrap(true); |
66 |
|
67 |
QVBoxLayout *layout = new QVBoxLayout; |
68 |
layout->addWidget(label); |
69 |
page->setLayout(layout); |
70 |
|
71 |
return page; |
72 |
} |
73 |
|
74 |
void SoundWizard::restartWizard(){ |
75 |
this->myWizard->restart(); |
76 |
} |
77 |
|
78 |
void SoundWizard::pageChanged(int pageId){ |
79 |
// Last page? |
80 |
if(pageId==4){ |
81 |
this->myWizard->setOption(QWizard::HaveCustomButton1, true); // set visible |
82 |
this->myWizard->button(QWizard::BackButton)->setEnabled(false); // disable back button, use restart if needed |
83 |
return; |
84 |
} |
85 |
this->myWizard->setOption(QWizard::HaveCustomButton1, false); // set invisible |
86 |
this->myWizard->button(QWizard::BackButton)->setEnabled(true); // set enable back button |
87 |
} |