-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.cpp
69 lines (57 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
63
64
65
66
67
68
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "hydratooldialog.h"
#include "version.h"
#include <QSettings>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QString title_ver_info;
// Load the embedded font.
QString fontPath = ":/fonts/LiberationSans-Regular.ttf";
QFontDatabase::addApplicationFont(fontPath);
QFont font("Liberation Sans",8);
this->setFont(font);
QFontDatabase db1;
title_ver_info = "hydratool v";
title_ver_info.append(VER_FILEVERSION_STR);
title_ver_info.append(VER_DATE_INFO_STR);
title_ver_info.append(" (Based on Qt");
title_ver_info.append(QT_VERSION_STR);
title_ver_info.append(")");
ui->setupUi(this);
this->setWindowTitle(title_ver_info);
hydratool_log = new hydratooldialog(0,
ui->dockWidget_hydratool_directdisk,
ui->dockWidget_terminal_directdisk,
ui->dockWidget_terminal,
ui->dockWidget_find);
setCentralWidget(hydratool_log);
readSettings();
}
MainWindow::~MainWindow()
{
writeSettings();
delete hydratool_log;
delete ui;
}
/*****************************************************************************/
/* Protected methods */
/*****************************************************************************/
void MainWindow::readSettings()
{
QSettings settings(SETTINGS_FILENAME, QSettings::IniFormat);
settings.beginGroup("MainWindow");
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
settings.endGroup();
}
void MainWindow::writeSettings()
{
QSettings settings(SETTINGS_FILENAME, QSettings::IniFormat);
settings.beginGroup("MainWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("windowState", saveState());
settings.endGroup();
}