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

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