2 #include <score/document/DocumentContext.hpp>
3 #include <score/plugins/StringFactoryKey.hpp>
28 struct DocumentContext;
49 QString prettyName()
const;
83 const QKeySequence& defaultShortcut);
86 const QKeySequence& defaultShortcut,
const QKeySequence& defaultShortcut2);
89 QAction* act, QString text,
const char* key,
const char* group_key,
90 const QKeySequence& defaultShortcut);
94 QAction* action()
const;
96 QKeySequence shortcut();
97 void setShortcut(
const QKeySequence& shortcut);
99 QKeySequence defaultShortcut();
104 QPointer<QAction> m_impl{};
108 QKeySequence m_default;
109 QKeySequence m_current;
112 template <
typename Action_T>
134 inline bool canAddAction(
const ActionKey& other)
const noexcept
136 for(
auto& act : container)
137 if(act.key() == other)
143 std::vector<Action> container;
145 template <
typename Action_T>
146 void add(QAction* ptr)
194 template <
typename Action_T>
204 inline bool canAddAction(
const ActionKey& other)
const noexcept
206 for(
const auto& act : m_actions)
212 std::vector<ActionKey> m_actions;
222 using ActionCondition::ActionCondition;
256 using ActionCondition::ActionCondition;
267 using ActionCondition::ActionCondition;
284 using ActionCondition::ActionCondition;
287 void changed(
bool b) E_SIGNAL(SCORE_LIB_BASE_EXPORT, changed, b)
292 template <
typename T>
294 template <
typename T>
296 template <
typename T>
312 #define SCORE_DECLARE_SELECTED_OBJECT_CONDITION(Type) \
316 class EnableWhenSelectionContains<Type> final \
317 : public score::SelectionActionCondition \
320 EnableWhenSelectionContains() \
321 : score::SelectionActionCondition{static_key()} \
325 static score::ActionConditionKey static_key() \
327 return score::ActionConditionKey{"SelectedObjectIs" #Type}; \
331 void action(score::ActionManager& mgr, score::MaybeDocument doc) override \
335 setEnabled(mgr, false); \
339 const auto& sel = doc->selectionStack.currentSelection(); \
340 auto res = ossia::any_of( \
341 sel, [](auto obj) { return bool(dynamic_cast<const Type*>(obj.data())); }); \
343 setEnabled(mgr, res); \
361 #define SCORE_DECLARE_FOCUSED_OBJECT_CONDITION(Type) \
365 class EnableWhenFocusedObjectIs<Type> final : public score::FocusActionCondition \
368 static score::ActionConditionKey static_key() \
370 return score::ActionConditionKey{"FocusedObjectIs" #Type}; \
373 EnableWhenFocusedObjectIs() \
374 : score::FocusActionCondition{static_key()} \
379 void action(score::ActionManager& mgr, score::MaybeDocument doc) override \
383 setEnabled(mgr, false); \
387 auto obj = doc->focus.get(); \
390 setEnabled(mgr, false); \
394 if(dynamic_cast<const Type*>(obj)) \
396 setEnabled(mgr, true); \
415 #define SCORE_DECLARE_DOCUMENT_CONDITION(Type) \
419 class EnableWhenDocumentIs<Type> final : public score::DocumentActionCondition \
422 static score::ActionConditionKey static_key() \
424 return score::ActionConditionKey{"DocumentIs" #Type}; \
426 EnableWhenDocumentIs() \
427 : score::DocumentActionCondition{static_key()} \
432 void action(score::ActionManager& mgr, score::MaybeDocument doc) override \
436 setEnabled(mgr, false); \
439 auto model = score::IDocument::try_get<Type>(doc->document); \
440 setEnabled(mgr, bool(model)); \
446 #define SCORE_DECLARE_ACTION(ActionName, Text, Group, Shortcut) \
454 struct MetaAction<Actions::ActionName> \
456 static score::Action make(QAction* ptr) \
458 return score::Action{ \
459 ptr, QObject::tr(Text), key(), score::ActionGroupKey{#Group}, Shortcut}; \
462 static score::ActionKey key() \
464 return score::ActionKey{#ActionName}; \
469 #define SCORE_DECLARE_ACTION_2S(ActionName, Text, Group, Shortcut1, Shortcut2) \
477 struct MetaAction<Actions::ActionName> \
479 static score::Action make(QAction* ptr) \
481 return score::Action{ptr, QObject::tr(Text), \
482 key(), score::ActionGroupKey{#Group}, \
483 Shortcut1, Shortcut2}; \
486 static score::ActionKey key() \
488 return score::ActionKey{#ActionName}; \
Base class for IdentifiedObject.
Definition: IdentifiedObjectAbstract.hpp:16
The ActionGroup class A semantic group of actions : for instance, all the actions related to audio re...
Definition: Action.hpp:41
The Action class.
Definition: Action.hpp:79
The ActionManager class.
Definition: ActionManager.hpp:19
Definition: Action.hpp:297
Definition: Action.hpp:295
Definition: Action.hpp:293
Base toolkit upon which the software is built.
Definition: Application.cpp:90
The ActionCondition struct.
Definition: Action.hpp:166
void add()
add Register an action for this condition.
Definition: Action.hpp:195
The ActionContainer struct.
Definition: Action.hpp:132
The CustomActionCondition struct.
Definition: Action.hpp:280
The DocumentActionCondition struct.
Definition: Action.hpp:221
Definition: DocumentContext.hpp:18
The EnableActionIfDocument struct.
Definition: Action.hpp:233
The FocusActionCondition struct.
Definition: Action.hpp:255
The SelectionActionCondition struct.
Definition: Action.hpp:266