ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/s10k/Vago/bgImageWizard/bgimagewizard.cpp
Revision: 1054
Committed: Wed Oct 12 21:35:13 2016 UTC (9 years ago) by s10k
Content type: text/x-c++src
Original Path: Vago/trunk/Vago/bgImageWizard/bgimagewizard.cpp
File size: 3143 byte(s)
Log Message:
Vago 1.1

File Contents

# Content
1 #include "bgimagewizard.h"
2
3 BGImageWizard::BGImageWizard(const QString &appDir, const QString &workspaceWizardLocation, QSettings *vagoSettings, Logger *myLogger)
4 {
5 this->appDir = appDir;
6 this->workspaceWizardLocation=workspaceWizardLocation;
7 this->vagoSettings=vagoSettings;
8 this->myLogger=myLogger;
9 this->bgImagesLocation=this->workspaceWizardLocation+"/BGImages";
10 }
11
12 int BGImageWizard::exec(){
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/background_image.png"));
22
23 //Center and resize QWizard (http://www.thedazzlersinc.com/source/2012/06/04/qt-center-window-in-screen/)
24 #ifdef Q_OS_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 BGImagePage2 *page2 = new BGImagePage2(this->myLogger);
36 BGImagePage3 *page3 = new BGImagePage3();
37 BGImagePageFinal *pageFinal = new BGImagePageFinal(this->appDir, this->myLogger, this->bgImagesLocation);
38
39 this->myWizard.addPage(createIntroPage());
40 this->myWizard.addPage(page2);
41 this->myWizard.addPage(page3);
42 this->myWizard.addPage(pageFinal);
43
44 this->myWizard.setWindowTitle("Background Image Wizard");
45
46 if(this->myWizard.exec()){ //modal and wait for finalization
47
48 }
49
50 return 0;
51 }
52
53 QWizardPage* BGImageWizard::createIntroPage() {
54 QWizardPage *page = new QWizardPage;
55 page->setTitle("Introduction");
56
57 QLabel *label = new QLabel("Welcome to the Oni Background Image Wizard.\n"
58 "This wizard will allow you to create in a few and simple steps Oni background images (TXMB) "
59 "that can be used in the menus or as backgrounds screens for the levels.");
60 label->setWordWrap(true);
61
62 QVBoxLayout *layout = new QVBoxLayout;
63 layout->addWidget(label);
64 page->setLayout(layout);
65
66 return page;
67 }
68
69 void BGImageWizard::restartWizard(){
70 this->myWizard.restart();
71 }
72
73 void BGImageWizard::pageChanged(int pageId){
74 // Last page?
75 if(pageId==3){
76 this->myWizard.setOption(QWizard::HaveCustomButton1, true); // set visible
77 this->myWizard.button(QWizard::BackButton)->setEnabled(false); // disable back button, use restart if needed
78 return;
79 }
80 this->myWizard.setOption(QWizard::HaveCustomButton1, false); // set invisible
81 this->myWizard.button(QWizard::BackButton)->setEnabled(true); // set enable back button
82 }