-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 53 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 6 |
2 files changed, 57 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 5a8038b..b7b35bc 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -204,26 +204,70 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, abList->load( addressbookOldXMLFilename() ); QFile::remove(addressbookOldXMLFilename()); } catMenu = new QPopupMenu( this ); catMenu->setCheckable( TRUE ); connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); populateCategories(); mbList->insertItem( tr("View"), catMenu ); setCentralWidget( abList ); + fontMenu = new QPopupMenu(this); + fontMenu->setCheckable( true ); + connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); + + fontMenu->insertItem("Small", 0); + fontMenu->insertItem("Normal", 1); + fontMenu->insertItem("Large", 2); + + defaultFont = new QFont( abList->font() ); + + slotSetFont(startFontSize); + + mbList->insertItem( tr("Font"), fontMenu); + setCentralWidget(abList); + // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); } +void AddressbookWindow::slotSetFont( int size ) { + + if (size > 2 || size < 0) + size = 1; + + startFontSize = size; + + switch (size) { + case 0: + fontMenu->setItemChecked(0, true); + fontMenu->setItemChecked(1, false); + fontMenu->setItemChecked(2, false); + abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); + break; + case 1: + fontMenu->setItemChecked(0, false); + fontMenu->setItemChecked(1, true); + fontMenu->setItemChecked(2, false); + abList->setFont( *defaultFont ); + break; + case 2: + fontMenu->setItemChecked(0, false); + fontMenu->setItemChecked(1, false); + fontMenu->setItemChecked(2, true); + abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); + break; + } +} + void AddressbookWindow::setDocument( const QString &filename ) { if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; QValueList<Contact> cl = Contact::readVCard( filename ); for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") // .arg( (*it).fullName() ); // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == // QMessageBox::Ok ) { abList->addEntry( *it ); @@ -235,24 +279,27 @@ void AddressbookWindow::setDocument( const QString &filename ) void AddressbookWindow::resizeEvent( QResizeEvent *e ) { QMainWindow::resizeEvent( e ); if ( centralWidget() == abList ) showList(); else if ( centralWidget() == mView ) showView(); } AddressbookWindow::~AddressbookWindow() { + Config cfg("AddressBook"); + cfg.setGroup("Font"); + cfg.writeEntry("fontSize", startFontSize); } void AddressbookWindow::slotUpdateToolbar() { Contact ce = abList->currentEntry(); actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); } void AddressbookWindow::showList() { if ( mView ) mView->hide(); setCentralWidget( abList ); @@ -704,37 +751,43 @@ void AddressbookWindow::initFields() Config cfg( "AddressBook" ); QString zn; // ### Write a function to keep this from happening again... QStringList::ConstIterator it; for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { allFields.append( i + 3 ); } cfg.setGroup( "Version" ); version = cfg.readNumEntry( "version" ); i = 0; + startFontSize = 1; + if ( version >= ADDRESSVERSION ) { cfg.setGroup( "ImportantCategory" ); zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); while ( !zn.isNull() ) { if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { slOrderedFields.clear(); break; } slOrderedFields.append( zn ); zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); } + cfg.setGroup( "Font" ); + startFontSize = cfg.readNumEntry( "fontSize", 1 ); + + } else { QString str; str = getenv("HOME"); str += "/Settings/AddressBook.conf"; QFile::remove( str ); } if ( slOrderedFields.count() > 0 ) { for( QStringList::ConstIterator it = slOrderedFields.begin(); it != slOrderedFields.end(); ++it ) { QValueList<int>::ConstIterator itVl; QStringList::ConstIterator itVis; itVl = allFields.begin(); diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 342077f..e2a7100 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -61,39 +61,41 @@ private slots: void slotListDelete(); void slotViewBack(); void slotViewEdit(); void slotPersonalView(); void listIsEmpty( bool ); void slotSettings(); void writeMail(); void slotBeam(); void beamDone( Ir * ); void slotFind(); void slotSetCategory( int ); void slotUpdateToolbar(); - + void slotSetFont(int); private: void initFields(); // inititialize our fields... AbLabel *abView(); void populateCategories(); - QPopupMenu *catMenu; + QPopupMenu *catMenu, *fontMenu; QPEToolBar *listTools; QToolButton *deleteButton; QValueList<int> allFields, orderedFields; QStringList slOrderedFields; enum Panes { paneList=0, paneView, paneEdit }; ContactEditor *abEditor; AbLabel *mView; AbTable *abList; QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; bool bAbEditFirstTime; int viewMargin; bool syncing; + QFont *defaultFont; + int startFontSize; }; #endif |