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

Last change on this file since 5045 was 5045, checked in by mervart, 12 years ago
File size: 5.1 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"
[5009]21#include "plugininterface.h"
[4815]22
23using namespace std;
[5001]24using namespace GnssCenter;
[4815]25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
[4860]28t_mainWin::t_mainWin(QWidget* parent, Qt::WindowFlags flags) :
[4815]29 QMainWindow(parent, flags) {
[4817]30
[4860]31 _mdi = new t_mdiArea(0);
[4818]32 setCentralWidget(_mdi);
33
[5039]34 // Handle Plugins
35 // --------------
36 QDir pluginsDir = QDir(qApp->applicationDirPath());
[5041]37
38 pluginsDir.cd("plugins");
[5039]39
40 foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
41 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
[5042]42 QObject* object = loader.instance();
43 qDebug() << fileName << object;
44
45 if (object) {
46 t_pluginInterface* plugin = qobject_cast<t_pluginInterface*>(object);
47 qDebug() << "Plugin: " << plugin;
[5045]48 if (plugin) {
49 plugin->show();
50 }
[5042]51 }
[5016]52 }
53
[4817]54 createMenu();
[4822]55 createToolBar();
56 createStatusBar();
[4815]57}
58
59// Destructor
60////////////////////////////////////////////////////////////////////////////
[4860]61t_mainWin::~t_mainWin() {
[4815]62}
[4817]63
64//
65////////////////////////////////////////////////////////////////////////////
[4860]66void t_mainWin::createToolBar() {
[4822]67 _fileToolBar = addToolBar(tr("File"));
68 _editToolBar = addToolBar(tr("Edit"));
69}
70
71//
72////////////////////////////////////////////////////////////////////////////
[4860]73void t_mainWin::createStatusBar() {
[4822]74 statusBar()->showMessage(tr("Ready"));
75}
76
77//
78////////////////////////////////////////////////////////////////////////////
[4860]79void t_mainWin::createMenu() {
[4817]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
[4846]95 _actMap = new QAction(tr("Show &Map"),this);
96 connect(_actMap, SIGNAL(triggered()), SLOT(slotMap()));
97
[4817]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);
[4846]115 _menuNew->addAction(_actMap);
[4817]116
117 _menuHlp = menuBar()->addMenu(tr("&Help"));
118 _menuHlp->addAction(_actHelp);
119 _menuHlp->addAction(_actAbout);
120}
121
122// Select Fonts
123////////////////////////////////////////////////////////////////////////////
[4860]124void t_mainWin::slotFontSel() {
[4817]125 bool ok;
126 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
127 if (ok) {
[4860]128 t_settings settings;
[4817]129 settings.setValue("font", newFont.toString());
130 QApplication::setFont(newFont);
131 }
132}
133
134// Save Options (serialize)
135////////////////////////////////////////////////////////////////////////////
[4860]136void t_mainWin::slotSaveOptions() {
137 t_settings settings;
[4817]138 settings.sync();
139}
140
141// Edit RTNet Input File
142////////////////////////////////////////////////////////////////////////////
[4860]143void t_mainWin::slotEditInput() {
[5027]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// }
[4817]151}
152
[4846]153// Edit RTNet Input File
154////////////////////////////////////////////////////////////////////////////
[4860]155void t_mainWin::slotMap() {
[5027]156// t_svgMap* svgMap = new t_svgMap();
157// QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
158// win->show();
[4846]159}
160
[4817]161// Help Window
162////////////////////////////////////////////////////////////////////////////
[4860]163void t_mainWin::slotHelp() {
[4817]164}
165
166// About Message
167////////////////////////////////////////////////////////////////////////////
[4860]168void t_mainWin::slotAbout() {
[4817]169}
170
171// Close Application gracefully
172////////////////////////////////////////////////////////////////////////////
[4860]173void t_mainWin::closeEvent(QCloseEvent* event) {
[4817]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.