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
***************************************************************************/
23
#include <QApplication>
27
Action::Action(QObject *parent) : QWidgetAction(parent) {
31
Action::Action(const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut)
32
: QWidgetAction(parent) {
35
setShortcut(shortcut);
37
connect(this, SIGNAL(triggered()), receiver, slot);
40
Action::Action(const QIcon &icon, const QString &text, QObject *parent, const QObject *receiver, const char *slot, const QKeySequence &shortcut)
41
: QWidgetAction(parent) {
45
setShortcut(shortcut);
47
connect(this, SIGNAL(triggered()), receiver, slot);
51
connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered()));
53
setProperty("isShortcutConfigurable", true);
56
void Action::slotTriggered() {
57
emit triggered(QApplication::mouseButtons(), QApplication::keyboardModifiers());
60
bool Action::isShortcutConfigurable() const {
61
return property("isShortcutConfigurable").toBool();
64
void Action::setShortcutConfigurable(bool b) {
65
setProperty("isShortcutConfigurable", b);
68
QKeySequence Action::shortcut(ShortcutTypes type) const {
70
if(type == DefaultShortcut)
71
return property("defaultShortcut").value<QKeySequence>();
73
if(shortcuts().count()) return shortcuts().value(0);
74
return QKeySequence();
77
void Action::setShortcut(const QShortcut &shortcut, ShortcutTypes type) {
78
setShortcut(shortcut.key(), type);
81
void Action::setShortcut(const QKeySequence &key, ShortcutTypes type) {
84
if(type & DefaultShortcut)
85
setProperty("defaultShortcut", key);
87
if(type & ActiveShortcut)
88
QAction::setShortcut(key);