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