source: ntrip/trunk/GnssCenter/main/mainwin.cpp@ 5028

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