diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-01-10 16:50:57 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-01-10 21:25:02 +0100 |
commit | 769c64fe5e34e0dd4d0d1641093765210a91ecff (patch) | |
tree | 8644ba2351acaa8ab1fa8d5d75176d87efbed5d5 /profile-widget/profilewidget2.cpp | |
parent | 3d8b0e6d3f7fb9f0efbb257889ec9d654a50bfc0 (diff) | |
download | subsurface-769c64fe5e34e0dd4d0d1641093765210a91ecff.tar.gz |
Replace ADD_ACTION macro by member function in profilewidget2.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 2d3b72dac..8a90cde1f 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -139,24 +139,14 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), addItemsToScene(); scene()->installEventFilter(this); #ifndef SUBSURFACE_MOBILE - QAction *action = NULL; setAcceptDrops(true); -#define ADD_ACTION(SHORTCUT, Slot) \ - action = new QAction(this); \ - action->setShortcut(SHORTCUT); \ - action->setShortcutContext(Qt::WindowShortcut); \ - addAction(action); \ - connect(action, SIGNAL(triggered(bool)), this, SLOT(Slot)); \ - actionsForKeys[SHORTCUT] = action; - - ADD_ACTION(Qt::Key_Escape, keyEscAction()); - ADD_ACTION(Qt::Key_Delete, keyDeleteAction()); - ADD_ACTION(Qt::Key_Up, keyUpAction()); - ADD_ACTION(Qt::Key_Down, keyDownAction()); - ADD_ACTION(Qt::Key_Left, keyLeftAction()); - ADD_ACTION(Qt::Key_Right, keyRightAction()); -#undef ADD_ACTION + addActionShortcut(Qt::Key_Escape, &ProfileWidget2::keyEscAction); + addActionShortcut(Qt::Key_Delete, &ProfileWidget2::keyDeleteAction); + addActionShortcut(Qt::Key_Up, &ProfileWidget2::keyUpAction); + addActionShortcut(Qt::Key_Down, &ProfileWidget2::keyDownAction); + addActionShortcut(Qt::Key_Left, &ProfileWidget2::keyLeftAction); + addActionShortcut(Qt::Key_Right, &ProfileWidget2::keyRightAction); #endif // SUBSURFACE_MOBILE #if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE) @@ -166,6 +156,18 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), #endif } +#ifndef SUBSURFACE_MOBILE +void ProfileWidget2::addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)()) +{ + QAction *action = new QAction(this); + action->setShortcut(shortcut); + action->setShortcutContext(Qt::WindowShortcut); + addAction(action); + connect(action, &QAction::triggered, this, slot); + actionsForKeys[shortcut] = action; +} +#endif // SUBSURFACE_MOBILE + #define SUBSURFACE_OBJ_DATA 1 #define SUBSURFACE_OBJ_DC_TEXT 0x42 |