From 13a24654240bee178104a287c6dac0d01c624ef5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 18 Apr 2019 00:58:19 +0200 Subject: [PATCH] Ref T609, encapsulate PTT action/key --- src/blackcore/context/contextaudio.cpp | 11 ------- src/blackcore/context/contextaudio.h | 6 ---- src/blackcore/context/contextaudioimpl.h | 3 +- .../components/infobarstatuscomponent.h | 3 +- .../components/settingshotkeycomponent.cpp | 3 +- src/blackmisc/input/actionhotkeydefs.cpp | 26 ++++++++++++++++ src/blackmisc/input/actionhotkeydefs.h | 31 +++++++++++++++++++ 7 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 src/blackmisc/input/actionhotkeydefs.cpp create mode 100644 src/blackmisc/input/actionhotkeydefs.h diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index 025d576e4..b7b98efb3 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -33,17 +33,6 @@ namespace BlackCore return s; } - const QString &IContextAudio::pttHotkeyAction() - { - static const QString s("/Voice/Activate push-to-talk"); - return s; - } - - const QPixmap &IContextAudio::pttHotkeyIcon() - { - return CIcons::radio16(); - } - IContextAudio *IContextAudio::create(CCoreFacade *runtime, CCoreFacadeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &connection) { switch (mode) diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index 32d70b36c..c5718ca32 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -72,12 +72,6 @@ namespace BlackCore //! Object path static const QString &ObjectPath(); - //! Hotkey identifier for PTT (push to talk) - static const QString &pttHotkeyAction(); - - //! Hotkey icon for PTT (push to talk) - static const QPixmap &pttHotkeyIcon(); - //! \copydoc CContext::getPathAndContextId() virtual QString getPathAndContextId() const override { return this->buildPathAndContextId(ObjectPath()); } diff --git a/src/blackcore/context/contextaudioimpl.h b/src/blackcore/context/contextaudioimpl.h index 0d144c84a..98da1f91d 100644 --- a/src/blackcore/context/contextaudioimpl.h +++ b/src/blackcore/context/contextaudioimpl.h @@ -22,6 +22,7 @@ #include "blackmisc/audio/audiodeviceinfolist.h" #include "blackmisc/audio/notificationsounds.h" #include "blackmisc/audio/voiceroomlist.h" +#include "blackmisc/input/actionhotkeydefs.h" #include "blackmisc/aviation/callsignset.h" #include "blackmisc/aviation/comsystem.h" #include "blackmisc/aviation/selcal.h" @@ -140,7 +141,7 @@ namespace BlackCore //! Voice channel by room QSharedPointer getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom); - CActionBind m_actionPtt { pttHotkeyAction(), pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmission }; + CActionBind m_actionPtt { BlackMisc::Input::pttHotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CContextAudio::setVoiceTransmission }; std::unique_ptr m_voice; //!< underlying voice lib std::unique_ptr m_audioMixer; diff --git a/src/blackgui/components/infobarstatuscomponent.h b/src/blackgui/components/infobarstatuscomponent.h index 909d651d6..b0a720b64 100644 --- a/src/blackgui/components/infobarstatuscomponent.h +++ b/src/blackgui/components/infobarstatuscomponent.h @@ -14,6 +14,7 @@ #include "blackcore/actionbind.h" #include "blackcore/network.h" #include "blackgui/blackguiexport.h" +#include "blackmisc/input/actionhotkeydefs.h" #include #include @@ -58,7 +59,7 @@ namespace BlackGui private: QScopedPointer ui; - BlackCore::CActionBind m_actionPtt { "/Voice/Activate push-to-talk", BlackMisc::CIcons::radio16(), this, &CInfoBarStatusComponent::onPttChanged }; + BlackCore::CActionBind m_actionPtt { BlackMisc::Input::pttHotkeyAction(), BlackMisc::Input::pttHotkeyIcon(), this, &CInfoBarStatusComponent::onPttChanged }; BlackMisc::CDigestSignal m_dsResize { this, &CInfoBarStatusComponent::adjustTextSize, 1000, 50 }; //! Init the LEDs diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index bb7a47d70..f7d5d74fe 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -13,6 +13,7 @@ #include "blackcore/context/contextapplication.h" #include "blackcore/context/contextaudio.h" #include "blackcore/inputmanager.h" +#include "blackmisc/input/actionhotkeydefs.h" #include "ui_settingshotkeycomponent.h" #include @@ -67,7 +68,7 @@ namespace BlackGui void CSettingsHotkeyComponent::registerDummyPttEntry() { Q_ASSERT_X(sApp && sApp->getInputManager(), Q_FUNC_INFO, "Missing input manager"); - sApp->getInputManager()->registerAction(IContextAudio::pttHotkeyAction(), IContextAudio::pttHotkeyIcon()); + sApp->getInputManager()->registerAction(pttHotkeyAction(), pttHotkeyIcon()); } void CSettingsHotkeyComponent::addEntry() diff --git a/src/blackmisc/input/actionhotkeydefs.cpp b/src/blackmisc/input/actionhotkeydefs.cpp new file mode 100644 index 000000000..eb3ebeac6 --- /dev/null +++ b/src/blackmisc/input/actionhotkeydefs.cpp @@ -0,0 +1,26 @@ +/* Copyright (C) 2019 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "actionhotkeydefs.h" + +namespace BlackMisc +{ + namespace Input + { + const QString &pttHotkeyAction() + { + static const QString s("/Voice/Activate push-to-talk"); + return s; + } + + const QPixmap &pttHotkeyIcon() + { + return CIcons::radio16(); + } + } // ns +} // ns diff --git a/src/blackmisc/input/actionhotkeydefs.h b/src/blackmisc/input/actionhotkeydefs.h new file mode 100644 index 000000000..399020d9b --- /dev/null +++ b/src/blackmisc/input/actionhotkeydefs.h @@ -0,0 +1,31 @@ +/* Copyright (C) 2019 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_INPUT_ACTIONHOTKEYDEFS_H +#define BLACKMISC_INPUT_ACTIONHOTKEYDEFS_H + +#include "blackmisc/icon.h" +#include "blackmisc/blackmiscexport.h" + +#include + +namespace BlackMisc +{ + namespace Input + { + //! PTT key + BLACKMISC_EXPORT const QString &pttHotkeyAction(); + + //! PTT key + BLACKMISC_EXPORT const QPixmap &pttHotkeyIcon(); + } // ns +} // ns + +#endif // guard