hivemind 1.0.0
Loading...
Searching...
No Matches
action.h
Go to the documentation of this file.
1#pragma once
2
3#include <QAction>
4
5namespace Gui
6{
7
8 /// \brief Small wrapper around QAction
9 ///
10 /// A tiny wrapper class around QAction that simply provides constructor
11 /// arguments to add on-click functionality and keyboard shortcuts.
12 class Action : public QAction
13 {
14 public:
15 /// \brief Constructs the Action widget.
16 /// \param parent The parent of the Action widget.
17 /// \param label The label to be displayed in the action.
18 /// \param onClick A function to call when the action is clicked.
19 /// \param shortcut A keyboard shortcut to activate the action.
20 ///
21 /// Typical usage:
22 /// \code{.cpp}
23 /// Action* openAction = new Action(
24 /// parent, QString::fromUtf8("Open..."),
25 /// []() {
26 /// QString fileName = QFileDialog::getOpenFileName(
27 /// nullptr, QString::fromUtf8("Open Image"),
28 /// QDir::currentPath(),
29 /// QString::fromUtf8("Image Files (*.png *.jpg *.bmp)"));
30 /// qInfo() << "File: " << fileName;
31 /// },
32 /// QKeySequence::Open);
33 /// \endcode
34 Action(QWidget* parent, const QString& label, void (*onClick)(void),
35 const QKeySequence& shortcut = QKeySequence::UnknownKey);
36 };
37
38} // namespace Gui
Small wrapper around QAction.
Definition: action.h:13
Definition: action.h:6