source: ntrip/trunk/GnssCenter/src/mainwin.cpp@ 5005

Last change on this file since 5005 was 5005, checked in by mervart, 11 years ago
File size: 4.6 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
6 * Class: t_mainWin
7 *
8 * Purpose: Re-Implements QMainWindow
9 *
10 * Author: L. Mervart
11 *
12 * Created: 05-Jan-2013
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include "mainwin.h"
19#include "settings.h"
20#include "mdiarea.h"
21#include "map/svgmap.h"
22#include "inpedit/inpfile.h"
23
24using namespace std;
25using namespace GnssCenter;
26
27// Constructor
28////////////////////////////////////////////////////////////////////////////
29t_mainWin::t_mainWin(QWidget* parent, Qt::WindowFlags flags) :
30 QMainWindow(parent, flags) {
31
32 _mdi = new t_mdiArea(0);
33 setCentralWidget(_mdi);
34
35 createMenu();
36 createToolBar();
37 createStatusBar();
38}
39
40// Destructor
41////////////////////////////////////////////////////////////////////////////
42t_mainWin::~t_mainWin() {
43}
44
45//
46////////////////////////////////////////////////////////////////////////////
47void t_mainWin::createToolBar() {
48 _fileToolBar = addToolBar(tr("File"));
49 _editToolBar = addToolBar(tr("Edit"));
50}
51
52//
53////////////////////////////////////////////////////////////////////////////
54void t_mainWin::createStatusBar() {
55 statusBar()->showMessage(tr("Ready"));
56}
57
58//
59////////////////////////////////////////////////////////////////////////////
60void t_mainWin::createMenu() {
61
62 // Create Actions
63 // --------------
64 _actFontSel = new QAction(tr("Select &Font"),this);
65 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
66
67 _actSaveOpt = new QAction(tr("&Save && Reread Configuration"),this);
68 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
69
70 _actQuit = new QAction(tr("&Quit"),this);
71 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
72
73 _actEditInput = new QAction(tr("&Edit Input File"),this);
74 connect(_actEditInput, SIGNAL(triggered()), SLOT(slotEditInput()));
75
76 _actMap = new QAction(tr("Show &Map"),this);
77 connect(_actMap, SIGNAL(triggered()), SLOT(slotMap()));
78
79 _actHelp = new QAction(tr("&Help Contents"),this);
80 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
81
82 _actAbout = new QAction(tr("&About"),this);
83 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
84
85 // Create Menu
86 // -----------
87 _menuFile = menuBar()->addMenu(tr("&File"));
88 _menuFile->addAction(_actFontSel);
89 _menuFile->addSeparator();
90 _menuFile->addAction(_actSaveOpt);
91 _menuFile->addSeparator();
92 _menuFile->addAction(_actQuit);
93
94 _menuNew = menuBar()->addMenu(tr("&New"));
95 _menuNew->addAction(_actEditInput);
96 _menuNew->addAction(_actMap);
97
98 _menuHlp = menuBar()->addMenu(tr("&Help"));
99 _menuHlp->addAction(_actHelp);
100 _menuHlp->addAction(_actAbout);
101}
102
103// Select Fonts
104////////////////////////////////////////////////////////////////////////////
105void t_mainWin::slotFontSel() {
106 bool ok;
107 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
108 if (ok) {
109 t_settings settings;
110 settings.setValue("font", newFont.toString());
111 QApplication::setFont(newFont);
112 }
113}
114
115// Save Options (serialize)
116////////////////////////////////////////////////////////////////////////////
117void t_mainWin::slotSaveOptions() {
118 t_settings settings;
119 settings.sync();
120}
121
122// Edit RTNet Input File
123////////////////////////////////////////////////////////////////////////////
124void t_mainWin::slotEditInput() {
125 QString fileName = QFileDialog::getOpenFileName(this);
126 if (!fileName.isEmpty()) {
127 t_inpFile* inpFile = new t_inpFile(fileName);
128 QMdiSubWindow* win = _mdi->addSubWindow(inpFile);
129 win->show();
130 }
131}
132
133// Edit RTNet Input File
134////////////////////////////////////////////////////////////////////////////
135void t_mainWin::slotMap() {
136 t_svgMap* svgMap = new t_svgMap();
137 svgMap->setMinimumSize(600, 400);
138 QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
139 win->show();
140}
141
142// Help Window
143////////////////////////////////////////////////////////////////////////////
144void t_mainWin::slotHelp() {
145}
146
147// About Message
148////////////////////////////////////////////////////////////////////////////
149void t_mainWin::slotAbout() {
150}
151
152// Close Application gracefully
153////////////////////////////////////////////////////////////////////////////
154void t_mainWin::closeEvent(QCloseEvent* event) {
155 int iRet = QMessageBox::question(this, "Close", "Save Options?",
156 QMessageBox::Yes, QMessageBox::No,
157 QMessageBox::Cancel);
158 if (iRet == QMessageBox::Cancel) {
159 event->ignore();
160 return;
161 }
162 else if (iRet == QMessageBox::Yes) {
163 slotSaveOptions();
164 }
165 QMainWindow::closeEvent(event);
166}
Note: See TracBrowser for help on using the repository browser.