ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/packageWizard/packagewizard.cpp
(Generate patch)

Comparing:
Vago/trunk/Vago/packageWizard/packagewizard.cpp (file contents), Revision 1047 by s10k, Fri Sep 16 22:51:26 2016 UTC vs.
s10k/Vago/packageWizard/packagewizard.cpp (file contents), Revision 1093 by s10k, Sat Dec 30 13:57:32 2017 UTC

# Line 1 | Line 1
1   #include "packagewizard.h"
2  
3 < PackageWizard::PackageWizard(QString workspaceWizardLocation, QSettings *vagoSettings, Logger *myLogger)
3 > PackageWizard::PackageWizard(const QString &appDir, QString workspaceWizardLocation, QSettings *vagoSettings)
4 >    :AbstractWizard(appDir, workspaceWizardLocation, vagoSettings, false)
5   {
5    this->workspaceWizardLocation=workspaceWizardLocation;
6    this->vagoSettings=vagoSettings;
7    this->myLogger=myLogger;
6      this->packagesLocation=this->workspaceWizardLocation+"/Packages";
7   }
8  
9 < int PackageWizard::exec(){
10 <    QWizard myWizard;
13 <
14 <    myWizard.setWindowIcon(QIcon(":/new/icons/package.png"));
15 <
16 <    //Center and resize QWizard (http://www.thedazzlersinc.com/source/2012/06/04/qt-center-window-in-screen/)
17 < #ifdef Q_OS_WIN
18 <    myWizard.resize(640,480);
19 < #else
20 <    myWizard.resize(800,600); // Mac OS pcs should be able to render this resolution without any problem. It's also better
21 <    // because the components on mac use more space
22 < #endif
23 <    QRect position = myWizard.frameGeometry();
24 <    position.moveCenter(QDesktopWidget().availableGeometry().center());
25 <    myWizard.move(position.topLeft());
26 <    //
27 <
28 <    PackagePage2 *page2 = new PackagePage2(this->myLogger);
9 > void PackageWizard::exec(){
10 >    PackagePage2 *page2 = new PackagePage2();
11      PackagePage3 *page3 = new PackagePage3();
12      PackagePage4 *page4 = new PackagePage4();
13 +    this->page4Pointer = page4; // save the pointer in class variable
14      PackagePageFinal *pageFinal = new PackagePageFinal(this->vagoSettings);
15  
16 <    myWizard.addPage(createIntroPage());
16 >    myWizard.addPage(
17 >        createIntroPage(
18 >                        "Welcome to the Anniversary Edition Installer 2 (AIE2) package"
19 >                         " creator wizard.\n"
20 >                         "This wizard will allow you to create in a few and simple steps a package for AIE2."
21 >                        )
22 >   );
23      myWizard.addPage(page2);
24      myWizard.addPage(page3);
25      myWizard.addPage(page4);
26      myWizard.addPage(pageFinal);
27  
28 <    myWizard.setWindowTitle("AIE2 Package Creator");
40 <
41 <    //If wizard finished with sucess
42 <    if(myWizard.exec()){ //modal and wait for finalization
43 <        createPackage(myWizard, page4);
44 <    }
45 <
46 <    return 0;
28 >    showWizard("AIE2 Package Creator", ":/new/icons/package.png");
29   }
30  
49 QWizardPage* PackageWizard::createIntroPage() {
50    QWizardPage *page = new QWizardPage;
51    page->setTitle("Introduction");
52
53    QLabel *label = new QLabel("Welcome to the Anniversary Edition Installer 2 (AIE2) package"
54                               " creator wizard.\n"
55                               "This wizard will allow you to create in a few and simple steps a package for AIE2.");
56    label->setWordWrap(true);
57
58    QVBoxLayout *layout = new QVBoxLayout;
59    layout->addWidget(label);
60    page->setLayout(layout);
31  
32 <    return page;
63 < }
64 <
65 < void PackageWizard::createPackage(const QWizard &myWizard, PackagePage4 *page4){
32 > void PackageWizard::createPackage(){
33      const QString aeVersion="2.0";
34  
35      //Get info page 2
36 <    QString modName=myWizard.field("leModName").toString();
37 <    QString authors=myWizard.field("leAuthors").toString();
38 <    QString version=myWizard.field("leVersion").toString();
39 <    QString description=myWizard.field("ptDescription").toString();
40 <    QString packageNumber=myWizard.field("lePackageNumber").toString();
41 <    bool bslReplace=myWizard.field("rbReplace").toBool();
36 >    QString modName=this->myWizard.field("leModName").toString();
37 >    QString authors=this->myWizard.field("leAuthors").toString();
38 >    QString version=this->myWizard.field("leVersion").toString();
39 >    QString description=this->myWizard.field("ptDescription").toString();
40 >    QString packageNumber=this->myWizard.field("lePackageNumber").toString();
41 >    bool bslReplace=this->myWizard.field("rbReplace").toBool();
42  
43      //Get info page 3
44 <    QString dependentPackages=myWizard.field("leDependentPackages").toString();
45 <    QString incompatiblePackages=myWizard.field("leIncompatiblePackages").toString();
46 <    QString unlockLevels=myWizard.field("leUnlockLevels").toString();
44 >    QString dependentPackages=this->myWizard.field("leDependentPackages").toString();
45 >    QString incompatiblePackages=this->myWizard.field("leIncompatiblePackages").toString();
46 >    QString unlockLevels=this->myWizard.field("leUnlockLevels").toString();
47  
48      //Get info page 4
49 <    const DropTableWidget *commonTable=page4->commonTable;
50 <    const DropTableWidget *windowsTable=page4->windowsTable;
51 <    const DropTableWidget *macTable=page4->macTable;
49 >    const DropTableWidget *commonTable=this->page4Pointer->commonTable;
50 >    const DropTableWidget *windowsTable=this->page4Pointer->windowsTable;
51 >    const DropTableWidget *macTable=this->page4Pointer->macTable;
52  
53      //Get info from final page
54 <    bool openFolder=myWizard.field("cbOpenFolder").toBool();
55 <    bool createZip=myWizard.field("cbCreateZip").toBool();
54 >    bool openFolder=this->myWizard.field("cbOpenFolder").toBool();
55 >    bool createZip=this->myWizard.field("cbCreateZip").toBool();
56      //Remember the final page choices to next time
57      this->vagoSettings->setValue("PackageCreator/OpenFolder",openFolder);
58      this->vagoSettings->setValue("PackageCreator/CreateZip",createZip);
59  
60 <    const QString packageName=packageNumber+Util::fullTrim(modName);
60 >    const QString packageName=packageNumber+Util::String::fullTrim(modName);
61  
62      // Start package creation...
63  
# Line 120 | Line 87 | void PackageWizard::createPackage(const
87      QFile modInfo(modDir+"Mod_Info.cfg");
88  
89      if (!modInfo.open(QIODevice::WriteOnly | QIODevice::Text)){ //open to write
90 <        UtilVago::showAndLogErrorPopUp(this->myLogger, "Couldn't create Mod_Info.cfg file when creating AE Package.");
90 >        UtilVago::showAndLogErrorPopUp("Couldn't create Mod_Info.cfg file when creating AE Package.");
91          return;
92      }
93  
# Line 156 | Line 123 | void PackageWizard::createPackage(const
123  
124      if(createZip){
125          if(!JlCompress::compressDir(this->packagesLocation+"/"+packageName+".zip", modDir)){
126 <            UtilVago::showAndLogErrorPopUp(this->myLogger, "An error occurred while zipping the package.");
126 >            UtilVago::showAndLogErrorPopUp("An error occurred while zipping the package.");
127          }
128      }
129  
# Line 194 | Line 161 | void PackageWizard::copyPackageFolders(c
161              }
162          }
163          QDir().mkpath(path); //create path if doesn't exist
164 <        if(!Util::copyDir(sourceFolder,path,false)){//copy contents (creates dest destination automatically if not exists yet)
164 >        if(!Util::FileSystem::copyDir(sourceFolder,path,false)){//copy contents (creates dest destination automatically if not exists yet)
165  
166 <         UtilVago::showAndLogErrorPopUpLogButton(this->myLogger, "An error occurred while copying the folder/files to the package folder: \n"
166 >         UtilVago::showAndLogErrorPopUpLogButton("An error occurred while copying the folder/files to the package folder: \n"
167                                                          "Copying from "+sourceFolder+"\n to "+path);
168          }
169      }
170   }
171 +
172 + void PackageWizard::beforeClose(QDialog::DialogCode resultStatus){
173 +
174 +    //If wizard finished with sucess, create the package
175 +    if(resultStatus == QDialog::Accepted){
176 +        createPackage();
177 +    }
178 + }
179 +

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)