Beginning of a Standard Action Configuration KCM (copy, paste .... )
David Faure
faure at kde.org
Thu Jun 12 19:44:12 BST 2008
On Saturday 07 June 2008, Michael Jansen wrote:
> Hi
>
> Patches attached.
>
> I'm lost on how to save the changes. There is an API function
> KStandardShortcuts::saveShortcut(). Am i really expected to walk over all
> actions in the collection, somehow find out which shortcuts is behind the
> action and save it?
>
> Then i could forget the standard actions and try to work directly with the
> standard shortcuts but that doesn't seem to be right either.
>
> Call KActionCollection::writeSettings could possibly be convinced to do the
> right thing but the we would have these changes not active in the application.
> Reload the standard shortcuts after saving them?
>
> Someone ideas?
A QMap? Or, better,
action->setData(id);
after creating it, and add member var
KActionCollection* m_actionCollection;
and then
void StandardActionsModule::save()
{
Q_FOREACH(QAction* action, m_actionCollection->actions()) {
int id = action->data().toInt();
KStandardShortcut::saveShortcut(id, action->shortcut());
}
}
Ah, but the StandardAction enum is not the StandardShortcut enum.
We need a way to access pInfo->idAccel in kstandardaction.cpp.
How about add this to kstandardaction?
KDEUI_EXPORT KStandardShortcut::StandardShortcut shortcutForAction(StandardAction id);
(requires #include <kstandardshortcut.h>, but that's fine)
Then you can call this before doing the setData, i.e. associate each qaction
with the StandardShortcut value for it.
David, who likes pseudo-coding and letting others doing all the bugfixing :-)
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel
mailing list