3 * Copyright (C) 2011 Roman Moravcik
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "gpscompasswindow.h"
24 GpsCompassWindow::GpsCompassWindow(QWidget *parent) : QMainWindow(parent)
26 m_screenLocked = false;
30 connect(parent, SIGNAL(screenLocked(bool)), this, SLOT(onScreenLocked(bool)));
33 GpsCompassWindow::~GpsCompassWindow()
38 void GpsCompassWindow::createUi()
40 #if defined(Q_OS_SYMBIAN)
41 setAttribute(Qt::WA_DeleteOnClose);
42 #elif defined(Q_WS_MAEMO_5)
43 setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
44 setAttribute(Qt::WA_Maemo5StackedWindow);
46 /* Workaround to show compass widget maximized */
50 setWindowTitle(tr("GPS compass"));
52 m_compass = new Compass(Compass::Gps);
53 setCentralWidget(m_compass);
56 QAction* backSoftkey = new QAction(tr("Back"), this);
57 backSoftkey->setSoftKeyRole(QAction::NegativeSoftKey);
58 connect(backSoftkey, SIGNAL(triggered()), this, SLOT(close()));
59 addAction(backSoftkey);
63 void GpsCompassWindow::onScreenLocked(bool locked)
65 m_screenLocked = locked;
68 void GpsCompassWindow::onPositionUpdated(const QGeoPositionInfo &position)
73 if (position.hasAttribute(QGeoPositionInfo::Direction)) {
74 m_compass->updateWidget(position.attribute(QGeoPositionInfo::Direction), true,
75 position.attribute(QGeoPositionInfo::GroundSpeed));
77 m_compass->updateWidget(0, false, 0);
81 void GpsCompassWindow::setPositionInfoSource(QGeoPositionInfoSource *positionInfoSource)
83 m_position = positionInfoSource;
85 connect(m_position, SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
86 SLOT(onPositionUpdated(const QGeoPositionInfo &)));
88 m_position->requestUpdate();