summaryrefslogtreecommitdiffstats
path: root/kaddressbook/kcmconfigs/kabconfigwidget.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kaddressbook/kcmconfigs/kabconfigwidget.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kaddressbook/kcmconfigs/kabconfigwidget.cpp')
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp223
1 files changed, 223 insertions, 0 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
new file mode 100644
index 000000000..7c57a926c
--- /dev/null
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -0,0 +1,223 @@
+/*
+ This file is part of KAddressBook.
+ Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+*/
+
+#include <qcheckbox.h>
+#include <qframe.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qtooltip.h>
+#include <qcombobox.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <ktrader.h>
+
+#include "addresseewidget.h"
+#include "kabprefs.h"
+
+#include "kabconfigwidget.h"
+
+KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
+ KDialog::spacingHint() );
+
+ QTabWidget *tabWidget = new QTabWidget( this );
+ topLayout->addWidget( tabWidget );
+
+ // General page
+ QWidget *generalPage = new QWidget( this );
+ QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHint(),
+ KDialog::spacingHint() );
+
+ QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
+ QBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
+ boxLayout->setAlignment( Qt::AlignTop );
+
+ mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
+ boxLayout->addWidget( mViewsSingleClickBox );
+
+ mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
+ boxLayout->addWidget( mNameParsing );
+
+ mTradeAsFamilyName = new QCheckBox( i18n( "Trade single name component as family name" ), groupBox, "mtrade" );
+ boxLayout->addWidget( mTradeAsFamilyName );
+/**
+ TODO: show the checkbox when we can compile agains kdelibs from HEAD, atm it
+ doesn't work and would just confuse the users ;)
+*/
+ mTradeAsFamilyName->hide();
+
+ mLimitContactDisplay = new QCheckBox( i18n( "Limit unfiltered display to 100 contacts" ), groupBox, "mlimit" );
+ boxLayout->addWidget( mLimitContactDisplay );
+
+ QBoxLayout *editorLayout = new QHBoxLayout( boxLayout, KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Addressee editor type:" ), groupBox );
+ editorLayout->addWidget( label );
+
+ mEditorCombo = new QComboBox( groupBox );
+ mEditorCombo->insertItem( i18n( "Full Editor" ) );
+ mEditorCombo->insertItem( i18n( "Simple Editor" ) );
+ label->setBuddy( mEditorCombo );
+ editorLayout->addWidget( mEditorCombo );
+
+ editorLayout->addStretch( 1 );
+
+
+ layout->addWidget( groupBox );
+
+ groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Script-Hooks" ), generalPage );
+ QGridLayout *grid = new QGridLayout( groupBox->layout(), 3, 2,
+ KDialog::spacingHint() );
+ label = new QLabel( i18n( "Phone:" ), groupBox );
+ grid->addWidget( label, 0, 0 );
+
+ mPhoneHook = new QLineEdit( groupBox );
+ QToolTip::add( mPhoneHook, i18n( "<ul><li>%N: Phone Number</li></ul>" ) );
+ grid->addWidget( mPhoneHook, 0, 1 );
+
+ label = new QLabel( i18n( "Fax:" ), groupBox );
+ grid->addWidget( label, 1, 0 );
+
+ mFaxHook = new QLineEdit( groupBox );
+ QToolTip::add( mFaxHook, i18n( "<ul><li>%N: Fax Number</li></ul>" ) );
+ grid->addWidget( mFaxHook, 1, 1 );
+
+
+ label = new QLabel( i18n( "SMS Text:" ), groupBox );
+ grid->addWidget( label, 2, 0 );
+
+ mSMSHook = new QLineEdit( groupBox );
+ QToolTip::add( mSMSHook, i18n( "<ul><li>%N: Phone Number</li><li>%F: File containing the text message(s)</li></ul>" ) );
+ grid->addWidget( mSMSHook, 2, 1 );
+
+
+ grid->setColStretch( 1, 1 );
+
+ layout->addWidget( groupBox );
+
+ groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Location Map" ), generalPage );
+ boxLayout = new QVBoxLayout( groupBox->layout(), KDialog::spacingHint() );
+ boxLayout->setAlignment( Qt::AlignTop );
+
+ mLocationMapURL = new QComboBox( true, groupBox );
+ mLocationMapURL->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
+ QToolTip::add( mLocationMapURL, i18n( "<ul> <li>%s: Street</li>"
+ "<li>%r: Region</li>"
+ "<li>%l: Location</li>"
+ "<li>%z: Zip Code</li>"
+ "<li>%c: Country ISO Code</li> </ul>" ) );
+ mLocationMapURL->insertStringList( KABPrefs::instance()->locationMapURLs() );
+ boxLayout->addWidget( mLocationMapURL );
+ layout->addWidget( groupBox );
+
+ connect( mNameParsing, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+ connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+ connect( mTradeAsFamilyName, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+ connect( mLimitContactDisplay, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
+ connect( mPhoneHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mSMSHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mFaxHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mLocationMapURL, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
+ connect( mEditorCombo, SIGNAL( activated( int ) ), SLOT( modified() ) );
+
+ tabWidget->addTab( generalPage, i18n( "General" ) );
+
+ // Addressee page
+ mAddresseeWidget = new AddresseeWidget( this );
+ tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
+ connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
+}
+
+void KABConfigWidget::restoreSettings()
+{
+ bool blocked = signalsBlocked();
+ blockSignals( true );
+
+ mNameParsing->setChecked( KABPrefs::instance()->automaticNameParsing() );
+ mViewsSingleClickBox->setChecked( KABPrefs::instance()->honorSingleClick() );
+ mPhoneHook->setText( KABPrefs::instance()->phoneHookApplication() );
+ mSMSHook->setText( KABPrefs::instance()->sMSHookApplication() );
+ mFaxHook->setText( KABPrefs::instance()->faxHookApplication() );
+ mAddresseeWidget->restoreSettings();
+ mEditorCombo->setCurrentItem( KABPrefs::instance()->editorType() );
+ mLocationMapURL->setCurrentText( KABPrefs::instance()->locationMapURL().arg( KGlobal::locale()->country() ) );
+ mLocationMapURL->lineEdit()->setCursorPosition( 0 );
+
+ KConfig config( "kabcrc", false, false );
+ config.setGroup( "General" );
+ mTradeAsFamilyName->setChecked( config.readBoolEntry( "TradeAsFamilyName", true ) );
+ mLimitContactDisplay->setChecked( config.readBoolEntry( "LimitContactDisplay", true ) );
+
+ blockSignals( blocked );
+
+ emit changed( false );
+}
+
+void KABConfigWidget::saveSettings()
+{
+ KABPrefs::instance()->setAutomaticNameParsing( mNameParsing->isChecked() );
+ KABPrefs::instance()->setHonorSingleClick( mViewsSingleClickBox->isChecked() );
+ KABPrefs::instance()->setPhoneHookApplication( mPhoneHook->text() );
+ KABPrefs::instance()->setSMSHookApplication( mSMSHook->text() );
+ KABPrefs::instance()->setFaxHookApplication( mFaxHook->text() );
+ KABPrefs::instance()->setEditorType( mEditorCombo->currentItem() );
+ KABPrefs::instance()->setLocationMapURL( mLocationMapURL->currentText() );
+ mAddresseeWidget->saveSettings();
+
+ KABPrefs::instance()->writeConfig();
+
+ KConfig config( "kabcrc", false, false );
+ config.setGroup( "General" );
+ config.writeEntry( "TradeAsFamilyName", mTradeAsFamilyName->isChecked() );
+ config.writeEntry( "LimitContactDisplay", mLimitContactDisplay->isChecked() );
+
+ emit changed( false );
+}
+
+void KABConfigWidget::defaults()
+{
+ mNameParsing->setChecked( true );
+ mViewsSingleClickBox->setChecked( false );
+ mEditorCombo->setCurrentItem( 0 );
+ mLimitContactDisplay->setChecked( true );
+
+ emit changed( true );
+}
+
+void KABConfigWidget::modified()
+{
+ emit changed( true );
+}
+
+#include "kabconfigwidget.moc"