diff --git a/src/mainview/components/CallActionBar.qml b/src/mainview/components/CallActionBar.qml index c64d77f7..17be260d 100644 --- a/src/mainview/components/CallActionBar.qml +++ b/src/mainview/components/CallActionBar.qml @@ -295,7 +295,7 @@ Control { icon.source: "qrc:/images/icons/plugins-24px.svg" icon.color: "white" text: JamiStrings.viewPlugin - enabled: UtilsAdapter.checkShowPluginsButton(true) + enabled: PluginAdapter.callMediaHandlersListCount } ] @@ -330,8 +330,7 @@ Control { if (!isAudioOnly && !isSIP) CallOverlayModel.addSecondaryControl(shareAction) CallOverlayModel.addSecondaryControl(recordAction) - if (UtilsAdapter.checkShowPluginsButton(true)) - CallOverlayModel.addSecondaryControl(pluginsAction) + CallOverlayModel.addSecondaryControl(pluginsAction) overflowItemCount = CallOverlayModel.secondaryModel().rowCount() muteAudioAction.checked = isAudioMuted diff --git a/src/mainview/components/CallViewContextMenu.qml b/src/mainview/components/CallViewContextMenu.qml index 1d2d1541..7ea1e555 100644 --- a/src/mainview/components/CallViewContextMenu.qml +++ b/src/mainview/components/CallViewContextMenu.qml @@ -159,7 +159,7 @@ ContextMenuAutoLoader { GeneralMenuItem { id: viewPlugin - canTrigger: UtilsAdapter.checkShowPluginsButton(true) + canTrigger: PluginAdapter.callMediaHandlersListCount itemName: JamiStrings.viewPlugin iconSource: "qrc:/images/icons/extension_24dp.svg" onClicked: { diff --git a/src/mainview/components/MessageWebViewHeader.qml b/src/mainview/components/MessageWebViewHeader.qml index c158f2b2..44b1abf0 100644 --- a/src/mainview/components/MessageWebViewHeader.qml +++ b/src/mainview/components/MessageWebViewHeader.qml @@ -186,14 +186,7 @@ Rectangle { PushButton { id: selectPluginButton - visible: UtilsAdapter.checkShowPluginsButton(false) - - Connections { - target: PluginAdapter - function onPluginHandlersUpdateStatus() { - selectPluginButton.visible = UtilsAdapter.checkShowPluginsButton(false) - } - } + visible: PluginAdapter.chatHandlersListCount anchors.right: sendContactRequestButton.visible ? sendContactRequestButton.left : diff --git a/src/pluginadapter.cpp b/src/pluginadapter.cpp index 6b1e99b4..a7a0ee59 100644 --- a/src/pluginadapter.cpp +++ b/src/pluginadapter.cpp @@ -22,7 +22,13 @@ PluginAdapter::PluginAdapter(LRCInstance* instance, QObject* parent) : QmlAdapterBase(instance, parent) -{} +{ + updateHandlersListCount(); + connect(&lrcInstance_->pluginModel(), + &lrc::api::PluginModel::modelUpdated, + this, + &PluginAdapter::updateHandlersListCount); +} QVariant PluginAdapter::getMediaHandlerSelectableModel(const QString& callId) @@ -81,3 +87,15 @@ PluginAdapter::getPluginPreferencesCategories(const QString& pluginId, bool remo categories.pop_back(); return categories; } + +void +PluginAdapter::updateHandlersListCount() +{ + if (lrcInstance_->pluginModel().getPluginsEnabled()) { + set_callMediaHandlersListCount(lrcInstance_->pluginModel().getCallMediaHandlers().size()); + set_chatHandlersListCount(lrcInstance_->pluginModel().getChatHandlers().size()); + } else { + set_callMediaHandlersListCount(0); + set_chatHandlersListCount(0); + } +} \ No newline at end of file diff --git a/src/pluginadapter.h b/src/pluginadapter.h index 7571ffd4..95d9175c 100644 --- a/src/pluginadapter.h +++ b/src/pluginadapter.h @@ -31,6 +31,9 @@ class PluginAdapter final : public QmlAdapterBase { Q_OBJECT + QML_PROPERTY(int, callMediaHandlersListCount) + QML_PROPERTY(int, chatHandlersListCount) + public: explicit PluginAdapter(LRCInstance* instance, QObject* parent = nullptr); ~PluginAdapter() = default; @@ -55,6 +58,8 @@ Q_SIGNALS: void pluginUninstalled(); private: + void updateHandlersListCount(); + std::unique_ptr pluginHandlerListModel_; std::unique_ptr preferenceItemListModel_; std::unique_ptr pluginItemListModel_; diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index fc21d142..d126b24f 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -300,17 +300,6 @@ UtilsAdapter::getAbsPath(QString path) #endif } -bool -UtilsAdapter::checkShowPluginsButton(bool isCall) -{ - if (isCall) - return lrcInstance_->pluginModel().getPluginsEnabled() - && (lrcInstance_->pluginModel().getCallMediaHandlers().size() > 0); - else - return lrcInstance_->pluginModel().getPluginsEnabled() - && (lrcInstance_->pluginModel().getChatHandlers().size() > 0); -} - QString UtilsAdapter::fileName(const QString& path) { diff --git a/src/utilsadapter.h b/src/utilsadapter.h index 6fd23d37..7df96763 100644 --- a/src/utilsadapter.h +++ b/src/utilsadapter.h @@ -71,7 +71,6 @@ public: Q_INVOKABLE QString toFileInfoName(QString inputFileName); Q_INVOKABLE QString toFileAbsolutepath(QString inputFileName); Q_INVOKABLE QString getAbsPath(QString path); - Q_INVOKABLE bool checkShowPluginsButton(bool isCall); Q_INVOKABLE QString fileName(const QString& path); Q_INVOKABLE QString getExt(const QString& path); Q_INVOKABLE bool isImage(const QString& fileExt);