2 * MainWindow.cpp 07/10/31
4 * Top window layer. All tabs will be added to this main window.
6 * Copyright: (c) 2007 CTU Dragons
7 * CTU FEE - Department of Control Engineering
8 * Authors: Martin Zidek, Michal Sojka, Tran Duy Khanh
14 #include "MainWindow.h"
15 #include "RobomonTuning.h"
16 #include "RobomonAtlantis.h"
18 MainWindow::MainWindow()
30 setCentralWidget(tabWidget);
32 addRobomonAtlantisTab();
35 void MainWindow::closeEvent(QCloseEvent *event)
37 while (closeCurrentTab() != -1) ;
41 void MainWindow::addRobomonTuningTab()
43 RobomonTuning *robomonTuning = new RobomonTuning();
44 tabWidget->addTab(robomonTuning, tr("Robomon Tuning"));
45 tabWidget->setCurrentWidget(robomonTuning);
48 void MainWindow::addRobomonAtlantisTab()
50 RobomonAtlantis *robomonAtlantis = new RobomonAtlantis();
51 tabWidget->addTab(robomonAtlantis, tr("Robomon - Temples of Atlantis"));
52 tabWidget->setCurrentWidget(robomonAtlantis);
53 connect(showMap, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showMap(bool)));
54 connect(showTrails, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showTrails(bool)));
55 connect(resetTrails, SIGNAL(triggered()), robomonAtlantis, SLOT(resetTrails()));
58 void MainWindow::about()
60 QMessageBox::about(this, tr("About Robomon"),
63 "<h1>Robomon 2.0</h1><br /><br />"
64 "<b>Robomon</b> is an application for graphic "
65 "visualization and control of the robot.<br /><br />"
67 "Martin ŽÍDEK, "
72 "<a href=\"http://rtime.felk.cvut.cz/dragons\">CTU Dragons</a>"
75 "<b>License:</b> GNU GPL v.2<br /></center>"
79 void MainWindow::help()
81 QMessageBox::about(this, tr("Help"),
82 tr("Here will be the help of the Robomon"));
85 void MainWindow::createActions()
87 exitAct = new QAction(tr("E&xit"), this);
88 exitAct->setShortcut(tr("Ctrl+Q"));
89 exitAct->setStatusTip(tr("Exit the application"));
90 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
92 robomonTuningAct = new QAction(QIcon(":/images/tuning.png"),
93 tr("Robot &Tuning"), this);
94 robomonTuningAct->setShortcut(tr("Ctrl+T"));
95 robomonTuningAct->setStatusTip(tr("Robomon of the Robot Explorer - tuning panel"));
96 connect(robomonTuningAct, SIGNAL(triggered()),
97 this, SLOT(addRobomonTuningTab()));
99 robomonAtlantisAct = new QAction(QIcon(":/images/robomon_atlantis.png"),
100 tr("Robot &Atlantis"), this);
101 robomonAtlantisAct->setShortcut(tr("Ctrl+A"));
102 robomonAtlantisAct->setStatusTip(tr("Robomon of the Robot Atlantis"));
103 connect(robomonAtlantisAct, SIGNAL(triggered()),
104 this, SLOT(addRobomonAtlantisTab()));
106 helpAct = new QAction(tr("&Help"), this);
107 helpAct->setStatusTip(tr("Show the Qt library's About box"));
108 connect(helpAct, SIGNAL(triggered()), this, SLOT(help()));
110 aboutAct = new QAction(tr("&About"), this);
111 aboutAct->setStatusTip(tr("Show information about the application"));
112 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
114 connect(closeToolButton, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
116 showTrails = new QAction("Show &trails", this);
117 showTrails->setCheckable(true);
118 showMap = new QAction("Show &map", this);
119 showMap->setCheckable(true);
120 resetTrails = new QAction("&Reset trails", this);
123 void MainWindow::createMenus()
125 fileMenu = menuBar()->addMenu(tr("&File"));
126 fileMenu->addSeparator();
127 fileMenu->addAction(exitAct);
130 m = menuBar()->addMenu(tr("&View"));
131 m->addAction(showMap);
132 m->addAction(showTrails);
133 m->addAction(resetTrails);
135 toolsMenu = menuBar()->addMenu(tr("&Tools"));
136 toolsMenu->addAction(robomonTuningAct);
137 toolsMenu->addAction(robomonAtlantisAct);
139 menuBar()->addSeparator();
141 helpMenu = menuBar()->addMenu(tr("&Help"));
142 helpMenu->addAction(helpAct);
143 helpMenu->addAction(aboutAct);
146 void MainWindow::createToolBars()
148 fileToolBar = addToolBar(tr("File"));
150 toolsToolBar = addToolBar(tr("Tools"));
151 toolsToolBar->addAction(robomonTuningAct);
152 toolsToolBar->addAction(robomonAtlantisAct);
155 void MainWindow::createStatusBar()
157 statusBar()->showMessage(tr("Ready"));
160 void MainWindow::createTabs()
162 tabWidget = new QTabWidget;
163 closeToolButton = new QToolButton();
165 closeToolButton->setIcon(QIcon(":/images/close.png"));
166 closeToolButton->setIconSize(QSize(14, 14));
167 closeToolButton->setShortcut(tr("Ctrl+W"));
168 closeToolButton->setToolTip(tr("Close tab (Ctrl+W)"));
169 tabWidget->setCornerWidget(closeToolButton);
172 int MainWindow::closeCurrentTab()
174 int index = tabWidget->currentIndex();
177 QWidget* tabPage = tabWidget->widget(index);
179 tabWidget->removeTab(index);