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

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