Skip to content
Snippets Groups Projects
Commit 9568f1c9 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk
Browse files

pluginadapter: add handler list count properties

All plugin buttons will be listening on these properties to
decide visibility or enabled

Change-Id: Id04f9b533e6aba26033c27a607fa531ce65ac588
parent db800b9b
Branches
Tags
No related merge requests found
......@@ -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,7 +330,6 @@ Control {
if (!isAudioOnly && !isSIP)
CallOverlayModel.addSecondaryControl(shareAction)
CallOverlayModel.addSecondaryControl(recordAction)
if (UtilsAdapter.checkShowPluginsButton(true))
CallOverlayModel.addSecondaryControl(pluginsAction)
overflowItemCount = CallOverlayModel.secondaryModel().rowCount()
......
......@@ -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: {
......
......@@ -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 :
......
......@@ -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
......@@ -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<PluginHandlerItemListModel> pluginHandlerListModel_;
std::unique_ptr<PreferenceItemListModel> preferenceItemListModel_;
std::unique_ptr<PluginItemListModel> pluginItemListModel_;
......
......@@ -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)
{
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment