-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·74 lines (58 loc) · 1.93 KB
/
main.cpp
File metadata and controls
executable file
·74 lines (58 loc) · 1.93 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
//AUTHORS: Matt Dumford, Anthony Phelps
#include "mainwindow.h"
#include "mainmenu.h"
#include "win_menu.h"
#include "gridsizescreen.h"
#include "usernamescreen.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QFile>
#include <QTextStream>
#include <QDir>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//set up width and height
QDesktopWidget *desktop = QApplication::desktop();
int screenWidth = desktop->width();
int screenHeight = desktop->height();
//create main window
MainWindow mainWindow;
mainWindow.setOrientation(MainWindow::ScreenOrientationLockPortrait);
mainWindow.resize(screenWidth, screenHeight);
mainWindow.showExpanded();
//check if there is already a username
//open directory to pictures folder
QDir dir = QDir(QDir::rootPath());
dir.cd("sdcard");
if(!dir.entryList().contains("Puzzle Pictures"))
dir.mkdir("Puzzle Pictures");
dir.cd("Puzzle Pictures");
//get list of files in pictures folder
QStringList files = dir.entryList();
//if there is already a username, give it to the main window and create a main menu
if(files.contains("user.name"))
{
QFile file(dir.absolutePath() + "/user.name");
QStringList strings;
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
while (!in.atEnd()) {
strings += in.readLine().split(";");
}
}
mainWindow.setUserName(strings.at(0));
qDebug() << mainWindow.getUserName();
MainMenu *mm = new MainMenu(&mainWindow, &mainWindow);
mm->display(screenWidth, screenHeight);
}
//if there is no username, make a username screen and get one
else
{
UsernameScreen *uns = new UsernameScreen(&mainWindow, &mainWindow);
uns->display(screenWidth, screenHeight);
}
return app.exec();
}