Commit c6c12511 authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 337435 - kmail vcard import pgp key

FIXED-IN: 4.14
BUG: 337435
parent ec8ff5d9
......@@ -22,6 +22,7 @@
#include <KComboBox>
#include <KLocalizedString>
#include <KSeparator>
#include <KUrlRequester>
#include <QButtonGroup>
#include <QVBoxLayout>
......@@ -30,7 +31,7 @@
IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent)
:KDialog(parent)
: KDialog(parent)
{
setCaption( i18n( "Create own vCard" ) );
setButtons( Ok|Cancel );
......@@ -43,6 +44,7 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
setMainWidget( mainWidget );
mButtonGroup = new QButtonGroup( this );
mButtonGroup->setObjectName(QLatin1String("buttongroup"));
// row 1: radio button
QRadioButton *radio = new QRadioButton( i18n("&With empty fields"), this );
......@@ -51,19 +53,47 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
mButtonGroup->addButton( radio, (int)Empty );
// row 2: radio button
radio = new QRadioButton( i18n("&Duplicate existing vCard"), this );
vlay->addWidget( radio );
mButtonGroup->addButton( radio, (int)ExistingEntry );
QRadioButton *fromExistingVCard = new QRadioButton( i18n("&From existing vCard"), this );
vlay->addWidget( fromExistingVCard );
mButtonGroup->addButton( fromExistingVCard, (int)FromExistingVCard );
// row 3: combobox with existing identities and label
// row 3: KUrlRequester
QHBoxLayout* hlay = new QHBoxLayout(); // inherits spacing
vlay->addLayout( hlay );
mVCardPath = new KUrlRequester;
mVCardPath->setObjectName(QLatin1String("kurlrequester_vcardpath"));
mVCardPath->setMode(KFile::LocalOnly|KFile::File);
QLabel *label = new QLabel( i18n("&VCard path:"), this );
label->setBuddy( mVCardPath );
label->setEnabled( false );
mVCardPath->setEnabled( false );
hlay->addWidget( label );
hlay->addWidget( mVCardPath );
connect( fromExistingVCard, SIGNAL(toggled(bool)),
label, SLOT(setEnabled(bool)) );
connect( fromExistingVCard, SIGNAL(toggled(bool)),
mVCardPath, SLOT(setEnabled(bool)) );
// row 4: radio button
QRadioButton *duplicateExistingVCard = new QRadioButton( i18n("&Duplicate existing vCard"), this );
vlay->addWidget( duplicateExistingVCard );
mButtonGroup->addButton( duplicateExistingVCard, (int)ExistingEntry );
// row 5: combobox with existing identities and label
hlay = new QHBoxLayout(); // inherits spacing
vlay->addLayout( hlay );
mComboBox = new KComboBox( this );
mComboBox->setObjectName(QLatin1String("identity_combobox"));
mComboBox->setEditable( false );
mComboBox->addItems( manager->shadowIdentities() );
mComboBox->addItems( manager ? manager->shadowIdentities() : QStringList() );
mComboBox->setEnabled( false );
QLabel *label = new QLabel( i18n("&Existing identities:"), this );
label = new QLabel( i18n("&Existing identities:"), this );
label->setBuddy( mComboBox );
label->setEnabled( false );
hlay->addWidget( label );
......@@ -74,9 +104,9 @@ IdentityAddVcardDialog::IdentityAddVcardDialog(KPIMIdentities::IdentityManager *
// enable/disable combobox and label depending on the third radio
// button's state:
connect( radio, SIGNAL(toggled(bool)),
connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
label, SLOT(setEnabled(bool)) );
connect( radio, SIGNAL(toggled(bool)),
connect( duplicateExistingVCard, SIGNAL(toggled(bool)),
mComboBox, SLOT(setEnabled(bool)) );
resize(350, 130);
}
......@@ -96,3 +126,8 @@ QString IdentityAddVcardDialog::duplicateVcardFromIdentity() const
return mComboBox->currentText();
}
KUrl IdentityAddVcardDialog::existingVCard() const
{
return mVCardPath->url();
}
......@@ -20,6 +20,7 @@
#include <KDialog>
class QButtonGroup;
class KComboBox;
class KUrlRequester;
namespace KPIMIdentities {
class IdentityManager;
......@@ -31,7 +32,8 @@ class IdentityAddVcardDialog: public KDialog
public:
enum DuplicateMode {
Empty,
ExistingEntry
ExistingEntry,
FromExistingVCard
};
explicit IdentityAddVcardDialog(KPIMIdentities::IdentityManager *manager, QWidget *parent = 0);
......@@ -39,10 +41,12 @@ public:
DuplicateMode duplicateMode() const;
QString duplicateVcardFromIdentity() const;
KUrl existingVCard() const;
private:
QButtonGroup *mButtonGroup;
KComboBox *mComboBox;
KUrlRequester *mVCardPath;
};
#endif // IDENTITYADDVCARDDIALOG_H
......@@ -999,6 +999,15 @@ void IdentityDialog::slotEditVcard()
editVcard(mVcardFilename);
break;
}
case IdentityAddVcardDialog::FromExistingVCard: {
const QString filename = dlg->existingVCard().path();
if(!filename.isEmpty()) {
mVcardFilename = filename;
}
qDebug()<<" filename "<<filename;
editVcard(mVcardFilename);
break;
}
}
}
delete dlg;
......
......@@ -18,3 +18,7 @@ kde4_add_unit_test( displaymessageformatactionmenutest ${kmail_displaymenu_sourc
target_link_libraries( displaymessageformatactionmenutest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} messageviewer)
set( kmail_identityaddvcarddialog_source identityaddvcarddialogtest.cpp ../identity/identityaddvcarddialog.cpp )
kde4_add_unit_test( identityaddvcarddialogtest ${kmail_identityaddvcarddialog_source})
target_link_libraries( identityaddvcarddialogtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} kpimidentities)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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
*/
#include "identityaddvcarddialogtest.h"
#include "../identity/identityaddvcarddialog.h"
#include <KComboBox>
#include <KUrlRequester>
#include <QButtonGroup>
#include <qtest_kde.h>
identityaddvcarddialogtest::identityaddvcarddialogtest()
{
}
void identityaddvcarddialogtest::shouldHaveDefaultValue()
{
IdentityAddVcardDialog dlg(0,0);
KComboBox *identityComboBox = qFindChild<KComboBox *>(&dlg, QLatin1String("identity_combobox"));
QVERIFY(identityComboBox);
QCOMPARE(identityComboBox->isEnabled(), false);
KUrlRequester *urlRequester = qFindChild<KUrlRequester *>(&dlg, QLatin1String("kurlrequester_vcardpath"));
QVERIFY(urlRequester);
QCOMPARE(urlRequester->isEnabled(), false);
QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(&dlg, QLatin1String("buttongroup"));
QVERIFY(buttonGroup);
QCOMPARE(dlg.duplicateMode(), IdentityAddVcardDialog::Empty);
}
QTEST_KDEMAIN(identityaddvcarddialogtest, GUI)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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
*/
#ifndef IDENTITYADDVCARDDIALOGTEST_H
#define IDENTITYADDVCARDDIALOGTEST_H
#include <QObject>
class identityaddvcarddialogtest : public QObject
{
Q_OBJECT
public:
identityaddvcarddialogtest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // IDENTITYADDVCARDDIALOGTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment