mirror of
https://github.com/savoirfairelinux/jami-client-qt.git
synced 2025-12-18 08:35:26 +08:00
plugin: implement PATH preference
Change-Id: If86856104409c9c6f8402e0c9229481d18c5b84f
This commit is contained in:
1
images/icons/insert_drive_file-24dp.svg
Normal file
1
images/icons/insert_drive_file-24dp.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"><path d="M0 0h24v24H0z" fill="none"/><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"/></svg>
|
||||||
|
After Width: | Height: | Size: 237 B |
@@ -136,7 +136,7 @@ HEADERS += ./src/smartlistmodel.h \
|
|||||||
./src/qmladapterbase.h \
|
./src/qmladapterbase.h \
|
||||||
./src/avadapter.h \
|
./src/avadapter.h \
|
||||||
./src/contactadapter.h \
|
./src/contactadapter.h \
|
||||||
./src/mediahandleradapter.h \
|
./src/pluginadapter.h \
|
||||||
./src/settingsadapter.h \
|
./src/settingsadapter.h \
|
||||||
./src/deviceitemlistmodel.h \
|
./src/deviceitemlistmodel.h \
|
||||||
./src/pluginitemlistmodel.h \
|
./src/pluginitemlistmodel.h \
|
||||||
@@ -150,7 +150,6 @@ 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 \
|
||||||
@@ -176,7 +175,7 @@ SOURCES += ./src/bannedlistmodel.cpp \
|
|||||||
./src/previewrenderer.cpp \
|
./src/previewrenderer.cpp \
|
||||||
./src/avadapter.cpp \
|
./src/avadapter.cpp \
|
||||||
./src/contactadapter.cpp \
|
./src/contactadapter.cpp \
|
||||||
./src/mediahandleradapter.cpp \
|
./src/pluginadapter.cpp \
|
||||||
./src/settingsadapter.cpp \
|
./src/settingsadapter.cpp \
|
||||||
./src/deviceitemlistmodel.cpp \
|
./src/deviceitemlistmodel.cpp \
|
||||||
./src/pluginitemlistmodel.cpp \
|
./src/pluginitemlistmodel.cpp \
|
||||||
@@ -190,7 +189,6 @@ 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 \
|
||||||
|
|||||||
@@ -117,5 +117,6 @@
|
|||||||
<file>images/icons/drafts-24px.svg</file>
|
<file>images/icons/drafts-24px.svg</file>
|
||||||
<file>images/icons/person_add-24px.svg</file>
|
<file>images/icons/person_add-24px.svg</file>
|
||||||
<file>images/icons/router-24px.svg</file>
|
<file>images/icons/router-24px.svg</file>
|
||||||
|
<file>images/icons/insert_drive_file-24dp.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "bannedlistmodel.h"
|
#include "bannedlistmodel.h"
|
||||||
#include "calladapter.h"
|
#include "calladapter.h"
|
||||||
#include "contactadapter.h"
|
#include "contactadapter.h"
|
||||||
#include "mediahandleradapter.h"
|
#include "pluginadapter.h"
|
||||||
#include "conversationsadapter.h"
|
#include "conversationsadapter.h"
|
||||||
#include "deviceitemlistmodel.h"
|
#include "deviceitemlistmodel.h"
|
||||||
#include "pluginitemlistmodel.h"
|
#include "pluginitemlistmodel.h"
|
||||||
|
|||||||
@@ -34,35 +34,35 @@ ItemDelegate {
|
|||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
LIST,
|
LIST,
|
||||||
USERLIST,
|
PATH,
|
||||||
DEFAULT
|
DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
property string preferenceName: ""
|
property string preferenceName: ""
|
||||||
property string preferenceSummary: ""
|
property string preferenceSummary: ""
|
||||||
|
property string preferenceKey: ""
|
||||||
property int preferenceType: -1
|
property int preferenceType: -1
|
||||||
property string preferenceCurrentValue: ""
|
property string preferenceCurrentValue: ""
|
||||||
property string preferenceNewValue: ""
|
property string preferenceNewValue: ""
|
||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
|
property string currentPath: ""
|
||||||
|
property bool isImage: false
|
||||||
|
property var fileFilters: []
|
||||||
property PluginListPreferenceModel pluginListPreferenceModel
|
property PluginListPreferenceModel pluginListPreferenceModel
|
||||||
|
|
||||||
signal btnPreferenceClicked
|
signal btnPreferenceClicked
|
||||||
signal preferenceAdded
|
|
||||||
|
|
||||||
function getNewPreferenceValueSlot(index){
|
function getNewPreferenceValueSlot(index){
|
||||||
pluginListPreferenceModel.idx = index
|
|
||||||
preferenceNewValue = pluginListPreferenceModel.preferenceNewValue
|
|
||||||
switch (preferenceType){
|
switch (preferenceType){
|
||||||
case PreferenceItemDelegate.LIST:
|
case PreferenceItemDelegate.LIST:
|
||||||
|
pluginListPreferenceModel.idx = index
|
||||||
|
preferenceNewValue = pluginListPreferenceModel.preferenceNewValue
|
||||||
btnPreferenceClicked()
|
btnPreferenceClicked()
|
||||||
break
|
break
|
||||||
case PreferenceItemDelegate.USERLIST:
|
case PreferenceItemDelegate.PATH:
|
||||||
if(index == 0){
|
if(index == 0){
|
||||||
preferenceFilePathDialog.pluginListPreferenceModel = pluginListPreferenceModel
|
|
||||||
preferenceFilePathDialog.title = qsTr("Select An Image to " + preferenceName)
|
preferenceFilePathDialog.title = qsTr("Select An Image to " + preferenceName)
|
||||||
preferenceFilePathDialog.nameFilters = [qsTr("PNG Files") + " (*.png)", qsTr(
|
preferenceFilePathDialog.nameFilters = fileFilters
|
||||||
"All files") + " (*)"]
|
|
||||||
preferenceFilePathDialog.preferenceKey = pluginListPreferenceModel.preferenceKey
|
|
||||||
preferenceFilePathDialog.open()
|
preferenceFilePathDialog.open()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -76,20 +76,13 @@ ItemDelegate {
|
|||||||
FileDialog {
|
FileDialog {
|
||||||
id: preferenceFilePathDialog
|
id: preferenceFilePathDialog
|
||||||
|
|
||||||
property string preferenceKey: ""
|
|
||||||
property PluginListPreferenceModel pluginListPreferenceModel
|
|
||||||
|
|
||||||
title: qsTr("Please choose a file")
|
title: qsTr("Please choose a file")
|
||||||
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
folder: "file://" + currentPath
|
||||||
|
|
||||||
onRejected: preferenceAdded()
|
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
var url = ClientWrapper.utilsAdaptor.getAbsPath(fileUrl.toString())
|
var url = ClientWrapper.utilsAdaptor.getAbsPath(fileUrl.toString())
|
||||||
ClientWrapper.pluginModel.addValueToPreference(pluginId, preferenceKey, url)
|
preferenceNewValue = url
|
||||||
pluginListPreferenceModel.populateLists()
|
btnPreferenceClicked()
|
||||||
pluginListPreferenceModel.getCurrentSettingIndex()
|
|
||||||
preferenceAdded()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,15 +90,14 @@ ItemDelegate {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
visible: preferenceType === PreferenceItemDelegate.DEFAULT
|
Layout.preferredWidth: root.width / 2
|
||||||
Layout.fillWidth: true
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||||
Layout.alignment: Qt.AlingVCenter | Qt.AligntLeft
|
|
||||||
Layout.leftMargin: 8
|
Layout.leftMargin: 8
|
||||||
|
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
|
||||||
font.kerning: true
|
|
||||||
font.bold: true
|
|
||||||
text: preferenceName
|
text: preferenceName
|
||||||
|
font.pointSize: JamiTheme.settingsFontSize
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: preferenceSummary
|
||||||
}
|
}
|
||||||
|
|
||||||
HoverableRadiusButton{
|
HoverableRadiusButton{
|
||||||
@@ -135,19 +127,6 @@ ItemDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
|
||||||
visible: preferenceType === PreferenceItemDelegate.LIST
|
|
||||||
Layout.preferredWidth: root.width / 2
|
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
|
||||||
Layout.leftMargin: 8
|
|
||||||
|
|
||||||
text: preferenceName
|
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
|
||||||
ToolTip.visible: hovered
|
|
||||||
ToolTip.text: preferenceSummary
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SettingParaCombobox {
|
SettingParaCombobox {
|
||||||
id: listPreferenceComboBox
|
id: listPreferenceComboBox
|
||||||
visible: preferenceType === PreferenceItemDelegate.LIST
|
visible: preferenceType === PreferenceItemDelegate.LIST
|
||||||
@@ -167,35 +146,29 @@ ItemDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
HoverableRadiusButton {
|
||||||
visible: preferenceType === PreferenceItemDelegate.USERLIST
|
id: pathPreferenceButton
|
||||||
Layout.preferredWidth: root.width / 2
|
visible: preferenceType === PreferenceItemDelegate.PATH
|
||||||
Layout.leftMargin: 8
|
Layout.preferredWidth: root.width / 2 - 16
|
||||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
Layout.maximumWidth: root.width / 2 - 16
|
||||||
|
|
||||||
text: preferenceName
|
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
|
||||||
ToolTip.visible: hovered
|
|
||||||
ToolTip.text: preferenceSummary
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SettingParaCombobox {
|
|
||||||
id: userListPreferenceComboBox
|
|
||||||
visible: preferenceType === PreferenceItemDelegate.USERLIST
|
|
||||||
Layout.preferredWidth: root.width / 2 - 8
|
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||||
Layout.rightMargin: 8
|
Layout.rightMargin: 30
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
|
||||||
font.pointSize: JamiTheme.settingsFontSize
|
radius: height / 2
|
||||||
font.kerning: true
|
|
||||||
|
|
||||||
model: pluginListPreferenceModel
|
icon.source: "qrc:/images/icons/round-folder-24px.svg"
|
||||||
currentIndex: pluginListPreferenceModel.getCurrentSettingIndex()
|
icon.height: 24
|
||||||
textRole: qsTr("PreferenceValue")
|
icon.width: 24
|
||||||
tooltipText: qsTr("Choose the preference")
|
|
||||||
onActivated: {
|
toolTipText: qsTr("Press to choose an image file")
|
||||||
getNewPreferenceValueSlot(index)
|
text: {
|
||||||
|
return ClientWrapper.utilsAdaptor.fileName(preferenceCurrentValue)
|
||||||
|
}
|
||||||
|
fontPointSize: JamiTheme.buttonFontSize
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
getNewPreferenceValueSlot(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Popup {
|
|||||||
id: root
|
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 = PluginAdapter.getMediaHandlerSelectableModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 350
|
width: 350
|
||||||
@@ -96,7 +96,7 @@ Popup {
|
|||||||
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
||||||
Layout.preferredHeight: 200
|
Layout.preferredHeight: 200
|
||||||
|
|
||||||
model: MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
model: PluginAdapter.getMediaHandlerSelectableModel()
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ Popup {
|
|||||||
onOpenPreferences: {
|
onOpenPreferences: {
|
||||||
mediahandlerPreferencePickerListView.pluginId = pluginId
|
mediahandlerPreferencePickerListView.pluginId = pluginId
|
||||||
mediahandlerPreferencePickerListView.mediaHandlerName = mediaHandlerName
|
mediahandlerPreferencePickerListView.mediaHandlerName = mediaHandlerName
|
||||||
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
|
||||||
stack.currentIndex = 1
|
stack.currentIndex = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,20 +204,24 @@ Popup {
|
|||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
property string mediaHandlerName: ""
|
property string mediaHandlerName: ""
|
||||||
|
|
||||||
model: MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
model: PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
delegate: PreferenceItemDelegate {
|
delegate: PreferenceItemDelegate {
|
||||||
id: mediaHandlerPreferenceDelegate
|
id: mediaHandlerPreferenceDelegate
|
||||||
width: mediahandlerPreferencePickerListView.width
|
width: mediahandlerPreferencePickerListView.width
|
||||||
height: 50
|
height: childrenRect.height
|
||||||
|
|
||||||
preferenceName: PreferenceName
|
preferenceName: PreferenceName
|
||||||
preferenceSummary: PreferenceSummary
|
preferenceSummary: PreferenceSummary
|
||||||
preferenceType: PreferenceType
|
preferenceType: PreferenceType
|
||||||
preferenceCurrentValue: PreferenceCurrentValue
|
preferenceCurrentValue: PreferenceCurrentValue
|
||||||
pluginId: PluginId
|
pluginId: PluginId
|
||||||
|
currentPath: CurrentPath
|
||||||
|
preferenceKey : PreferenceKey
|
||||||
|
fileFilters: FileFilters
|
||||||
|
isImage: IsImage
|
||||||
pluginListPreferenceModel: PluginListPreferenceModel{
|
pluginListPreferenceModel: PluginListPreferenceModel{
|
||||||
id: pluginListPreferenceModel
|
id: pluginListPreferenceModel
|
||||||
preferenceKey : PreferenceKey
|
preferenceKey : PreferenceKey
|
||||||
@@ -227,13 +231,9 @@ Popup {
|
|||||||
onClicked: mediahandlerPreferencePickerListView.currentIndex = index
|
onClicked: mediahandlerPreferencePickerListView.currentIndex = index
|
||||||
|
|
||||||
onBtnPreferenceClicked: {
|
onBtnPreferenceClicked: {
|
||||||
ClientWrapper.pluginModel.setPluginPreference(pluginListPreferenceModel.pluginId,
|
ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
pluginListPreferenceModel.preferenceKey,
|
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||||
pluginListPreferenceModel.preferenceNewValue)
|
|
||||||
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onPreferenceAdded: mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollIndicator.vertical: ScrollIndicator {}
|
ScrollIndicator.vertical: ScrollIndicator {}
|
||||||
@@ -246,7 +246,7 @@ Popup {
|
|||||||
|
|
||||||
onAboutToShow: {
|
onAboutToShow: {
|
||||||
// Reset the model on each show.
|
// Reset the model on each show.
|
||||||
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "mediahandleradapter.h"
|
|
||||||
|
|
||||||
#include "lrcinstance.h"
|
|
||||||
|
|
||||||
MediaHandlerAdapter::MediaHandlerAdapter(QObject* parent)
|
|
||||||
: QmlAdapterBase(parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QVariant
|
|
||||||
MediaHandlerAdapter::getMediaHandlerSelectableModel()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Called from qml every time contact picker refreshes.
|
|
||||||
*/
|
|
||||||
mediaHandlerListModel_.reset(new MediaHandlerItemListModel(this));
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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;
|
|
||||||
};
|
|
||||||
49
src/pluginadapter.cpp
Normal file
49
src/pluginadapter.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*!
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pluginadapter.h"
|
||||||
|
|
||||||
|
#include "lrcinstance.h"
|
||||||
|
|
||||||
|
PluginAdapter::PluginAdapter(QObject* parent)
|
||||||
|
: QmlAdapterBase(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PluginAdapter::getMediaHandlerSelectableModel()
|
||||||
|
{
|
||||||
|
mediaHandlerListModel_.reset(new MediaHandlerItemListModel(this));
|
||||||
|
return QVariant::fromValue(mediaHandlerListModel_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PluginAdapter::getPluginSelectableModel()
|
||||||
|
{
|
||||||
|
pluginItemListModel_.reset(new PluginItemListModel(this));
|
||||||
|
return QVariant::fromValue(pluginItemListModel_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PluginAdapter::getPluginPreferencesModel(const QString& pluginId, const QString& mediaHandlerName)
|
||||||
|
{
|
||||||
|
preferenceItemListModel_.reset(new PreferenceItemListModel(this));
|
||||||
|
preferenceItemListModel_->setMediaHandlerName(mediaHandlerName);
|
||||||
|
preferenceItemListModel_->setPluginId(pluginId);
|
||||||
|
|
||||||
|
return QVariant::fromValue(preferenceItemListModel_.get());
|
||||||
|
}
|
||||||
@@ -19,31 +19,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qmladapterbase.h"
|
#include "qmladapterbase.h"
|
||||||
|
#include "pluginitemlistmodel.h"
|
||||||
#include "mediahandleritemlistmodel.h"
|
#include "mediahandleritemlistmodel.h"
|
||||||
#include "mediahandlerlistpreferencemodel.h"
|
#include "pluginlistpreferencemodel.h"
|
||||||
#include "preferenceitemlistmodel.h"
|
#include "preferenceitemlistmodel.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class MediaHandlerAdapter final : public QmlAdapterBase
|
class PluginAdapter final : public QmlAdapterBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MediaHandlerAdapter(QObject* parent = nullptr);
|
explicit PluginAdapter(QObject* parent = nullptr);
|
||||||
~MediaHandlerAdapter() = default;
|
~PluginAdapter() = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void safeInit() override {};
|
void safeInit() override {};
|
||||||
|
|
||||||
Q_INVOKABLE QVariant getMediaHandlerSelectableModel();
|
Q_INVOKABLE QVariant getMediaHandlerSelectableModel();
|
||||||
Q_INVOKABLE QVariant getMediaHandlerPreferencesModel(QString pluginId, QString mediaHandlerName);
|
Q_INVOKABLE QVariant getPluginSelectableModel();
|
||||||
Q_INVOKABLE QVariant getMediaHandlerPreferencesSelectableModel(QString pluginId);
|
Q_INVOKABLE QVariant getPluginPreferencesModel(const QString& pluginId,
|
||||||
|
const QString& mediaHandlerName = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<MediaHandlerItemListModel> mediaHandlerListModel_;
|
std::unique_ptr<MediaHandlerItemListModel> mediaHandlerListModel_;
|
||||||
std::unique_ptr<PreferenceItemListModel> mediaHandlerPreferenceItemListModel_;
|
std::unique_ptr<PreferenceItemListModel> preferenceItemListModel_;
|
||||||
std::unique_ptr<MediaHandlerListPreferenceModel> mediaHandlerListPreferenceModel_;
|
std::unique_ptr<PluginItemListModel> pluginItemListModel_;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -33,6 +33,8 @@ PluginListPreferenceModel::populateLists()
|
|||||||
const auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
const auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||||
for (const auto& preference : preferences) {
|
for (const auto& preference : preferences) {
|
||||||
if (preference["key"] == preferenceKey_) {
|
if (preference["key"] == preferenceKey_) {
|
||||||
|
if (preference.find("entries") != preference.end()
|
||||||
|
&& preference.find("entryValues") != preference.end())
|
||||||
preferenceList_ = preference["entries"].split(",");
|
preferenceList_ = preference["entries"].split(",");
|
||||||
preferenceValuesList_ = preference["entryValues"].split(",");
|
preferenceValuesList_ = preference["entryValues"].split(",");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,10 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "preferenceitemlistmodel.h"
|
#include "preferenceitemlistmodel.h"
|
||||||
|
#include "utils.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
std::map<QString, int> mapType {{QString("List"), PreferenceItemListModel::Type::LIST},
|
std::map<QString, int> mapType {{QString("List"), PreferenceItemListModel::Type::LIST},
|
||||||
{QString("UserList"), PreferenceItemListModel::Type::USERLIST}};
|
{QString("Path"), PreferenceItemListModel::Type::PATH}};
|
||||||
|
|
||||||
PreferenceItemListModel::PreferenceItemListModel(QObject* parent)
|
PreferenceItemListModel::PreferenceItemListModel(QObject* parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
@@ -55,14 +56,27 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto details = preferenceList_.at(index.row());
|
auto details = preferenceList_.at(index.row());
|
||||||
int type = Type::DEFAULT;
|
|
||||||
auto it = mapType.find(details["type"]);
|
|
||||||
if (it != mapType.end()) {
|
|
||||||
type = mapType[details["type"]];
|
|
||||||
}
|
|
||||||
QString preferenceCurrent = LRCInstance::pluginModel().getPluginPreferencesValues(
|
QString preferenceCurrent = LRCInstance::pluginModel().getPluginPreferencesValues(
|
||||||
pluginId_)[details["key"]];
|
pluginId_)[details["key"]];
|
||||||
|
|
||||||
|
int type = Type::DEFAULT;
|
||||||
|
QString currentPath = "";
|
||||||
|
QStringList acceptedFiles = {};
|
||||||
|
bool checkImage = false;
|
||||||
|
auto it = mapType.find(details["type"]);
|
||||||
|
if (it != mapType.end()) {
|
||||||
|
type = mapType[details["type"]];
|
||||||
|
if (type == Type::PATH) {
|
||||||
|
currentPath = preferenceCurrent;
|
||||||
|
currentPath.truncate(preferenceCurrent.lastIndexOf("/"));
|
||||||
|
QStringList mimeTypeList = details["mimeType"].split(',');
|
||||||
|
for (auto& mimeType : mimeTypeList) {
|
||||||
|
QString fileExt = mimeType.mid(mimeType.lastIndexOf("/") + 1);
|
||||||
|
acceptedFiles.append((fileExt.toUpper() + " Files") + " (*." + fileExt + ")");
|
||||||
|
checkImage = UtilsAdapter().isImage(fileExt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Role::PreferenceKey:
|
case Role::PreferenceKey:
|
||||||
return QVariant(details["key"]);
|
return QVariant(details["key"]);
|
||||||
@@ -76,6 +90,12 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
|||||||
return QVariant(pluginId_);
|
return QVariant(pluginId_);
|
||||||
case Role::PreferenceCurrentValue:
|
case Role::PreferenceCurrentValue:
|
||||||
return QVariant(preferenceCurrent);
|
return QVariant(preferenceCurrent);
|
||||||
|
case Role::CurrentPath:
|
||||||
|
return QVariant(currentPath);
|
||||||
|
case Role::FileFilters:
|
||||||
|
return QVariant(acceptedFiles);
|
||||||
|
case Role::IsImage:
|
||||||
|
return QVariant(checkImage);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -90,6 +110,9 @@ PreferenceItemListModel::roleNames() const
|
|||||||
roles[PreferenceType] = "PreferenceType";
|
roles[PreferenceType] = "PreferenceType";
|
||||||
roles[PluginId] = "PluginId";
|
roles[PluginId] = "PluginId";
|
||||||
roles[PreferenceCurrentValue] = "PreferenceCurrentValue";
|
roles[PreferenceCurrentValue] = "PreferenceCurrentValue";
|
||||||
|
roles[CurrentPath] = "CurrentPath";
|
||||||
|
roles[FileFilters] = "FileFilters";
|
||||||
|
roles[IsImage] = "IsImage";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,21 +190,8 @@ PreferenceItemListModel::preferencesCount()
|
|||||||
} else {
|
} else {
|
||||||
auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||||
for (auto& preference : preferences) {
|
for (auto& preference : preferences) {
|
||||||
std::string scope = preference["scope"].toStdString();
|
QStringList scopeList = preference["scope"].split(",");
|
||||||
std::string delimiter = ",";
|
if (scopeList.contains(mediaHandlerName_))
|
||||||
|
|
||||||
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);
|
preferenceList_.push_back(preference);
|
||||||
}
|
}
|
||||||
return preferenceList_.size();
|
return preferenceList_.size();
|
||||||
|
|||||||
@@ -38,12 +38,15 @@ public:
|
|||||||
PreferenceSummary,
|
PreferenceSummary,
|
||||||
PreferenceType,
|
PreferenceType,
|
||||||
PluginId,
|
PluginId,
|
||||||
PreferenceCurrentValue
|
PreferenceCurrentValue,
|
||||||
|
CurrentPath,
|
||||||
|
FileFilters,
|
||||||
|
IsImage
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LIST,
|
LIST,
|
||||||
USERLIST,
|
PATH,
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
} Type;
|
} Type;
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,8 @@
|
|||||||
#include "conversationsadapter.h"
|
#include "conversationsadapter.h"
|
||||||
#include "deviceitemlistmodel.h"
|
#include "deviceitemlistmodel.h"
|
||||||
#include "distantrenderer.h"
|
#include "distantrenderer.h"
|
||||||
#include "mediahandleradapter.h"
|
#include "pluginadapter.h"
|
||||||
#include "mediahandleritemlistmodel.h"
|
#include "mediahandleritemlistmodel.h"
|
||||||
#include "mediahandlerlistpreferencemodel.h"
|
|
||||||
#include "messagesadapter.h"
|
#include "messagesadapter.h"
|
||||||
#include "namedirectory.h"
|
#include "namedirectory.h"
|
||||||
#include "preferenceitemlistmodel.h"
|
#include "preferenceitemlistmodel.h"
|
||||||
@@ -117,7 +116,6 @@ void registerTypes()
|
|||||||
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.
|
||||||
@@ -141,7 +139,7 @@ void registerTypes()
|
|||||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0);
|
QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0);
|
||||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 1, 0);
|
QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 1, 0);
|
||||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", ContactAdapter, 1, 0);
|
QML_REGISTERSINGLETONTYPE("net.jami.Models", ContactAdapter, 1, 0);
|
||||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", MediaHandlerAdapter, 1, 0);
|
QML_REGISTERSINGLETONTYPE("net.jami.Models", PluginAdapter, 1, 0);
|
||||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", ClientWrapper, 1, 0);
|
QML_REGISTERSINGLETONTYPE("net.jami.Models", ClientWrapper, 1, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ ItemDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: qsTr("Show preferences")
|
ToolTip.text: qsTr("Show/Hide preferences")
|
||||||
|
|
||||||
onClicked: btnPreferencesPluginClicked()
|
onClicked: btnPreferencesPluginClicked()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,10 @@ Rectangle {
|
|||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
LIST,
|
LIST,
|
||||||
USERLIST,
|
PATH,
|
||||||
DEFAULT
|
DEFAULT
|
||||||
}
|
}
|
||||||
|
|
||||||
signal updatePluginList
|
|
||||||
|
|
||||||
property string pluginName: ""
|
property string pluginName: ""
|
||||||
property string pluginIcon: ""
|
property string pluginIcon: ""
|
||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
@@ -45,14 +43,6 @@ Rectangle {
|
|||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
function updatePreferenceListDisplayed(){
|
|
||||||
// settings
|
|
||||||
preferenceItemListModel.pluginId = pluginId
|
|
||||||
preferenceItemListModel.reset()
|
|
||||||
var size = 50 * preferenceItemListModel.preferencesCount
|
|
||||||
pluginPreferenceView.height = size
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetPluginSlot(){
|
function resetPluginSlot(){
|
||||||
resetPluginMessageBox.open()
|
resetPluginMessageBox.open()
|
||||||
}
|
}
|
||||||
@@ -65,8 +55,7 @@ Rectangle {
|
|||||||
} else {
|
} else {
|
||||||
ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId)
|
ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId)
|
||||||
}
|
}
|
||||||
updatePluginList()
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||||
updatePreferenceListDisplayed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPluginSlot(){
|
function uninstallPluginSlot(){
|
||||||
@@ -75,7 +64,6 @@ Rectangle {
|
|||||||
|
|
||||||
function uninstallPlugin(){
|
function uninstallPlugin(){
|
||||||
ClientWrapper.pluginModel.uninstallPlugin(pluginId)
|
ClientWrapper.pluginModel.uninstallPlugin(pluginId)
|
||||||
updatePluginList()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
@@ -115,10 +103,6 @@ Rectangle {
|
|||||||
onAccepted: resetPlugin()
|
onAccepted: resetPlugin()
|
||||||
}
|
}
|
||||||
|
|
||||||
PreferenceItemListModel {
|
|
||||||
id: preferenceItemListModel
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.left: root.left
|
anchors.left: root.left
|
||||||
anchors.right: root.right
|
anchors.right: root.right
|
||||||
@@ -195,19 +179,23 @@ Rectangle {
|
|||||||
Layout.minimumHeight: 0
|
Layout.minimumHeight: 0
|
||||||
Layout.preferredHeight: childrenRect.height + 30
|
Layout.preferredHeight: childrenRect.height + 30
|
||||||
|
|
||||||
model: preferenceItemListModel
|
model: PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||||
|
|
||||||
delegate: PreferenceItemDelegate{
|
delegate: PreferenceItemDelegate{
|
||||||
id: preferenceItemDelegate
|
id: preferenceItemDelegate
|
||||||
|
|
||||||
width: pluginPreferenceView.width
|
width: pluginPreferenceView.width
|
||||||
height: 50
|
height: childrenRect.height
|
||||||
|
|
||||||
preferenceName: PreferenceName
|
preferenceName: PreferenceName
|
||||||
preferenceSummary: PreferenceSummary
|
preferenceSummary: PreferenceSummary
|
||||||
preferenceType: PreferenceType
|
preferenceType: PreferenceType
|
||||||
preferenceCurrentValue: PreferenceCurrentValue
|
preferenceCurrentValue: PreferenceCurrentValue
|
||||||
pluginId: PluginId
|
pluginId: PluginId
|
||||||
|
currentPath: CurrentPath
|
||||||
|
preferenceKey: PreferenceKey
|
||||||
|
fileFilters: FileFilters
|
||||||
|
isImage: IsImage
|
||||||
pluginListPreferenceModel: PluginListPreferenceModel{
|
pluginListPreferenceModel: PluginListPreferenceModel{
|
||||||
id: pluginListPreferenceModel
|
id: pluginListPreferenceModel
|
||||||
preferenceKey : PreferenceKey
|
preferenceKey : PreferenceKey
|
||||||
@@ -218,12 +206,9 @@ Rectangle {
|
|||||||
pluginPreferenceView.currentIndex = index
|
pluginPreferenceView.currentIndex = index
|
||||||
}
|
}
|
||||||
onBtnPreferenceClicked: {
|
onBtnPreferenceClicked: {
|
||||||
setPreference(pluginListPreferenceModel.pluginId,
|
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
pluginListPreferenceModel.preferenceKey,
|
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||||
pluginListPreferenceModel.preferenceNewValue)
|
}
|
||||||
updatePreferenceListDisplayed()
|
|
||||||
}
|
|
||||||
onPreferenceAdded: preferenceItemListModel.reset()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,6 @@ Rectangle {
|
|||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
function updatePluginListDisplayed() {
|
|
||||||
// settings
|
|
||||||
pluginItemListModel.reset()
|
|
||||||
var size = 50 * pluginItemListModel.pluginsCount
|
|
||||||
pluginListView.height = size + 15
|
|
||||||
}
|
|
||||||
|
|
||||||
function openPluginFileSlot(){
|
function openPluginFileSlot(){
|
||||||
pluginPathDialog.open()
|
pluginPathDialog.open()
|
||||||
}
|
}
|
||||||
@@ -52,7 +45,6 @@ Rectangle {
|
|||||||
loaded = ClientWrapper.pluginModel.loadPlugin(pluginId)
|
loaded = ClientWrapper.pluginModel.loadPlugin(pluginId)
|
||||||
if(pluginListPreferencesView.pluginId === pluginId)
|
if(pluginListPreferencesView.pluginId === pluginId)
|
||||||
pluginListPreferencesView.isLoaded = loaded
|
pluginListPreferencesView.isLoaded = loaded
|
||||||
updatePluginListDisplayed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded){
|
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded){
|
||||||
@@ -67,13 +59,11 @@ Rectangle {
|
|||||||
pluginListPreferencesView.pluginId = pluginId
|
pluginListPreferencesView.pluginId = pluginId
|
||||||
pluginListPreferencesView.isLoaded = isLoaded
|
pluginListPreferencesView.isLoaded = isLoaded
|
||||||
}
|
}
|
||||||
pluginListPreferencesView.updatePreferenceListDisplayed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hidePreferences(){
|
function hidePreferences(){
|
||||||
pluginListPreferencesView.pluginId = ""
|
pluginListPreferencesView.pluginId = ""
|
||||||
pluginListPreferencesView.visible = false
|
pluginListPreferencesView.visible = false
|
||||||
pluginListPreferencesView.updatePreferenceListDisplayed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JamiFileDialog {
|
JamiFileDialog {
|
||||||
@@ -97,7 +87,6 @@ Rectangle {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
var url = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
|
var url = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
|
||||||
ClientWrapper.pluginModel.installPlugin(url, true)
|
ClientWrapper.pluginModel.installPlugin(url, true)
|
||||||
updatePluginListDisplayed()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,8 +111,8 @@ Rectangle {
|
|||||||
id: installButton
|
id: installButton
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
Layout.preferredWidth: preferredWidth
|
Layout.preferredWidth: JamiTheme.preferredFieldWidth
|
||||||
Layout.preferredHeight: preferredHeight
|
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||||
|
|
||||||
color: JamiTheme.buttonTintedBlack
|
color: JamiTheme.buttonTintedBlack
|
||||||
hoveredColor: JamiTheme.buttonTintedBlackHovered
|
hoveredColor: JamiTheme.buttonTintedBlackHovered
|
||||||
@@ -149,9 +138,7 @@ Rectangle {
|
|||||||
Layout.minimumHeight: 0
|
Layout.minimumHeight: 0
|
||||||
Layout.preferredHeight: childrenRect.height
|
Layout.preferredHeight: childrenRect.height
|
||||||
|
|
||||||
model: PluginItemListModel{
|
model: PluginAdapter.getPluginSelectableModel()
|
||||||
id: pluginItemListModel
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: PluginItemDelegate{
|
delegate: PluginItemDelegate{
|
||||||
id: pluginItemDelegate
|
id: pluginItemDelegate
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ Rectangle {
|
|||||||
// settings
|
// settings
|
||||||
enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled()
|
enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled()
|
||||||
pluginListSettingsView.visible = enabledplugin.checked
|
pluginListSettingsView.visible = enabledplugin.checked
|
||||||
if (pluginListSettingsView.visible) {
|
|
||||||
pluginListSettingsView.updatePluginListDisplayed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function slotSetPluginEnabled(state){
|
function slotSetPluginEnabled(state){
|
||||||
@@ -114,9 +111,7 @@ Rectangle {
|
|||||||
slotSetPluginEnabled(checked)
|
slotSetPluginEnabled(checked)
|
||||||
|
|
||||||
pluginListSettingsView.visible = checked
|
pluginListSettingsView.visible = checked
|
||||||
if (pluginListSettingsView.visible) {
|
if (!pluginListSettingsView.visible) {
|
||||||
pluginListSettingsView.updatePluginListDisplayed()
|
|
||||||
} else {
|
|
||||||
ClientWrapper.pluginModel.toggleCallMediaHandler("", true)
|
ClientWrapper.pluginModel.toggleCallMediaHandler("", true)
|
||||||
pluginListSettingsView.hidePreferences()
|
pluginListSettingsView.hidePreferences()
|
||||||
}
|
}
|
||||||
@@ -144,10 +139,6 @@ Rectangle {
|
|||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
Layout.minimumHeight: 0
|
Layout.minimumHeight: 0
|
||||||
Layout.preferredHeight: childrenRect.height
|
Layout.preferredHeight: childrenRect.height
|
||||||
|
|
||||||
onUpdatePluginList:{
|
|
||||||
pluginListSettingsView.updatePluginListDisplayed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,8 +184,10 @@ Utils::removeOldVersions()
|
|||||||
qDebug() << "Found startup link for Ring. Removing it and killing Ring.exe.";
|
qDebug() << "Found startup link for Ring. Removing it and killing Ring.exe.";
|
||||||
Utils::DeleteStartupLink(TEXT("Ring"));
|
Utils::DeleteStartupLink(TEXT("Ring"));
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("taskkill", QStringList()
|
process.start("taskkill",
|
||||||
<< "/im" << "Ring.exe" << "/f");
|
QStringList() << "/im"
|
||||||
|
<< "Ring.exe"
|
||||||
|
<< "/f");
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,7 +669,8 @@ Utils::getAvatarColor(const QString &canonicalUri)
|
|||||||
|
|
||||||
/* Generate a QImage representing a dummy user avatar, when user doesn't provide it.
|
/* Generate a QImage representing a dummy user avatar, when user doesn't provide it.
|
||||||
* Current rendering is a flat colored circle with a centered letter.
|
* Current rendering is a flat colored circle with a centered letter.
|
||||||
* The color of the letter is computed from the circle color to be visible whaterver be the circle color.
|
* The color of the letter is computed from the circle color to be visible whaterver be the circle
|
||||||
|
* color.
|
||||||
*/
|
*/
|
||||||
QImage
|
QImage
|
||||||
Utils::fallbackAvatar(const QSize size, const QString& canonicalUriStr, const QString& letterStr)
|
Utils::fallbackAvatar(const QSize size, const QString& canonicalUriStr, const QString& letterStr)
|
||||||
@@ -1072,7 +1075,6 @@ UtilsAdapter::getCallStatusStr(int statusInt)
|
|||||||
return lrc::api::call::to_string(status);
|
return lrc::api::call::to_string(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns true if name is valid registered name
|
// returns true if name is valid registered name
|
||||||
bool
|
bool
|
||||||
UtilsAdapter::validateRegNameForm(const QString& regName)
|
UtilsAdapter::validateRegNameForm(const QString& regName)
|
||||||
@@ -1111,3 +1113,11 @@ UtilsAdapter::checkShowPluginsButton()
|
|||||||
return LRCInstance::pluginModel().getPluginsEnabled()
|
return LRCInstance::pluginModel().getPluginsEnabled()
|
||||||
&& (LRCInstance::pluginModel().listLoadedPlugins().size() > 0);
|
&& (LRCInstance::pluginModel().listLoadedPlugins().size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
UtilsAdapter::isImage(const QString& fileExt) const
|
||||||
|
{
|
||||||
|
if (fileExt == "png" || fileExt == "jpg" || fileExt == "jpeg")
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
98
src/utils.h
98
src/utils.h
@@ -223,8 +223,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void
|
void slotOneShotDisconnectConnection()
|
||||||
slotOneShotDisconnectConnection()
|
|
||||||
{
|
{
|
||||||
if (connection_) {
|
if (connection_) {
|
||||||
QObject::disconnect(*connection_);
|
QObject::disconnect(*connection_);
|
||||||
@@ -308,11 +307,7 @@ public:
|
|||||||
, previous(blocked->blockSignals(true))
|
, previous(blocked->blockSignals(true))
|
||||||
{}
|
{}
|
||||||
~Blocker() { blocked->blockSignals(previous); }
|
~Blocker() { blocked->blockSignals(previous); }
|
||||||
T *
|
T* operator->() { return blocked; }
|
||||||
operator->()
|
|
||||||
{
|
|
||||||
return blocked;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -365,38 +360,20 @@ public:
|
|||||||
/// Singleton
|
/// Singleton
|
||||||
static UtilsAdapter& instance();
|
static UtilsAdapter& instance();
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getChangeLog() { return Utils::getChangeLog(); }
|
||||||
getChangeLog()
|
|
||||||
{
|
|
||||||
return Utils::getChangeLog();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getProjectCredits() { return Utils::getProjectCredits(); }
|
||||||
getProjectCredits()
|
|
||||||
{
|
|
||||||
return Utils::getProjectCredits();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getVersionStr() { return QString(VERSION_STRING); }
|
||||||
getVersionStr()
|
|
||||||
{
|
|
||||||
return QString(VERSION_STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE void
|
Q_INVOKABLE void setText(QString text) { clipboard_->setText(text, QClipboard::Clipboard); }
|
||||||
setText(QString text)
|
|
||||||
{
|
|
||||||
clipboard_->setText(text, QClipboard::Clipboard);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString qStringFromFile(const QString& filename)
|
||||||
qStringFromFile(const QString &filename)
|
|
||||||
{
|
{
|
||||||
return Utils::QByteArrayFromFile(filename);
|
return Utils::QByteArrayFromFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getStyleSheet(const QString& name, const QString& source)
|
||||||
getStyleSheet(const QString &name, const QString &source)
|
|
||||||
{
|
{
|
||||||
auto simplifiedCSS = source.simplified().replace("'", "\"");
|
auto simplifiedCSS = source.simplified().replace("'", "\"");
|
||||||
QString s = QString::fromLatin1("(function() {"
|
QString s = QString::fromLatin1("(function() {"
|
||||||
@@ -410,31 +387,17 @@ public:
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getCachePath()
|
||||||
getCachePath()
|
|
||||||
{
|
{
|
||||||
QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
||||||
dataDir.cdUp();
|
dataDir.cdUp();
|
||||||
return dataDir.absolutePath() + "/jami";
|
return dataDir.absolutePath() + "/jami";
|
||||||
}
|
}
|
||||||
Q_INVOKABLE bool
|
Q_INVOKABLE bool createStartupLink() { return Utils::CreateStartupLink(L"Jami"); }
|
||||||
createStartupLink()
|
Q_INVOKABLE QString GetRingtonePath() { return Utils::GetRingtonePath(); }
|
||||||
{
|
Q_INVOKABLE bool checkStartupLink() { return Utils::CheckStartupLink(L"Jami"); }
|
||||||
return Utils::CreateStartupLink(L"Jami");
|
|
||||||
}
|
|
||||||
Q_INVOKABLE QString
|
|
||||||
GetRingtonePath()
|
|
||||||
{
|
|
||||||
return Utils::GetRingtonePath();
|
|
||||||
}
|
|
||||||
Q_INVOKABLE bool
|
|
||||||
checkStartupLink()
|
|
||||||
{
|
|
||||||
return Utils::CheckStartupLink(L"Jami");
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE const QString
|
Q_INVOKABLE const QString getContactImageString(const QString& accountId, const QString& uid)
|
||||||
getContactImageString(const QString &accountId, const QString &uid)
|
|
||||||
{
|
{
|
||||||
return Utils::getContactImageString(accountId, uid);
|
return Utils::getContactImageString(accountId, uid);
|
||||||
}
|
}
|
||||||
@@ -464,34 +427,26 @@ public:
|
|||||||
Q_INVOKABLE bool validateRegNameForm(const QString& regName);
|
Q_INVOKABLE bool validateRegNameForm(const QString& regName);
|
||||||
Q_INVOKABLE QString getRecordQualityString(int value);
|
Q_INVOKABLE QString getRecordQualityString(int value);
|
||||||
Q_INVOKABLE QString getCurrentPath();
|
Q_INVOKABLE QString getCurrentPath();
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString stringSimplifier(QString input) { return input.simplified(); }
|
||||||
stringSimplifier(QString input)
|
|
||||||
{
|
|
||||||
return input.simplified();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString toNativeSeparators(QString inputDir)
|
||||||
toNativeSeparators(QString inputDir)
|
|
||||||
{
|
{
|
||||||
return QDir::toNativeSeparators(inputDir);
|
return QDir::toNativeSeparators(inputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString toFileInfoName(QString inputFileName)
|
||||||
toFileInfoName(QString inputFileName)
|
|
||||||
{
|
{
|
||||||
QFileInfo fi(inputFileName);
|
QFileInfo fi(inputFileName);
|
||||||
return fi.fileName();
|
return fi.fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString toFileAbsolutepath(QString inputFileName)
|
||||||
toFileAbsolutepath(QString inputFileName)
|
|
||||||
{
|
{
|
||||||
QFileInfo fi(inputFileName);
|
QFileInfo fi(inputFileName);
|
||||||
return fi.absolutePath();
|
return fi.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString getAbsPath(QString path)
|
||||||
getAbsPath(QString path)
|
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
return path.replace("file:///", "").replace("\n", "").replace("\r", "");
|
return path.replace("file:///", "").replace("\n", "").replace("\r", "");
|
||||||
@@ -500,8 +455,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE QString
|
Q_INVOKABLE QString getCroppedImageBase64FromFile(QString fileName, int size)
|
||||||
getCroppedImageBase64FromFile(QString fileName, int size)
|
|
||||||
{
|
{
|
||||||
auto image = Utils::cropImage(QImage(fileName));
|
auto image = Utils::cropImage(QImage(fileName));
|
||||||
auto croppedImage = image.scaled(size,
|
auto croppedImage = image.scaled(size,
|
||||||
@@ -513,6 +467,20 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE bool checkShowPluginsButton();
|
Q_INVOKABLE bool checkShowPluginsButton();
|
||||||
|
|
||||||
|
Q_INVOKABLE QString fileName(const QString& path)
|
||||||
|
{
|
||||||
|
QFileInfo fi(path);
|
||||||
|
return fi.fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getExt(const QString& path)
|
||||||
|
{
|
||||||
|
QFileInfo fi(path);
|
||||||
|
return fi.completeSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isImage(const QString& fileExt) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QClipboard* clipboard_;
|
QClipboard* clipboard_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user