14 CGuiActionBindHandler::CGuiActionBindHandler(
QAction *action) :
QObject(action), m_action(action)
16 this->connectDestroy(action);
17 connect(
sApp, &CApplication::aboutToShutdown,
this, &CGuiActionBindHandler::unbind);
22 this->connectDestroy(button);
23 connect(
sApp, &CApplication::aboutToShutdown,
this, &CGuiActionBindHandler::unbind);
26 CGuiActionBindHandler::~CGuiActionBindHandler() {}
32 if (!menu || menu->
isEmpty()) {
return boundActions; }
35 if (action->text().isEmpty()) {
continue; }
36 if (action->isSeparator()) {
continue; }
39 CGuiActionBindHandler::appendPath(path, action->text()).
remove(
'&');
40 if (action->menu()) { CGuiActionBindHandler::bindMenu(action->menu(), pathNew); }
42 const bool hasIcon = !action->icon().isNull();
50 pathNew, CIcons::StandardIconEmpty16, bindHandler, &CGuiActionBindHandler::boundFunction,
51 [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); }));
53 bindHandler->m_index = actionBinding->getIndex();
54 boundActions.
append(actionBinding);
65 CGuiActionBindHandler::appendPath(path, button->
text()).
remove(
'&');
67 const bool hasIcon = !button->
icon().isNull();
74 pathNew, CIcons::StandardIconEmpty16, bindHandler, &CGuiActionBindHandler::boundFunction,
75 [bindHandler]() { CGuiActionBindHandler::actionBindWasDestroyed(bindHandler); }));
77 bindHandler->m_index = actionBinding->getIndex();
83 if (!bindHandler) {
return; }
88 void CGuiActionBindHandler::connectDestroy(
QObject *
object)
94 void CGuiActionBindHandler::unbind()
96 if (this->hasTarget())
104 void CGuiActionBindHandler::reset()
111 bool CGuiActionBindHandler::hasTarget()
const {
return (m_button || m_action) && m_index >= 0; }
113 void CGuiActionBindHandler::boundFunction(
bool enabled)
115 if (!enabled || !this->hasTarget()) {
return; }
116 if (m_action) { m_action->trigger(); }
117 else if (m_button) { m_button->click(); }
122 return CFileUtils::appendFilePaths(path, name);
125 const QString &CGuiActionBindHandler::pathSwiftPilotClient()
127 static const QString s(
"Pilot client UI/");
131 const QString &CGuiActionBindHandler::pathSwiftCore()
133 static const QString s(
"Core UI/");
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
CInputManager * getInputManager() const
The input manager, if available.
QObject derived handler to be registered with swift::core::CActionBind.
Backend services of the swift project, like dealing with the network or the simulators.
Free functions in swift::misc.
void append(QList< T > &&value)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QTextStream & reset(QTextStream &stream)
QFuture< QtFuture::ArgsType< Signal >> connect(Sender *sender, Signal signal)