This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Kopete] Copy description

Tags: None
(comma "," separated)
User avatar
cojack
Registered Member
Posts
3
Karma
0
OS

[Kopete] Copy description

Sun Oct 30, 2011 5:51 pm
Hello, I writed a some code to copy description from user status:

Code: Select all
Index: kopete/contactlist/kopetecontactlistview.h
===================================================================
--- kopete/contactlist/kopetecontactlistview.h  (wersja 1261596)
+++ kopete/contactlist/kopetecontactlistview.h  (kopia robocza)
@@ -114,6 +114,7 @@
        void addToAddContactMenu( Kopete::Account* account );
        void removeToAddContactMenu( const Kopete::Account *account );
        void addContact();
+        void copyDescription();
 
 private:
        Kopete::MetaContact* metaContactFromIndex( const QModelIndex& index ) const;



Index: kopete/contactlist/kopetecontactlistview.cpp
===================================================================
--- kopete/contactlist/kopetecontactlistview.cpp        (wersja 1261596)
+++ kopete/contactlist/kopetecontactlistview.cpp        (kopia robocza)
@@ -40,6 +40,7 @@
 #include <KToolInvocation>
 #include <kxmlguifactory.h>
 #include <kabc/stdaddressbook.h>
+#include <QDBusInterface>
 
 #include "kopeteuiglobal.h"
 #include "kopetecontactlistelement.h"
@@ -85,6 +86,7 @@
        KAction *actionSendEmail;
        KSelectAction *actionMove;
        KSelectAction *actionCopy;
+        KAction *actionCopyDescription;
        KAction *actionRename;
        KAction *actionRemove;
        KAction *actionAddTemporaryContact;
@@ -196,6 +198,11 @@
        ac->addAction( "contactAddContact", d->actionAddContact );
        d->actionAddContact->menu()->addTitle( i18n("Select Account") );
 
+        // feateure was misssing since 1998 ^^
+        d->actionCopyDescription = new KActionMenu( KIcon( QLatin1String("edit-copy") ), i18n("Copy description"), ac );
+        ac->addAction( "contactCopyDescription", d->actionCopyDescription );
+        connect( d->actionCopyDescription, SIGNAL(triggered()), this, SLOT(copyDescription()));
+
        d->actionAddTemporaryContact = new KAction( KIcon("list-add-user"), i18n( "Add to Your Contact List" ), ac );
        ac->addAction( "contactAddTemporaryContact", d->actionAddTemporaryContact );
        connect( d->actionAddTemporaryContact, SIGNAL(triggered(bool)), this, SLOT(addTemporaryContact()) );
@@ -1186,6 +1193,19 @@
        return height;
 }
 
+void KopeteContactListView::copyDescription()
+{
+    QModelIndex index = currentIndex();
+    if ( !index.isValid() )
+            return;
+
+    QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper");
+    if (klipper.isValid()) {
+        klipper.call("setClipboardContents", metaContactFromIndex( index )->statusMessage().message());
+    }
+
+}
+
 #include "kopetecontactlistview.moc"
 
 // vim: set noet ts=4 sts=4 sw=4:


Then when you compile it, just go to the configure toolbar and add the Copy description action.

Regards.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]