20#ifndef LIBREPCB_EDITOR_EDITORCOMMAND_H
21#define LIBREPCB_EDITOR_EDITORCOMMAND_H
54 Q_DECLARE_FLAGS(Flags,
Flag)
69 const
char* description, const QString& iconFp, Flags flags,
70 const QList<QKeySequence>& defaultKeySequences,
71 QObject* parent =
nullptr) noexcept;
97 ActionFlags flags = ActionFlags()) const noexcept;
98 template <typename TContext, typename TSlot>
99 QAction*
createAction(QObject* parent, const TContext* context, TSlot slot,
100 ActionFlags flags = ActionFlags()) const noexcept {
103 ? Qt::QueuedConnection
104 : Qt::AutoConnection;
106 QObject::connect(action, &QAction::toggled, context, slot, conType);
108 QObject::connect(action, &QAction::triggered, context, slot, conType);
120 QAction*
setupAction(QAction* action, ActionFlags flags)
const noexcept;
121 bool eventFilter(QObject* obj, QEvent* event)
noexcept override;
139Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::editor::EditorCommand::Flags)
140Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::editor::EditorCommand::ActionFlags)
Command for editors, e.g. to be added to a QMenu.
Definition editorcommand.h:42
QString mIdentifier
Definition editorcommand.h:125
QIcon mIcon
Definition editorcommand.h:130
QString getDisplayTextNoTr() const noexcept
Definition editorcommand.h:78
Flags mFlags
Definition editorcommand.h:131
QString mDescription
Definition editorcommand.h:129
const char * mDescriptionNoTr
Definition editorcommand.h:128
void setKeySequences(const QList< QKeySequence > &sequences) noexcept
Definition editorcommand.cpp:90
const QIcon & getIcon() const noexcept
Definition editorcommand.h:82
static QString unescapeAmpersand(QString text) noexcept
Definition editorcommand.cpp:206
Flag
Definition editorcommand.h:47
QList< QKeySequence > mKeySequences
Definition editorcommand.h:133
EditorCommand & operator=(const EditorCommand &rhs)=delete
void updateTranslations() noexcept
Definition editorcommand.cpp:102
void shortcutsChanged(const QList< QKeySequence > &sequences)
const QString & getDescription() const noexcept
Definition editorcommand.h:81
const QList< QKeySequence > getDefaultKeySequences() const noexcept
Definition editorcommand.h:84
QString getDisplayText() const noexcept
Definition editorcommand.h:77
QString mText
Definition editorcommand.h:127
const QList< QKeySequence > & getKeySequences() const noexcept
Definition editorcommand.h:87
QAction * setupAction(QAction *action, ActionFlags flags) const noexcept
Definition editorcommand.cpp:118
const QString & getText() const noexcept
Definition editorcommand.h:76
const char * mTextNoTr
Definition editorcommand.h:126
const QString & getIdentifier() const noexcept
Definition editorcommand.h:75
const Flags & getFlags() const noexcept
Definition editorcommand.h:83
QAction * createAction(QObject *parent, ActionFlags flags=ActionFlags()) const noexcept
Definition editorcommand.cpp:109
bool eventFilter(QObject *obj, QEvent *event) noexcept override
Definition editorcommand.cpp:160
QList< QKeySequence > mDefaultKeySequences
Definition editorcommand.h:132
ActionFlag
Definition editorcommand.h:56
@ ReactOnToggle
React on toggled() instead of triggered().
@ WidgetShortcut
Restrict the shortcut to its widget.
@ QueuedConnection
Create a queued signal/slot connection.
@ NoShortcuts
Create an action without shortcuts.
@ ApplicationShortcut
Make the shortcut application global.
Definition occmodel.cpp:76