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

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