summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-05 17:46:46 (UTC)
committer alwin <alwin>2005-03-05 17:46:46 (UTC)
commita287cf7aad0660d4c7a573ff4da8ef35c78bb712 (patch) (unidiff)
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
@@ -1,219 +1,237 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6 6
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/qcopenvelope_qws.h>
9 10
10#include "defines.h" 11#include "defines.h"
11#include "mainwindow.h" 12#include "mainwindow.h"
12 13
13using namespace Opie::Core; 14using namespace Opie::Core;
14 15
15MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 16MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
16 : QMainWindow( parent, name, flags ) 17 : QMainWindow( parent, name, flags )
17{ 18{
18 19
19 setCaption( tr( "Mail" ) ); 20 setCaption( tr( "Mail" ) );
20 setToolBarsMovable( false ); 21 setToolBarsMovable( false );
21 22
22 toolBar = new QToolBar( this ); 23 toolBar = new QToolBar( this );
23 menuBar = new QMenuBar( toolBar ); 24 menuBar = new QMenuBar( toolBar );
24 mailMenu = new QPopupMenu( menuBar ); 25 mailMenu = new QPopupMenu( menuBar );
25 menuBar->insertItem( tr( "Mail" ), mailMenu ); 26 menuBar->insertItem( tr( "Mail" ), mailMenu );
26 settingsMenu = new QPopupMenu( menuBar ); 27 settingsMenu = new QPopupMenu( menuBar );
27 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 28 menuBar->insertItem( tr( "Settings" ), settingsMenu );
28 29
29 addToolBar( toolBar ); 30 addToolBar( toolBar );
30 toolBar->setHorizontalStretchable( true ); 31 toolBar->setHorizontalStretchable( true );
31 32
32 QLabel *spacer = new QLabel( toolBar ); 33 QLabel *spacer = new QLabel( toolBar );
33 spacer->setBackgroundMode( QWidget::PaletteButton ); 34 spacer->setBackgroundMode( QWidget::PaletteButton );
34 toolBar->setStretchableWidget( spacer ); 35 toolBar->setStretchableWidget( spacer );
35 36
36 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
37 0, 0, this ); 38 0, 0, this );
38 composeMail->addTo( toolBar ); 39 composeMail->addTo( toolBar );
39 composeMail->addTo( mailMenu ); 40 composeMail->addTo( mailMenu );
40 41
41 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
42 0, 0, this ); 43 0, 0, this );
43 sendQueued->addTo( toolBar ); 44 sendQueued->addTo( toolBar );
44 sendQueued->addTo( mailMenu ); 45 sendQueued->addTo( mailMenu );
45 46
46 /* 47 /*
47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 48 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
48 0, 0, this ); 49 0, 0, this );
49 syncFolders->addTo( toolBar ); 50 syncFolders->addTo( toolBar );
50 syncFolders->addTo( mailMenu ); 51 syncFolders->addTo( mailMenu );
51 */ 52 */
52 53
53 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 54 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
54 0, 0, this, 0, true ); 55 0, 0, this, 0, true );
55 showFolders->addTo( toolBar ); 56 showFolders->addTo( toolBar );
56 showFolders->addTo( mailMenu ); 57 showFolders->addTo( mailMenu );
57 showFolders->setOn( true ); 58 showFolders->setOn( true );
58 connect(showFolders, SIGNAL( toggled(bool) ), 59 connect(showFolders, SIGNAL( toggled(bool) ),
59 SLOT( slotShowFolders(bool) ) ); 60 SLOT( slotShowFolders(bool) ) );
60 61
61 /* 62 /*
62 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), 63 searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ),
63 0, 0, this ); 64 0, 0, this );
64 searchMails->addTo( toolBar ); 65 searchMails->addTo( toolBar );
65 searchMails->addTo( mailMenu ); 66 searchMails->addTo( mailMenu );
66 */ 67 */
67 68
68 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); 69 deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this);
69 deleteMails->addTo( toolBar ); 70 deleteMails->addTo( toolBar );
70 deleteMails->addTo( mailMenu ); 71 deleteMails->addTo( mailMenu );
71 connect( deleteMails, SIGNAL( activated() ), 72 connect( deleteMails, SIGNAL( activated() ),
72 SLOT( slotDeleteMail() ) ); 73 SLOT( slotDeleteMail() ) );
73 74
74 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , 75 editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) ,
75 0, 0, this ); 76 0, 0, this );
76 editSettings->addTo( settingsMenu ); 77 editSettings->addTo( settingsMenu );
77 connect( editSettings, SIGNAL( activated() ), 78 connect( editSettings, SIGNAL( activated() ),
78 SLOT( slotEditSettings() ) ); 79 SLOT( slotEditSettings() ) );
79 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , 80 editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) ,
80 0, 0, this ); 81 0, 0, this );
81 editAccounts->addTo( settingsMenu ); 82 editAccounts->addTo( settingsMenu );
82 83
83 //setCentralWidget( view ); 84 //setCentralWidget( view );
84 85
85 QVBox* wrapperBox = new QVBox( this ); 86 QVBox* wrapperBox = new QVBox( this );
86 setCentralWidget( wrapperBox ); 87 setCentralWidget( wrapperBox );
87 88
88 QWidget *view = new QWidget( wrapperBox ); 89 QWidget *view = new QWidget( wrapperBox );
89
90 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 90 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
91 91
92 folderView = new AccountView( view ); 92 folderView = new AccountView( view );
93 folderView->header()->hide(); 93 folderView->header()->hide();
94 folderView->setRootIsDecorated( true ); 94 folderView->setRootIsDecorated( true );
95 folderView->addColumn( tr( "Mailbox" ) ); 95 folderView->addColumn( tr( "Mailbox" ) );
96 96
97 layout->addWidget( folderView ); 97 layout->addWidget( folderView );
98 98
99 mailView = new QListView( view ); 99 mailView = new QListView( view );
100 mailView->addColumn( "" ); 100 mailView->addColumn( "" );
101 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 101 mailView->addColumn( tr( "Subject" ),QListView::Manual );
102 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 102 mailView->addColumn( tr( "Sender" ),QListView::Manual );
103 mailView->addColumn( tr( "Size" ),QListView::Manual); 103 mailView->addColumn( tr( "Size" ),QListView::Manual);
104 mailView->addColumn( tr( "Date" )); 104 mailView->addColumn( tr( "Date" ));
105 mailView->setAllColumnsShowFocus(true); 105 mailView->setAllColumnsShowFocus(true);
106 mailView->setShowSortIndicator(true); 106 mailView->setShowSortIndicator(true);
107 mailView->setSorting(4,false); 107 mailView->setSorting(4,false);
108 108
109 statusWidget = new StatusWidget( wrapperBox ); 109 statusWidget = new StatusWidget( wrapperBox );
110 statusWidget->hide(); 110 statusWidget->hide();
111 111
112 layout->addWidget( mailView ); 112 layout->addWidget( mailView );
113 layout->setStretchFactor( folderView, 1 ); 113 layout->setStretchFactor( folderView, 1 );
114 layout->setStretchFactor( mailView, 2 ); 114 layout->setStretchFactor( mailView, 2 );
115 115
116 m_Rotate = (QApplication::desktop()->width() > QApplication::desktop()->height()?0:90);
117
116 slotAdjustLayout(); 118 slotAdjustLayout();
117 119
118 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 120 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
119 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 121 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
120 122
121 connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, 123 connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this,
122 SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); 124 SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) );
123 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 125 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
124 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 126 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
125 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 127 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
126 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 128 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
127 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 129 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
128 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 130 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
129// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 131// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
130 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 132 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
131 // Added by Stefan Eilers to allow starting by addressbook.. 133 // Added by Stefan Eilers to allow starting by addressbook..
132 // copied from old mail2 134 // copied from old mail2
133#if !defined(QT_NO_COP) 135#if !defined(QT_NO_COP)
134 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), 136 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
135 this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); 137 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
138 m_sysChannel = new QCopChannel( "QPE/System", this );
139 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
140 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
136#endif 141#endif
137 142
138 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 143 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
139} 144}
140 145
141MainWindow::~MainWindow() 146MainWindow::~MainWindow()
142{ 147{
143} 148}
144 149
150void MainWindow::systemMessage( const QCString& msg, const QByteArray& data )
151{
152 int _newrotation;
153 QDataStream stream( data, IO_ReadOnly );
154 if ( msg == "setCurrentRotation(int)" )
155 {
156 stream >> _newrotation;
157 if (m_Rotate != _newrotation) {
158 slotAdjustLayout();
159 m_Rotate = _newrotation;
160 }
161 }
162}
163
145void MainWindow::appMessage(const QCString &, const QByteArray &) 164void MainWindow::appMessage(const QCString &, const QByteArray &)
146{ 165{
147 odebug << "appMessage not reached" << oendl; 166 odebug << "appMessage not reached" << oendl;
148} 167}
149 168
150void MainWindow::slotAdjustLayout() { 169void MainWindow::slotAdjustLayout() {
151 170
152 QWidget *d = QApplication::desktop(); 171 QWidget *d = QApplication::desktop();
153 172 if ( d->width() < d->height() ) {
154 if ( d->width() < d->height() ) { 173 layout->setDirection( QBoxLayout::TopToBottom );
155 layout->setDirection( QBoxLayout::TopToBottom );
156 } else { 174 } else {
157 layout->setDirection( QBoxLayout::LeftToRight ); 175 layout->setDirection( QBoxLayout::LeftToRight );
158 } 176 }
159} 177}
160 178
161void MainWindow::slotAdjustColumns() 179void MainWindow::slotAdjustColumns()
162{ 180{
163 bool hidden = folderView->isHidden(); 181 bool hidden = folderView->isHidden();
164 if ( hidden ) folderView->show(); 182 if ( hidden ) folderView->show();
165 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 183 folderView->setColumnWidth( 0, folderView->visibleWidth() );
166 if ( hidden ) folderView->hide(); 184 if ( hidden ) folderView->hide();
167 185
168 mailView->setColumnWidth( 0, 10 ); 186 mailView->setColumnWidth( 0, 10 );
169 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 187 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
170 mailView->setColumnWidth( 2, 80 ); 188 mailView->setColumnWidth( 2, 80 );
171 mailView->setColumnWidth( 3, 50 ); 189 mailView->setColumnWidth( 3, 50 );
172 mailView->setColumnWidth( 4, 50 ); 190 mailView->setColumnWidth( 4, 50 );
173} 191}
174 192
175void MainWindow::slotEditSettings() 193void MainWindow::slotEditSettings()
176{ 194{
177} 195}
178 196
179void MainWindow::slotShowFolders( bool ) 197void MainWindow::slotShowFolders( bool )
180{ 198{
181 odebug << "slotShowFolders not reached" << oendl; 199 odebug << "slotShowFolders not reached" << oendl;
182} 200}
183 201
184void MainWindow::refreshMailView(const QValueList<RecMailP>&) 202void MainWindow::refreshMailView(const QValueList<RecMailP>&)
185{ 203{
186 odebug << "refreshMailView not reached" << oendl; 204 odebug << "refreshMailView not reached" << oendl;
187} 205}
188 206
189void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) 207void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int )
190{ 208{
191 odebug << "mailLeftClicked not reached" << oendl; 209 odebug << "mailLeftClicked not reached" << oendl;
192} 210}
193 211
194void MainWindow::displayMail() 212void MainWindow::displayMail()
195{ 213{
196 odebug << "displayMail not reached" << oendl; 214 odebug << "displayMail not reached" << oendl;
197} 215}
198 216
199void MainWindow::slotDeleteMail() 217void MainWindow::slotDeleteMail()
200{ 218{
201 odebug << "deleteMail not reached" << oendl; 219 odebug << "deleteMail not reached" << oendl;
202} 220}
203 221
204void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 222void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
205{ 223{
206 odebug << "mailHold not reached" << oendl; 224 odebug << "mailHold not reached" << oendl;
207} 225}
208 226
209void MainWindow::slotSendQueued() 227void MainWindow::slotSendQueued()
210{ 228{
211} 229}
212 230
213void MainWindow::slotEditAccounts() 231void MainWindow::slotEditAccounts()
214{ 232{
215} 233}
216 234
217void MainWindow::slotComposeMail() 235void MainWindow::slotComposeMail()
218{ 236{
219} 237}
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
@@ -1,56 +1,60 @@
1#ifndef MAINWINDOW_H 1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H 2#define MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qaction.h> 6#include <qaction.h>
7 7
8#include <qtoolbar.h> 8#include <qtoolbar.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10 10
11#include "accountview.h" 11#include "accountview.h"
12#include "statuswidget.h" 12#include "statuswidget.h"
13 13
14#include <libmailwrapper/mailtypes.h> 14#include <libmailwrapper/mailtypes.h>
15#include <opie2/osmartpointer.h> 15#include <opie2/osmartpointer.h>
16 16
17class RecMail; 17class RecMail;
18class QCopChannel;
18 19
19class MainWindow : public QMainWindow 20class MainWindow : public QMainWindow
20{ 21{
21 Q_OBJECT 22 Q_OBJECT
22 23
23public: 24public:
24 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 25 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
25 virtual ~MainWindow(); 26 virtual ~MainWindow();
26 27
27public slots: 28public slots:
28 virtual void slotAdjustColumns(); 29 virtual void slotAdjustColumns();
29 virtual void appMessage(const QCString &msg, const QByteArray &data); 30 virtual void appMessage(const QCString &msg, const QByteArray &data);
30 virtual void slotComposeMail(); 31 virtual void slotComposeMail();
32 virtual void systemMessage( const QCString&, const QByteArray& );
31 33
32protected slots: 34protected slots:
33 virtual void slotSendQueued(); 35 virtual void slotSendQueued();
34 virtual void slotEditAccounts(); 36 virtual void slotEditAccounts();
35 virtual void slotShowFolders( bool show ); 37 virtual void slotShowFolders( bool show );
36 virtual void refreshMailView(const QValueList<RecMailP>&); 38 virtual void refreshMailView(const QValueList<RecMailP>&);
37 virtual void displayMail(); 39 virtual void displayMail();
38 virtual void slotDeleteMail(); 40 virtual void slotDeleteMail();
39 virtual void mailHold(int, QListViewItem *,const QPoint&,int); 41 virtual void mailHold(int, QListViewItem *,const QPoint&,int);
40 virtual void slotAdjustLayout(); 42 virtual void slotAdjustLayout();
41 virtual void slotEditSettings(); 43 virtual void slotEditSettings();
42 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); 44 virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int );
43 45
44protected: 46protected:
45 QToolBar *toolBar; 47 QToolBar *toolBar;
46 StatusWidget *statusWidget; 48 StatusWidget *statusWidget;
47 QMenuBar *menuBar; 49 QMenuBar *menuBar;
48 QPopupMenu *mailMenu, *settingsMenu; 50 QPopupMenu *mailMenu, *settingsMenu;
49 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, 51 QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails,
50 *editSettings, *editAccounts, *syncFolders; 52 *editSettings, *editAccounts, *syncFolders;
51 AccountView *folderView; 53 AccountView *folderView;
52 QListView *mailView; 54 QListView *mailView;
53 QBoxLayout *layout; 55 QBoxLayout *layout;
56 int m_Rotate;
57 QCopChannel* m_sysChannel;
54}; 58};
55 59
56#endif 60#endif