summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-05 17:46:46 (UTC)
committer alwin <alwin>2005-03-05 17:46:46 (UTC)
commita287cf7aad0660d4c7a573ff4da8ef35c78bb712 (patch) (side-by-side diff)
treedf6b26dca01f4b41710197b1653225c52b4b287b
parentc017febf6f4092bb968d12df5a30a0af30066048 (diff)
downloadopie-a287cf7aad0660d4c7a573ff4da8ef35c78bb712.zip
opie-a287cf7aad0660d4c7a573ff4da8ef35c78bb712.tar.gz
opie-a287cf7aad0660d4c7a573ff4da8ef35c78bb712.tar.bz2
change the layoutdirection of main window when display is rotating
(LeftToRight when 0 rotation, TopToButtom when 90)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/mainwindow.cpp32
-rw-r--r--noncore/net/mail/mainwindow.h4
2 files changed, 29 insertions, 7 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index c115b32..93d80d9 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -8,2 +8,3 @@
#include <qpe/qpeapplication.h>
+#include <qpe/qcopenvelope_qws.h>
@@ -88,3 +89,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
QWidget *view = new QWidget( wrapperBox );
-
layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
@@ -115,2 +115,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
+ m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90);
+
slotAdjustLayout();
@@ -135,2 +137,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
+ m_sysChannel = new QCopChannel( "QPE/System", this );
+ connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
+ this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
#endif
@@ -144,2 +149,16 @@ MainWindow::~MainWindow()
+void MainWindow::systemMessage( const QCString& msg, const QByteArray& data )
+{
+ int _newrotation;
+ QDataStream stream( data, IO_ReadOnly );
+ if ( msg == "setCurrentRotation(int)" )
+ {
+ stream >> _newrotation;
+ if (m_Rotate != _newrotation) {
+ slotAdjustLayout();
+ m_Rotate = _newrotation;
+ }
+ }
+}
+
void MainWindow::appMessage(const QCString &, const QByteArray &)
@@ -151,9 +170,8 @@ void MainWindow::slotAdjustLayout() {
- QWidget *d = QApplication::desktop();
-
- if ( d->width() < d->height() ) {
- layout->setDirection( QBoxLayout::TopToBottom );
+ QWidget *d = QApplication::desktop();
+ if ( d->width() < d->height() ) {
+ layout->setDirection( QBoxLayout::TopToBottom );
} else {
- layout->setDirection( QBoxLayout::LeftToRight );
- }
+ layout->setDirection( QBoxLayout::LeftToRight );
+ }
}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index 8d004c6..8cec888 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -17,2 +17,3 @@
class RecMail;
+class QCopChannel;
@@ -30,2 +31,3 @@ public slots:
virtual void slotComposeMail();
+ virtual void systemMessage( const QCString&, const QByteArray& );
@@ -53,2 +55,4 @@ protected:
QBoxLayout *layout;
+ int m_Rotate;
+ QCopChannel* m_sysChannel;
};