-rw-r--r-- | kmicromail/mainwindow.cpp | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 250d114..0794e00 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -1,45 +1,46 @@ // CHANGED 2004-08-06 Lutz Rogowski #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> //#include <kdialog.h> #include <kiconloader.h> #include <kapplication.h> #ifdef DESKTOP_VERSION #include <qapplication.h> #include <qstatusbar.h> #include <kabc/stdaddressbook.h> extern QStatusBar* globalSstatusBarMainWindow; #else #include <qpe/qpeapplication.h> #include <klocale.h> #endif #include "defines.h" +#include "koprefs.h" #include "mainwindow.h" #include "mailistviewitem.h" #include <KDGanttMinimizeSplitter.h> #include "koprefs.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name ) //, flags ) { #ifdef DESKTOP_VERSION globalSstatusBarMainWindow = statusBar(); #endif setCaption( i18n( "KOpieMail/Pi" ) ); setToolBarsMovable( false ); //KABC::StdAddressBook::self(); toolBar = new QToolBar( this ); menuBar = new QPEMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( i18n( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( i18n( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); @@ -63,127 +64,146 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); /* syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); */ showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); showFolders->setOn( true ); connect(showFolders, SIGNAL( toggled(bool) ), SLOT( slotShowFolders(bool) ) ); /* searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 0, 0, this ); - searchMails->addTo( toolBar ); + searchMails->kopddTo( toolBar ); searchMails->addTo( mailMenu ); */ deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); deleteMails->addTo( toolBar ); deleteMails->addTo( mailMenu ); connect( deleteMails, SIGNAL( activated() ), SLOT( slotDeleteAllMail() ) ); editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 0, 0, this ); editSettings->addTo( settingsMenu ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 0, 0, this ); editAccounts->addTo( settingsMenu ); codecMenu = new QPopupMenu( menuBar ); codecMenu->insertItem( "Western (iso-8859-1)",0,0); codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); codecMenu->insertItem( "Western (iso-8859-15)",2,2); codecMenu->insertItem( "Chinese (big-5)",3,3); codecMenu->insertItem( "Unicode (utf-8)",4,4); codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); //disabled //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); //setCentralWidget( view ); QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); // QWidget *view = new QWidget( wrapperBox ); KDGanttMinimizeSplitter* splithor = new KDGanttMinimizeSplitter( Qt::Vertical, wrapperBox); splithor->setMinimizeDirection( KDGanttMinimizeSplitter::Down); KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, splithor); split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); - QWidget* infoBox = new QWidget( splithor ); - QGridLayout *griLay = new QGridLayout( infoBox, 2,2); - griLay->addWidget( new QLabel ( i18n("Su:"), infoBox ),0,0 ); - griLay->addWidget( new QLabel ( i18n("Fr:"), infoBox ),1,0 ); - griLay->addWidget( new QLabel ( i18n("To:"), infoBox ),2,0 ); - griLay->addWidget( subLE = new QLineEdit( infoBox ),0,1) ; - griLay->addWidget( fromLE = new QLineEdit( infoBox ),1,1) ; - griLay->addWidget( toLE = new QLineEdit( infoBox ),2,1) ; - infoBox->setMaximumHeight( infoBox->sizeHint().height() ); + subLE = 0; + fromLE = 0; + toLE = 0; + if ( KOPrefs::instance()->mShowInfoSub || KOPrefs::instance()->mShowInfoFrom || KOPrefs::instance()->mShowInfoTo ) { + QWidget* infoBox = new QWidget( splithor ); + QGridLayout *griLay = new QGridLayout( infoBox, 2,2); + if ( KOPrefs::instance()->mShowInfoSub ) { + griLay->addWidget( new QLabel ( i18n("Su:"), infoBox ),0,0 ); + griLay->addWidget( subLE = new QLineEdit( infoBox ),0,1) ; + } + if ( KOPrefs::instance()->mShowInfoFrom ) { + griLay->addWidget( new QLabel ( i18n("Fr:"), infoBox ),1,0 ); + griLay->addWidget( fromLE = new QLineEdit( infoBox ),1,1) ; + } + if ( KOPrefs::instance()->mShowInfoTo ) { + griLay->addWidget( new QLabel ( i18n("To:"), infoBox ),2,0 ); + griLay->addWidget( toLE = new QLineEdit( infoBox ),2,1) ; + } + infoBox->setMaximumHeight( infoBox->sizeHint().height() ); + if ( !KOPrefs::instance()->mShowInfoStart ) { + QTimer::singleShot( 1,splithor, SLOT ( toggle() ) ); + } + } + + folderView = new AccountView( split ); folderView->header()->hide(); folderView->setRootIsDecorated( false ); folderView->addColumn( i18n( "Mailbox" ) ); //layout->addWidget( folderView ); mailView = new QListView( split ); mailView->addColumn( i18n( " " ) ); mailView->addColumn( i18n( "Subject" ),QListView::Manual ); mailView->addColumn( i18n( "Sender" ),QListView::Manual ); mailView->addColumn( i18n( "Size" ),QListView::Manual); mailView->addColumn( i18n( "Date" ),QListView::Manual); if ( KOPrefs::instance()->mShowToField ) mailView->addColumn( i18n( "To" ),QListView::Manual); mailView->setAllColumnsShowFocus(true); //mailView->setSorting(-1); mailView->setRootIsDecorated( false ); statusWidget = new StatusWidget( wrapperBox ); statusWidget->hide(); //layout->addWidget( mailView ); //layout->setStretchFactor( folderView, 1 ); //layout->setStretchFactor( mailView, 2 ); slotAdjustLayout(); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); - QPEApplication::setStylusOperation( subLE ,QPEApplication::RightOnHold); - QPEApplication::setStylusOperation( fromLE ,QPEApplication::RightOnHold); - QPEApplication::setStylusOperation( toLE ,QPEApplication::RightOnHold); + if ( subLE ) + QPEApplication::setStylusOperation( subLE ,QPEApplication::RightOnHold); + if ( fromLE ) + QPEApplication::setStylusOperation( fromLE ,QPEApplication::RightOnHold); + if ( toLE ) + QPEApplication::setStylusOperation( toLE ,QPEApplication::RightOnHold); #endif connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, SLOT( mailLeftClicked(QListViewItem*) ) ); connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, SLOT( mailLeftClicked(QListViewItem*) ) ); connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), this,SLOT(refreshMailView(const QValueList<RecMailP>&))); connect( mailView, SIGNAL( currentChanged (QListViewItem* )),this, SLOT( setInfoFields(QListViewItem*) ) ); connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); //mailView->setMultiSelection ( true ); mailView->setSelectionMode( QListView::Extended ); QValueList<int> list; int fw = 100; if ( QApplication::desktop()->width() > 320 ) fw = 50; list.append( fw ); @@ -206,60 +226,60 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) menuBar->insertItem( i18n( "Help" ), helpMenu ); QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); li->addTo(helpMenu); li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); li->addTo(helpMenu); li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); li->addTo(helpMenu); connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); slotSetCodec( KOPrefs::instance()->mCurrentCodec ); #ifdef DESKTOP_VERSION resize ( 640, 480 ); #endif } MainWindow::~MainWindow() { } void MainWindow::setInfoFields(QListViewItem* item ) { if ( item == 0) { - subLE->setText(""); - fromLE->setText(""); - toLE->setText(""); + if ( subLE ) subLE->setText(""); + if ( fromLE ) fromLE->setText(""); + if ( toLE ) toLE->setText(""); return; } RecMailP mail = ((MailListViewItem*)item)->data(); - subLE->setText(mail->getSubject()); - fromLE->setText(mail->getFrom()); - toLE->setText(mail->To().join(";" )); - subLE->setCursorPosition(0); - fromLE->setCursorPosition(0); - toLE->setCursorPosition(0); + if ( subLE ) subLE->setText(mail->getSubject()); + if ( fromLE ) fromLE->setText(mail->getFrom()); + if ( toLE ) toLE->setText(mail->To().join(";" )); + if ( subLE ) subLE->setCursorPosition(0); + if ( fromLE ) fromLE->setCursorPosition(0); + if ( toLE ) toLE->setCursorPosition(0); } void MainWindow::slotSetCodec( int codec ) { codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); //qDebug("codec %d ", codec); KOPrefs::instance()->mCurrentCodec = codec; KOPrefs::instance()->isDirty = true; QString name; switch ( codec ) { case 0: name = "iso-8859-1"; break; case 1: name = "iso-8859-5"; break; case 2: name = "iso-8859-15"; break; case 3: name = "big-5"; break; case 4: name = "utf-8"; |