Add some hotkeys
authorChristoph Egger <Christoph.Egger@fau.de>
Mon, 16 Feb 2015 12:17:29 +0000 (13:17 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Mon, 16 Feb 2015 12:17:29 +0000 (13:17 +0100)
src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx
src/gui/qt.hxx

index 611f3da62822307dc1043944f944f6a079a60ed0..754d5b2b0f1ab244b7932e77f571b14f1abc4d85 100644 (file)
@@ -62,6 +62,18 @@ Mainwindow::Mainwindow(InformationManager* mgr)
                        auto item = new QListWidgetItem(name.c_str(), listWidget);
                        item->setBackground(QBrush(QColor(0xff, 0xdd, 0xdd)));
                });
                        auto item = new QListWidgetItem(name.c_str(), listWidget);
                        item->setBackground(QBrush(QColor(0xff, 0xdd, 0xdd)));
                });
+       setGlobalHotkeys();
+}
+
+void Mainwindow::setGlobalHotkeys() {
+       QShortcut *shortcut = new QShortcut(QKeySequence("f"), this);
+       connect(shortcut, &QShortcut::activated, this, &Mainwindow::requestNewFunction);
+
+       shortcut = new QShortcut(QKeySequence("r"), listWidget);
+       connect(shortcut, &QShortcut::activated, [=]() {
+                       QListWidgetItem * item = listWidget->currentItem();
+                       if (item) renameFunction(item);
+               });
 }
 
 void Mainwindow::quit()
 }
 
 void Mainwindow::quit()
index a78b44617f5ee7d4f8db3238045fb366d3362125..179a9c40ac5f6aacf72972883922504a6f7e3a01 100644 (file)
@@ -25,6 +25,7 @@ public:
 
 private:
        void addFunction(Function* fun);
 
 private:
        void addFunction(Function* fun);
+       void setGlobalHotkeys();
 
        QTextEdit *textEdit;
        QPushButton *quitButton;
 
        QTextEdit *textEdit;
        QPushButton *quitButton;
index 64ca4c11c26a889a78b0dae740ecd11ea97a4625..97a1d280071d72ba55ba4c72d2511bf848829b43 100644 (file)
@@ -24,5 +24,6 @@
 #include <QLabel>
 #include <QtGui>
 #include <QMenu>
 #include <QLabel>
 #include <QtGui>
 #include <QMenu>
+#include <QShortcut>
 
 #endif /* INCLUDE__qt_hxx_ */
 
 #endif /* INCLUDE__qt_hxx_ */