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

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