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

Last change on this file since 5015 was 5015, 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"
[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
[4817]36 createMenu();
[4822]37 createToolBar();
38 createStatusBar();
[4815]39}
40
41// Destructor
42////////////////////////////////////////////////////////////////////////////
[4860]43t_mainWin::~t_mainWin() {
[4815]44}
[4817]45
46//
47////////////////////////////////////////////////////////////////////////////
[4860]48void t_mainWin::createToolBar() {
[4822]49 _fileToolBar = addToolBar(tr("File"));
50 _editToolBar = addToolBar(tr("Edit"));
51}
52
53//
54////////////////////////////////////////////////////////////////////////////
[4860]55void t_mainWin::createStatusBar() {
[4822]56 statusBar()->showMessage(tr("Ready"));
57}
58
59//
60////////////////////////////////////////////////////////////////////////////
[4860]61void t_mainWin::createMenu() {
[4817]62
63 // Create Actions
64 // --------------
65 _actFontSel = new QAction(tr("Select &Font"),this);
66 connect(_actFontSel, SIGNAL(triggered()), SLOT(slotFontSel()));
67
68 _actSaveOpt = new QAction(tr("&Save && Reread Configuration"),this);
69 connect(_actSaveOpt, SIGNAL(triggered()), SLOT(slotSaveOptions()));
70
71 _actQuit = new QAction(tr("&Quit"),this);
72 connect(_actQuit, SIGNAL(triggered()), SLOT(close()));
73
74 _actEditInput = new QAction(tr("&Edit Input File"),this);
75 connect(_actEditInput, SIGNAL(triggered()), SLOT(slotEditInput()));
76
[4846]77 _actMap = new QAction(tr("Show &Map"),this);
78 connect(_actMap, SIGNAL(triggered()), SLOT(slotMap()));
79
[4817]80 _actHelp = new QAction(tr("&Help Contents"),this);
81 connect(_actHelp, SIGNAL(triggered()), SLOT(slotHelp()));
82
83 _actAbout = new QAction(tr("&About"),this);
84 connect(_actAbout, SIGNAL(triggered()), SLOT(slotAbout()));
85
86 // Create Menu
87 // -----------
88 _menuFile = menuBar()->addMenu(tr("&File"));
89 _menuFile->addAction(_actFontSel);
90 _menuFile->addSeparator();
91 _menuFile->addAction(_actSaveOpt);
92 _menuFile->addSeparator();
93 _menuFile->addAction(_actQuit);
94
95 _menuNew = menuBar()->addMenu(tr("&New"));
96 _menuNew->addAction(_actEditInput);
[4846]97 _menuNew->addAction(_actMap);
[4817]98
99 _menuHlp = menuBar()->addMenu(tr("&Help"));
100 _menuHlp->addAction(_actHelp);
101 _menuHlp->addAction(_actAbout);
102}
103
104// Select Fonts
105////////////////////////////////////////////////////////////////////////////
[4860]106void t_mainWin::slotFontSel() {
[4817]107 bool ok;
108 QFont newFont = QFontDialog::getFont(&ok, this->font(), this);
109 if (ok) {
[4860]110 t_settings settings;
[4817]111 settings.setValue("font", newFont.toString());
112 QApplication::setFont(newFont);
113 }
114}
115
116// Save Options (serialize)
117////////////////////////////////////////////////////////////////////////////
[4860]118void t_mainWin::slotSaveOptions() {
119 t_settings settings;
[4817]120 settings.sync();
121}
122
123// Edit RTNet Input File
124////////////////////////////////////////////////////////////////////////////
[4860]125void t_mainWin::slotEditInput() {
[4818]126 QString fileName = QFileDialog::getOpenFileName(this);
127 if (!fileName.isEmpty()) {
[5015]128 t_inpEdit* inpEdit = new t_inpEdit();
129 inpEdit->setInputFile(fileName);
130 QMdiSubWindow* win = _mdi->addSubWindow(inpEdit);
[4821]131 win->show();
[4818]132 }
[4817]133}
134
[4846]135// Edit RTNet Input File
136////////////////////////////////////////////////////////////////////////////
[4860]137void t_mainWin::slotMap() {
138 t_svgMap* svgMap = new t_svgMap();
139 QMdiSubWindow* win = _mdi->addSubWindow(svgMap);
[4846]140 win->show();
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.