-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
142 lines (114 loc) · 3.51 KB
/
mainwindow.cpp
File metadata and controls
142 lines (114 loc) · 3.51 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
//will clean up includes later
#include <QApplication>
#include <QtGui>
#include <QFileDialog>
#include <QFileSystemModel>
#include <QLineEdit>
QString tempDirPath = QDir::homePath() + "/.sourceInstallerTemp/";
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
/*QMessageBox msgBox;
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText("Click File > Automatic Mode to start automatic compiling.");
msgBox.exec();
*/
}
MainWindow::~MainWindow()
{
delete ui;
}
QString getFile()
{
return (QFileDialog::getOpenFileName(0,"Choose a tar.gz or tar.bz2 file to compile...",QDir::homePath(),"Compressed tarball files (*.tar.gz *.tar.bz2)"));
}
void extractFile(QString sourceFile)
{
if (sourceFile == "" || !(QFile::exists(sourceFile)) ||(!(sourceFile.right(4)==".bz2" && !(sourceFile.right(3)==".gz"))))
{
QMessageBox msgBox;
msgBox.setText("No file set or file does not exist!");
msgBox.exec();
return;
}
QProcess::execute("mkdir "+ tempDirPath);
if (sourceFile.right(4)==".bz2")
QProcess::execute("tar -xJf "+ sourceFile + " -C " + tempDirPath);
else if (sourceFile.right(3)==".gz")
QProcess::execute("tar -xzf "+ sourceFile + " -C " + tempDirPath);
QMessageBox msgBox;
msgBox.setText(tempDirPath);
msgBox.exec();
return;
}
void buildStart(QString buildCommand, QString envVariables, QString makeOptions)
{
QProcess::execute(buildCommand);
QProcess::execute("make " + makeOptions);
/*
QWidget sudoPassDialog;
QLabel *passwordLabel = new QLabel("Enter your sudo password to install this application or click Cancel not to.");
QLineEdit *passwordBox = new QLineEdit(&sudoPassDialog);
sudoPassDialog.show();
*/
}
void MainWindow::on_autoCompileButton_clicked()
{
extractFile(ui->dirTextAuto->text());
//getBuildType();
}
void MainWindow::on_browseButtonAuto_clicked()
{
QString sourceFilePath = getFile();
ui->dirTextAuto->setText(sourceFilePath);
ui->dirTextAdvanced->setText(sourceFilePath);
ui->dirTextManual->setText(sourceFilePath);
}
void MainWindow::on_browseButtonManual_clicked()
{
QString sourceFilePath = getFile();
ui->dirTextAuto->setText(sourceFilePath);
ui->dirTextAdvanced->setText(sourceFilePath);
ui->dirTextManual->setText(sourceFilePath);
}
void MainWindow::on_browseButtonAdvanced_clicked()
{
QString sourceFilePath = getFile();
ui->dirTextAuto->setText(sourceFilePath);
ui->dirTextAdvanced->setText(sourceFilePath);
ui->dirTextManual->setText(sourceFilePath);
}
void MainWindow::on_pushButton_clicked()
{
buildStart("./configure","","");
}
void MainWindow::on_manualCompileButton_clicked()
{
if (ui->configSource->isChecked())
{
if (QFile::exists(tempDirPath+"/configure"))
{
buildStart(tempDirPath + "/configure", "","");
}
else
{
}
}
else if (ui->qtSource->isChecked())
buildStart("mkdir "+tempDirPath+"/Build; cd "+tempDirPath+"; qmake ..","","");
else if (ui->autogenSource->isChecked()&& QFile::exists(tempDirPath+"/autogen.sh"));
//buildStart(tempDirPath+"/autogen.sh");
}
void MainWindow::on_actionQuit_triggered()
{
exit(0);
}
void MainWindow::on_advancedCompileButton_clicked()
{
if (ui->qtSource_2->isChecked())
buildStart(ui->customCompileCommand->text(), ui->ENV_VARS->text(), ui->makeFlags->text());
}