~ubuntu-branches/ubuntu/jaunty/quassel/jaunty

« back to all changes in this revision

Viewing changes to src/uisupport/action.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-11-17 15:22:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081117152246-3lwlpnr4r08910kv
Tags: 0.3.1-0ubuntu1
* New upstream release (LP: #271403)
* Drop all patches originated from upstream (quassel_*)
* Compile with non-builtin quassel icons
  + Introduce new quassel-data package
  + quassel and quassel-client depend on quassel-data
  + Don't manually enforce icon installation for desktop files in debian/rules
  + Add quassel_01_fix_iconloader.patch
* Drop perl build dependency, I have no clue why it was added in the first
  place. Neither changelog nor Bazaar knows, and since quassel compiles just
  fine without it, removing it should be save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 *   along with this program; if not, write to the                         *
17
17
 *   Free Software Foundation, Inc.,                                       *
18
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************
 
20
 * Parts of this implementation are taken from KDE's kaction.cpp           *
19
21
 ***************************************************************************/
 
22
 
 
23
#include <QApplication>
 
24
 
 
25
#include "action.h"
 
26
 
 
27
Action::Action(QObject *parent) : QWidgetAction(parent) {
 
28
  init();
 
29
}
 
30
 
 
31
Action::Action(const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut)
 
32
: QWidgetAction(parent) {
 
33
  init();
 
34
  setText(text);
 
35
  setShortcut(shortcut);
 
36
  if(receiver && slot)
 
37
    connect(this, SIGNAL(triggered()), receiver, slot);
 
38
}
 
39
 
 
40
Action::Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut)
 
41
: QWidgetAction(parent) {
 
42
  init();
 
43
  setIcon(icon);
 
44
  setText(text);
 
45
  setShortcut(shortcut);
 
46
  if(receiver && slot)
 
47
    connect(this, SIGNAL(triggered()), receiver, slot);
 
48
}
 
49
 
 
50
void Action::init() {
 
51
  connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered()));
 
52
 
 
53
  setProperty("isShortcutConfigurable", true);
 
54
}
 
55
 
 
56
void Action::slotTriggered() {
 
57
  emit triggered(QApplication::mouseButtons(), QApplication::keyboardModifiers());
 
58
}
 
59
 
 
60
bool Action::isShortcutConfigurable() const {
 
61
  return property("isShortcutConfigurable").toBool();
 
62
}
 
63
 
 
64
void Action::setShortcutConfigurable(bool b) {
 
65
  setProperty("isShortcutConfigurable", b);
 
66
}
 
67
 
 
68
QKeySequence Action::shortcut(ShortcutTypes type) const {
 
69
  Q_ASSERT(type);
 
70
  if(type == DefaultShortcut)
 
71
    return property("defaultShortcut").value<QKeySequence>();
 
72
 
 
73
  if(shortcuts().count()) return shortcuts().value(0);
 
74
  return QKeySequence();
 
75
}
 
76
 
 
77
void Action::setShortcut(const QShortcut &shortcut, ShortcutTypes type) {
 
78
  setShortcut(shortcut.key(), type);
 
79
}
 
80
 
 
81
void Action::setShortcut(const QKeySequence &key, ShortcutTypes type) {
 
82
  Q_ASSERT(type);
 
83
 
 
84
  if(type & DefaultShortcut)
 
85
    setProperty("defaultShortcut", key);
 
86
 
 
87
  if(type & ActiveShortcut)
 
88
    QAction::setShortcut(key);
 
89
}