+jspeed (0.1-5) unstable; urgency=low
+
+ * Faster and better screen rotation using Qt Mobility.
+
+ -- Jesse Hakanen <jessehakanen@gmail.com> Sun, 1 Aug 2010 13:00:29 +0100
+
jspeed (0.1-4) unstable; urgency=low
* Fixed a bug in theme scheduler settings saving.
Section: user/navigation
Priority: optional
Maintainer: Jesse Hakanen <jessehakanen@gmail.com>
-Build-Depends: debhelper (>= 5), libqt4-dev, libzip-dev, liblocation-dev, libgconf2-dev, libqtm-dev
+Build-Depends: debhelper (>= 5), libqt4-dev, libzip-dev, liblocation-dev, libgconf2-dev, libqtm-dev, libqtm-sensors
Standards-Version: 3.7.2
Homepage: http://jspeed.garage.maemo.org
TARGET = jspeed
TEMPLATE = app
CONFIG += mobility
-MOBILITY += multimedia
+MOBILITY += multimedia sensors
SOURCES += src/main.cpp \
src/mainwindow.cpp \
src/mainwindowstack.cpp \
src/themepicker.cpp \
src/mediaplayer.cpp \
src/soundselector.cpp \
- src/buttonbox.cpp
+ src/buttonbox.cpp \
+ src/orientation.cpp
HEADERS += src/mainwindow.h \
src/mainwindowstack.h \
src/location.h \
src/themepicker.h \
src/mediaplayer.h \
src/soundselector.h \
- src/buttonbox.h
+ src/buttonbox.h \
+ src/orientation.h
RESOURCES = src/resources.qrc
CONFIG += link_pkgconfig
PKGCONFIG += liblocation libzip
#include "poialerts.h"
#include "speedalarm.h"
#include "mediaplayer.h"
+#include "orientation.h"
+#include <QOrientationSensor>
+#include <QSensor>
-MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0), mainScreen_(0)
+
+MainWindow::MainWindow(): QMainWindow(0), menu_(0), themeLoader_(0),
+mainScreen_(0), orientation_(0)
{
setWindowTitle(tr("jSpeed"));
showFullScreen();
+ orientation_ = new Orientation(this);
+ orientation_->start();
addScreens();
QTimer::singleShot(500, this, SLOT(loadServices()));
}
return false;
}
- if(mainScreen_->orientationEnabled(WidgetScreen::LANDSCAPE) &&
- mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
- {
- setAttribute(Qt::WA_Maemo5AutoOrientation, true);
- }
- else if(mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
+ int orientations = 0;
+
+ if(mainScreen_->orientationEnabled(WidgetScreen::LANDSCAPE))
{
- setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ orientations |= Orientation::LANDSCAPE;
}
- else
+ if(mainScreen_->orientationEnabled(WidgetScreen::PORTRAIT))
{
- setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ orientations |= Orientation::PORTRAIT;
}
+ orientation_->setSupportedOrientations(orientations);
+ orientation_->update();
+
return true;
}
class MainMenu;
class ThemeLoader;
class WidgetScreen;
+class Orientation;
class MainWindow : public QMainWindow
{
MainMenu* menu_;
ThemeLoader* themeLoader_;
WidgetScreen* mainScreen_;
+ Orientation* orientation_;
};
--- /dev/null
+/*
+ * This file is part of jSpeed.
+ *
+ * jSpeed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * jSpeed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "orientation.h"
+
+Orientation::Orientation(QMainWindow* window): QtMobility::QOrientationSensor(window),
+current_(QtMobility::QOrientationReading::TopUp), orientations_(0), window_(window)
+{
+ connect(this, SIGNAL(readingChanged()), this, SLOT(onReadingChanged()));
+}
+
+void Orientation::setSupportedOrientations(int orientations)
+{
+ orientations_ = orientations;
+}
+
+void Orientation::update()
+{
+ using QtMobility::QOrientationReading;
+
+ OrientationName orientation = LANDSCAPE;
+
+ QOrientationReading::Orientation current = reading()->orientation();
+
+ switch(current)
+ {
+ case QOrientationReading::LeftUp:
+ orientation = PORTRAIT;
+ break;
+ case QOrientationReading::FaceUp:
+ if(current_ == QOrientationReading::LeftUp)
+ {
+ orientation = PORTRAIT;
+ }
+ else
+ {
+ orientation = LANDSCAPE;
+ }
+ break;
+ default:
+ orientation = LANDSCAPE;
+ break;
+ }
+
+ current_ = current;
+
+ if(orientations_ & orientation)
+ {
+ switch(orientation)
+ {
+ case LANDSCAPE:
+ window_->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ break;
+ case PORTRAIT:
+ window_->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ break;
+ }
+ }
+ else
+ {
+ if(orientations_ & LANDSCAPE)
+ {
+ window_->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+ }
+ else if(orientations_ & PORTRAIT)
+ {
+ window_->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+ }
+ }
+}
+
+void Orientation::onReadingChanged()
+{
+ if(reading()->orientation() != current_)
+ {
+ update();
+ emit changed();
+ }
+}
--- /dev/null
+/*
+ * This file is part of jSpeed.
+ *
+ * jSpeed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * jSpeed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef ORIENTATION_H
+#define ORIENTATION_H
+
+#include <QtGui/QMainWindow>
+#include <QOrientationReading>
+#include <QOrientationSensor>
+
+class Orientation : public QtMobility::QOrientationSensor
+{
+ Q_OBJECT
+
+public:
+ enum OrientationName {LANDSCAPE = 0x01, PORTRAIT = 0x02};
+ Orientation(QMainWindow* window);
+ void setSupportedOrientations(int orientations);
+
+public slots:
+ void update();
+
+signals:
+ void changed();
+
+private slots:
+ void onReadingChanged();
+
+private:
+ QtMobility::QOrientationReading::Orientation current_;
+ int orientations_;
+ QMainWindow* window_;
+};
+
+#endif
if(screens_.find(o) != screens_.end())
{
currentOrientation_ = o;
- setCurrentWidget(screens_[o]);
screens_[o]->reArrange();
+ setCurrentWidget(screens_[o]);
screens_[o]->forceRepaint();
}
}