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

Last change on this file since 5055 was 5055, checked in by mervart, 11 years ago
File size: 4.6 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
22using namespace std;
23using namespace GnssCenter;
24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
27t_mainWin::t_mainWin(QWidget* parent, Qt::WindowFlags flags) :
28 QMainWindow(parent, flags) {
29
30 _mdi = new t_mdiArea(0);
31 setCentralWidget(_mdi);
32
33 createMenu();
34 createToolBar();
35 createStatusBar();
36
37 // Handle Plugins
38 // --------------
39 QDir pluginsDir = QDir(qApp->applicationDirPath());
40
41 pluginsDir.cd("plugins");
42
43 foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
44 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
45 QObject* object = loader.instance();
46 qDebug() << pluginsDir.absoluteFilePath(fileName) << object;
47 if (object) {
48 t_pluginFactoryInterface* plugin = qobject_cast<t_pluginFactoryInterface*>(object);
49 qDebug() << "Plugin: " << plugin;
50 if (plugin) {
51 for (int ii = 1; ii <= 2; ii++) {
52 t_pluginInterface* widget = plugin->create();
53 widget->show();
54 }
55 }
56 }
57 }
58
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 _actHelp = new QAction(tr("&Help Contents"),this);
95 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
96
97 _actAbout = new QAction(tr("&About"),this);
98 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
99
100 // Create Menu
101 // -----------
102 _menuFile = menuBar()->addMenu(tr("&File"));
103 _menuFile->addAction(_actFontSel);
104 _menuFile->addSeparator();
105 _menuFile->addAction(_actSaveOpt);
106 _menuFile->addSeparator();
107 _menuFile->addAction(_actQuit);
108
109 _menuPlugins = menuBar()->addMenu(tr("&Plugins"));
110
111 _menuHlp = menuBar()->addMenu(tr("&Help"));
112 _menuHlp->addAction(_actHelp);
113 _menuHlp->addAction(_actAbout);
114}
115
116// Select Fonts
117////////////////////////////////////////////////////////////////////////////
118void t_mainWin::slotFontSel() {
119 bool ok;
120 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
121 if (ok) {
122 t_settings settings;
123 settings.setValue("font", newFont.toString());
124 QApplication::setFont(newFont);
125 }
126}
127
128// Save Options (serialize)
129////////////////////////////////////////////////////////////////////////////
130void t_mainWin::slotSaveOptions() {
131 t_settings settings;
132 settings.sync();
133}
134
135//
136////////////////////////////////////////////////////////////////////////////
137void t_mainWin::slotStartPlugin() {
138// t_svgMap* svgMap = new t_svgMap();
139// QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
140// win->show();
141}
142
143// Help Window
144////////////////////////////////////////////////////////////////////////////
145void t_mainWin::slotHelp() {
146}
147
148// About Message
149////////////////////////////////////////////////////////////////////////////
150void t_mainWin::slotAbout() {
151}
152
153// Close Application gracefully
154////////////////////////////////////////////////////////////////////////////
155void t_mainWin::closeEvent(QCloseEvent* event) {
156 int iRet = QMessageBox::question(this, "Close", "Save Options?",
157 QMessageBox::Yes, QMessageBox::No,
158 QMessageBox::Cancel);
159 if (iRet == QMessageBox::Cancel) {
160 event->ignore();
161 return;
162 }
163 else if (iRet == QMessageBox::Yes) {
164 slotSaveOptions();
165 }
166 QMainWindow::closeEvent(event);
167}
Note: See TracBrowser for help on using the repository browser.