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

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