source: ntrip/trunk/GnssCenter/src/mainwin.cpp@ 5016

Last change on this file since 5016 was 5016, checked in by mervart, 11 years ago
File size: 4.9 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"
[5005]22#include "map/svgmap.h"
[5015]23#include "inpedit/inpedit.h"
[4815]24
25using namespace std;
[5001]26using namespace GnssCenter;
[4815]27
28// Constructor
29////////////////////////////////////////////////////////////////////////////
[4860]30t_mainWin::t_mainWin(QWidget* parent, Qt::WindowFlags flags) :
[4815]31 QMainWindow(parent, flags) {
[4817]32
[4860]33 _mdi = new t_mdiArea(0);
[4818]34 setCentralWidget(_mdi);
35
[5016]36 // Handle Static Plugins
37 // ---------------------
38 qDebug() << "Number of static plugins: " << QPluginLoader::staticInstances().size();
39 foreach (QObject* plugin, QPluginLoader::staticInstances()) {
40 }
41
[4817]42 createMenu();
[4822]43 createToolBar();
44 createStatusBar();
[4815]45}
46
47// Destructor
48////////////////////////////////////////////////////////////////////////////
[4860]49t_mainWin::~t_mainWin() {
[4815]50}
[4817]51
52//
53////////////////////////////////////////////////////////////////////////////
[4860]54void t_mainWin::createToolBar() {
[4822]55 _fileToolBar = addToolBar(tr("File"));
56 _editToolBar = addToolBar(tr("Edit"));
57}
58
59//
60////////////////////////////////////////////////////////////////////////////
[4860]61void t_mainWin::createStatusBar() {
[4822]62 statusBar()->showMessage(tr("Ready"));
63}
64
65//
66////////////////////////////////////////////////////////////////////////////
[4860]67void t_mainWin::createMenu() {
[4817]68
69 // Create Actions
70 // --------------
71 _actFontSel = new QAction(tr("Select &Font"),this);
72 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
73
74 _actSaveOpt = new QAction(tr("&Save && Reread Configuration"),this);
75 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
76
77 _actQuit = new QAction(tr("&Quit"),this);
78 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
79
80 _actEditInput = new QAction(tr("&Edit Input File"),this);
81 connect(_actEditInput, SIGNAL(triggered()), SLOT(slotEditInput()));
82
[4846]83 _actMap = new QAction(tr("Show &Map"),this);
84 connect(_actMap, SIGNAL(triggered()), SLOT(slotMap()));
85
[4817]86 _actHelp = new QAction(tr("&Help Contents"),this);
87 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
88
89 _actAbout = new QAction(tr("&About"),this);
90 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
91
92 // Create Menu
93 // -----------
94 _menuFile = menuBar()->addMenu(tr("&File"));
95 _menuFile->addAction(_actFontSel);
96 _menuFile->addSeparator();
97 _menuFile->addAction(_actSaveOpt);
98 _menuFile->addSeparator();
99 _menuFile->addAction(_actQuit);
100
101 _menuNew = menuBar()->addMenu(tr("&New"));
102 _menuNew->addAction(_actEditInput);
[4846]103 _menuNew->addAction(_actMap);
[4817]104
105 _menuHlp = menuBar()->addMenu(tr("&Help"));
106 _menuHlp->addAction(_actHelp);
107 _menuHlp->addAction(_actAbout);
108}
109
110// Select Fonts
111////////////////////////////////////////////////////////////////////////////
[4860]112void t_mainWin::slotFontSel() {
[4817]113 bool ok;
114 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
115 if (ok) {
[4860]116 t_settings settings;
[4817]117 settings.setValue("font", newFont.toString());
118 QApplication::setFont(newFont);
119 }
120}
121
122// Save Options (serialize)
123////////////////////////////////////////////////////////////////////////////
[4860]124void t_mainWin::slotSaveOptions() {
125 t_settings settings;
[4817]126 settings.sync();
127}
128
129// Edit RTNet Input File
130////////////////////////////////////////////////////////////////////////////
[4860]131void t_mainWin::slotEditInput() {
[4818]132 QString fileName = QFileDialog::getOpenFileName(this);
133 if (!fileName.isEmpty()) {
[5015]134 t_inpEdit* inpEdit = new t_inpEdit();
135 inpEdit->setInputFile(fileName);
136 QMdiSubWindow* win = _mdi->addSubWindow(inpEdit);
[4821]137 win->show();
[4818]138 }
[4817]139}
140
[4846]141// Edit RTNet Input File
142////////////////////////////////////////////////////////////////////////////
[4860]143void t_mainWin::slotMap() {
144 t_svgMap* svgMap = new t_svgMap();
145 QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
[4846]146 win->show();
147}
148
[4817]149// Help Window
150////////////////////////////////////////////////////////////////////////////
[4860]151void t_mainWin::slotHelp() {
[4817]152}
153
154// About Message
155////////////////////////////////////////////////////////////////////////////
[4860]156void t_mainWin::slotAbout() {
[4817]157}
158
159// Close Application gracefully
160////////////////////////////////////////////////////////////////////////////
[4860]161void t_mainWin::closeEvent(QCloseEvent* event) {
[4817]162 int iRet = QMessageBox::question(this, "Close", "Save Options?",
163 QMessageBox::Yes, QMessageBox::No,
164 QMessageBox::Cancel);
165 if (iRet == QMessageBox::Cancel) {
166 event->ignore();
167 return;
168 }
169 else if (iRet == QMessageBox::Yes) {
170 slotSaveOptions();
171 }
172 QMainWindow::closeEvent(event);
173}
Note: See TracBrowser for help on using the repository browser.