-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
154 lines (111 loc) · 4.63 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
#include "MainWindow.h"
#include "ui_mainwindow.h"
\
#include "TournamentMenu.h"
#include "EnterTournamentNameDialog.h"
#include "MainMenu.h"
#include <QVBoxLayout>
#include <memory>
#include <fstream>
#include <QDir>
#include <QFileInfo>
#include <QFileDialog>
#include <QStandardPaths>
#include <QCloseEvent>
#include <QMessageBox>
#include "RoundMenu.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setStyleSheet("color: black;"
"background-color: #58CCED;"
"selection-color: white;"
"selection-background-color: blue;");
//white FFFFFF
//creamish F9DFCB
//light blue CBEFF9
//medium blue 58CCED
pointerToMainWindow = this;
ui->textBrowser->setStyleSheet("QTextBrowser {background-color: #FFFFFF}");
ui->startTournamentButton->setStyleSheet("QPushButton::hover{background-color : lightgreen;}"
"QPushButton {background-color: #FFFFFF}");
ui->continueTournamentButton->setStyleSheet("QPushButton::hover{background-color : lightgreen;}"
"QPushButton {background-color: #FFFFFF}");
ui->exitButton->setStyleSheet("QPushButton::hover{background-color : lightgreen;}"
"QPushButton {background-color: #FFFFFF}");
//ui->continueTournamentButton->setEnabled(true);
this->setWindowTitle("Jackbox Tournament Manager");
this->setMinimumWidth(100);
this->setMinimumHeight(50);
QMediaPlayer *player = new QMediaPlayer;
this->player = player;
// ...
//player->setMedia(QUrl::fromLocalFile("C:\\TestDirectory"));
player->setVolume(100);
player->play();
MainMenu *MM = new MainMenu(this->pointerToMainWindow);
this->setCentralWidget(MM);
//setStyleSheet("QMessageBox{background: rgb(255,0,0); border: none;font-family: Arial; font-style: normal; font-size: 15pt; color: #000000 ; }");
}
MainWindow::MainWindow(QMainWindow *pointerToMainWindow){
this->pointerToMainWindow = pointerToMainWindow;
MainMenu *MM = new MainMenu(this->pointerToMainWindow);
this->setCentralWidget(MM);
//setStyleSheet("QMessageBox{background: rgb(255,0,0); border: none;font-family: Arial; font-style: normal; font-size: 15pt; color: #000000 ; }");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_exitButton_clicked()
{
//delete ui;
//this->close();
}
void MainWindow::on_startTournamentButton_clicked()
{
EnterTournamentName ETR(this);
ETR.exec();
std::string tournamentName = ETR.getTournamentName();
formatPlayersInTournamentFile();
std::shared_ptr<Tournament> T = std::make_shared<Tournament>(tournamentName);
QMainWindow *ptrToWindow = this;
TournamentMenu *TM = new TournamentMenu(std::move(T), ptrToWindow);
//TM->show()
//instead of the above ^^^
setCentralWidget(TM);
//This makes it so that instead of popping up an entirely new window, we just update the main window by changing the central widget contents.
//(For every menu I want to do this with, it requires me adding a QMainWindow *PointerToMainWindow so I have a way to reference the main window and change the central widget.
//this->resize(338,528);
}
void MainWindow::on_continueTournamentButton_clicked()
{
std::shared_ptr<Tournament> T = std::make_shared<Tournament>();
QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
path = path + "/JBT Saved Tournaments";
QString folder_name = QFileDialog::getExistingDirectory(this, "Choose a tournament to load.", path);
T->deserializeTournamentName(folder_name);
T->deserializeTournamentPlayers(folder_name);
T->deserializeAllRounds(folder_name);
TournamentMenu *TM = new TournamentMenu(std::move(T));
TM->show();
}
void MainWindow::formatPlayersInTournamentFile(){
std::ofstream OUTFILE;
OUTFILE.open("C:\\Users\\George\\Desktop\\people.txt");
//OUTFILE << "LIST OF PLAYERS IN TOURNAMENT" << "\n";
OUTFILE.close();
}
QWidget* MainWindow::getCenterWidget(){
return this->centerWidget;
}
void MainWindow::closeEvent(QCloseEvent *event) // show prompt when user wants to close app
{
event->ignore();
if (QMessageBox::Yes == QMessageBox::question(this, "Close Confirmation", "Exit?\nUNSAVED CHANGES WILL BE LOST", QMessageBox::Yes | QMessageBox::No))
{
event->accept();
}
}