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
RevLine 
[4815]1
2/* -------------------------------------------------------------------------
3 * RTNet GUI
4 * -------------------------------------------------------------------------
5 *
[4860]6 * Class: t_mainWin
[4815]7 *
8 * Purpose: Re-Implements QMainWindow
9 *
10 * Author: L. Mervart
11 *
12 * Created: 05-Jan-2013
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
[4860]18#include "mainwin.h"
19#include "settings.h"
20#include "mdiarea.h"
[4815]21
22using namespace std;
[5001]23using namespace GnssCenter;
[4815]24
25// Constructor
26////////////////////////////////////////////////////////////////////////////
[4860]27t_mainWin::t_mainWin(QWidget* parent, Qt::WindowFlags flags) :
[4815]28 QMainWindow(parent, flags) {
[4817]29
[4860]30 _mdi = new t_mdiArea(0);
[4818]31 setCentralWidget(_mdi);
32
[5055]33 createMenu();
34 createToolBar();
35 createStatusBar();
36
[5039]37 // Handle Plugins
38 // --------------
39 QDir pluginsDir = QDir(qApp->applicationDirPath());
[5041]40
41 pluginsDir.cd("plugins");
[5039]42
43 foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
44 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
[5042]45 QObject* object = loader.instance();
[5052]46 qDebug() << pluginsDir.absoluteFilePath(fileName) << object;
[5042]47 if (object) {
[5052]48 t_pluginFactoryInterface* plugin = qobject_cast<t_pluginFactoryInterface*>(object);
[5042]49 qDebug() << "Plugin: " << plugin;
[5045]50 if (plugin) {
[5054]51 for (int ii = 1; ii <= 2; ii++) {
52 t_pluginInterface* widget = plugin->create();
53 widget->show();
54 }
[5045]55 }
[5042]56 }
[5016]57 }
58
[4815]59}
60
61// Destructor
62////////////////////////////////////////////////////////////////////////////
[4860]63t_mainWin::~t_mainWin() {
[4815]64}
[4817]65
66//
67////////////////////////////////////////////////////////////////////////////
[4860]68void t_mainWin::createToolBar() {
[4822]69 _fileToolBar = addToolBar(tr("File"));
70 _editToolBar = addToolBar(tr("Edit"));
71}
72
73//
74////////////////////////////////////////////////////////////////////////////
[4860]75void t_mainWin::createStatusBar() {
[4822]76 statusBar()->showMessage(tr("Ready"));
77}
78
79//
80////////////////////////////////////////////////////////////////////////////
[4860]81void t_mainWin::createMenu() {
[4817]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
[5055]109 _menuPlugins = menuBar()->addMenu(tr("&Plugins"));
[4817]110
111 _menuHlp = menuBar()->addMenu(tr("&Help"));
112 _menuHlp->addAction(_actHelp);
113 _menuHlp->addAction(_actAbout);
114}
115
116// Select Fonts
117////////////////////////////////////////////////////////////////////////////
[4860]118void t_mainWin::slotFontSel() {
[4817]119 bool ok;
120 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
121 if (ok) {
[4860]122 t_settings settings;
[4817]123 settings.setValue("font", newFont.toString());
124 QApplication::setFont(newFont);
125 }
126}
127
128// Save Options (serialize)
129////////////////////////////////////////////////////////////////////////////
[4860]130void t_mainWin::slotSaveOptions() {
131 t_settings settings;
[4817]132 settings.sync();
133}
134
[5055]135//
[4817]136////////////////////////////////////////////////////////////////////////////
[5055]137void t_mainWin::slotStartPlugin() {
[5027]138// t_svgMap* svgMap = new t_svgMap();
139// QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
140// win->show();
[4846]141}
142
[4817]143// Help Window
144////////////////////////////////////////////////////////////////////////////
[4860]145void t_mainWin::slotHelp() {
[4817]146}
147
148// About Message
149////////////////////////////////////////////////////////////////////////////
[4860]150void t_mainWin::slotAbout() {
[4817]151}
152
153// Close Application gracefully
154////////////////////////////////////////////////////////////////////////////
[4860]155void t_mainWin::closeEvent(QCloseEvent* event) {
[4817]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.