--- Vago/trunk/Vago/packageWizard/packagewizard.cpp 2016/09/16 22:51:26 1047 +++ s10k/Vago/packageWizard/packagewizard.cpp 2017/12/30 13:43:28 1092 @@ -1,91 +1,58 @@ #include "packagewizard.h" -PackageWizard::PackageWizard(QString workspaceWizardLocation, QSettings *vagoSettings, Logger *myLogger) +PackageWizard::PackageWizard(const QString &appDir, QString workspaceWizardLocation, QSettings *vagoSettings, Logger *myLogger) + :AbstractWizard(appDir, workspaceWizardLocation, vagoSettings, myLogger, false) { - this->workspaceWizardLocation=workspaceWizardLocation; - this->vagoSettings=vagoSettings; - this->myLogger=myLogger; this->packagesLocation=this->workspaceWizardLocation+"/Packages"; } -int PackageWizard::exec(){ - QWizard myWizard; - - myWizard.setWindowIcon(QIcon(":/new/icons/package.png")); - - //Center and resize QWizard (http://www.thedazzlersinc.com/source/2012/06/04/qt-center-window-in-screen/) -#ifdef Q_OS_WIN - myWizard.resize(640,480); -#else - myWizard.resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better - // because the components on mac use more space -#endif - QRect position = myWizard.frameGeometry(); - position.moveCenter(QDesktopWidget().availableGeometry().center()); - myWizard.move(position.topLeft()); - // - +void PackageWizard::exec(){ PackagePage2 *page2 = new PackagePage2(this->myLogger); PackagePage3 *page3 = new PackagePage3(); PackagePage4 *page4 = new PackagePage4(); + this->page4Pointer = page4; // save the pointer in class variable PackagePageFinal *pageFinal = new PackagePageFinal(this->vagoSettings); - myWizard.addPage(createIntroPage()); + myWizard.addPage( + createIntroPage( + "Welcome to the Anniversary Edition Installer 2 (AIE2) package" + " creator wizard.\n" + "This wizard will allow you to create in a few and simple steps a package for AIE2." + ) + ); myWizard.addPage(page2); myWizard.addPage(page3); myWizard.addPage(page4); myWizard.addPage(pageFinal); - myWizard.setWindowTitle("AIE2 Package Creator"); - - //If wizard finished with sucess - if(myWizard.exec()){ //modal and wait for finalization - createPackage(myWizard, page4); - } - - return 0; + showWizard("AIE2 Package Creator", ":/new/icons/package.png"); } -QWizardPage* PackageWizard::createIntroPage() { - QWizardPage *page = new QWizardPage; - page->setTitle("Introduction"); - - QLabel *label = new QLabel("Welcome to the Anniversary Edition Installer 2 (AIE2) package" - " creator wizard.\n" - "This wizard will allow you to create in a few and simple steps a package for AIE2."); - label->setWordWrap(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - page->setLayout(layout); - return page; -} - -void PackageWizard::createPackage(const QWizard &myWizard, PackagePage4 *page4){ +void PackageWizard::createPackage(){ const QString aeVersion="2.0"; //Get info page 2 - QString modName=myWizard.field("leModName").toString(); - QString authors=myWizard.field("leAuthors").toString(); - QString version=myWizard.field("leVersion").toString(); - QString description=myWizard.field("ptDescription").toString(); - QString packageNumber=myWizard.field("lePackageNumber").toString(); - bool bslReplace=myWizard.field("rbReplace").toBool(); + QString modName=this->myWizard.field("leModName").toString(); + QString authors=this->myWizard.field("leAuthors").toString(); + QString version=this->myWizard.field("leVersion").toString(); + QString description=this->myWizard.field("ptDescription").toString(); + QString packageNumber=this->myWizard.field("lePackageNumber").toString(); + bool bslReplace=this->myWizard.field("rbReplace").toBool(); //Get info page 3 - QString dependentPackages=myWizard.field("leDependentPackages").toString(); - QString incompatiblePackages=myWizard.field("leIncompatiblePackages").toString(); - QString unlockLevels=myWizard.field("leUnlockLevels").toString(); + QString dependentPackages=this->myWizard.field("leDependentPackages").toString(); + QString incompatiblePackages=this->myWizard.field("leIncompatiblePackages").toString(); + QString unlockLevels=this->myWizard.field("leUnlockLevels").toString(); //Get info page 4 - const DropTableWidget *commonTable=page4->commonTable; - const DropTableWidget *windowsTable=page4->windowsTable; - const DropTableWidget *macTable=page4->macTable; + const DropTableWidget *commonTable=this->page4Pointer->commonTable; + const DropTableWidget *windowsTable=this->page4Pointer->windowsTable; + const DropTableWidget *macTable=this->page4Pointer->macTable; //Get info from final page - bool openFolder=myWizard.field("cbOpenFolder").toBool(); - bool createZip=myWizard.field("cbCreateZip").toBool(); + bool openFolder=this->myWizard.field("cbOpenFolder").toBool(); + bool createZip=this->myWizard.field("cbCreateZip").toBool(); //Remember the final page choices to next time this->vagoSettings->setValue("PackageCreator/OpenFolder",openFolder); this->vagoSettings->setValue("PackageCreator/CreateZip",createZip); @@ -201,3 +168,12 @@ void PackageWizard::copyPackageFolders(c } } } + +void PackageWizard::beforeClose(QDialog::DialogCode resultStatus){ + + //If wizard finished with sucess, create the package + if(resultStatus == QDialog::Accepted){ + createPackage(); + } +} +