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

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