streamio.cpp \
playlist.cpp \
downloadmanager.cpp \
- grooveprogressbar.cpp
+ grooveprogressbar.cpp \
+ qmaemo5rotator.cpp
HEADERS += \
groove.h \
streamio.h \
playlist.h \
downloadmanager.h \
- grooveprogressbar.h
+ grooveprogressbar.h \
+ qmaemo5rotator.h
</valuemap>
<value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
<valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
- <value key="192.168.1.3" type="QDateTime">2010-06-19T01:08:31</value>
+ <value key="192.168.1.3" type="QDateTime">2010-06-20T16:49:36</value>
</valuemap>
<value key="Qt4ProjectManager.MaemoRunConfiguration.Simulator" type="QString"></value>
</valuemap>
#############################################################################
# Makefile for building: groove
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Sat Jun 19 00:00:46 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Sun Jun 20 16:58:17 2010
# Project: Groove.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile Groove.pro
splayer.cpp \
streamio.cpp \
playlist.cpp \
- downloadmanager.cpp moc_groove.cpp \
+ downloadmanager.cpp \
+ grooveprogressbar.cpp \
+ qmaemo5rotator.cpp moc_groove.cpp \
moc_gscom.cpp \
moc_splayer.cpp \
moc_streamio.cpp \
moc_playlist.cpp \
- moc_downloadmanager.cpp
+ moc_downloadmanager.cpp \
+ moc_grooveprogressbar.cpp \
+ moc_qmaemo5rotator.cpp
OBJECTS = main.o \
groove.o \
gscom.o \
streamio.o \
playlist.o \
downloadmanager.o \
+ grooveprogressbar.o \
+ qmaemo5rotator.o \
moc_groove.o \
moc_gscom.o \
moc_splayer.o \
moc_streamio.o \
moc_playlist.o \
- moc_downloadmanager.o
+ moc_downloadmanager.o \
+ moc_grooveprogressbar.o \
+ moc_qmaemo5rotator.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/linux.conf \
dist:
@$(CHK_DIR_EXISTS) .tmp/groove1.0.0 || $(MKDIR) .tmp/groove1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/groove1.0.0/ && $(COPY_FILE) --parents groove.h gscom.h splayer.h streamio.h playlist.h downloadmanager.h .tmp/groove1.0.0/ && $(COPY_FILE) --parents main.cpp groove.cpp gscom.cpp splayer.cpp streamio.cpp playlist.cpp downloadmanager.cpp .tmp/groove1.0.0/ && (cd `dirname .tmp/groove1.0.0` && $(TAR) groove1.0.0.tar groove1.0.0 && $(COMPRESS) groove1.0.0.tar) && $(MOVE) `dirname .tmp/groove1.0.0`/groove1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/groove1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/groove1.0.0/ && $(COPY_FILE) --parents groove.h gscom.h splayer.h streamio.h playlist.h downloadmanager.h grooveprogressbar.h qmaemo5rotator.h .tmp/groove1.0.0/ && $(COPY_FILE) --parents main.cpp groove.cpp gscom.cpp splayer.cpp streamio.cpp playlist.cpp downloadmanager.cpp grooveprogressbar.cpp qmaemo5rotator.cpp .tmp/groove1.0.0/ && (cd `dirname .tmp/groove1.0.0` && $(TAR) groove1.0.0.tar groove1.0.0 && $(COMPRESS) groove1.0.0.tar) && $(MOVE) `dirname .tmp/groove1.0.0`/groove1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/groove1.0.0
clean:compiler_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp
+compiler_moc_header_make_all: moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp moc_grooveprogressbar.cpp moc_qmaemo5rotator.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp
+ -$(DEL_FILE) moc_groove.cpp moc_gscom.cpp moc_splayer.cpp moc_streamio.cpp moc_playlist.cpp moc_downloadmanager.cpp moc_grooveprogressbar.cpp moc_qmaemo5rotator.cpp
moc_groove.cpp: gscom.h \
splayer.h \
streamio.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h \
groove.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) groove.h -o moc_groove.cpp
moc_splayer.cpp: streamio.h \
splayer.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h \
splayer.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) splayer.h -o moc_splayer.cpp
moc_streamio.cpp: splayer.h \
streamio.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h \
streamio.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) streamio.h -o moc_streamio.cpp
moc_downloadmanager.cpp: downloadmanager.h
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) downloadmanager.h -o moc_downloadmanager.cpp
+moc_grooveprogressbar.cpp: qmaemo5rotator.h \
+ grooveprogressbar.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) grooveprogressbar.h -o moc_grooveprogressbar.cpp
+
+moc_qmaemo5rotator.cpp: qmaemo5rotator.h
+ /usr/bin/moc-qt4 $(DEFINES) $(INCPATH) qmaemo5rotator.h -o moc_qmaemo5rotator.cpp
+
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
main.o: main.cpp groove.h \
gscom.h \
splayer.h \
- streamio.h
+ streamio.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
groove.o: groove.cpp groove.h \
gscom.h \
splayer.h \
- streamio.h
+ streamio.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o groove.o groove.cpp
gscom.o: gscom.cpp gscom.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o gscom.o gscom.cpp
splayer.o: splayer.cpp splayer.h \
- streamio.h
+ streamio.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o splayer.o splayer.cpp
streamio.o: streamio.cpp streamio.h \
- splayer.h
+ splayer.h \
+ grooveprogressbar.h \
+ qmaemo5rotator.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o streamio.o streamio.cpp
playlist.o: playlist.cpp playlist.h
downloadmanager.o: downloadmanager.cpp downloadmanager.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o downloadmanager.o downloadmanager.cpp
+grooveprogressbar.o: grooveprogressbar.cpp grooveprogressbar.h \
+ qmaemo5rotator.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o grooveprogressbar.o grooveprogressbar.cpp
+
+qmaemo5rotator.o: qmaemo5rotator.cpp qmaemo5rotator.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qmaemo5rotator.o qmaemo5rotator.cpp
+
moc_groove.o: moc_groove.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_groove.o moc_groove.cpp
moc_downloadmanager.o: moc_downloadmanager.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_downloadmanager.o moc_downloadmanager.cpp
+moc_grooveprogressbar.o: moc_grooveprogressbar.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_grooveprogressbar.o moc_grooveprogressbar.cpp
+
+moc_qmaemo5rotator.o: moc_qmaemo5rotator.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_qmaemo5rotator.o moc_qmaemo5rotator.cpp
+
####### Install
install_target: first FORCE
#include "groove.h"
-
+#include "qmaemo5rotator.h"
groove::groove(QWidget *parent) :
/*QPalette pal = resultView->palette();
pal.setBrush(QPalette::Highlight,QBrush(Qt::transparent,Qt::NoBrush));
resultView->setPalette(pal);*/
-
+ portrait = false;
layout->addWidget(sMethod);
-#ifdef Q_WS_MAEMO_5
- setAttribute(Qt::WA_Maemo5AutoOrientation,true);
-#endif
+ rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this);
layout->addWidget(lineEdit);
layout->addWidget(button);
vlayout->addLayout(layout);
connect(stopButton,SIGNAL(clicked()),this,SLOT(stop()));
connect(gs,SIGNAL(sKeyFound()),this,SLOT(startP()));
connect(moreButton,SIGNAL(clicked()),this,SLOT(moreB()));
+ //connect(rotator,SIGNAL(orientationChanged(Orientation)),this,SLOT(orientationChanged()));
}
void groove::search()
{
return;
player->~sPlayer();
player = new sPlayer();
+#ifdef Q_WS_MAEMO_5
+ player->play(gs->streamID,gs->sku,rot->currentOrientation());
+#else
player->play(gs->streamID,gs->sku);
-
+#endif
}
void groove::stop()
{
{
qDebug() << "He pressed the button";
}
+void groove::orientationChanged()
+{
+#ifdef Q_WS_MAEMO_5
+ QRect screenGeometry = QApplication::desktop()->screenGeometry();
+ if (screenGeometry.width() > screenGeometry.height())
+ portrait = false;
+ else
+ portrait = true;
+#endif
+}
#include <QtGui>
#include "gscom.h"
#include "splayer.h"
+#include "qmaemo5rotator.h"
#include <QMenuBar>
class groove : public QWidget
void startP();
void stop();
void moreB();
+ void orientationChanged();
private:
sPlayer *player;
QLineEdit *lineEdit;
QTableView *resultView;
QPushButton *button;
+ bool portrait;
gscom *gs;
+ QMaemo5Rotator *rot;
};
#include "grooveprogressbar.h"
-
+#include "qmaemo5rotator.h"
grooveProgressBar::grooveProgressBar(QDialog *parent) :
QDialog(parent)
{
lay->addWidget(bar);
this->setLayout(lay);
this->setWindowTitle("Downloading / Buffering");
+ rot = new QMaemo5Rotator(QMaemo5Rotator::AutomaticBehavior,this);
}
void grooveProgressBar::setMaximum(int maximum)
{
#include <QDialog>
#include <QtGui>
+#include "qmaemo5rotator.h"
class grooveProgressBar : public QDialog
{
void setMaximum(int maximum);
void setValue(int position);
int maximum();
+ QMaemo5Rotator *rot;
signals:
QApplication a(argc, argv);\r
a.setApplicationName("Groove");\r
groove gs; //create Groove!\r
+#ifdef Q_WS_MAEMO_5\r
+ //setAttribute(Qt::WA_Maemo5AutoOrientation,true);\r
+ //a.setAttribute(Qt::WA_Maemo5AutoOrientation,true);\r
+#endif\r
#if defined(Q_WS_S60)\r
gs.showMaximized();\r
#else\r
--- /dev/null
+
+#include "qmaemo5rotator.h"
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
+#include <mce/dbus-names.h>
+#include <mce/mode-names.h>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusMessage>
+#endif
+
+QMaemo5Rotator::QMaemo5Rotator(RotationBehavior behavior, QWidget *parent)
+ : QObject(parent),
+ isSetUp(false)
+{
+ setCurrentBehavior(behavior);
+}
+
+QMaemo5Rotator::~QMaemo5Rotator()
+{
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
+ QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
+#endif
+}
+
+const QMaemo5Rotator::RotationBehavior QMaemo5Rotator::currentBehavior()
+{
+ return _currentBehavior;
+}
+
+const QMaemo5Rotator::Orientation QMaemo5Rotator::currentOrientation()
+{
+ return _currentOrientation;
+}
+
+void QMaemo5Rotator::setCurrentBehavior(QMaemo5Rotator::RotationBehavior value)
+{
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
+ if (value == _currentBehavior && isSetUp)
+ return;
+
+ isSetUp = true;
+ _currentBehavior = value;
+
+ if (value == QMaemo5Rotator::AutomaticBehavior)
+ {
+ QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
+ QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_DEVICE_ORIENTATION_SIG, this, SLOT(on_orientation_changed(QString)));
+ }
+ else
+ {
+ QDBusConnection::systemBus().call(QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
+
+ if (value == QMaemo5Rotator::PortraitBehavior)
+ {
+ setCurrentOrientation(QMaemo5Rotator::PortraitOrientation);
+ }
+ else
+ {
+ setCurrentOrientation(QMaemo5Rotator::LandscapeOrientation);
+ }
+ }
+#endif
+}
+
+void QMaemo5Rotator::setCurrentOrientation(QMaemo5Rotator::Orientation value)
+{
+ _currentOrientation = value;
+ QWidget *par = (QWidget*)parent();
+
+ switch (value)
+ {
+ case QMaemo5Rotator::PortraitOrientation:
+ if (par != NULL)
+ {
+#if defined(Q_WS_MAEMO_5)
+ par->setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
+ par->setAttribute(Qt::WA_Maemo5PortraitOrientation, true);
+#endif
+ }
+ orientationChanged(QMaemo5Rotator::PortraitOrientation);
+ break;
+ case QMaemo5Rotator::LandscapeOrientation:
+ if (par != NULL)
+ {
+#if defined(Q_WS_MAEMO_5)
+ par->setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
+ par->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);
+#endif
+ }
+ orientationChanged(QMaemo5Rotator::LandscapeOrientation);
+
+ break;
+ }
+}
+
+void QMaemo5Rotator::on_orientation_changed(const QString& newOrientation)
+{
+ if (newOrientation == QLatin1String(MCE_ORIENTATION_PORTRAIT) || newOrientation == QLatin1String(MCE_ORIENTATION_PORTRAIT_INVERTED))
+ {
+ setCurrentOrientation(QMaemo5Rotator::PortraitOrientation);
+ }
+ else
+ {
+ setCurrentOrientation(QMaemo5Rotator::LandscapeOrientation);
+ }
+ QApplication::desktop()->updateGeometry();
+}
--- /dev/null
+#ifndef QMAEMO5ROTATOR_H
+#define QMAEMO5ROTATOR_H
+
+//----------
+// Provides a means of WORKING automatic rotation for Maemo 5 apps. (The default Qt solution is buggy.)
+//----------
+
+#include <Qt>
+#include <QtGui>
+#include <QtCore>
+
+class QMaemo5Rotator : private QObject
+{
+
+ Q_OBJECT
+
+public:
+
+ enum RotationBehavior
+ {
+ AutomaticBehavior = 0,
+ LandscapeBehavior = 1,
+ PortraitBehavior = 2
+ };
+
+ enum Orientation
+ {
+ LandscapeOrientation = 0,
+ PortraitOrientation = 1
+ };
+
+private:
+
+ bool isSetUp;
+ RotationBehavior _currentBehavior;
+ Orientation _currentOrientation;
+
+public:
+
+ explicit QMaemo5Rotator(RotationBehavior behavior = LandscapeBehavior, QWidget *parent = NULL);
+ ~QMaemo5Rotator();
+
+ const RotationBehavior currentBehavior();
+ const Orientation currentOrientation();
+ void setCurrentBehavior(RotationBehavior value);
+ void setCurrentOrientation(Orientation value);
+
+private slots:
+
+ void on_orientation_changed(const QString& newOrienation);
+
+signals:
+
+ void orientationChanged(Orientation orientation);
+
+};
+
+#endif // QMAEMO5ROTATOR_H
//pd->hide();
//reply->abort();
}
+void sPlayer::play(QString StreamKey, QUrl server, QMaemo5Rotator::Orientation orientation)
+{
+ this->play(StreamKey, server);
+#ifdef Q_WS_MAEMO_5
+ if(orientation == QMaemo5Rotator::PortraitOrientation)
+ pd->rot->setCurrentOrientation(orientation);
+#endif
+ //isPortrait = false; //just make the compilier happy on non-maemo
+}
void sPlayer::play(QString StreamKey,QUrl server)
{
}
pd = new grooveProgressBar();
//pd->setAttribute();
-
-#ifdef Q_WS_MAEMO_5
- pd->setAttribute(Qt::WA_Maemo5AutoOrientation,true);
- //pd->setModal(false);
-#endif
pd->show();
pd->setValue(0);
QNetworkRequest req;
playing = true;
media->setCurrentSource(Phonon::MediaSource(buffer));
media->play();
+ pd->hide();
qDebug() << "Playing";
}
}
buffer->seek(last);
//buffer->data().append(reply->readAll());*/
//qDebug() << "Download speed (KB/S): " << b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024;
- if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 25)
+ if ( b >= t*0.05 && !playing && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 10)
{
pd->hide();
playing = true;
public:
explicit sPlayer(QObject *parent = 0);
void play(QString StreamKey, QUrl server);
+ void play(QString StreamKey, QUrl server,QMaemo5Rotator::Orientation orientation);
void stop();
~sPlayer();