summaryrefslogtreecommitdiff
authortux_mike <tux_mike>2002-04-09 03:22:49 (UTC)
committer tux_mike <tux_mike>2002-04-09 03:22:49 (UTC)
commit0099a303b216b57e22aea5e28ee31abb6fb18736 (patch) (side-by-side diff)
tree308c64b1d48553bf067ae36303728248322311fe
parent3c37907fd38287a8402cca1063ce6ba69c75e954 (diff)
downloadopie-0099a303b216b57e22aea5e28ee31abb6fb18736.zip
opie-0099a303b216b57e22aea5e28ee31abb6fb18736.tar.gz
opie-0099a303b216b57e22aea5e28ee31abb6fb18736.tar.bz2
Added font selection.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp53
-rw-r--r--core/pim/addressbook/addressbook.h6
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
@@ -168,127 +168,174 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
a->addTo( edit );
a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( edit );
// Create Views
// This is safe to call without checking to see if it exists...
// not to mention it also does the necessary stuff for the
// journaling...
QString str = addressbookXMLFilename();
if ( str.isNull() ) {
QMessageBox::warning( this, tr("Out of Space"),
tr("There is not enough space to create\n"
"neccessary startup files.\n"
"\nFree up some space before\nentering data!")
);
}
abList = new AbTable( &orderedFields, this, "table" );
abList->setHScrollBarMode( QScrollView::AlwaysOff );
connect( abList, SIGNAL( empty( bool ) ),
this, SLOT( listIsEmpty( bool ) ) );
connect( abList, SIGNAL( details() ),
this, SLOT( slotListView() ) );
connect( abList, SIGNAL(currentChanged(int,int)),
this, SLOT(slotUpdateToolbar()) );
mView = 0;
abList->load( addressbookXMLFilename() );
if ( QFile::exists(addressbookOldXMLFilename()) ) {
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 );
// }
}
}
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 );
abList->show();
// update our focues... (or use a stack widget!);
abList->setFocus();
}
void AddressbookWindow::showView()
{
if ( abList->numRows() > 0 ) {
abList->hide();
setCentralWidget( abView() );
mView->show();
mView->setFocus();
}
}
void AddressbookWindow::slotListNew()
{
Contact cnt;
if( !syncing ) {
if ( abEditor )
abEditor->setEntry( cnt );
abView()->init( cnt );
editEntry( NewEntry );
} else {
QMessageBox::warning(this, tr("Contacts"),
tr("Can not edit data, currently syncing"));
}
}
void AddressbookWindow::slotListView()
{
abView()->init( abList->currentEntry() );
mView->sync();
showView();
}
@@ -668,109 +715,115 @@ bool AddressbookWindow::save()
return TRUE;
}
void AddressbookWindow::slotSettings()
{
AddressSettings frmSettings( this );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
frmSettings.showMaximized();
#endif
if ( frmSettings.exec() ) {
allFields.clear();
orderedFields.clear();
slOrderedFields.clear();
initFields();
if ( abEditor )
abEditor->loadFields();
abList->refresh();
}
}
void AddressbookWindow::initFields()
{
// we really don't need the things from the configuration, anymore
// only thing that is important are the important categories. So,
// Call the contact functions that correspond to these old functions...
QStringList xmlFields = Contact::fields();
QStringList visibleFields = Contact::trfields();
xmlFields.remove( "Title" );
visibleFields.remove( tr("Name Title") );
visibleFields.remove( tr("Notes") );
int i,
version;
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();
for ( itVis = visibleFields.begin();
itVis != visibleFields.end() && itVl != allFields.end();
++itVis, ++itVl ) {
if ( *it == *itVis && itVl != allFields.end() ) {
orderedFields.append( *itVl );
}
}
}
} else {
QValueList<int>::ConstIterator it;
for ( it = allFields.begin(); it != allFields.end(); ++it )
orderedFields.append( *it );
slOrderedFields = visibleFields;
orderedFields.remove( Qtopia::AddressUid );
orderedFields.remove( Qtopia::Title );
orderedFields.remove( Qtopia::Groups );
orderedFields.remove( Qtopia::AddressCategory );
orderedFields.remove( Qtopia::FirstName );
orderedFields.remove( Qtopia::LastName );
orderedFields.remove( Qtopia::DefaultEmail );
orderedFields.remove( Qtopia::FileAs );
orderedFields.remove( Qtopia::Notes );
orderedFields.remove( Qtopia::Gender );
slOrderedFields.remove( tr("Name Title") );
slOrderedFields.remove( tr("First Name") );
slOrderedFields.remove( tr("Last Name") );
slOrderedFields.remove( tr("File As") );
slOrderedFields.remove( tr("Default Email") );
slOrderedFields.remove( tr("Notes") );
slOrderedFields.remove( tr("Gender") );
}
}
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
@@ -25,75 +25,77 @@
class ContactEditor;
class AbLabel;
class AbTable;
class QPEToolBar;
class QPopupMenu;
class QToolButton;
class QDialog;
class Ir;
class QAction;
class AddressbookWindow: public QMainWindow
{
Q_OBJECT
public:
AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~AddressbookWindow();
protected:
void resizeEvent( QResizeEvent * e );
void showList();
void showView();
enum EntryMode { NewEntry=0, EditEntry };
void editPersonal();
void editEntry( EntryMode );
void closeEvent( QCloseEvent *e );
bool save();
public slots:
void flush();
void reload();
void appMessage(const QCString &, const QByteArray &);
void setDocument( const QString & );
private slots:
void slotListNew();
void slotListView();
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