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

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