From: druid23 Date: Sat, 21 Aug 2010 14:31:43 +0000 (+0100) Subject: Persist orientation settings. X-Git-Tag: v0.5~18 X-Git-Url: https://vcs.maemo.org/git/?p=vlc-remote;a=commitdiff_plain;h=430b1891e7f0ed166b23cc72bcc966a7b42ecf5c Persist orientation settings. modified: appsettings.cpp modified: appsettings.h modified: browsemainwindow.ui modified: main.cpp modified: playermainwindow.cpp modified: playermainwindow.ui --- diff --git a/appsettings.cpp b/appsettings.cpp index 570158b..2c59e8a 100644 --- a/appsettings.cpp +++ b/appsettings.cpp @@ -50,3 +50,13 @@ bool AppSettings::setHomeDirectory(VlcDirectory dir) { QList* AppSettings::getFavourites() { return new QList(); } bool AppSettings::addFavourite(VlcDirectory dir) { return true; } bool AppSettings::deleteFavourite(VlcDirectory dir) { return true; } +Orientation AppSettings::setOrientation(Orientation orientation) { + QSettings sets; + sets.setValue("config/orientation", (int)orientation); + return orientation; +} +Orientation AppSettings::getOrientation() { + QSettings sets; + return (Orientation)(sets.value("config/orientation", AUTO_ROTATE).toInt()); +} + diff --git a/appsettings.h b/appsettings.h index 2a752be..407b5a2 100644 --- a/appsettings.h +++ b/appsettings.h @@ -23,6 +23,11 @@ struct VlcDirectory { QString name; QString path; }; +enum Orientation { + AUTO_ROTATE = 0, + LANDSCAPE, + PORTRAIT +}; class AppSettings { public: @@ -35,6 +40,8 @@ public: static bool addFavourite(VlcDirectory dir); static bool deleteFavourite(VlcDirectory dir); static bool setHomeDirectory(VlcDirectory dir); + static Orientation setOrientation(Orientation orientation); + static Orientation getOrientation(); //private: //static QSettings settings; }; diff --git a/browsemainwindow.ui b/browsemainwindow.ui index 395c0dd..ace0713 100644 --- a/browsemainwindow.ui +++ b/browsemainwindow.ui @@ -62,8 +62,8 @@ - - + + diff --git a/main.cpp b/main.cpp index 6c74fa1..8e21758 100644 --- a/main.cpp +++ b/main.cpp @@ -50,7 +50,21 @@ int main(int argc, char *argv[]) mainwindow->showMaximized(); #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) -mainwindow->setAttribute(Qt::WA_Maemo5AutoOrientation, true); + Orientation o = AppSettings::getOrientation(); + switch (o) { + case AUTO_ROTATE: + mainwindow->setAttribute(Qt::WA_Maemo5AutoOrientation, true); + break; + case LANDSCAPE: + mainwindow->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); + break; + case PORTRAIT: + mainwindow->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); + break; + default: + mainwindow->setAttribute(Qt::WA_Maemo5AutoOrientation, true); + break; + } #endif return a.exec(); } diff --git a/playermainwindow.cpp b/playermainwindow.cpp index c77bd56..ee806f1 100644 --- a/playermainwindow.cpp +++ b/playermainwindow.cpp @@ -23,6 +23,7 @@ #include "configdialog.h" #include "aboutdialog.h" #include "accountdialog.h" + #include "appsettings.h" //#include "vlcstatus.h" PlayerMainWindow::PlayerMainWindow(QWidget *parent) : @@ -86,6 +87,7 @@ connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout())); connect(ui->actionPortrait,SIGNAL(triggered()),this,SLOT(setPortrait())); connect(ui->actionLandscape,SIGNAL(triggered()),this,SLOT(setLandscape())); + connect(ui->actionAutoRotate,SIGNAL(triggered()),this,SLOT(setAutoRotate())); connect(ui->playlistButton,SIGNAL(clicked()),mPlayListMainWindow,SLOT(show())); connect(ui->playlistButton,SIGNAL(clicked()),mPlayListMainWindow,SLOT(showPlayList())); connect(ui->browseButton,SIGNAL(clicked()),mBrowserMainWindow,SLOT(show())); @@ -160,25 +162,26 @@ void PlayerMainWindow::setPortrait() { - #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) - this->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); + #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + AppSettings::setOrientation(PORTRAIT); + this->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); #endif - - } void PlayerMainWindow::setLandscape() { - #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) - this->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); - #endif + #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + AppSettings::setOrientation(LANDSCAPE); + this->setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); + #endif } void PlayerMainWindow::setAutoRotate() { #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) - this->setAttribute(Qt::WA_Maemo5AutoOrientation, true); - #endif + AppSettings::setOrientation(AUTO_ROTATE); + this->setAttribute(Qt::WA_Maemo5AutoOrientation, true); + #endif } void PlayerMainWindow::orientationChanged() { diff --git a/playermainwindow.ui b/playermainwindow.ui index fb7648c..a9d9065 100644 --- a/playermainwindow.ui +++ b/playermainwindow.ui @@ -285,6 +285,7 @@ + @@ -308,6 +309,11 @@ Landscape Mode + + + Auto Rotate + +