summaryrefslogtreecommitdiffabout
path: root/kmicromail/mainwindow.cpp
Unidiff
Diffstat (limited to 'kmicromail/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/mainwindow.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 98eb9a5..3013931 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -1,55 +1,56 @@
1 1
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qvbox.h> 4#include <qvbox.h>
5#include <qheader.h> 5#include <qheader.h>
6#include <qtimer.h> 6#include <qtimer.h>
7#include <qlayout.h> 7#include <qlayout.h>
8//#include <kdialog.h> 8//#include <kdialog.h>
9#include <kiconloader.h> 9#include <kiconloader.h>
10#include <kapplication.h> 10#include <kapplication.h>
11 11
12#ifdef DESKTOP_VERSION 12#ifdef DESKTOP_VERSION
13#include <qapplication.h> 13#include <qapplication.h>
14#include <qstatusbar.h> 14#include <qstatusbar.h>
15#include <kabc/stdaddressbook.h>
15extern QStatusBar* globalSstatusBarMainWindow; 16extern QStatusBar* globalSstatusBarMainWindow;
16#else 17#else
17#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
18#endif 19#endif
19#include "defines.h" 20#include "defines.h"
20#include "mainwindow.h" 21#include "mainwindow.h"
21#include <KDGanttMinimizeSplitter.h> 22#include <KDGanttMinimizeSplitter.h>
22 23
23#include <kabc/stdaddressbook.h> 24#include "koprefs.h"
24 25
25MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 26MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
26 : QMainWindow( parent, name ) //, flags ) 27 : QMainWindow( parent, name ) //, flags )
27{ 28{
28#ifdef DESKTOP_VERSION 29#ifdef DESKTOP_VERSION
29 globalSstatusBarMainWindow = statusBar(); 30 globalSstatusBarMainWindow = statusBar();
30#endif 31#endif
31 setCaption( i18n( "KOpieMail/Pi" ) ); 32 setCaption( i18n( "KOpieMail/Pi" ) );
32 setToolBarsMovable( false ); 33 setToolBarsMovable( false );
33 //KABC::StdAddressBook::self(); 34 //KABC::StdAddressBook::self();
34 toolBar = new QToolBar( this ); 35 toolBar = new QToolBar( this );
35 menuBar = new QPEMenuBar( toolBar ); 36 menuBar = new QPEMenuBar( toolBar );
36 mailMenu = new QPopupMenu( menuBar ); 37 mailMenu = new QPopupMenu( menuBar );
37 menuBar->insertItem( i18n( "Mail" ), mailMenu ); 38 menuBar->insertItem( i18n( "Mail" ), mailMenu );
38 settingsMenu = new QPopupMenu( menuBar ); 39 settingsMenu = new QPopupMenu( menuBar );
39 menuBar->insertItem( i18n( "Settings" ), settingsMenu ); 40 menuBar->insertItem( i18n( "Settings" ), settingsMenu );
40 41
41 addToolBar( toolBar ); 42 addToolBar( toolBar );
42 toolBar->setHorizontalStretchable( true ); 43 toolBar->setHorizontalStretchable( true );
43 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 44 QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"),
44 0, 0, this ); 45 0, 0, this );
45 connect(getMail, SIGNAL( activated() ), 46 connect(getMail, SIGNAL( activated() ),
46 SLOT( slotGetAllMail() ) ); 47 SLOT( slotGetAllMail() ) );
47 getMail->addTo( mailMenu ); 48 getMail->addTo( mailMenu );
48 49
49 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 50 getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"),
50 0, 0, this ); 51 0, 0, this );
51 getMail->addTo( toolBar ); 52 getMail->addTo( toolBar );
52 getMail->addTo( mailMenu ); 53 getMail->addTo( mailMenu );
53 connect(getMail, SIGNAL( activated() ), 54 connect(getMail, SIGNAL( activated() ),
54 SLOT( slotGetMail() ) ); 55 SLOT( slotGetMail() ) );
55 56
@@ -70,65 +71,72 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
70 syncFolders->addTo( mailMenu ); 71 syncFolders->addTo( mailMenu );
71 */ 72 */
72 73
73 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 74 showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") ,
74 0, 0, this, 0, true ); 75 0, 0, this, 0, true );
75 showFolders->addTo( toolBar ); 76 showFolders->addTo( toolBar );
76 showFolders->addTo( mailMenu ); 77 showFolders->addTo( mailMenu );
77 showFolders->setOn( true ); 78 showFolders->setOn( true );
78 connect(showFolders, SIGNAL( toggled(bool) ), 79 connect(showFolders, SIGNAL( toggled(bool) ),
79 SLOT( slotShowFolders(bool) ) ); 80 SLOT( slotShowFolders(bool) ) );
80 81
81 /* 82 /*
82 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 83 searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ),
83 0, 0, this ); 84 0, 0, this );
84 searchMails->addTo( toolBar ); 85 searchMails->addTo( toolBar );
85 searchMails->addTo( mailMenu ); 86 searchMails->addTo( mailMenu );
86 */ 87 */
87 88
88 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); 89 deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this);
89 deleteMails->addTo( toolBar ); 90 deleteMails->addTo( toolBar );
90 deleteMails->addTo( mailMenu ); 91 deleteMails->addTo( mailMenu );
91 connect( deleteMails, SIGNAL( activated() ), 92 connect( deleteMails, SIGNAL( activated() ),
92 SLOT( slotDeleteMail() ) ); 93 SLOT( slotDeleteMail() ) );
93 94
94 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 95 editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") ,
95 0, 0, this ); 96 0, 0, this );
96 editSettings->addTo( settingsMenu ); 97 editSettings->addTo( settingsMenu );
97 connect( editSettings, SIGNAL( activated() ), 98 connect( editSettings, SIGNAL( activated() ),
98 SLOT( slotEditSettings() ) ); 99 SLOT( slotEditSettings() ) );
99 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 100 editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") ,
100 0, 0, this ); 101 0, 0, this );
101 editAccounts->addTo( settingsMenu ); 102 editAccounts->addTo( settingsMenu );
102 103 codecMenu = new QPopupMenu( menuBar );
104 codecMenu->insertItem( "Western (iso-8859-1)",0,0);
105 codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1);
106 codecMenu->insertItem( "Western (iso-8859-15)",2,2);
107 codecMenu->insertItem( "Chinese (big-5)",3,3);
108 codecMenu->insertItem( "Unicode (utf-8)",4,4);
109 codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5);
110 settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu);
103 //setCentralWidget( view ); 111 //setCentralWidget( view );
104 112
105 QVBox* wrapperBox = new QVBox( this ); 113 QVBox* wrapperBox = new QVBox( this );
106 setCentralWidget( wrapperBox ); 114 setCentralWidget( wrapperBox );
107 115
108 // QWidget *view = new QWidget( wrapperBox ); 116 // QWidget *view = new QWidget( wrapperBox );
109 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 117 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
110 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 118 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
111 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 119 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
112 120
113 folderView = new AccountView( split ); 121 folderView = new AccountView( split );
114 folderView->header()->hide(); 122 folderView->header()->hide();
115 folderView->setRootIsDecorated( false ); 123 folderView->setRootIsDecorated( false );
116 folderView->addColumn( i18n( "Mailbox" ) ); 124 folderView->addColumn( i18n( "Mailbox" ) );
117 125
118 //layout->addWidget( folderView ); 126 //layout->addWidget( folderView );
119 127
120 mailView = new QListView( split ); 128 mailView = new QListView( split );
121 mailView->addColumn( i18n( " " ) ); 129 mailView->addColumn( i18n( " " ) );
122 mailView->addColumn( i18n( "Subject" ),QListView::Manual ); 130 mailView->addColumn( i18n( "Subject" ),QListView::Manual );
123 mailView->addColumn( i18n( "Sender" ),QListView::Manual ); 131 mailView->addColumn( i18n( "Sender" ),QListView::Manual );
124 mailView->addColumn( i18n( "Size" ),QListView::Manual); 132 mailView->addColumn( i18n( "Size" ),QListView::Manual);
125 mailView->addColumn( i18n( "Date" ),QListView::Manual); 133 mailView->addColumn( i18n( "Date" ),QListView::Manual);
126 mailView->setAllColumnsShowFocus(true); 134 mailView->setAllColumnsShowFocus(true);
127 //mailView->setSorting(-1); 135 //mailView->setSorting(-1);
128 mailView->setRootIsDecorated( false ); 136 mailView->setRootIsDecorated( false );
129 statusWidget = new StatusWidget( wrapperBox ); 137 statusWidget = new StatusWidget( wrapperBox );
130 statusWidget->hide(); 138 statusWidget->hide();
131 139
132 //layout->addWidget( mailView ); 140 //layout->addWidget( mailView );
133 //layout->setStretchFactor( folderView, 1 ); 141 //layout->setStretchFactor( folderView, 1 );
134 //layout->setStretchFactor( mailView, 2 ); 142 //layout->setStretchFactor( mailView, 2 );
@@ -154,73 +162,106 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
154 mailView->setSelectionMode( QListView::Extended ); 162 mailView->setSelectionMode( QListView::Extended );
155 QValueList<int> list; 163 QValueList<int> list;
156 int fw = 100; 164 int fw = 100;
157 if ( QApplication::desktop()->width() > 320 ) 165 if ( QApplication::desktop()->width() > 320 )
158 fw = 50; 166 fw = 50;
159 list.append( fw ); 167 list.append( fw );
160 list.append( 100 ); 168 list.append( 100 );
161 split->setSizes( list ); 169 split->setSizes( list );
162 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 170 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
163 mailView->setShowSortIndicator ( true ); 171 mailView->setShowSortIndicator ( true );
164 QLabel *spacer = new QLabel( toolBar ); 172 QLabel *spacer = new QLabel( toolBar );
165 spacer->setBackgroundMode( QWidget::PaletteButton ); 173 spacer->setBackgroundMode( QWidget::PaletteButton );
166 toolBar->setStretchableWidget( spacer ); 174 toolBar->setStretchableWidget( spacer );
167 175
168 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 176 QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
169 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 177 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
170 if ( QApplication::desktop()->width() > 320 ) 178 if ( QApplication::desktop()->width() > 320 )
171 closeMail->addTo(toolBar); 179 closeMail->addTo(toolBar);
172 closeMail->addTo(mailMenu); 180 closeMail->addTo(mailMenu);
173 181
174 182
175 QPopupMenu* helpMenu = new QPopupMenu( menuBar ); 183 QPopupMenu* helpMenu = new QPopupMenu( menuBar );
176 menuBar->insertItem( i18n( "Help" ), helpMenu ); 184 menuBar->insertItem( i18n( "Help" ), helpMenu );
177 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); 185 QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this);
178 connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); 186 connect( li, SIGNAL( activated() ), SLOT( showAbout()) );
179 li->addTo(helpMenu); 187 li->addTo(helpMenu);
180 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); 188 li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this);
181 connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); 189 connect( li, SIGNAL( activated() ), SLOT( showLicence()) );
182 li->addTo(helpMenu); 190 li->addTo(helpMenu);
183 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); 191 li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this);
184 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); 192 connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) );
185 li->addTo(helpMenu); 193 li->addTo(helpMenu);
194 connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) );
195 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
186#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
187 resize ( 640, 480 ); 197 resize ( 640, 480 );
188#endif 198#endif
189} 199}
190 200
191MainWindow::~MainWindow() 201MainWindow::~MainWindow()
192{ 202{
193} 203}
194 204
205void MainWindow::slotSetCodec( int codec )
206{
207 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false );
208 //qDebug("codec %d ", codec);
209 KOPrefs::instance()->mCurrentCodec = codec;
210 KOPrefs::instance()->isDirty = true;
211 QString name;
212 switch ( codec ) {
213 case 0:
214 name = "iso-8859-1";
215 break;
216 case 1:
217 name = "iso-8859-5";
218 break;
219 case 2:
220 name = "iso-8859-15";
221 break;
222 case 3:
223 name = "big-5";
224 break;
225 case 4:
226 name = "utf-8";
227 break;
228 case 5:
229 name = KOPrefs::instance()->mSendCodec.lower();
230 break;
231 }
232 KOPrefs::instance()->mCurrentCodeName = name ;
233 codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")");
234 codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true );
235}
195void MainWindow::showLicence() 236void MainWindow::showLicence()
196{ 237{
197 KApplication::showLicence(); 238 KApplication::showLicence();
198} 239}
199void MainWindow::showAbout() 240void MainWindow::showAbout()
200{ 241{
201 QString version; 242 QString version;
202#include <../version> 243#include <../version>
203 244
204 QString cap = "About KOpieMail/Pi"; 245 QString cap = "About KOpieMail/Pi";
205 QString text =i18n("KOpieMail/Platform-independent\n") + 246 QString text =i18n("KOpieMail/Platform-independent\n") +
206 "(OM/Pi) " + version + " - " 247 "(OM/Pi) " + version + " - "
207 248
208#ifdef DESKTOP_VERSION 249#ifdef DESKTOP_VERSION
209 "Desktop Edition\n" 250 "Desktop Edition\n"
210#else 251#else
211 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" 252 "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n"
212#endif 253#endif
213 "www.pi-sync.net\n\n" 254 "www.pi-sync.net\n\n"
214 255
215 256
216 257
217"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" 258"Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n"
218 "KOpieMail/Pi is based on Opie Mail\n" 259 "KOpieMail/Pi is based on Opie Mail\n"
219 "Copyright (c) Rajko Albrecht and the Opie team\n" 260 "Copyright (c) Rajko Albrecht and the Opie team\n"
220 "KOpieMail/Pi is licensed under the GPL\n" 261 "KOpieMail/Pi is licensed under the GPL\n"
221 "\n" 262 "\n"
222 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" 263 "KOpieMail/Pi uses LibEtPan - a mail stuff library\n"
223 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" 264 "Copyright (C) 2001, 2002 - DINH Viet Hoa\n"
224 "libEtPan has its own licence - see LibEtPan licence\n"; 265 "libEtPan has its own licence - see LibEtPan licence\n";
225 266
226 KApplication::showText( cap, text ); 267 KApplication::showText( cap, text );