X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fuisupport%2Factioncollection.cpp;h=c553554bcffd769c26c4bb7de78aa648fe58a001;hb=fc07679cda72e37ef2d2c3e6ed4468c5563f679e;hp=a20d9183027bb49183f65c4ac30dbd47b4c82a73;hpb=bfc967d449565c7435aecfb007e2df6fab1f9188;p=quassel.git diff --git a/src/uisupport/actioncollection.cpp b/src/uisupport/actioncollection.cpp index a20d9183..c553554b 100644 --- a/src/uisupport/actioncollection.cpp +++ b/src/uisupport/actioncollection.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,11 +20,15 @@ * Parts of this implementation are based on KDE's KActionCollection. * ***************************************************************************/ +#ifndef HAVE_KDE + #include +#include #include "actioncollection.h" #include "action.h" +#include "uisettings.h" ActionCollection::ActionCollection(QObject *parent) : QObject(parent) { _connectTriggered = _connectHovered = false; @@ -49,7 +53,8 @@ QList ActionCollection::actions() const { } Action *ActionCollection::addAction(const QString &name, Action *action) { - QAction *act = addAction(name, action); + QAction *act = addAction(name, static_cast(action)); + Q_UNUSED(act); Q_ASSERT(act == action); return action; } @@ -73,7 +78,7 @@ QAction *ActionCollection::addAction(const QString &name, QAction *action) { else action->setObjectName(indexName); if(indexName.isEmpty()) - indexName = QString("unnamed-%1").arg((int)action, 16); + indexName = indexName.sprintf("unnamed-%p", (void *)action); // do we already have this action? if(_actionByName.value(indexName, 0) == action) @@ -124,12 +129,30 @@ QAction *ActionCollection::takeAction(QAction *action) { } void ActionCollection::readSettings() { - + ShortcutSettings s; + QStringList savedShortcuts = s.savedShortcuts(); + + foreach(const QString &name, _actionByName.keys()) { + if(!savedShortcuts.contains(name)) + continue; + Action *action = qobject_cast(_actionByName.value(name)); + if(action) + action->setShortcut(s.loadShortcut(name), Action::ActiveShortcut); + } } void ActionCollection::writeSettings() const { - - + ShortcutSettings s; + foreach(const QString &name, _actionByName.keys()) { + Action *action = qobject_cast(_actionByName.value(name)); + if(!action) + continue; + if(!action->isShortcutConfigurable()) + continue; + if(action->shortcut(Action::ActiveShortcut) == action->shortcut(Action::DefaultShortcut)) + continue; + s.saveShortcut(name, action->shortcut(Action::ActiveShortcut)); + } } void ActionCollection::slotActionTriggered() { @@ -206,6 +229,10 @@ void ActionCollection::clearAssociatedWidgets() { _associatedWidgets.clear(); } +void ActionCollection::associatedWidgetDestroyed(QObject *obj) { + _associatedWidgets.removeAll(static_cast(obj)); +} + bool ActionCollection::unlistAction(QAction *action) { // This might be called with a partly destroyed QAction! @@ -220,3 +247,5 @@ bool ActionCollection::unlistAction(QAction *action) { return true; } + +#endif /* HAVE_KDE */