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

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