forked from trolley813/OpenFool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
62 lines (53 loc) · 1.97 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
#include "mainwindow.h"
#include "settingsdialog.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QDesktopServices>
#include <QUrl>
#include <QLabel>
#include <QOpenGLWidget>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
"hyst329", "OpenFool", this);
if (settings->value("rendering/opengl", false).toBool())
ui->graphicsView->setViewport(new QOpenGLWidget);
table = new Table(settings, this);
ui->graphicsView->setScene(table);
QLabel *gameLabel = new QLabel(tr("Game status"));
ui->statusBar->addWidget(gameLabel);
connect(table, SIGNAL(setGameStatusText(QString)), gameLabel,
SLOT(setText(QString)));
resizeEvent(nullptr); // it's safe because event value isn't actually used
}
MainWindow::~MainWindow() { delete ui; }
void MainWindow::resizeEvent(QResizeEvent *event)
{
QRectF bounds = table->sceneRect();
ui->graphicsView->fitInView(bounds, Qt::KeepAspectRatio);
}
void MainWindow::on_actionNew_Game_triggered() { table->newGame(); }
void MainWindow::on_actionStats_triggered()
{
QMessageBox::information(this, tr("Stats isn't yet implemented..."),
tr("But it is planned in future versions."));
}
void MainWindow::on_actionSettings_triggered()
{
SettingsDialog *sd = new SettingsDialog(settings, this);
sd->show();
}
void MainWindow::on_actionQuit_triggered() { QApplication::quit(); }
void MainWindow::on_actionHelp_triggered()
{
QMessageBox::information(this, tr("Help system is actually absent"),
tr("You will be redirected to Wikipedia page"));
QDesktopServices::openUrl(QUrl("https://en.wikipedia.org/wiki/Durak"));
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, "OpenFool",
"Free and open source Fool game implementation");
}