From fc0e7683878ac10eb9a4675f61e6443a13ced946 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 21 Dec 2012 10:41:15 +0100 Subject: Implemented new shortcut key system. Fade in/out shortcut tooltips. Close pcpviewer on window close due to commit/nocommit/discard actions. --- client/widgets/button.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'client/widgets/button.cc') diff --git a/client/widgets/button.cc b/client/widgets/button.cc index 6ef6ac8..06bf594 100644 --- a/client/widgets/button.cc +++ b/client/widgets/button.cc @@ -30,6 +30,7 @@ #include #include "common.h" +#include "debug.h" #include "macrowindow.h" @@ -37,7 +38,7 @@ Button::Button(QDomNode &node, MacroWindow *macrowindow) : Widget(node, macrowindow) { button = new QPushButton(); - widget = button; + setWidget(button); setCommonAttributes(button, node); @@ -61,6 +62,17 @@ Button::Button(QDomNode &node, MacroWindow *macrowindow) connect(this, SIGNAL(act_cancel()), macrowindow, SLOT(cancel())); connect(macrowindow, SIGNAL(macroHasChanged()), this, SLOT(do_enable())); } + + if(elem.attribute("action") == "commit") { + QList lst; + lst << QKeySequence("Ctrl+Enter"); + lst << QKeySequence("Ctrl+Return"); + QAction *a = new QAction(widget_name, this); + a->setShortcuts(lst); + button->addAction(a); + connect(a, SIGNAL(triggered()), + this, SLOT(shortcutActivated())); + } } Button::~Button() @@ -82,3 +94,9 @@ void Button::do_enable() { button->setEnabled(true); } + +void Button::shortcutActivated() +{ + setKeyboardFocus(); + button->click(); +} -- cgit v1.2.3