-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
118 lines (98 loc) · 3.39 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* This file is part of t411 Client Installer.
t411 Client Installer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
t411 Client Installer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t411 Client Installer. If not, see <http://www.gnu.org/licenses/>. */
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Détection du Windows
QString os;
if (QSysInfo::windowsVersion() == QSysInfo::WV_NT)
os = "Windows NT";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_2000)
os = "Windows 2000";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_XP)
os = "Windows XP";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_2003)
os = "Windows XP x64";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_VISTA)
os = "Windows Vista";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS7)
os = "Windows 7";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8)
os = "Windows 8";
else if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS8_1)
os = "Windows 8.1";
else
os = "Windows";
installer = new Installer(this, os);
connect(installer, SIGNAL(refreshLayout(QGridLayout*)), this, SLOT(refreshLayout(QGridLayout*)));
installer->determineClient();
installer->doNextStage();
}
MainWindow::~MainWindow()
{
clear();
delete ui;
delete installer;
}
void MainWindow::refreshLayout(QGridLayout *newlayout)
{
clear();
ui->o_content->setLayout(newlayout);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if (ui->b_suivant->text() == "Terminer")
installer->pressedFinish();
QMessageBox wannaQuit(QMessageBox::Question, "Quitter", "Voulez-vous vraiment quitter l'installation ?", QMessageBox::Yes | QMessageBox::No);
wannaQuit.setButtonText(QMessageBox::Yes, "Oui");
wannaQuit.setButtonText(QMessageBox::No, "Non");
wannaQuit.setDefaultButton(QMessageBox::No);
if (wannaQuit.exec() == QMessageBox::Yes)
event->accept();
else
event->ignore();
}
void MainWindow::pressedQuit()
{
close();
}
void MainWindow::pressedNext()
{
ui->b_suivant->setDisabled(true);
installer->doNextStage();
}
void MainWindow::enableNext()
{
ui->b_suivant->setEnabled(true);
}
void MainWindow::disableQuit()
{
ui->b_quitter->setDisabled(true);
}
void MainWindow::enableFinish()
{
ui->b_suivant->setText("Terminer");
ui->b_suivant->setEnabled(true);
ui->b_suivant->disconnect();
connect(ui->b_suivant, SIGNAL(released()), installer, SLOT(pressedFinish()));
}
void MainWindow::clear()
{
foreach (QWidget *w, ui->o_content->findChildren<QWidget*>())
if (w->objectName() != "t411label" && w->objectName() != "aboutlabel")
w->deleteLater();
delete ui->o_content->layout();
}