author | alwin <alwin> | 2005-03-05 17:46:46 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-05 17:46:46 (UTC) |
commit | a287cf7aad0660d4c7a573ff4da8ef35c78bb712 (patch) (side-by-side diff) | |
tree | df6b26dca01f4b41710197b1653225c52b4b287b | |
parent | c017febf6f4092bb968d12df5a30a0af30066048 (diff) | |
download | opie-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)
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 32 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 4 |
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 @@ -5,8 +5,9 @@ #include <qlayout.h> #include <opie2/odebug.h> #include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> #include "defines.h" #include "mainwindow.h" @@ -85,9 +86,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); QWidget *view = new QWidget( wrapperBox ); - layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); @@ -112,8 +112,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) layout->addWidget( mailView ); layout->setStretchFactor( folderView, 1 ); layout->setStretchFactor( mailView, 2 ); + m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90); + slotAdjustLayout(); QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); @@ -132,8 +134,11 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) // copied from old mail2 #if !defined(QT_NO_COP) connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 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 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); } @@ -141,22 +146,35 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 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 &) { odebug << "appMessage not reached" << oendl; } 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 ); + } } void MainWindow::slotAdjustColumns() { 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 @@ -14,8 +14,9 @@ #include <libmailwrapper/mailtypes.h> #include <opie2/osmartpointer.h> class RecMail; +class QCopChannel; class MainWindow : public QMainWindow { Q_OBJECT @@ -27,8 +28,9 @@ public: public slots: virtual void slotAdjustColumns(); virtual void appMessage(const QCString &msg, const QByteArray &data); virtual void slotComposeMail(); + virtual void systemMessage( const QCString&, const QByteArray& ); protected slots: virtual void slotSendQueued(); virtual void slotEditAccounts(); @@ -50,7 +52,9 @@ protected: *editSettings, *editAccounts, *syncFolders; AccountView *folderView; QListView *mailView; QBoxLayout *layout; + int m_Rotate; + QCopChannel* m_sysChannel; }; #endif |