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

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