1 // checksum 0xcf61 version 0x30002
3 This file was generated by the Mobile Qt Application wizard of Qt Creator.
4 MainWindow is a convenience class containing mobile device specific code
5 such as screen orientation handling.
6 It is recommended not to modify this file, since newer versions of Qt Creator
7 may offer an updated version of it.
10 #include "mainWindow.h"
11 #include "windowMap.h"
12 #include "ui_mainWindow.h"
17 #include <QMessageBox>
19 MainWindow::MainWindow(QWidget *parent)
20 : QMainWindow(parent), ui(new Ui::MainWindow)
24 log = new Log(this,"gpssniffer.log",DEBUG_VERBOSITY);
26 settings = new Settings(log);
29 windowMap = new WindowMap(this,settings,log);
30 windowMap->setWindowTitle(tr("GPSSniffer->Activity"));
33 //log->debug("log and windowMap created!");
35 QAction *simulateAction = new QAction(tr("Simulate GPS"),this);
36 QAction *tracksAction = new QAction(tr("Load tracks"), this);
37 QAction *settingsAction = new QAction(tr("Settings"), this);
38 // the next line doesn't work in Maemo 5
39 //settingsAction->setIcon(QIcon(":/images/shadow.png"));
40 QAction *activityAction = new QAction(tr("New activity"), this);
41 QAction *quitAction = new QAction(tr("Quit"),this);
43 //log->debug("connecting all slots...");
44 connect(simulateAction, SIGNAL(triggered()), SLOT(simulate()));
45 connect(tracksAction, SIGNAL(triggered()), SLOT(tracks()));
46 connect(settingsAction, SIGNAL(triggered()), SLOT(configureSettings()));
47 connect(activityAction, SIGNAL(triggered()), SLOT(newActivity()));
48 connect(quitAction, SIGNAL(triggered()), SLOT(quit()));
50 connect(ui->simulateButton, SIGNAL(clicked()), SLOT(simulate()));
51 connect(ui->tracksButton, SIGNAL(clicked()), SLOT(tracks()));
52 //connect(ui->settingsButton, SIGNAL(clicked()), SLOT(configureSettings()));
53 connect(ui->newActivityButton, SIGNAL(clicked()), SLOT(newActivity()));
54 connect(ui->quitButton, SIGNAL(clicked()), SLOT(quit()));
61 //ui->tracksButton->setStyleSheet(ui->tracksButton->styleSheet().append("border-radius: 20px"));
63 #if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
64 menuBar()->addAction(simulateAction);
65 menuBar()->addAction(tracksAction);
66 menuBar()->addAction(settingsAction);
67 menuBar()->addAction(activityAction);
68 menuBar()->addAction(quitAction);
70 QMenu *menu = menuBar()->addMenu("&Options");
71 menu->addAction(simulateAction);
72 menu->addAction(tracksAction);
73 menu->addAction(settingsAction);
74 menu->addAction(activityAction);
75 menu->addAction(quitAction);
79 MainWindow::~MainWindow()
81 qDebug()<< "destructor MainWindow";
83 qDebug() << "ui deleted";
85 qDebug() << "windowMap deleted";
87 qDebug()<< "destructor end";
90 void MainWindow::quit(){
94 void MainWindow::configureSettings(){
99 void MainWindow::tracks(){
100 log->debug("Load tracks window...");
102 windowMap = new WindowMap(this,settings,log);
104 windowMap->setOrientation(WindowMap::ScreenOrientationAuto);
105 windowMap->setWindowTitle(tr("GPSSniffer->Activity"));
106 windowMap->setMode(Mode_LoadTracksWindow);
107 windowMap->setMenuLoadTracks();
108 windowMap->showExpanded();
112 void MainWindow::simulate(){
114 log->debug("new Activity simulating window...");
115 windowMap = new WindowMap(this,settings,log);
116 windowMap->setOrientation(WindowMap::ScreenOrientationAuto);
117 windowMap->setWindowTitle(tr("GPSSniffer->Activity"));
118 windowMap->setMode(Mode_NewActivityMode);
119 windowMap->setSimulateGPS(true);
120 windowMap->setMenuActivity();
121 log->debug(QString("MAIN WINDOWS SETTINGS CONFIGURED?:%1").arg(settings->getIsConfigured()));
123 windowMap->showExpanded();
127 void MainWindow::newActivity(){
128 log->debug("new Activity window...");
129 windowMap = new WindowMap(this,settings,log);
130 windowMap->setWindowTitle(tr("GPSSniffer->Activity"));
131 windowMap->setOrientation(WindowMap::ScreenOrientationAuto);
132 windowMap->setMode(Mode_NewActivityMode);
133 windowMap->setMenuActivity();
134 log->debug(QString("MAIN WINDOWS SETTINGS CONFIGURED?:%1").arg(settings->getIsConfigured()));
135 windowMap->showExpanded();
141 void MainWindow::setOrientation(ScreenOrientation orientation)
144 #if defined(Q_OS_SYMBIAN)
145 // If the version of Qt on the device is < 4.7.2, that attribute won't work
146 if (orientation != ScreenOrientationAuto) {
147 const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
148 if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
149 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
153 #endif // Q_OS_SYMBIAN
155 Qt::WidgetAttribute attribute;
156 switch (orientation) {
157 #if QT_VERSION < 0x040702
158 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
159 case ScreenOrientationLockPortrait:
160 attribute = static_cast<Qt::WidgetAttribute>(128);
162 case ScreenOrientationLockLandscape:
163 attribute = static_cast<Qt::WidgetAttribute>(129);
166 case ScreenOrientationAuto:
167 attribute = static_cast<Qt::WidgetAttribute>(130);
169 #else // QT_VERSION < 0x040702
170 case ScreenOrientationLockPortrait:
171 attribute = Qt::WA_LockPortraitOrientation;
173 case ScreenOrientationLockLandscape:
174 attribute = Qt::WA_LockLandscapeOrientation;
177 case ScreenOrientationAuto:
178 attribute = Qt::WA_AutoOrientation;
180 #endif // QT_VERSION < 0x040702
182 setAttribute(attribute, true);
186 void MainWindow::showExpanded()
190 #elif defined(Q_WS_MAEMO_5)
197 void MainWindow::closeEvent(QCloseEvent *event){