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