~ubuntu-branches/ubuntu/vivid/kdepim/vivid

« back to all changes in this revision

Viewing changes to kmail/identitydialog.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Jonathan Riddell, Rohan Garg, Scott Kitterman
  • Date: 2012-11-21 13:12:36 UTC
  • mfrom: (0.2.33)
  • Revision ID: package-import@ubuntu.com-20121121131236-32ijw9a2txrar80k
Tags: 4:4.9.80-0ubuntu1
[ Jonathan Riddell ]
* New upstream beta release

[ Rohan Garg ]
* Add nepomuk-core-dev to build-deps

[ Scott Kitterman ]
* Add new package, libpimcommon4
  - Add libpimcommon4.install
  - Add to debian/control, including kdepim-dbg and kdepim-dev depends
  - Add to kdepim-dev.install
* Remove usr/bin/backupmail and related files from kmail.install as they are
  not provided by upstream anymore
* Add usr/bin/pimsettingexporter and related files to kmail.install
* Add libnepomukwidgets-dev to build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
*/
31
31
 
32
32
#include "identitydialog.h"
 
33
#include "identityeditvcarddialog.h"
 
34
#include "identityaddvcarddialog.h"
 
35
 
 
36
#include <kpimidentities/identitymanager.h>
33
37
 
34
38
// other KMail headers:
35
39
#ifndef KDEPIM_MOBILE_UI
55
59
#include <kpimidentities/identity.h>
56
60
#include <kpimidentities/signatureconfigurator.h>
57
61
 
 
62
#include "messagecomposer/autocorrection/composerautocorrectionlanguage.h"
 
63
 
58
64
#include <libkdepim/addresseelineedit.h>
59
65
// libkleopatra:
60
66
#include "libkleo/ui/keyrequester.h"
76
82
#include <kpushbutton.h>
77
83
#include <kcombobox.h>
78
84
#include <ktabwidget.h>
 
85
#include <KStandardDirs>
79
86
#include <sonnet/dictionarycombobox.h>
80
87
 
81
88
// Qt headers:
83
90
#include <QCheckBox>
84
91
#include <QVBoxLayout>
85
92
#include <QGridLayout>
 
93
#include <QFile>
86
94
 
87
95
// other headers:
88
96
#include <gpgme++/key.h>
359
367
    glay->setSpacing( spacingHint() );
360
368
    glay->setMargin( marginHint() );
361
369
    // the last (empty) row takes all the remaining space
362
 
    glay->setRowStretch( 9-1, 1 );
363
370
    glay->setColumnStretch( 1, 1 );
364
371
 
365
372
    // "Reply-To Address" line edit and label:
470
477
    connect( mTransportCheck, SIGNAL(toggled(bool)),
471
478
             mTransportCombo, SLOT(setEnabled(bool)) );
472
479
 
 
480
    ++row;
 
481
    mAttachMyVCard = new QCheckBox(i18n("Attach my vcard to message"), tab);
 
482
    glay->addWidget( mAttachMyVCard, row, 0 );
 
483
    mEditVCard = new KPushButton(i18n("Create..."),tab);
 
484
    connect(mEditVCard,SIGNAL(clicked()),SLOT(slotEditVcard()));
 
485
    glay->addWidget( mEditVCard, row, 1 );
 
486
 
 
487
 
 
488
    ++row;
 
489
    mAutoCorrectionLanguage = new MessageComposer::ComposerAutoCorrectionLanguage(tab);
 
490
    glay->addWidget( mAutoCorrectionLanguage, row, 1 );
 
491
    label = new QLabel( i18n("Autocorrection Language:"), tab );
 
492
    label->setBuddy( mAutoCorrectionLanguage );
 
493
    glay->addWidget( label, row, 0 );
 
494
 
 
495
    ++row;
 
496
    glay->setRowStretch( row, 1 );
 
497
 
473
498
    // the last row is a spacer
474
499
 
475
500
    //
793
818
    else
794
819
      mTemplatesCombo->setCollection( Akonadi::Collection( ident.templates().toLongLong() ) );
795
820
 
 
821
    mVcardFilename = ident.vCardFile();
 
822
 
 
823
    mAutoCorrectionLanguage->setLanguage(ident.autocorrectionLanguage());
 
824
    updateVcardButton();
 
825
    if(mVcardFilename.isEmpty()) {
 
826
      mVcardFilename = KStandardDirs::locateLocal("appdata",ident.identityName() + QLatin1String(".vcf"));
 
827
    }
 
828
    mAttachMyVCard->setChecked(ident.attachVcard());
796
829
    // "Templates" tab:
797
830
#ifndef KDEPIM_MOBILE_UI
798
831
    uint identity = ident.uoid();
861
894
    }
862
895
    else
863
896
      ident.setTemplates( QString() );
 
897
    ident.setVCardFile(mVcardFilename);
 
898
    ident.setAutocorrectionLanguage(mAutoCorrectionLanguage->language());
 
899
    updateVcardButton();
 
900
    ident.setAttachVcard(mAttachMyVCard->isChecked());
 
901
 
864
902
    // "Templates" tab:
865
903
#ifndef KDEPIM_MOBILE_UI
866
904
    uint identity = ident.uoid();
878
916
    ident.setXFace( mXFaceConfigurator->xface() );
879
917
    ident.setXFaceEnabled( mXFaceConfigurator->isXFaceEnabled() );
880
918
#endif
881
 
  }
 
919
 
 
920
  }
 
921
  void IdentityDialog::slotEditVcard()
 
922
  {
 
923
    if(QFile(mVcardFilename).exists()) {
 
924
      editVcard(mVcardFilename);
 
925
    } else {
 
926
      if ( !MailCommon::Kernel::self()->kernelIsRegistered() ) {
 
927
        return;
 
928
      }
 
929
      KPIMIdentities::IdentityManager *manager = KernelIf->identityManager();
 
930
 
 
931
      IdentityAddVcardDialog dlg(manager, this);
 
932
      if(dlg.exec()) {
 
933
        IdentityAddVcardDialog::DuplicateMode mode = dlg.duplicateMode();
 
934
        switch(mode) {
 
935
        case IdentityAddVcardDialog::Empty: {
 
936
          editVcard(mVcardFilename);
 
937
        }
 
938
        break;
 
939
        case IdentityAddVcardDialog::ExistingEntry: {
 
940
           KPIMIdentities::Identity ident = manager->modifyIdentityForName( dlg.duplicateVcardFromIdentity() );
 
941
           const QString filename = ident.vCardFile();
 
942
           if(!filename.isEmpty()) {
 
943
             QFile::copy(filename,mVcardFilename);
 
944
           }
 
945
           editVcard(mVcardFilename);
 
946
        }
 
947
        break;
 
948
        }
 
949
      }
 
950
    }
 
951
  }
 
952
 
 
953
  void IdentityDialog::editVcard(const QString& filename)
 
954
  {
 
955
    IdentityEditVcardDialog dlg(this);
 
956
    dlg.loadVcard(filename);
 
957
    if(dlg.exec()) {
 
958
       mVcardFilename = dlg.saveVcard();
 
959
       updateVcardButton();
 
960
    }
 
961
  }
 
962
 
 
963
  void IdentityDialog::updateVcardButton()
 
964
  {
 
965
    if(!QFile(mVcardFilename).exists()) {
 
966
      mEditVCard->setText(i18n("Create..."));
 
967
    } else {
 
968
      mEditVCard->setText(i18n("Edit..."));
 
969
    }
 
970
  }
 
971
 
882
972
}
883
973
 
884
974
#include "identitydialog.moc"