author | harlekin <harlekin> | 2003-12-09 12:20:41 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-09 12:20:41 (UTC) |
commit | e7d88d21f5b5daede2d04479b7e1157c2ffe7396 (patch) (unidiff) | |
tree | ce334f5144e5c8884852eb571e40e7aa422cc6d3 | |
parent | 7dac080b72cc36559e72563ffc9ad88f71b0574a (diff) | |
download | opie-e7d88d21f5b5daede2d04479b7e1157c2ffe7396.zip opie-e7d88d21f5b5daede2d04479b7e1157c2ffe7396.tar.gz opie-e7d88d21f5b5daede2d04479b7e1157c2ffe7396.tar.bz2 |
more flexible layout, and different base layouts based on current screen rotation
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 6e8f4d3..7af7d83 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,29 +1,31 @@ | |||
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 | 6 | ||
7 | #include <qpe/qpeapplication.h> | ||
6 | 8 | ||
7 | #include "defines.h" | 9 | #include "defines.h" |
8 | #include "mainwindow.h" | 10 | #include "mainwindow.h" |
9 | #include "viewmail.h" | 11 | #include "viewmail.h" |
10 | 12 | ||
11 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 13 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
12 | : QMainWindow( parent, name, flags ) | 14 | : QMainWindow( parent, name, flags ) |
13 | { | 15 | { |
14 | setCaption( tr( "Opie-Mail" ) ); | 16 | setCaption( tr( "Opie-Mail" ) ); |
15 | setToolBarsMovable( false ); | 17 | setToolBarsMovable( false ); |
16 | 18 | ||
17 | toolBar = new QToolBar( this ); | 19 | toolBar = new QToolBar( this ); |
18 | menuBar = new QMenuBar( toolBar ); | 20 | menuBar = new QMenuBar( toolBar ); |
19 | mailMenu = new QPopupMenu( menuBar ); | 21 | mailMenu = new QPopupMenu( menuBar ); |
20 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 22 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
21 | settingsMenu = new QPopupMenu( menuBar ); | 23 | settingsMenu = new QPopupMenu( menuBar ); |
22 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 24 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
23 | 25 | ||
24 | addToolBar( toolBar ); | 26 | addToolBar( toolBar ); |
25 | toolBar->setHorizontalStretchable( true ); | 27 | toolBar->setHorizontalStretchable( true ); |
26 | 28 | ||
27 | QLabel *spacer = new QLabel( toolBar ); | 29 | QLabel *spacer = new QLabel( toolBar ); |
28 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 30 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
29 | toolBar->setStretchableWidget( spacer ); | 31 | toolBar->setStretchableWidget( spacer ); |
@@ -43,65 +45,79 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
43 | syncFolders->addTo( toolBar ); | 45 | syncFolders->addTo( toolBar ); |
44 | syncFolders->addTo( mailMenu ); | 46 | syncFolders->addTo( mailMenu ); |
45 | 47 | ||
46 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 48 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
47 | 0, 0, this, 0, true ); | 49 | 0, 0, this, 0, true ); |
48 | showFolders->addTo( toolBar ); | 50 | showFolders->addTo( toolBar ); |
49 | showFolders->addTo( mailMenu ); | 51 | showFolders->addTo( mailMenu ); |
50 | connect(showFolders, SIGNAL( toggled( bool ) ), | 52 | connect(showFolders, SIGNAL( toggled( bool ) ), |
51 | SLOT( slotShowFolders( bool ) ) ); | 53 | SLOT( slotShowFolders( bool ) ) ); |
52 | 54 | ||
53 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 55 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
54 | 0, 0, this ); | 56 | 0, 0, this ); |
55 | searchMails->addTo( toolBar ); | 57 | searchMails->addTo( toolBar ); |
56 | searchMails->addTo( mailMenu ); | 58 | searchMails->addTo( mailMenu ); |
57 | 59 | ||
58 | 60 | ||
59 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 61 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
60 | 0, 0, this ); | 62 | 0, 0, this ); |
61 | editSettings->addTo( settingsMenu ); | 63 | editSettings->addTo( settingsMenu ); |
62 | 64 | ||
63 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 65 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
64 | 0, 0, this ); | 66 | 0, 0, this ); |
65 | editAccounts->addTo( settingsMenu ); | 67 | editAccounts->addTo( settingsMenu ); |
66 | 68 | ||
67 | QVBox *view = new QVBox( this ); | 69 | QWidget *view = new QWidget( this ); |
68 | setCentralWidget( view ); | 70 | setCentralWidget( view ); |
69 | 71 | ||
72 | |||
73 | QWidget *d = QApplication::desktop(); | ||
74 | QBoxLayout *layout; | ||
75 | |||
76 | if ( d->width() < d->height() ) { | ||
77 | layout = new QVBoxLayout( view ); | ||
78 | } else { | ||
79 | layout = new QHBoxLayout( view ); | ||
80 | } | ||
81 | |||
70 | folderView = new AccountView( view ); | 82 | folderView = new AccountView( view ); |
71 | folderView->header()->hide(); | 83 | folderView->header()->hide(); |
72 | folderView->setMinimumHeight( 90 ); | ||
73 | folderView->setMaximumHeight( 90 ); | ||
74 | folderView->addColumn( tr( "Mailbox" ) ); | 84 | folderView->addColumn( tr( "Mailbox" ) ); |
75 | folderView->hide(); | 85 | folderView->hide(); |
76 | 86 | ||
87 | layout->addWidget( folderView ); | ||
88 | |||
77 | mailView = new QListView( view ); | 89 | mailView = new QListView( view ); |
78 | mailView->setMinimumHeight( 50 ); | ||
79 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 90 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
80 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 91 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
81 | mailView->addColumn( tr( "Date" )); | 92 | mailView->addColumn( tr( "Date" )); |
82 | mailView->setAllColumnsShowFocus(true); | 93 | mailView->setAllColumnsShowFocus(true); |
83 | mailView->setSorting(-1); | 94 | mailView->setSorting(-1); |
95 | |||
96 | layout->addWidget( mailView ); | ||
97 | layout->setStretchFactor( folderView, 1 ); | ||
98 | layout->setStretchFactor( mailView, 2 ); | ||
99 | |||
84 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 100 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
85 | SLOT( displayMail( QListViewItem * ) ) ); | 101 | SLOT( displayMail( QListViewItem * ) ) ); |
86 | 102 | ||
87 | connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); | 103 | connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); |
88 | 104 | ||
89 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 105 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
90 | } | 106 | } |
91 | 107 | ||
92 | void MainWindow::slotAdjustColumns() | 108 | void MainWindow::slotAdjustColumns() |
93 | { | 109 | { |
94 | bool hidden = folderView->isHidden(); | 110 | bool hidden = folderView->isHidden(); |
95 | if ( hidden ) folderView->show(); | 111 | if ( hidden ) folderView->show(); |
96 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 112 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
97 | if ( hidden ) folderView->hide(); | 113 | if ( hidden ) folderView->hide(); |
98 | 114 | ||
99 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); | 115 | mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); |
100 | mailView->setColumnWidth( 1, 80 ); | 116 | mailView->setColumnWidth( 1, 80 ); |
101 | mailView->setColumnWidth( 2, 50 ); | 117 | mailView->setColumnWidth( 2, 50 ); |
102 | } | 118 | } |
103 | 119 | ||
104 | void MainWindow::slotShowFolders( bool show ) | 120 | void MainWindow::slotShowFolders( bool show ) |
105 | { | 121 | { |
106 | qDebug( "Show Folders" ); | 122 | qDebug( "Show Folders" ); |
107 | if ( show && folderView->isHidden() ) { | 123 | if ( show && folderView->isHidden() ) { |