You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
5.2 KiB
169 lines
5.2 KiB
15 years ago
|
/*=========================================================================
|
||
|
| KCardDAV
|
||
|
|--------------------------------------------------------------------------
|
||
|
| (c) 2010 Timothy Pearson
|
||
|
|
|
||
|
| This project is released under the GNU General Public License.
|
||
|
| Please see the file COPYING for more details.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Configuration and properties dialog
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| INCLUDES
|
||
|
========================================================================*/
|
||
|
|
||
|
#include "resource.h"
|
||
|
#include "config.h"
|
||
|
#include "configwidgets.h"
|
||
|
|
||
|
#include <kcombobox.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kdialog.h>
|
||
|
#include <klocale.h>
|
||
|
#include <klineedit.h>
|
||
|
#include <klistview.h>
|
||
|
#include <kurlrequester.h>
|
||
|
|
||
14 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqcheckbox.h>
|
||
15 years ago
|
|
||
|
/*=========================================================================
|
||
|
| NAMESPACE
|
||
|
========================================================================*/
|
||
|
|
||
|
using namespace KABC;
|
||
|
|
||
|
/*=========================================================================
|
||
|
| CONSTANTS
|
||
|
========================================================================*/
|
||
|
|
||
|
/*=========================================================================
|
||
|
| STATIC METHODS
|
||
|
========================================================================*/
|
||
|
|
||
|
ResourceCardDav* ResourceCardDavConfig::getCardDavResource(KRES::Resource* resource) {
|
||
|
ResourceCardDav *res = dynamic_cast<ResourceCardDav *>( resource );
|
||
|
if (!res) {
|
||
13 years ago
|
kdDebug() << "invalid resource type" << '\n';
|
||
15 years ago
|
}
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
CardDavPrefs* ResourceCardDavConfig::getPrefs(ResourceCardDav* res) {
|
||
|
CardDavPrefs* p = NULL;
|
||
|
|
||
|
if (res) {
|
||
|
p = res->prefs();
|
||
|
if (!p) {
|
||
13 years ago
|
kdDebug() << "CardDAV: res->prefs() returned NULL" << '\n';
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
return p;
|
||
|
}
|
||
|
|
||
|
/*=========================================================================
|
||
|
| CONSTRUCTOR / DESTRUCTOR
|
||
|
========================================================================*/
|
||
|
|
||
13 years ago
|
ResourceCardDavConfig::ResourceCardDavConfig( TQWidget *parent )
|
||
|
: KRES::ConfigWidget( parent )
|
||
15 years ago
|
{
|
||
|
setupUI();
|
||
|
}
|
||
|
|
||
|
/*=========================================================================
|
||
|
| METHODS
|
||
|
========================================================================*/
|
||
|
|
||
|
void ResourceCardDavConfig::loadSettings( KRES::Resource *resource ) {
|
||
|
ResourceCardDav* res = getCardDavResource(resource);
|
||
|
CardDavPrefs* p = getPrefs(res);
|
||
|
if (NULL != p) {
|
||
|
mUrl->setText(p->url());
|
||
|
mUsername->setText(p->username());
|
||
|
mRememberPassword->setChecked(p->rememberPassword());
|
||
|
mPassword->setText(p->password());
|
||
15 years ago
|
mUseUriNotUID->setChecked(p->useURI());
|
||
15 years ago
|
|
||
|
mReloadConfig->loadSettings(res);
|
||
|
mSaveConfig->loadSettings(res);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ResourceCardDavConfig::saveSettings( KRES::Resource *resource ) {
|
||
|
ResourceCardDav* res = getCardDavResource(resource);
|
||
|
if (NULL != res) {
|
||
|
mReloadConfig->saveSettings(res);
|
||
|
mSaveConfig->saveSettings(res);
|
||
|
|
||
|
CardDavPrefs* p = getPrefs(res);
|
||
|
if (NULL != p) {
|
||
|
p->setUrl(mUrl->text());
|
||
|
p->setUsername(mUsername->text());
|
||
|
p->setRememberPassword(mRememberPassword->isChecked());
|
||
|
p->setPassword(mPassword->text());
|
||
15 years ago
|
p->setUseURI(mUseUriNotUID->isChecked());
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void ResourceCardDavConfig::setupUI() {
|
||
14 years ago
|
TQVBoxLayout *vertical = new TQVBoxLayout(this);
|
||
15 years ago
|
|
||
14 years ago
|
TQGridLayout *mainLayout = new TQGridLayout( this );
|
||
15 years ago
|
|
||
|
// URL
|
||
14 years ago
|
TQLabel *label = new TQLabel( i18n( "URL:" ), this );
|
||
|
mUrl = new TQLineEdit( this );
|
||
15 years ago
|
mainLayout->addWidget( label, 1, 0 );
|
||
|
mainLayout->addWidget( mUrl, 1, 1 );
|
||
|
|
||
|
// Username
|
||
14 years ago
|
label = new TQLabel( i18n( "Username:" ), this );
|
||
|
mUsername = new TQLineEdit( this );
|
||
15 years ago
|
mainLayout->addWidget( label, 2, 0 );
|
||
|
mainLayout->addWidget( mUsername, 2, 1 );
|
||
|
|
||
|
// Password
|
||
14 years ago
|
label = new TQLabel( i18n( "Password:" ), this );
|
||
|
mPassword = new TQLineEdit( this );
|
||
|
mPassword->setEchoMode( TQLineEdit::Password );
|
||
15 years ago
|
mainLayout->addWidget( label, 3, 0 );
|
||
|
mainLayout->addWidget( mPassword, 3, 1 );
|
||
|
|
||
|
// Remember password checkbox
|
||
14 years ago
|
mRememberPassword = new TQCheckBox( i18n("Remember password"), this );
|
||
15 years ago
|
mainLayout->addWidget(mRememberPassword, 4, 1);
|
||
|
|
||
14 years ago
|
mUseUriNotUID = new TQCheckBox( i18n( "Use URI instead of UID when modifying existing contacts" ), this );
|
||
15 years ago
|
mainLayout->addWidget( mUseUriNotUID, 5, 1 );
|
||
|
|
||
15 years ago
|
// configs
|
||
14 years ago
|
TQHBoxLayout* horizontal = new TQHBoxLayout(this);
|
||
15 years ago
|
|
||
|
// Reload config
|
||
|
mReloadConfig = new CardDavReloadConfig(this);
|
||
|
horizontal->addWidget(mReloadConfig);
|
||
|
|
||
|
// Save config
|
||
|
mSaveConfig = new CardDavSaveConfig(this);
|
||
|
horizontal->addWidget(mSaveConfig);
|
||
|
|
||
|
// FIXME: This feature does not work; hide the UI elements for later use
|
||
|
mRememberPassword->hide();
|
||
|
label->hide();
|
||
|
mPassword->hide();
|
||
|
|
||
14 years ago
|
// combining layouts
|
||
15 years ago
|
vertical->addLayout(mainLayout);
|
||
|
vertical->addLayout(horizontal);
|
||
|
}
|
||
|
|
||
14 years ago
|
#include "config.moc"
|
||
|
|
||
15 years ago
|
// EOF ========================================================================
|