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

Howto set a new action for shortcut

Tags: None
(comma "," separated)
gattoo
Registered Member
Posts
6
Karma
0
OS

Howto set a new action for shortcut

Wed Jul 15, 2009 3:55 pm
Hello everyone, can i get a little help? )
I'm working around Kopete junior job: https://bugs.kde.org/show_bug.cgi?id=84080

1. How can i add a new command (like "Away", "Create New Group") to Kopete -> Settings -> Configure Shortcuts.

2. Also how do i know what signal does this shortcut emit to catch it (or how it can be done, if there is no signal).

3. And, finally, how can i run default browser with specified link or a default mail client with specified mail address.

Thx a lot

Last edited by gattoo on Thu Jul 23, 2009 11:10 am, edited 2 times in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You are looking for the "KAction" class. It allows setting the "shortcut" which will trigger one of its signals. You will need to add the action to the action collection ( KActionCollection ) also.

Not sure how "Configure Shortcuts" works exactly, but it probably involves the action collection.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
gattoo
Registered Member
Posts
6
Karma
0
OS
thx, i passed through KAction (it doesnt work yet, but now i know where it hides)
i was also told to try KToolInvocation to run a default browser and mailer
gattoo
Registered Member
Posts
6
Karma
0
OS
one more trouble...

I managed to add an action to kopetewindow.cpp and it even worked, but this is not what i want.
Whatever i do, i cant add an action to historyguiclient.cpp or even to kopetechatwindow.cpp. I mean this action doesn't appear in ChatView's "Settings -> Configure
Shortcuts"

trying to add smth like this in kopetechatwindow.cpp

actionOpenLastUrl=new KAction( i18n( "&Open Last Url" ), coll );
coll->addAction( "open_lasturl", actionOpenLastUrl );
connect( actionOpenLastUrl, SIGNAL(triggered(bool)), this, SLOT(slotOpenLastUrl()) );

or smth like this in historyguiclient.cpp

KAction *actionOpenLastUrl = new KAction ( KIcon ( "go-last" ), i18n ( "Open Last Url" ), this );
actionCollection()->addAction ( "openLastUrl", actionOpenLastUrl );
connect ( actionOpenLastUrl, SIGNAL ( triggered ( bool ) ), this, SLOT ( slotOpenLastUrl() ) )

none of the ways work.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Which of the shortcut dialogs are you checking? Just by looking at the code it appears that there are two possible dialogs, "Global Keyboard Shortcuts" and normal "Keyboard Shortcuts". Your shortcuts should definitely appear in the normal dialog, and simply adding the shortcut to the action collection should be sufficient.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
gattoo
Registered Member
Posts
6
Karma
0
OS
I managed to add an action to a "normal" "Keyboard Shortcuts" as you said (at main Kopete window, kopetewindow.cpp file), but this is not what i want.

When i'm opening a new contact to chat with, a new ChatView window appears. This ChatView window also has "Settings -> Configure Shortcuts". This shortcuts dialog is my target.

As i can understand the source, i can add an action to that dialog in two ways (historyguiclient.cpp - preferable, kopetechatwindow.cpp - alternative), but none of them works.


Bookmarks



Who is online

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