mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-19 14:15:54 +02:00
callView: add mediahandler preferences
Change-Id: Ib569048646b9e62ceac3f435d641cb4daf5a57d5
This commit is contained in:
parent
85a4cb4ddf
commit
dc25dfa904
16 changed files with 639 additions and 181 deletions
|
@ -150,6 +150,7 @@ HEADERS += ./src/smartlistmodel.h \
|
||||||
./src/videoinputdevicemodel.h \
|
./src/videoinputdevicemodel.h \
|
||||||
./src/audiooutputdevicemodel.h \
|
./src/audiooutputdevicemodel.h \
|
||||||
./src/pluginlistpreferencemodel.h \
|
./src/pluginlistpreferencemodel.h \
|
||||||
|
./src/mediahandlerlistpreferencemodel.h \
|
||||||
./src/videoformatfpsmodel.h \
|
./src/videoformatfpsmodel.h \
|
||||||
./src/videoformatresolutionmodel.h \
|
./src/videoformatresolutionmodel.h \
|
||||||
./src/audiomanagerlistmodel.h
|
./src/audiomanagerlistmodel.h
|
||||||
|
@ -189,6 +190,7 @@ SOURCES += ./src/bannedlistmodel.cpp \
|
||||||
./src/videoinputdevicemodel.cpp \
|
./src/videoinputdevicemodel.cpp \
|
||||||
./src/audiooutputdevicemodel.cpp \
|
./src/audiooutputdevicemodel.cpp \
|
||||||
./src/pluginlistpreferencemodel.cpp \
|
./src/pluginlistpreferencemodel.cpp \
|
||||||
|
./src/mediahandlerlistpreferencemodel.cpp \
|
||||||
./src/videoformatfpsmodel.cpp \
|
./src/videoformatfpsmodel.cpp \
|
||||||
./src/videoformatresolutionmodel.cpp \
|
./src/videoformatresolutionmodel.cpp \
|
||||||
./src/audiomanagerlistmodel.cpp
|
./src/audiomanagerlistmodel.cpp
|
||||||
|
|
4
qml.qrc
4
qml.qrc
|
@ -14,11 +14,11 @@
|
||||||
<file>src/settingsview/components/AdvancedSettingsView.qml</file>
|
<file>src/settingsview/components/AdvancedSettingsView.qml</file>
|
||||||
<file>src/settingsview/components/AdvancedSIPSettingsView.qml</file>
|
<file>src/settingsview/components/AdvancedSIPSettingsView.qml</file>
|
||||||
<file>src/settingsview/components/LevelMeter.qml</file>
|
<file>src/settingsview/components/LevelMeter.qml</file>
|
||||||
<file>src/settingsview/components/SettingParaCombobox.qml</file>
|
<file>src/commoncomponents/SettingParaCombobox.qml</file>
|
||||||
<file>src/settingsview/components/DeviceItemDelegate.qml</file>
|
<file>src/settingsview/components/DeviceItemDelegate.qml</file>
|
||||||
<file>src/settingsview/components/PluginItemDelegate.qml</file>
|
<file>src/settingsview/components/PluginItemDelegate.qml</file>
|
||||||
<file>src/mainview/components/MediaHandlerItemDelegate.qml</file>
|
<file>src/mainview/components/MediaHandlerItemDelegate.qml</file>
|
||||||
<file>src/settingsview/components/PreferenceItemDelegate.qml</file>
|
<file>src/commoncomponents/PreferenceItemDelegate.qml</file>
|
||||||
<file>src/settingsview/components/BannedItemDelegate.qml</file>
|
<file>src/settingsview/components/BannedItemDelegate.qml</file>
|
||||||
<file>src/settingsview/components/VideoCodecDelegate.qml</file>
|
<file>src/settingsview/components/VideoCodecDelegate.qml</file>
|
||||||
<file>src/settingsview/components/AudioCodecDelegate.qml</file>
|
<file>src/settingsview/components/AudioCodecDelegate.qml</file>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/**
|
||||||
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,16 +16,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.14
|
||||||
import QtQuick.Window 2.15
|
import QtQuick.Window 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Controls.Universal 2.12
|
import QtQuick.Controls.Universal 2.12
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.14
|
import QtGraphicalEffects 1.14
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
import Qt.labs.platform 1.1
|
||||||
|
import QtQuick.Dialogs 1.3
|
||||||
import net.jami.Models 1.0
|
import net.jami.Models 1.0
|
||||||
|
|
||||||
import "../../commoncomponents"
|
import "../commoncomponents"
|
||||||
|
|
||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
@ -71,19 +73,19 @@ ItemDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JamiFileDialog {
|
FileDialog {
|
||||||
id: preferenceFilePathDialog
|
id: preferenceFilePathDialog
|
||||||
|
|
||||||
property string preferenceKey: ""
|
property string preferenceKey: ""
|
||||||
property PluginListPreferenceModel pluginListPreferenceModel
|
property PluginListPreferenceModel pluginListPreferenceModel
|
||||||
|
|
||||||
mode: JamiFileDialog.OpenFile
|
title: qsTr("Please choose a file")
|
||||||
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
||||||
|
|
||||||
onRejected: preferenceAdded()
|
onRejected: preferenceAdded()
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
var url = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
|
var url = ClientWrapper.utilsAdaptor.getAbsPath(fileUrl.toString())
|
||||||
ClientWrapper.pluginModel.addValueToPreference(pluginId, preferenceKey, url)
|
ClientWrapper.pluginModel.addValueToPreference(pluginId, preferenceKey, url)
|
||||||
pluginListPreferenceModel.populateLists()
|
pluginListPreferenceModel.populateLists()
|
||||||
pluginListPreferenceModel.getCurrentSettingIndex()
|
pluginListPreferenceModel.getCurrentSettingIndex()
|
||||||
|
@ -103,7 +105,7 @@ ItemDelegate {
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
font.pointSize: JamiTheme.settingsFontSize
|
||||||
font.kerning: true
|
font.kerning: true
|
||||||
font.bold: true
|
font.bold: true
|
||||||
text: pluginName === "" ? pluginId : pluginName
|
text: preferenceName
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverableRadiusButton{
|
HoverableRadiusButton{
|
|
@ -23,7 +23,7 @@ import QtQuick.Controls.Universal 2.12
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.14
|
import QtGraphicalEffects 1.14
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
import "../../constant"
|
import "../constant"
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: control
|
id: control
|
|
@ -3,7 +3,7 @@
|
||||||
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>
|
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>
|
||||||
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
||||||
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
#include "audiomanagerlistmodel.h"
|
#include "audiomanagerlistmodel.h"
|
||||||
#include "audiooutputdevicemodel.h"
|
#include "audiooutputdevicemodel.h"
|
||||||
#include "pluginlistpreferencemodel.h"
|
#include "pluginlistpreferencemodel.h"
|
||||||
|
#include "mediahandlerlistpreferencemodel.h"
|
||||||
#include "avadapter.h"
|
#include "avadapter.h"
|
||||||
#include "bannedlistmodel.h"
|
#include "bannedlistmodel.h"
|
||||||
#include "calladapter.h"
|
#include "calladapter.h"
|
||||||
|
@ -313,6 +314,7 @@ MainApplication::qmlInitialization()
|
||||||
QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0);
|
QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0);
|
||||||
QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0);
|
QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0);
|
||||||
QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0);
|
QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0);
|
||||||
|
QML_REGISTERTYPE(MediaHandlerListPreferenceModel, 1, 0);
|
||||||
/*
|
/*
|
||||||
* Register QQuickItem type.
|
* Register QQuickItem type.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,81 +34,50 @@ ItemDelegate {
|
||||||
property string mediaHandlerId: ""
|
property string mediaHandlerId: ""
|
||||||
property string mediaHandlerIcon: ""
|
property string mediaHandlerIcon: ""
|
||||||
property bool isLoaded: false
|
property bool isLoaded: false
|
||||||
|
property string pluginId: ""
|
||||||
|
|
||||||
signal btnLoadMediaHandlerToggled
|
signal btnLoadMediaHandlerToggled
|
||||||
|
signal openPreferences
|
||||||
highlighted: ListView.isCurrentItem
|
|
||||||
|
|
||||||
RowLayout{
|
RowLayout{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Label{
|
Label{
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
Layout.bottomMargin: 8
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||||
|
|
||||||
Layout.minimumWidth: 30
|
width: 30
|
||||||
Layout.preferredWidth: 30
|
|
||||||
Layout.maximumWidth: 30
|
|
||||||
|
|
||||||
Layout.minimumHeight: 30
|
|
||||||
Layout.preferredHeight: 30
|
|
||||||
Layout.maximumHeight: 30
|
|
||||||
|
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
anchors.fill: parent
|
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent
|
anchors.centerIn: parent
|
||||||
source: "file:" + mediaHandlerIcon
|
source: "file:" + mediaHandlerIcon
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout{
|
Label{
|
||||||
Layout.fillWidth: true
|
id: labelDeviceId
|
||||||
Layout.fillHeight: true
|
|
||||||
|
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
Layout.topMargin: 8
|
Layout.fillWidth: true
|
||||||
Layout.bottomMargin: 8
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
RowLayout{
|
font.pointSize: JamiTheme.settingsFontSize
|
||||||
|
font.kerning: true
|
||||||
Layout.minimumHeight: 30
|
text: mediaHandlerName === "" ? mediaHandlerId : mediaHandlerName
|
||||||
|
|
||||||
Label{
|
|
||||||
id: labelDeviceId
|
|
||||||
|
|
||||||
Layout.minimumHeight: 20
|
|
||||||
|
|
||||||
font.pointSize: 10
|
|
||||||
font.kerning: true
|
|
||||||
text: mediaHandlerName === "" ? mediaHandlerId : mediaHandlerName
|
|
||||||
}
|
|
||||||
|
|
||||||
Item{
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
Layout.minimumWidth: 0
|
|
||||||
Layout.minimumHeight: 20
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Switch {
|
Switch {
|
||||||
id: loadSwitch
|
id: loadSwitch
|
||||||
property bool isHovering: false
|
property bool isHovering: false
|
||||||
|
|
||||||
Layout.bottomMargin: 8
|
Layout.rightMargin: 8
|
||||||
Layout.rightMargin: 22
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
|
|
||||||
Layout.maximumWidth: 30
|
width: 30
|
||||||
Layout.preferredWidth: 30
|
height: 30
|
||||||
Layout.minimumWidth: 30
|
|
||||||
|
|
||||||
Layout.minimumHeight: 30
|
|
||||||
Layout.preferredHeight: 30
|
|
||||||
Layout.maximumHeight: 30
|
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: {
|
ToolTip.text: {
|
||||||
|
@ -140,5 +109,31 @@ ItemDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HoverableRadiusButton{
|
||||||
|
id: btnPreferencesMediaHandler
|
||||||
|
|
||||||
|
backgroundColor: "white"
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
|
||||||
|
Layout.rightMargin: 8
|
||||||
|
Layout.preferredHeight: 25
|
||||||
|
|
||||||
|
buttonImageHeight: height
|
||||||
|
buttonImageWidth: height
|
||||||
|
|
||||||
|
source:{
|
||||||
|
return "qrc:/images/icons/round-settings-24px.svg"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: {
|
||||||
|
return qsTr(pluginId)
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
openPreferences()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,102 +24,226 @@ import net.jami.Models 1.0
|
||||||
import "../../commoncomponents"
|
import "../../commoncomponents"
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
id: mediahandlerPickerPopup
|
id: root
|
||||||
|
|
||||||
function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) {
|
function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) {
|
||||||
ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded)
|
ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded)
|
||||||
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
contentWidth: 350
|
width: 350
|
||||||
contentHeight: mediahandlerPickerPopupRectColumnLayout.height + 50
|
height: contentItem.height
|
||||||
|
|
||||||
padding: 0
|
|
||||||
|
|
||||||
modal: true
|
modal: true
|
||||||
|
|
||||||
contentItem: Rectangle {
|
contentItem: StackLayout {
|
||||||
id: mediahandlerPickerPopupRect
|
id: stack
|
||||||
|
currentIndex: 0
|
||||||
|
height: childrenRect.height
|
||||||
|
|
||||||
width: 250
|
Rectangle {
|
||||||
|
id: mediahandlerPickerPopupRect
|
||||||
|
width: root.width
|
||||||
|
height: childrenRect.height + 50
|
||||||
|
color: "white"
|
||||||
|
radius: 10
|
||||||
|
|
||||||
HoverableButton {
|
HoverableButton {
|
||||||
id: closeButton
|
id: closeButton
|
||||||
|
|
||||||
anchors.top: mediahandlerPickerPopupRect.top
|
anchors.top: mediahandlerPickerPopupRect.top
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.right: mediahandlerPickerPopupRect.right
|
anchors.right: mediahandlerPickerPopupRect.right
|
||||||
anchors.rightMargin: 5
|
anchors.rightMargin: 5
|
||||||
|
|
||||||
width: 30
|
width: 30
|
||||||
height: 30
|
height: 30
|
||||||
|
|
||||||
radius: 30
|
radius: 30
|
||||||
source: "qrc:/images/icons/round-close-24px.svg"
|
source: "qrc:/images/icons/round-close-24px.svg"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
mediahandlerPickerPopup.close()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
id: mediahandlerPickerPopupRectColumnLayout
|
|
||||||
|
|
||||||
anchors.top: mediahandlerPickerPopupRect.top
|
|
||||||
anchors.topMargin: 15
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: mediahandlerPickerTitle
|
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
|
||||||
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
|
||||||
Layout.preferredHeight: 30
|
|
||||||
|
|
||||||
font.pointSize: JamiTheme.textFontSize
|
|
||||||
font.bold: true
|
|
||||||
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
|
|
||||||
text: qsTr("Choose plugin")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ColumnLayout {
|
||||||
id: mediahandlerPickerListView
|
id: mediahandlerPickerPopupRectColumnLayout
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
anchors.top: mediahandlerPickerPopupRect.top
|
||||||
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
anchors.topMargin: 15
|
||||||
Layout.preferredHeight: 200
|
height: 230
|
||||||
|
|
||||||
model: MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
Text {
|
||||||
|
id: mediahandlerPickerTitle
|
||||||
|
|
||||||
clip: true
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
|
||||||
delegate: MediaHandlerItemDelegate {
|
font.pointSize: JamiTheme.textFontSize
|
||||||
id: mediaHandlerItemDelegate
|
font.bold: true
|
||||||
visible: ClientWrapper.pluginModel.getPluginsEnabled()
|
|
||||||
width: mediahandlerPickerListView.width
|
|
||||||
height: 50
|
|
||||||
|
|
||||||
mediaHandlerName : MediaHandlerName
|
horizontalAlignment: Text.AlignHCenter
|
||||||
mediaHandlerId: MediaHandlerId
|
verticalAlignment: Text.AlignVCenter
|
||||||
mediaHandlerIcon: MediaHandlerIcon
|
|
||||||
isLoaded: IsLoaded
|
|
||||||
|
|
||||||
onBtnLoadMediaHandlerToggled: {
|
|
||||||
toggleMediaHandlerSlot(mediaHandlerId, isLoaded)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
text: qsTr("Choose plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollIndicator.vertical: ScrollIndicator {}
|
ListView {
|
||||||
|
id: mediahandlerPickerListView
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
||||||
|
Layout.preferredHeight: 200
|
||||||
|
|
||||||
|
model: MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
delegate: MediaHandlerItemDelegate {
|
||||||
|
id: mediaHandlerItemDelegate
|
||||||
|
visible: ClientWrapper.pluginModel.getPluginsEnabled()
|
||||||
|
width: mediahandlerPickerListView.width
|
||||||
|
height: 50
|
||||||
|
|
||||||
|
mediaHandlerName : MediaHandlerName
|
||||||
|
mediaHandlerId: MediaHandlerId
|
||||||
|
mediaHandlerIcon: MediaHandlerIcon
|
||||||
|
isLoaded: IsLoaded
|
||||||
|
pluginId: PluginId
|
||||||
|
|
||||||
|
onBtnLoadMediaHandlerToggled: {
|
||||||
|
toggleMediaHandlerSlot(mediaHandlerId, isLoaded)
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpenPreferences: {
|
||||||
|
mediahandlerPreferencePickerListView.pluginId = pluginId
|
||||||
|
mediahandlerPreferencePickerListView.mediaHandlerName = mediaHandlerName
|
||||||
|
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
||||||
|
stack.currentIndex = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radius: 10
|
Rectangle {
|
||||||
color: "white"
|
id: mediahandlerPreferencePopupRect2
|
||||||
|
width: root.width
|
||||||
|
height: childrenRect.height + 50
|
||||||
|
color: "white"
|
||||||
|
radius: 10
|
||||||
|
|
||||||
|
HoverableButton {
|
||||||
|
id: backButton
|
||||||
|
anchors.top: mediahandlerPreferencePopupRect2.top
|
||||||
|
anchors.topMargin: 5
|
||||||
|
anchors.left: mediahandlerPreferencePopupRect2.left
|
||||||
|
anchors.leftMargin: 5
|
||||||
|
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
radius: 30
|
||||||
|
source: "qrc:/images/icons/ic_arrow_back_24px.svg"
|
||||||
|
toolTipText: qsTr("Go back to plugins list")
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: {
|
||||||
|
stack.currentIndex = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HoverableButton {
|
||||||
|
id: closeButton2
|
||||||
|
|
||||||
|
anchors.top: mediahandlerPreferencePopupRect2.top
|
||||||
|
anchors.topMargin: 5
|
||||||
|
anchors.right: mediahandlerPreferencePopupRect2.right
|
||||||
|
anchors.rightMargin: 5
|
||||||
|
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
radius: 30
|
||||||
|
source: "qrc:/images/icons/round-close-24px.svg"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
stack.currentIndex = 0
|
||||||
|
root.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
|
||||||
|
anchors.top: mediahandlerPreferencePopupRect2.top
|
||||||
|
anchors.topMargin: 15
|
||||||
|
height: 230
|
||||||
|
|
||||||
|
Text {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.preferredWidth: mediahandlerPreferencePopupRect2.width
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
|
||||||
|
font.pointSize: JamiTheme.textFontSize
|
||||||
|
font.bold: true
|
||||||
|
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
|
text: qsTr("Preference")
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: mediahandlerPreferencePickerListView
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
||||||
|
Layout.preferredHeight: 200
|
||||||
|
|
||||||
|
property string pluginId: ""
|
||||||
|
property string mediaHandlerName: ""
|
||||||
|
|
||||||
|
model: MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
delegate: PreferenceItemDelegate {
|
||||||
|
id: mediaHandlerPreferenceDelegate
|
||||||
|
width: mediahandlerPreferencePickerListView.width
|
||||||
|
height: 50
|
||||||
|
|
||||||
|
preferenceName: PreferenceName
|
||||||
|
preferenceSummary: PreferenceSummary
|
||||||
|
preferenceType: PreferenceType
|
||||||
|
preferenceCurrentValue: PreferenceCurrentValue
|
||||||
|
pluginId: PluginId
|
||||||
|
pluginListPreferenceModel: PluginListPreferenceModel{
|
||||||
|
id: pluginListPreferenceModel
|
||||||
|
preferenceKey : PreferenceKey
|
||||||
|
pluginId: PluginId
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: mediahandlerPreferencePickerListView.currentIndex = index
|
||||||
|
|
||||||
|
onBtnPreferenceClicked: {
|
||||||
|
ClientWrapper.pluginModel.setPluginPreference(pluginListPreferenceModel.pluginId,
|
||||||
|
pluginListPreferenceModel.preferenceKey,
|
||||||
|
pluginListPreferenceModel.preferenceNewValue)
|
||||||
|
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||||
|
}
|
||||||
|
|
||||||
|
onPreferenceAdded: mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollIndicator.vertical: ScrollIndicator {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAboutToHide: stack.currentIndex = 0
|
||||||
|
|
||||||
onAboutToShow: {
|
onAboutToShow: {
|
||||||
// Reset the model on each show.
|
// Reset the model on each show.
|
||||||
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
#include "lrcinstance.h"
|
#include "lrcinstance.h"
|
||||||
|
|
||||||
MediaHandlerAdapter::MediaHandlerAdapter(QObject *parent)
|
MediaHandlerAdapter::MediaHandlerAdapter(QObject* parent)
|
||||||
: QmlAdapterBase(parent)
|
: QmlAdapterBase(parent)
|
||||||
{ }
|
{}
|
||||||
|
|
||||||
MediaHandlerAdapter::~MediaHandlerAdapter() {}
|
MediaHandlerAdapter::~MediaHandlerAdapter() {}
|
||||||
|
|
||||||
|
@ -37,6 +37,31 @@ MediaHandlerAdapter::getMediaHandlerSelectableModel()
|
||||||
return QVariant::fromValue(mediaHandlerListModel_.get());
|
return QVariant::fromValue(mediaHandlerListModel_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
MediaHandlerAdapter::getMediaHandlerPreferencesModel(QString pluginId, QString mediaHandlerName)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Called from qml every time contact picker refreshes.
|
||||||
|
*/
|
||||||
|
mediaHandlerPreferenceItemListModel_.reset(new PreferenceItemListModel(this));
|
||||||
|
mediaHandlerPreferenceItemListModel_->setMediaHandlerName(mediaHandlerName);
|
||||||
|
mediaHandlerPreferenceItemListModel_->setPluginId(pluginId);
|
||||||
|
|
||||||
|
return QVariant::fromValue(mediaHandlerPreferenceItemListModel_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
MediaHandlerAdapter::getMediaHandlerPreferencesSelectableModel(QString pluginId)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Called from qml every time contact picker refreshes.
|
||||||
|
*/
|
||||||
|
mediaHandlerListPreferenceModel_.reset(new MediaHandlerListPreferenceModel(this));
|
||||||
|
mediaHandlerListPreferenceModel_->setPluginId(pluginId);
|
||||||
|
|
||||||
|
return QVariant::fromValue(mediaHandlerListPreferenceModel_.get());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaHandlerAdapter::initQmlObject()
|
MediaHandlerAdapter::initQmlObject()
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,6 +21,8 @@
|
||||||
#include "qmladapterbase.h"
|
#include "qmladapterbase.h"
|
||||||
//#include "smartlistmodel.h"
|
//#include "smartlistmodel.h"
|
||||||
#include "mediahandleritemlistmodel.h"
|
#include "mediahandleritemlistmodel.h"
|
||||||
|
#include "mediahandlerlistpreferencemodel.h"
|
||||||
|
#include "preferenceitemlistmodel.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
@ -31,14 +33,17 @@ class MediaHandlerAdapter : public QmlAdapterBase
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MediaHandlerAdapter(QObject *parent = nullptr);
|
explicit MediaHandlerAdapter(QObject* parent = nullptr);
|
||||||
~MediaHandlerAdapter();
|
~MediaHandlerAdapter();
|
||||||
|
|
||||||
Q_INVOKABLE QVariant getMediaHandlerSelectableModel();
|
Q_INVOKABLE QVariant getMediaHandlerSelectableModel();
|
||||||
|
Q_INVOKABLE QVariant getMediaHandlerPreferencesModel(QString pluginId, QString mediaHandlerName);
|
||||||
|
Q_INVOKABLE QVariant getMediaHandlerPreferencesSelectableModel(QString pluginId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initQmlObject();
|
void initQmlObject();
|
||||||
|
|
||||||
std::unique_ptr<MediaHandlerItemListModel> mediaHandlerListModel_;
|
std::unique_ptr<MediaHandlerItemListModel> mediaHandlerListModel_;
|
||||||
|
std::unique_ptr<PreferenceItemListModel> mediaHandlerPreferenceItemListModel_;
|
||||||
|
std::unique_ptr<MediaHandlerListPreferenceModel> mediaHandlerListPreferenceModel_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,14 +18,14 @@
|
||||||
|
|
||||||
#include "mediahandleritemlistmodel.h"
|
#include "mediahandleritemlistmodel.h"
|
||||||
|
|
||||||
MediaHandlerItemListModel::MediaHandlerItemListModel(QObject *parent)
|
MediaHandlerItemListModel::MediaHandlerItemListModel(QObject* parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MediaHandlerItemListModel::~MediaHandlerItemListModel() {}
|
MediaHandlerItemListModel::~MediaHandlerItemListModel() {}
|
||||||
|
|
||||||
int
|
int
|
||||||
MediaHandlerItemListModel::rowCount(const QModelIndex &parent) const
|
MediaHandlerItemListModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
/*
|
/*
|
||||||
|
@ -40,7 +40,7 @@ MediaHandlerItemListModel::rowCount(const QModelIndex &parent) const
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
MediaHandlerItemListModel::columnCount(const QModelIndex &parent) const
|
MediaHandlerItemListModel::columnCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
/*
|
/*
|
||||||
|
@ -50,7 +50,7 @@ MediaHandlerItemListModel::columnCount(const QModelIndex &parent) const
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
MediaHandlerItemListModel::data(const QModelIndex &index, int role) const
|
MediaHandlerItemListModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
auto mediahandlerList = LRCInstance::pluginModel().listCallMediaHandlers();
|
auto mediahandlerList = LRCInstance::pluginModel().listCallMediaHandlers();
|
||||||
if (!index.isValid() || mediahandlerList.size() <= index.row()) {
|
if (!index.isValid() || mediahandlerList.size() <= index.row()) {
|
||||||
|
@ -63,16 +63,21 @@ MediaHandlerItemListModel::data(const QModelIndex &index, int role) const
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
if (status["name"] == details.id)
|
if (status["name"] == details.id)
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
if (!details.pluginId.isEmpty()) {
|
||||||
|
details.pluginId.remove(details.pluginId.size() - 5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Role::MediaHandlerName:
|
case Role::MediaHandlerName:
|
||||||
return QVariant(details.name);
|
return QVariant(details.name);
|
||||||
case Role::MediaHandlerId:
|
case Role::MediaHandlerId:
|
||||||
return QVariant(mediahandlerList.at(index.row()));
|
return QVariant(mediahandlerList.at(index.row()));
|
||||||
case Role::MediaHandlerIcon:
|
case Role::MediaHandlerIcon:
|
||||||
return QVariant(details.iconPath);
|
return QVariant(details.iconPath);
|
||||||
case Role::IsLoaded:
|
case Role::IsLoaded:
|
||||||
return QVariant(loaded);
|
return QVariant(loaded);
|
||||||
|
case Role::PluginId:
|
||||||
|
return QVariant(details.pluginId);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -85,12 +90,13 @@ MediaHandlerItemListModel::roleNames() const
|
||||||
roles[MediaHandlerId] = "MediaHandlerId";
|
roles[MediaHandlerId] = "MediaHandlerId";
|
||||||
roles[MediaHandlerIcon] = "MediaHandlerIcon";
|
roles[MediaHandlerIcon] = "MediaHandlerIcon";
|
||||||
roles[IsLoaded] = "IsLoaded";
|
roles[IsLoaded] = "IsLoaded";
|
||||||
|
roles[PluginId] = "PluginId";
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex
|
QModelIndex
|
||||||
MediaHandlerItemListModel::index(int row, int column, const QModelIndex &parent) const
|
MediaHandlerItemListModel::index(int row, int column, const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
if (column != 0) {
|
if (column != 0) {
|
||||||
|
@ -104,14 +110,14 @@ MediaHandlerItemListModel::index(int row, int column, const QModelIndex &parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex
|
QModelIndex
|
||||||
MediaHandlerItemListModel::parent(const QModelIndex &child) const
|
MediaHandlerItemListModel::parent(const QModelIndex& child) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(child);
|
Q_UNUSED(child);
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags
|
Qt::ItemFlags
|
||||||
MediaHandlerItemListModel::flags(const QModelIndex &index) const
|
MediaHandlerItemListModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
|
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,25 +29,31 @@ class MediaHandlerItemListModel : public QAbstractListModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Role { MediaHandlerName = Qt::UserRole + 1, MediaHandlerId, MediaHandlerIcon, IsLoaded };
|
enum Role {
|
||||||
|
MediaHandlerName = Qt::UserRole + 1,
|
||||||
|
MediaHandlerId,
|
||||||
|
MediaHandlerIcon,
|
||||||
|
IsLoaded,
|
||||||
|
PluginId
|
||||||
|
};
|
||||||
Q_ENUM(Role)
|
Q_ENUM(Role)
|
||||||
|
|
||||||
explicit MediaHandlerItemListModel(QObject *parent = 0);
|
explicit MediaHandlerItemListModel(QObject* parent = 0);
|
||||||
~MediaHandlerItemListModel();
|
~MediaHandlerItemListModel();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QAbstractListModel override.
|
* QAbstractListModel override.
|
||||||
*/
|
*/
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent) const override;
|
int columnCount(const QModelIndex& parent) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||||
/*
|
/*
|
||||||
* Override role name as access point in qml.
|
* Override role name as access point in qml.
|
||||||
*/
|
*/
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
|
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &child) const;
|
QModelIndex parent(const QModelIndex& child) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is to reset the model when there's new account added.
|
* This function is to reset the model when there's new account added.
|
||||||
|
|
154
src/mediahandlerlistpreferencemodel.cpp
Normal file
154
src/mediahandlerlistpreferencemodel.cpp
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
||||||
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mediahandlerlistpreferencemodel.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
MediaHandlerListPreferenceModel::MediaHandlerListPreferenceModel(QObject* parent)
|
||||||
|
: QAbstractListModel(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
MediaHandlerListPreferenceModel::~MediaHandlerListPreferenceModel() {}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaHandlerListPreferenceModel::populateLists()
|
||||||
|
{
|
||||||
|
preferenceValuesList_.clear();
|
||||||
|
preferenceList_.clear();
|
||||||
|
const auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
for (const auto& preference : preferences) {
|
||||||
|
if (preference["key"] == preferenceKey_) {
|
||||||
|
auto entries = preference["entries"];
|
||||||
|
auto entriesValues = preference["entryValues"];
|
||||||
|
std::string entry = entries.toStdString();
|
||||||
|
std::string entryValues = entriesValues.toStdString();
|
||||||
|
std::string delimiter = ",";
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
std::string token;
|
||||||
|
while ((pos = entry.find(delimiter)) != std::string::npos) {
|
||||||
|
preferenceList_.emplace_back(entry.substr(0, pos));
|
||||||
|
|
||||||
|
entry.erase(0, pos + delimiter.length());
|
||||||
|
}
|
||||||
|
preferenceList_.emplace_back(entry.substr(0, pos));
|
||||||
|
while ((pos = entryValues.find(delimiter)) != std::string::npos) {
|
||||||
|
preferenceValuesList_.emplace_back(entryValues.substr(0, pos));
|
||||||
|
|
||||||
|
entryValues.erase(0, pos + delimiter.length());
|
||||||
|
}
|
||||||
|
preferenceValuesList_.emplace_back(entryValues.substr(0, pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getCurrentSettingIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MediaHandlerListPreferenceModel::rowCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
if (!parent.isValid()) {
|
||||||
|
/// Count
|
||||||
|
return preferenceList_.size();
|
||||||
|
}
|
||||||
|
/// A valid QModelIndex returns 0 as no entry has sub-elements.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MediaHandlerListPreferenceModel::columnCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
/// Only need one column.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
MediaHandlerListPreferenceModel::data(const QModelIndex& index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid() || preferenceList_.size() <= index.row()) {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (role) {
|
||||||
|
case Role::PreferenceValue:
|
||||||
|
return QVariant(QString::fromStdString(preferenceList_.at(index.row())));
|
||||||
|
case Role::PreferenceEntryValue:
|
||||||
|
return QVariant(QString::fromStdString(preferenceValuesList_.at(index.row())));
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray>
|
||||||
|
MediaHandlerListPreferenceModel::roleNames() const
|
||||||
|
{
|
||||||
|
QHash<int, QByteArray> roles;
|
||||||
|
roles[PreferenceValue] = "PreferenceValue";
|
||||||
|
roles[PreferenceEntryValue] = "PreferenceEntryValue";
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
MediaHandlerListPreferenceModel::index(int row, int column, const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
if (column != 0) {
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row >= 0 && row < rowCount()) {
|
||||||
|
return createIndex(row, column);
|
||||||
|
}
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex
|
||||||
|
MediaHandlerListPreferenceModel::parent(const QModelIndex& child) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(child);
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags
|
||||||
|
MediaHandlerListPreferenceModel::flags(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable;
|
||||||
|
if (!index.isValid()) {
|
||||||
|
return QAbstractItemModel::flags(index);
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaHandlerListPreferenceModel::reset()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
MediaHandlerListPreferenceModel::getCurrentSettingIndex()
|
||||||
|
{
|
||||||
|
auto resultList = match(index(0, 0), PreferenceEntryValue, preferenceCurrentValue());
|
||||||
|
|
||||||
|
int resultRowIndex = 0;
|
||||||
|
if (resultList.size() > 0) {
|
||||||
|
resultRowIndex = resultList[0].row();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultRowIndex;
|
||||||
|
}
|
102
src/mediahandlerlistpreferencemodel.h
Normal file
102
src/mediahandlerlistpreferencemodel.h
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
#include "api/pluginmodel.h"
|
||||||
|
|
||||||
|
#include "lrcinstance.h"
|
||||||
|
|
||||||
|
class MediaHandlerListPreferenceModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
|
||||||
|
Q_PROPERTY(QString preferenceKey READ preferenceKey WRITE setPreferenceKey)
|
||||||
|
Q_PROPERTY(QString preferenceNewValue READ preferenceNewValue WRITE setPreferenceNewValue)
|
||||||
|
Q_PROPERTY(int idx READ idx WRITE setIdx)
|
||||||
|
Q_PROPERTY(int optSize READ optSize)
|
||||||
|
public:
|
||||||
|
enum Role { PreferenceValue = Qt::UserRole + 1, PreferenceEntryValue };
|
||||||
|
Q_ENUM(Role)
|
||||||
|
|
||||||
|
explicit MediaHandlerListPreferenceModel(QObject* parent = 0);
|
||||||
|
~MediaHandlerListPreferenceModel();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* QAbstractListModel override.
|
||||||
|
*/
|
||||||
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
|
int columnCount(const QModelIndex& parent) const override;
|
||||||
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||||
|
/*
|
||||||
|
* Override role name as access point in qml.
|
||||||
|
*/
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
|
||||||
|
QModelIndex parent(const QModelIndex& child) const;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is to reset the model when there's new account added.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void reset();
|
||||||
|
/*
|
||||||
|
* This function is to get the current preference value
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE int getCurrentSettingIndex();
|
||||||
|
|
||||||
|
Q_INVOKABLE void populateLists();
|
||||||
|
|
||||||
|
void setPreferenceNewValue(const QString preferenceNewValue)
|
||||||
|
{
|
||||||
|
preferenceNewValue_ = preferenceNewValue;
|
||||||
|
}
|
||||||
|
void setPreferenceKey(const QString preferenceKey) { preferenceKey_ = preferenceKey; }
|
||||||
|
void setPluginId(const QString pluginId)
|
||||||
|
{
|
||||||
|
pluginId_ = pluginId;
|
||||||
|
populateLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setIdx(const int index) { idx_ = index; }
|
||||||
|
|
||||||
|
int idx() { return idx_; }
|
||||||
|
QString preferenceCurrentValue()
|
||||||
|
{
|
||||||
|
return LRCInstance::pluginModel().getPluginPreferencesValues(pluginId_)[preferenceKey_];
|
||||||
|
}
|
||||||
|
|
||||||
|
QString preferenceNewValue()
|
||||||
|
{
|
||||||
|
preferenceNewValue_ = QString::fromStdString(preferenceValuesList_[idx_]);
|
||||||
|
return preferenceNewValue_;
|
||||||
|
}
|
||||||
|
QString preferenceKey() { return preferenceKey_; }
|
||||||
|
QString pluginId() { return pluginId_; }
|
||||||
|
int optSize() { return preferenceValuesList_.size(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString pluginId_ = "";
|
||||||
|
QString preferenceKey_ = "";
|
||||||
|
QString preferenceNewValue_ = "";
|
||||||
|
std::vector<std::string> preferenceValuesList_;
|
||||||
|
std::vector<std::string> preferenceList_;
|
||||||
|
int idx_ = 0;
|
||||||
|
};
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,7 +33,7 @@ PreferenceItemListModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
if (!parent.isValid()) {
|
if (!parent.isValid()) {
|
||||||
/// Count.
|
/// Count.
|
||||||
return LRCInstance::pluginModel().getPluginPreferences(pluginId_).size();
|
return preferenceList_.size();
|
||||||
}
|
}
|
||||||
/// A valid QModelIndex returns 0 as no entry has sub-elements.
|
/// A valid QModelIndex returns 0 as no entry has sub-elements.
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -50,12 +50,11 @@ PreferenceItemListModel::columnCount(const QModelIndex& parent) const
|
||||||
QVariant
|
QVariant
|
||||||
PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
auto preferenceList = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
if (!index.isValid() || preferenceList_.size() <= index.row()) {
|
||||||
if (!index.isValid() || preferenceList.size() <= index.row()) {
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto details = preferenceList.at(index.row());
|
auto details = preferenceList_.at(index.row());
|
||||||
int type = Type::DEFAULT;
|
int type = Type::DEFAULT;
|
||||||
auto it = mapType.find(details["type"]);
|
auto it = mapType.find(details["type"]);
|
||||||
if (it != mapType.end()) {
|
if (it != mapType.end()) {
|
||||||
|
@ -142,10 +141,49 @@ void
|
||||||
PreferenceItemListModel::setPluginId(const QString& pluginId)
|
PreferenceItemListModel::setPluginId(const QString& pluginId)
|
||||||
{
|
{
|
||||||
pluginId_ = pluginId;
|
pluginId_ = pluginId;
|
||||||
|
preferencesCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
PreferenceItemListModel::mediaHandlerName() const
|
||||||
|
{
|
||||||
|
return mediaHandlerName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PreferenceItemListModel::setMediaHandlerName(const QString mediaHandlerName)
|
||||||
|
{
|
||||||
|
mediaHandlerName_ = mediaHandlerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PreferenceItemListModel::preferencesCount()
|
PreferenceItemListModel::preferencesCount()
|
||||||
{
|
{
|
||||||
return LRCInstance::pluginModel().getPluginPreferences(pluginId_).size();
|
if (!preferenceList_.isEmpty())
|
||||||
|
return preferenceList_.size();
|
||||||
|
if (mediaHandlerName_.isEmpty()) {
|
||||||
|
preferenceList_ = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
return preferenceList_.size();
|
||||||
|
} else {
|
||||||
|
auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||||
|
for (auto& preference : preferences) {
|
||||||
|
std::string scope = preference["scope"].toStdString();
|
||||||
|
std::string delimiter = ",";
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
std::string token;
|
||||||
|
while ((pos = scope.find(delimiter)) != std::string::npos) {
|
||||||
|
token = scope.substr(0, pos);
|
||||||
|
if (token == mediaHandlerName_.toStdString()) {
|
||||||
|
preferenceList_.push_back(preference);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
scope.erase(0, pos + delimiter.length());
|
||||||
|
}
|
||||||
|
token = scope.substr(0, pos);
|
||||||
|
if (token == mediaHandlerName_.toStdString())
|
||||||
|
preferenceList_.push_back(preference);
|
||||||
|
}
|
||||||
|
return preferenceList_.size();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -29,6 +29,7 @@ class PreferenceItemListModel : public QAbstractListModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
|
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
|
||||||
|
Q_PROPERTY(QString mediaHandlerName READ mediaHandlerName WRITE setMediaHandlerName)
|
||||||
Q_PROPERTY(int preferencesCount READ preferencesCount)
|
Q_PROPERTY(int preferencesCount READ preferencesCount)
|
||||||
public:
|
public:
|
||||||
enum Role {
|
enum Role {
|
||||||
|
@ -72,8 +73,12 @@ public:
|
||||||
|
|
||||||
QString pluginId() const;
|
QString pluginId() const;
|
||||||
void setPluginId(const QString& pluginId);
|
void setPluginId(const QString& pluginId);
|
||||||
|
QString mediaHandlerName() const;
|
||||||
|
void setMediaHandlerName(const QString mediaHandlerName);
|
||||||
int preferencesCount();
|
int preferencesCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString pluginId_;
|
QString pluginId_;
|
||||||
|
QString mediaHandlerName_ = "";
|
||||||
|
VectorMapStringString preferenceList_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/**
|
||||||
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
||||||
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -45,11 +45,9 @@ ItemDelegate {
|
||||||
id: pluginImage
|
id: pluginImage
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
|
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
|
||||||
Layout.fillHeight: true
|
|
||||||
width: 30
|
width: 30
|
||||||
|
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
anchors.fill: parent
|
|
||||||
Image {
|
Image {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
source: "file:"+pluginIcon
|
source: "file:"+pluginIcon
|
||||||
|
@ -73,7 +71,6 @@ ItemDelegate {
|
||||||
id: loadSwitch
|
id: loadSwitch
|
||||||
property bool isHovering: false
|
property bool isHovering: false
|
||||||
Layout.rightMargin: 8
|
Layout.rightMargin: 8
|
||||||
Layout.fillHeight: true
|
|
||||||
width: 20
|
width: 20
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
|
@ -90,7 +87,6 @@ ItemDelegate {
|
||||||
id: switchBackground
|
id: switchBackground
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: btnMouseArea
|
id: btnMouseArea
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onPressed: {
|
onPressed: {
|
||||||
}
|
}
|
||||||
|
@ -124,13 +120,9 @@ ItemDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: {
|
ToolTip.text: qsTr("Show preferences")
|
||||||
return qsTr("Show preferences")
|
|
||||||
}
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: btnPreferencesPluginClicked()
|
||||||
btnPreferencesPluginClicked()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue