Skip to content

Commit

Permalink
Implement the setting to turn on/off auto-rotation for maemo 5
Browse files Browse the repository at this point in the history
  • Loading branch information
ieatlint committed Dec 5, 2010
1 parent b27b53f commit 1319c74
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
17 changes: 13 additions & 4 deletions magread.cpp
Expand Up @@ -40,7 +40,9 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) {

//Set the auto-rotation for Maemo5
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
if( settings->value( "autoReorient" ) == true ) {
setAttribute( Qt::WA_Maemo5AutoOrientation, true );
}
#endif


Expand Down Expand Up @@ -295,16 +297,17 @@ void MagRead::removeShowData() {
void MagRead::settingsPage() {
onMainPage = false;

SettingsPage *settings = new SettingsPage;
SettingsPage *settingsWidget = new SettingsPage;
connect( settingsWidget, SIGNAL( autoReorientSig( bool ) ), this, SLOT( autoReorient( bool ) ) );

#ifdef Q_OS_SYMBIAN
setCentralWidget( settings );
setCentralWidget( settingsWidget );
#else
if( mainLayout->count() > 1 ) {
mainLayout->itemAt( 0 )->widget()->hide();
mainLayout->removeItem( mainLayout->itemAt( 0 ) );
}
mainLayout->insertWidget( 0, settings, 1 );
mainLayout->insertWidget( 0, settingsWidget, 1 );
#endif

#ifdef Q_OS_SYMBIAN
Expand All @@ -316,6 +319,12 @@ void MagRead::settingsPage() {
removeShowData();
}

void MagRead::autoReorient( bool enabled ) {
#ifdef Q_WS_MAEMO_5
setAttribute( Qt::WA_Maemo5AutoOrientation, enabled );
#endif
}

/* Credit Page */
void MagRead::creditPage() {
notice( "Successfully Read Credit Card", 750 );
Expand Down
1 change: 1 addition & 0 deletions magread.h
Expand Up @@ -113,6 +113,7 @@ class MagRead : public QMainWindow {
void aboutDialogue();
void showData();
void settingsPage();
void autoReorient( bool enabled );
};

#endif // MAGREAD_H
11 changes: 9 additions & 2 deletions settingspage.cpp
Expand Up @@ -38,7 +38,7 @@ void SettingsPage::makeGeneralBox() {
formatAAMVA->setCheckState( Qt::Checked );
connect( formatAAMVA, SIGNAL( stateChanged( int ) ), this, SLOT( formatAAMVA_checked( int ) ) );

#ifndef Q_OS_SYMBIAN
#ifdef Q_WS_MAEMO_5
autoReorient = new QCheckBox( "Auto-reorient Screen" );//not symbian
generalLayout->addWidget( autoReorient );
if( settings->value( "autoReorient" ) == true )
Expand Down Expand Up @@ -85,7 +85,14 @@ void SettingsPage::autoReorient_checked( int state ) {
if( state == Qt::Checked )
settings->setValue( "autoReorient", true );
else
settings->setValue( "autoReorient", false );
settings->setValue( "autoReorient", false );
#ifdef Q_WS_MAEMO_5
if( settings->value( "autoReorient" ) == true ) {
emit autoReorientSig( true );
} else {
emit autoReorientSig( false );
}
#endif
}

void SettingsPage::timeOutChanged( int value ) {
Expand Down
1 change: 1 addition & 0 deletions settingspage.h
Expand Up @@ -46,6 +46,7 @@ class SettingsPage : public QScrollArea {
QSlider *silenceSlider;

signals:
void autoReorientSig( bool );

private slots:
void formatCredit_checked( int state );
Expand Down

0 comments on commit 1319c74

Please sign in to comment.