-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
executable file
·171 lines (144 loc) · 4.08 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setUI();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setUI()
{
configDir = QDir::homePath()+"/windeployConfig.appconfig";
setFixedSize(542, 242);
readConfig();
if (WindeployQtLocation == "")
ui->stackedWidget->setCurrentIndex(0);
else
ui->stackedWidget->setCurrentIndex(2);
}
void MainWindow::readConfig()
{
QFile file(configDir);
if (!file.open(QIODevice::ReadOnly | QFile::Text))
{
WindeployQtLocation = "";
return;
}
QTextStream in(&file);
WindeployQtLocation = in.readAll();
file.close();
}
void MainWindow::writeConfig()
{
QFile file(configDir);
if(!file.open(QIODevice::WriteOnly | QFile::Text))
{
return;
}
QTextStream out(&file);
QString text = ui->windeploySource->text();
out << text;
file.close();
}
void MainWindow::on_continueBtn_clicked()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::on_browseBtn_clicked()
{
WindeployQtLocation = QFileDialog::getOpenFileName(this, "Select the Location");
ui->windeploySource->setText(WindeployQtLocation);
}
void MainWindow::on_continueBtn2_clicked()
{
if (ui->windeploySource->text() == "")
QMessageBox::warning(this, "Warning", "You are about to leaving environment unset. Browse the windeployqt location.");
else
{
ui->stackedWidget->setCurrentIndex(2);
writeConfig();
}
}
void MainWindow::on_projectBrowseBtn_clicked()
{
if (ui->stackedWidget->currentIndex() == 2)
{
ProjectSource = QFileDialog::getOpenFileName(this, "Select exe");
ui->projectSource->setText(ProjectSource);
QFileInfo f;
f.setFile(ProjectSource);
if (f.canonicalPath().endsWith("/release"))
{
ui->qmlRelease->setChecked(true);
}
else if (f.canonicalPath().endsWith("/debug"))
{
ui->qmlDebug->setChecked(true);
}
}
else
{
ui->stackedWidget->setCurrentIndex(2);
on_projectBrowseBtn_clicked();
}
}
void MainWindow::on_generateBtn_clicked()
{
QString l = "\"";
QString fil = WindeployQtLocation + " " + l + ui->projectSource->text() + l;
const char* cmd = fil.toLocal8Bit().constData();
int i = system(cmd);
(i == 0)? ui->errorString->setText("<p style=\"color: #009B34\">Generated Successfully!</p>") : ui->errorString->setText("<p style=\"color: #FF0000\">Generate failed! Check the path and try again</p>");
}
void MainWindow::on_actionBrowse_triggered()
{
on_projectBrowseBtn_clicked();
}
void MainWindow::on_actionQuit_triggered()
{
MainWindow::close();
}
void MainWindow::on_actionSettings_triggered()
{
ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::on_actionReset_triggered()
{
QString l = "\"";
QString fil = "del " + l + configDir + l;
const char* cmd = fil.toLocal8Bit().constData();
system(cmd);
}
void MainWindow::on_actionMinimize_triggered()
{
MainWindow::showMinimized();
}
void MainWindow::on_actionAbout_Qt_triggered()
{
QMessageBox::aboutQt(this, "About Qt");
}
void MainWindow::on_generateQmlBtn_clicked()
{
QString l = "\"";
QString type = (ui->qmlDebug->isChecked())? "--debug" : "--release"; //"--debug";
QString dir = " --qmldir C:/Qt/5.15.2/mingw81_64/qml ";
QString fil = WindeployQtLocation + " " + type + dir + l + ui->projectSource->text() + l;
const char* cmd = fil.toLocal8Bit().constData();
int i = system(cmd);
(i == 0)? ui->errorString->setText("<p style=\"color: #009B34\">Generated Successfully!</p>") : ui->errorString->setText("<p style=\"color: #FF0000\">Generate failed! Check the path and try again</p>");
}
void MainWindow::on_label_6_linkActivated()
{
ui->stackedWidget->setCurrentIndex(2);
}
void MainWindow::on_actionFollow_me_on_twitter_triggered()
{
QUrl url;
url.setUrl("https://twitter.com/prog_naveed");
QDesktopServices::openUrl(url);
}