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

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