23 #include <KontactInterface/Core>
26 #include <KActionCollection>
27 #include <KCmdLineArgs>
31 #include <QDBusConnection>
32 #include <QDBusMessage>
37 : KontactInterface::Plugin( core, core, "kaddressbook" )
39 setComponentData( KontactPluginFactory::componentData() );
41 KGlobal::locale()->insertCatalog( QLatin1String(
"libkdepim") );
42 KGlobal::locale()->insertCatalog( QLatin1String(
"kabc") );
43 KGlobal::locale()->insertCatalog( QLatin1String(
"libakonadi") );
44 KGlobal::locale()->insertCatalog( QLatin1String(
"kabcakonadi" ));
47 new KAction( KIcon( QLatin1String(
"contact-new") ),
48 i18nc(
"@action:inmenu",
"New Contact..." ),
this );
49 actionCollection()->addAction( QLatin1String(
"new_contact"), action );
50 connect( action, SIGNAL(triggered(
bool)), SLOT(slotNewContact()) );
51 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_C ) );
53 i18nc(
"@info:status",
"Create a new contact" ) );
55 i18nc(
"@info:whatsthis",
56 "You will be presented with a dialog where you can create a new contact." ) );
57 insertNewAction( action );
60 new KAction( KIcon( QLatin1String(
"user-group-new") ),
61 i18nc(
"@action:inmenu",
"New Contact Group..." ),
this );
62 actionCollection()->addAction( QLatin1String(
"new_contactgroup"), action );
63 connect( action, SIGNAL(triggered(
bool)), SLOT(slotNewContactGroup()) );
64 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_G ) );
66 i18nc(
"@info:status",
"Create a new contact group" ) );
68 i18nc(
"@info:whatsthis",
69 "You will be presented with a dialog where you can create a new contact group." ) );
70 insertNewAction( action );
73 new KAction( KIcon( QLatin1String(
"view-refresh") ),
74 i18nc(
"@action:inmenu",
"Sync Contacts" ),
this );
75 actionCollection()->addAction( QLatin1String(
"kaddressbook_sync"), syncAction );
76 connect( syncAction, SIGNAL(triggered(
bool)), SLOT(slotSyncContacts()) );
77 syncAction->setHelpText(
78 i18nc(
"@info:status",
"Synchronize groupware contacts" ) );
79 syncAction->setWhatsThis(
80 i18nc(
"@info:whatsthis",
81 "Choose this option to synchronize your groupware contacts." ) );
82 insertSyncAction( syncAction );
84 mUniqueAppWatcher =
new KontactInterface::UniqueAppWatcher(
85 new KontactInterface::UniqueAppHandlerFactory<KAddressBookUniqueAppHandler>(),
this );
92 void KAddressBookPlugin::slotNewContact()
99 if ( part->metaObject()->indexOfMethod(
"newContact()" ) == -1 ) {
100 kWarning() <<
"KAddressBook part is missing slot newContact()";
104 QMetaObject::invokeMethod( part,
"newContact" );
107 void KAddressBookPlugin::slotNewContactGroup()
114 if ( part->metaObject()->indexOfMethod(
"newGroup()" ) == -1 ) {
115 kWarning() <<
"KAddressBook part is missing slot newGroup()";
119 QMetaObject::invokeMethod( part,
"newGroup" );
132 KParts::ReadOnlyPart *part = loadPart();
138 if ( part->action(
"akonadi_contact_create" ) ) {
139 KAction *newAction = qobject_cast<KAction*>( part->action(
"akonadi_contact_create" ) );
141 newAction->setShortcut( QKeySequence() );
150 return mUniqueAppWatcher->isRunningStandalone();
156 actions << QLatin1String(
"akonadi_contact_create") << QLatin1String(
"akonadi_contact_group_create");
160 void KAddressBookPlugin::slotSyncContacts()
163 QDBusMessage message =
164 QDBusMessage::createMethodCall(
"org.kde.kmail",
"/Groupware",
165 "org.kde.kmail.groupware",
167 message << QString(
"Contact" );
168 QDBusConnection::sessionBus().send( message );
170 kWarning() << QLatin1String(
" Need to port to AKONADI: KAddressBookPlugin::slotSyncNotes");
176 KCmdLineArgs::addCmdLineOptions( KCmdLineOptions() );
183 (void)plugin()->part();
184 return KontactInterface::UniqueAppHandler::newInstance();
188 #include "kaddressbook_plugin.moc"
KParts::ReadOnlyPart * createPart()
virtual void loadCommandLineOptions()
bool isRunningStandalone() const
QStringList invisibleToolbarActions() const
virtual int newInstance()