-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·78 lines (61 loc) · 2.45 KB
/
Copy pathmain.cpp
File metadata and controls
executable file
·78 lines (61 loc) · 2.45 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
/*
Yellowcot 1.2.6, released 2013-03-23
Copyleft 2013 Anthony Karam Karam
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui>
#include "mainwindow.h"
#include "yellowcot.h"
int main(int argc, char *argv[]) {
//define qapplication class
QApplication app(argc, argv);
//make string variable
char str[STRLEN];
//make file object
FILE *file;
//quit if it is not the only Yellowcot instance
memset(str, 0, STRLEN);
sprintf(str, "%s", TMPDIR);
if ((file = fopen(str, "r"))) {
memset(str, 0, STRLEN);
sprintf(str, "Multiple, simultaneous instances of Yellowcot is not yet a supported feature. If you are certain another instance is not running, you may execute \"sudo rm -r %s\".", TMPDIR);
QMessageBox::critical(0, QString("Fatal Error"), QString(str));
return 1;
fclose (file);
}
//create temporary directory for yellowcot quiz
sysprintf("mkdir %s", TMPDIR);
//create config file if it doesn't already exist
sysprintf("cp ~/.yellowcot/config %s/config > /dev/null 2>&1", TMPDIR);
memset(str, 0, STRLEN);
sprintf(str, "%s/config", TMPDIR);
if ((file = fopen(str, "r"))) {
fclose(file);
remove(str);
}
else {
sysprintf("echo -e \"# Yellowcot configuration file\n#\n# If you'd like to use a font other than the default, specify\n# its path (e.g. /usr/local/share/fonts/c/code2000.ttf) here.\n#font=\n# Specify the font size here.\nfontsize=24\" > %s/config", TMPDIR);
sysprintf("mkdir ~/.yellowcot");
sysprintf("mv %s/config ~/.yellowcot/config", TMPDIR);
}
//start translator
QTranslator translator;
translator.load(QString("yellowcot_") + QLocale::system().name());
app.installTranslator(&translator);
//create and show main window
MainWindow mainWindow;
mainWindow.show();
//delete temporary file when yellowcot is about to quit
QObject::connect(&app, SIGNAL(aboutToQuit()), &mainWindow, SLOT(removeTempFiles()));
//pass control to qt
return app.exec();
}