ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/soundWizard/soundwizard.cpp
Revision: 793
Committed: Sat Apr 6 23:30:00 2013 UTC (12 years, 6 months ago) by s10k
Content type: text/x-c++src
Original Path: Vago/trunk/Vago/soundWizard/soundwizard.cpp
File size: 3197 byte(s)
Log Message:
mac resolutions usually are higher than in pcs. So I've updated the app
to start as 800x600 (in mac).

File Contents

# Content
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 #ifdef Q_WS_WIN
25 this->myWizard->resize(640,480);
26 #else
27 this->myWizard->resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better
28 // because the components on mac use more space
29 #endif
30 QRect position = this->myWizard->frameGeometry();
31 position.moveCenter(QDesktopWidget().availableGeometry().center());
32 this->myWizard->move(position.topLeft());
33 //
34
35 SoundPage2 *page2 = new SoundPage2();
36 SoundPage3 *page3 = new SoundPage3();
37 SoundPage4 *page4 = new SoundPage4();
38 SoundPageFinal *pageFinal = new SoundPageFinal(this->soundsLocation,page2->soundTable,this->myLogger, this->commandMap);
39
40 this->myWizard->addPage(createIntroPage());
41 this->myWizard->addPage(page2);
42 this->myWizard->addPage(page3);
43 this->myWizard->addPage(page4);
44 this->myWizard->addPage(pageFinal);
45
46 this->myWizard->setWindowTitle("Sound wizard");
47
48 //If wizard finished with sucess
49 if(this->myWizard->exec()){ //modal and wait for finalization
50 //createPackage(this->myWizard, page4);
51 }
52
53 delete this->myWizard; // not needed anymore
54
55 return 0;
56 }
57
58 QWizardPage* SoundWizard::createIntroPage() {
59 QWizardPage *page = new QWizardPage;
60 page->setTitle("Introduction");
61
62 QLabel *label = new QLabel("Welcome to the Oni Sound wizard.\n"
63 "This wizard will allow you to convert in a few and simple steps sounds to oni format.");
64 label->setWordWrap(true);
65
66 QVBoxLayout *layout = new QVBoxLayout;
67 layout->addWidget(label);
68 page->setLayout(layout);
69
70 return page;
71 }
72
73 void SoundWizard::restartWizard(){
74 this->myWizard->restart();
75 }
76
77 void SoundWizard::pageChanged(int pageId){
78 // Last page?
79 if(pageId==4){
80 this->myWizard->setOption(QWizard::HaveCustomButton1, true); // set visible
81 this->myWizard->button(QWizard::BackButton)->setEnabled(false); // disable back button, use restart if needed
82 return;
83 }
84 this->myWizard->setOption(QWizard::HaveCustomButton1, false); // set invisible
85 this->myWizard->button(QWizard::BackButton)->setEnabled(true); // set enable back button
86 }