Reset the input prior to processing it in order to prevent issues with per-chat histo...
[quassel.git] / src / uisupport / actioncollection.cpp
index 9175ecc..c553554 100644 (file)
@@ -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  *
  * Parts of this implementation are based on KDE's KActionCollection.      *
  ***************************************************************************/
 
+#ifndef HAVE_KDE
+
 #include <QAction>
 #include <QDebug>
 
 #include "actioncollection.h"
 
 #include "action.h"
+#include "uisettings.h"
 
 ActionCollection::ActionCollection(QObject *parent) : QObject(parent) {
   _connectTriggered = _connectHovered = false;
@@ -126,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<Action *>(_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<Action *>(_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() {
@@ -226,3 +247,5 @@ bool ActionCollection::unlistAction(QAction *action) {
 
   return true;
 }
+
+#endif /* HAVE_KDE */