-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
89 lines (75 loc) · 2.66 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
/* This file is part of Terraria Server Manager.
Terraria Server Manager 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.
Terraria Server Manager 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 Terraria Server Manager. If not, see <http://www.gnu.org/licenses/>. */
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Widgets/ServerTabWidget.h"
#include "Widgets/ConfigManager.h"
#include "Widgets/ConfigSelector.h"
#include "Widgets/Options.h"
#include "Util/Utility.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
init();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::init()
{
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
connect(ui->actionHost, SIGNAL(triggered()), this, SLOT(slot_actionHost_triggered()));
connect(ui->actionShutdown, SIGNAL(triggered()), this, SLOT(slot_actionShutdown_triggered()));
connect(ui->actionConfigurations, SIGNAL(triggered()), this, SLOT(slot_actionConfigurations_triggered()));
connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT(slot_actionOptions_triggered()));
}
void MainWindow::slot_actionShutdown_triggered()
{
removeSelectedServerTab();
}
void MainWindow::slot_actionConfigurations_triggered()
{
ConfigManager *configManager = new ConfigManager(this);
configManager->exec();
delete configManager;
}
void MainWindow::slot_actionHost_triggered()
{
//launch a ConfigSelector
ConfigSelector *configSelector = new ConfigSelector(this);
configSelector->exec();
QString config = configSelector->getConfig();
if(!config.isNull() && !config.isEmpty())
addServerTab(config);
delete configSelector;
}
void MainWindow::slot_actionOptions_triggered()
{
/* Options *options = new Options(this);
options->exec();
int isaveTimer = options->getSaveMinutes();
delete options;*/
//TODO
}
void MainWindow::addServerTab(QString name) {
QWidget *tabWidget = new ServerTabWidget(name);
ui->tabWidget->addTab(tabWidget, name);
}
void MainWindow::removeSelectedServerTab() {
int index = ui->tabWidget->currentIndex();
QWidget *instance = ui->tabWidget->widget(index);
ui->tabWidget->removeTab(index);
delete instance;
}