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/avadapter.h \
|
||||
./src/contactadapter.h \
|
||||
./src/mediahandleradapter.h \
|
||||
./src/pluginadapter.h \
|
||||
./src/settingsadapter.h \
|
||||
./src/deviceitemlistmodel.h \
|
||||
./src/pluginitemlistmodel.h \
|
||||
@@ -150,7 +150,6 @@ HEADERS += ./src/smartlistmodel.h \
|
||||
./src/videoinputdevicemodel.h \
|
||||
./src/audiooutputdevicemodel.h \
|
||||
./src/pluginlistpreferencemodel.h \
|
||||
./src/mediahandlerlistpreferencemodel.h \
|
||||
./src/videoformatfpsmodel.h \
|
||||
./src/videoformatresolutionmodel.h \
|
||||
./src/audiomanagerlistmodel.h \
|
||||
@@ -176,7 +175,7 @@ SOURCES += ./src/bannedlistmodel.cpp \
|
||||
./src/previewrenderer.cpp \
|
||||
./src/avadapter.cpp \
|
||||
./src/contactadapter.cpp \
|
||||
./src/mediahandleradapter.cpp \
|
||||
./src/pluginadapter.cpp \
|
||||
./src/settingsadapter.cpp \
|
||||
./src/deviceitemlistmodel.cpp \
|
||||
./src/pluginitemlistmodel.cpp \
|
||||
@@ -190,7 +189,6 @@ SOURCES += ./src/bannedlistmodel.cpp \
|
||||
./src/videoinputdevicemodel.cpp \
|
||||
./src/audiooutputdevicemodel.cpp \
|
||||
./src/pluginlistpreferencemodel.cpp \
|
||||
./src/mediahandlerlistpreferencemodel.cpp \
|
||||
./src/videoformatfpsmodel.cpp \
|
||||
./src/videoformatresolutionmodel.cpp \
|
||||
./src/audiomanagerlistmodel.cpp \
|
||||
|
||||
@@ -117,5 +117,6 @@
|
||||
<file>images/icons/drafts-24px.svg</file>
|
||||
<file>images/icons/person_add-24px.svg</file>
|
||||
<file>images/icons/router-24px.svg</file>
|
||||
<file>images/icons/insert_drive_file-24dp.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "bannedlistmodel.h"
|
||||
#include "calladapter.h"
|
||||
#include "contactadapter.h"
|
||||
#include "mediahandleradapter.h"
|
||||
#include "pluginadapter.h"
|
||||
#include "conversationsadapter.h"
|
||||
#include "deviceitemlistmodel.h"
|
||||
#include "pluginitemlistmodel.h"
|
||||
|
||||
@@ -34,35 +34,35 @@ ItemDelegate {
|
||||
|
||||
enum Type {
|
||||
LIST,
|
||||
USERLIST,
|
||||
PATH,
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
property string preferenceName: ""
|
||||
property string preferenceSummary: ""
|
||||
property string preferenceKey: ""
|
||||
property int preferenceType: -1
|
||||
property string preferenceCurrentValue: ""
|
||||
property string preferenceNewValue: ""
|
||||
property string pluginId: ""
|
||||
property string currentPath: ""
|
||||
property bool isImage: false
|
||||
property var fileFilters: []
|
||||
property PluginListPreferenceModel pluginListPreferenceModel
|
||||
|
||||
signal btnPreferenceClicked
|
||||
signal preferenceAdded
|
||||
|
||||
function getNewPreferenceValueSlot(index){
|
||||
pluginListPreferenceModel.idx = index
|
||||
preferenceNewValue = pluginListPreferenceModel.preferenceNewValue
|
||||
switch (preferenceType){
|
||||
case PreferenceItemDelegate.LIST:
|
||||
pluginListPreferenceModel.idx = index
|
||||
preferenceNewValue = pluginListPreferenceModel.preferenceNewValue
|
||||
btnPreferenceClicked()
|
||||
break
|
||||
case PreferenceItemDelegate.USERLIST:
|
||||
case PreferenceItemDelegate.PATH:
|
||||
if(index == 0){
|
||||
preferenceFilePathDialog.pluginListPreferenceModel = pluginListPreferenceModel
|
||||
preferenceFilePathDialog.title = qsTr("Select An Image to " + preferenceName)
|
||||
preferenceFilePathDialog.nameFilters = [qsTr("PNG Files") + " (*.png)", qsTr(
|
||||
"All files") + " (*)"]
|
||||
preferenceFilePathDialog.preferenceKey = pluginListPreferenceModel.preferenceKey
|
||||
preferenceFilePathDialog.nameFilters = fileFilters
|
||||
preferenceFilePathDialog.open()
|
||||
}
|
||||
else
|
||||
@@ -76,20 +76,13 @@ ItemDelegate {
|
||||
FileDialog {
|
||||
id: preferenceFilePathDialog
|
||||
|
||||
property string preferenceKey: ""
|
||||
property PluginListPreferenceModel pluginListPreferenceModel
|
||||
|
||||
title: qsTr("Please choose a file")
|
||||
folder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
|
||||
|
||||
onRejected: preferenceAdded()
|
||||
folder: "file://" + currentPath
|
||||
|
||||
onAccepted: {
|
||||
var url = ClientWrapper.utilsAdaptor.getAbsPath(fileUrl.toString())
|
||||
ClientWrapper.pluginModel.addValueToPreference(pluginId, preferenceKey, url)
|
||||
pluginListPreferenceModel.populateLists()
|
||||
pluginListPreferenceModel.getCurrentSettingIndex()
|
||||
preferenceAdded()
|
||||
preferenceNewValue = url
|
||||
btnPreferenceClicked()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,15 +90,14 @@ ItemDelegate {
|
||||
anchors.fill: parent
|
||||
|
||||
Label {
|
||||
visible: preferenceType === PreferenceItemDelegate.DEFAULT
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlingVCenter | Qt.AligntLeft
|
||||
Layout.preferredWidth: root.width / 2
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
Layout.leftMargin: 8
|
||||
|
||||
font.pointSize: JamiTheme.settingsFontSize
|
||||
font.kerning: true
|
||||
font.bold: true
|
||||
text: preferenceName
|
||||
font.pointSize: JamiTheme.settingsFontSize
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: preferenceSummary
|
||||
}
|
||||
|
||||
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 {
|
||||
id: listPreferenceComboBox
|
||||
visible: preferenceType === PreferenceItemDelegate.LIST
|
||||
@@ -167,35 +146,29 @@ ItemDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: preferenceType === PreferenceItemDelegate.USERLIST
|
||||
Layout.preferredWidth: root.width / 2
|
||||
Layout.leftMargin: 8
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
|
||||
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
|
||||
HoverableRadiusButton {
|
||||
id: pathPreferenceButton
|
||||
visible: preferenceType === PreferenceItemDelegate.PATH
|
||||
Layout.preferredWidth: root.width / 2 - 16
|
||||
Layout.maximumWidth: root.width / 2 - 16
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
Layout.rightMargin: 8
|
||||
Layout.rightMargin: 30
|
||||
Layout.preferredHeight: 30
|
||||
|
||||
font.pointSize: JamiTheme.settingsFontSize
|
||||
font.kerning: true
|
||||
radius: height / 2
|
||||
|
||||
model: pluginListPreferenceModel
|
||||
currentIndex: pluginListPreferenceModel.getCurrentSettingIndex()
|
||||
textRole: qsTr("PreferenceValue")
|
||||
tooltipText: qsTr("Choose the preference")
|
||||
onActivated: {
|
||||
getNewPreferenceValueSlot(index)
|
||||
icon.source: "qrc:/images/icons/round-folder-24px.svg"
|
||||
icon.height: 24
|
||||
icon.width: 24
|
||||
|
||||
toolTipText: qsTr("Press to choose an image file")
|
||||
text: {
|
||||
return ClientWrapper.utilsAdaptor.fileName(preferenceCurrentValue)
|
||||
}
|
||||
fontPointSize: JamiTheme.buttonFontSize
|
||||
|
||||
onClicked: {
|
||||
getNewPreferenceValueSlot(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ Popup {
|
||||
id: root
|
||||
function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) {
|
||||
ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded)
|
||||
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel()
|
||||
}
|
||||
|
||||
width: 350
|
||||
@@ -96,7 +96,7 @@ Popup {
|
||||
Layout.preferredWidth: mediahandlerPickerPopupRect.width
|
||||
Layout.preferredHeight: 200
|
||||
|
||||
model: MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||
model: PluginAdapter.getMediaHandlerSelectableModel()
|
||||
|
||||
clip: true
|
||||
|
||||
@@ -119,7 +119,7 @@ Popup {
|
||||
onOpenPreferences: {
|
||||
mediahandlerPreferencePickerListView.pluginId = pluginId
|
||||
mediahandlerPreferencePickerListView.mediaHandlerName = mediaHandlerName
|
||||
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
||||
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
|
||||
stack.currentIndex = 1
|
||||
}
|
||||
}
|
||||
@@ -204,20 +204,24 @@ Popup {
|
||||
property string pluginId: ""
|
||||
property string mediaHandlerName: ""
|
||||
|
||||
model: MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediaHandlerName)
|
||||
model: PluginAdapter.getPluginPreferencesModel(pluginId, mediaHandlerName)
|
||||
|
||||
clip: true
|
||||
|
||||
delegate: PreferenceItemDelegate {
|
||||
id: mediaHandlerPreferenceDelegate
|
||||
width: mediahandlerPreferencePickerListView.width
|
||||
height: 50
|
||||
height: childrenRect.height
|
||||
|
||||
preferenceName: PreferenceName
|
||||
preferenceSummary: PreferenceSummary
|
||||
preferenceType: PreferenceType
|
||||
preferenceCurrentValue: PreferenceCurrentValue
|
||||
pluginId: PluginId
|
||||
currentPath: CurrentPath
|
||||
preferenceKey : PreferenceKey
|
||||
fileFilters: FileFilters
|
||||
isImage: IsImage
|
||||
pluginListPreferenceModel: PluginListPreferenceModel{
|
||||
id: pluginListPreferenceModel
|
||||
preferenceKey : PreferenceKey
|
||||
@@ -227,13 +231,9 @@ Popup {
|
||||
onClicked: mediahandlerPreferencePickerListView.currentIndex = index
|
||||
|
||||
onBtnPreferenceClicked: {
|
||||
ClientWrapper.pluginModel.setPluginPreference(pluginListPreferenceModel.pluginId,
|
||||
pluginListPreferenceModel.preferenceKey,
|
||||
pluginListPreferenceModel.preferenceNewValue)
|
||||
mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||
ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||
}
|
||||
|
||||
onPreferenceAdded: mediahandlerPreferencePickerListView.model = MediaHandlerAdapter.getMediaHandlerPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName)
|
||||
}
|
||||
|
||||
ScrollIndicator.vertical: ScrollIndicator {}
|
||||
@@ -246,7 +246,7 @@ Popup {
|
||||
|
||||
onAboutToShow: {
|
||||
// Reset the model on each show.
|
||||
mediahandlerPickerListView.model = MediaHandlerAdapter.getMediaHandlerSelectableModel()
|
||||
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel()
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#include "qmladapterbase.h"
|
||||
#include "pluginitemlistmodel.h"
|
||||
#include "mediahandleritemlistmodel.h"
|
||||
#include "mediahandlerlistpreferencemodel.h"
|
||||
#include "pluginlistpreferencemodel.h"
|
||||
#include "preferenceitemlistmodel.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QString>
|
||||
|
||||
class MediaHandlerAdapter final : public QmlAdapterBase
|
||||
class PluginAdapter final : public QmlAdapterBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MediaHandlerAdapter(QObject* parent = nullptr);
|
||||
~MediaHandlerAdapter() = default;
|
||||
explicit PluginAdapter(QObject* parent = nullptr);
|
||||
~PluginAdapter() = default;
|
||||
|
||||
protected:
|
||||
void safeInit() override {};
|
||||
|
||||
Q_INVOKABLE QVariant getMediaHandlerSelectableModel();
|
||||
Q_INVOKABLE QVariant getMediaHandlerPreferencesModel(QString pluginId, QString mediaHandlerName);
|
||||
Q_INVOKABLE QVariant getMediaHandlerPreferencesSelectableModel(QString pluginId);
|
||||
Q_INVOKABLE QVariant getPluginSelectableModel();
|
||||
Q_INVOKABLE QVariant getPluginPreferencesModel(const QString& pluginId,
|
||||
const QString& mediaHandlerName = "");
|
||||
|
||||
private:
|
||||
std::unique_ptr<MediaHandlerItemListModel> mediaHandlerListModel_;
|
||||
std::unique_ptr<PreferenceItemListModel> mediaHandlerPreferenceItemListModel_;
|
||||
std::unique_ptr<MediaHandlerListPreferenceModel> mediaHandlerListPreferenceModel_;
|
||||
|
||||
std::unique_ptr<PreferenceItemListModel> preferenceItemListModel_;
|
||||
std::unique_ptr<PluginItemListModel> pluginItemListModel_;
|
||||
};
|
||||
@@ -33,6 +33,8 @@ PluginListPreferenceModel::populateLists()
|
||||
const auto preferences = LRCInstance::pluginModel().getPluginPreferences(pluginId_);
|
||||
for (const auto& preference : preferences) {
|
||||
if (preference["key"] == preferenceKey_) {
|
||||
if (preference.find("entries") != preference.end()
|
||||
&& preference.find("entryValues") != preference.end())
|
||||
preferenceList_ = preference["entries"].split(",");
|
||||
preferenceValuesList_ = preference["entryValues"].split(",");
|
||||
break;
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "preferenceitemlistmodel.h"
|
||||
#include "utils.h"
|
||||
#include <map>
|
||||
|
||||
std::map<QString, int> mapType {{QString("List"), PreferenceItemListModel::Type::LIST},
|
||||
{QString("UserList"), PreferenceItemListModel::Type::USERLIST}};
|
||||
{QString("Path"), PreferenceItemListModel::Type::PATH}};
|
||||
|
||||
PreferenceItemListModel::PreferenceItemListModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
@@ -55,14 +56,27 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
|
||||
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(
|
||||
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) {
|
||||
case Role::PreferenceKey:
|
||||
return QVariant(details["key"]);
|
||||
@@ -76,6 +90,12 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant(pluginId_);
|
||||
case Role::PreferenceCurrentValue:
|
||||
return QVariant(preferenceCurrent);
|
||||
case Role::CurrentPath:
|
||||
return QVariant(currentPath);
|
||||
case Role::FileFilters:
|
||||
return QVariant(acceptedFiles);
|
||||
case Role::IsImage:
|
||||
return QVariant(checkImage);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@@ -90,6 +110,9 @@ PreferenceItemListModel::roleNames() const
|
||||
roles[PreferenceType] = "PreferenceType";
|
||||
roles[PluginId] = "PluginId";
|
||||
roles[PreferenceCurrentValue] = "PreferenceCurrentValue";
|
||||
roles[CurrentPath] = "CurrentPath";
|
||||
roles[FileFilters] = "FileFilters";
|
||||
roles[IsImage] = "IsImage";
|
||||
return roles;
|
||||
}
|
||||
|
||||
@@ -167,21 +190,8 @@ PreferenceItemListModel::preferencesCount()
|
||||
} 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())
|
||||
QStringList scopeList = preference["scope"].split(",");
|
||||
if (scopeList.contains(mediaHandlerName_))
|
||||
preferenceList_.push_back(preference);
|
||||
}
|
||||
return preferenceList_.size();
|
||||
|
||||
@@ -38,12 +38,15 @@ public:
|
||||
PreferenceSummary,
|
||||
PreferenceType,
|
||||
PluginId,
|
||||
PreferenceCurrentValue
|
||||
PreferenceCurrentValue,
|
||||
CurrentPath,
|
||||
FileFilters,
|
||||
IsImage
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LIST,
|
||||
USERLIST,
|
||||
PATH,
|
||||
DEFAULT,
|
||||
} Type;
|
||||
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
#include "conversationsadapter.h"
|
||||
#include "deviceitemlistmodel.h"
|
||||
#include "distantrenderer.h"
|
||||
#include "mediahandleradapter.h"
|
||||
#include "pluginadapter.h"
|
||||
#include "mediahandleritemlistmodel.h"
|
||||
#include "mediahandlerlistpreferencemodel.h"
|
||||
#include "messagesadapter.h"
|
||||
#include "namedirectory.h"
|
||||
#include "preferenceitemlistmodel.h"
|
||||
@@ -117,7 +116,6 @@ void registerTypes()
|
||||
QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0);
|
||||
QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0);
|
||||
QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0);
|
||||
QML_REGISTERTYPE(MediaHandlerListPreferenceModel, 1, 0);
|
||||
|
||||
/*
|
||||
* Register QQuickItem type.
|
||||
@@ -141,7 +139,7 @@ void registerTypes()
|
||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0);
|
||||
QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 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);
|
||||
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ ItemDelegate {
|
||||
}
|
||||
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Show preferences")
|
||||
ToolTip.text: qsTr("Show/Hide preferences")
|
||||
|
||||
onClicked: btnPreferencesPluginClicked()
|
||||
}
|
||||
|
||||
@@ -32,12 +32,10 @@ Rectangle {
|
||||
|
||||
enum Type {
|
||||
LIST,
|
||||
USERLIST,
|
||||
PATH,
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
signal updatePluginList
|
||||
|
||||
property string pluginName: ""
|
||||
property string pluginIcon: ""
|
||||
property string pluginId: ""
|
||||
@@ -45,14 +43,6 @@ Rectangle {
|
||||
|
||||
visible: false
|
||||
|
||||
function updatePreferenceListDisplayed(){
|
||||
// settings
|
||||
preferenceItemListModel.pluginId = pluginId
|
||||
preferenceItemListModel.reset()
|
||||
var size = 50 * preferenceItemListModel.preferencesCount
|
||||
pluginPreferenceView.height = size
|
||||
}
|
||||
|
||||
function resetPluginSlot(){
|
||||
resetPluginMessageBox.open()
|
||||
}
|
||||
@@ -65,8 +55,7 @@ Rectangle {
|
||||
} else {
|
||||
ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId)
|
||||
}
|
||||
updatePluginList()
|
||||
updatePreferenceListDisplayed()
|
||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||
}
|
||||
|
||||
function uninstallPluginSlot(){
|
||||
@@ -75,7 +64,6 @@ Rectangle {
|
||||
|
||||
function uninstallPlugin(){
|
||||
ClientWrapper.pluginModel.uninstallPlugin(pluginId)
|
||||
updatePluginList()
|
||||
}
|
||||
|
||||
function setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||
@@ -115,10 +103,6 @@ Rectangle {
|
||||
onAccepted: resetPlugin()
|
||||
}
|
||||
|
||||
PreferenceItemListModel {
|
||||
id: preferenceItemListModel
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.left: root.left
|
||||
anchors.right: root.right
|
||||
@@ -195,19 +179,23 @@ Rectangle {
|
||||
Layout.minimumHeight: 0
|
||||
Layout.preferredHeight: childrenRect.height + 30
|
||||
|
||||
model: preferenceItemListModel
|
||||
model: PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||
|
||||
delegate: PreferenceItemDelegate{
|
||||
id: preferenceItemDelegate
|
||||
|
||||
width: pluginPreferenceView.width
|
||||
height: 50
|
||||
height: childrenRect.height
|
||||
|
||||
preferenceName: PreferenceName
|
||||
preferenceSummary: PreferenceSummary
|
||||
preferenceType: PreferenceType
|
||||
preferenceCurrentValue: PreferenceCurrentValue
|
||||
pluginId: PluginId
|
||||
currentPath: CurrentPath
|
||||
preferenceKey: PreferenceKey
|
||||
fileFilters: FileFilters
|
||||
isImage: IsImage
|
||||
pluginListPreferenceModel: PluginListPreferenceModel{
|
||||
id: pluginListPreferenceModel
|
||||
preferenceKey : PreferenceKey
|
||||
@@ -218,12 +206,9 @@ Rectangle {
|
||||
pluginPreferenceView.currentIndex = index
|
||||
}
|
||||
onBtnPreferenceClicked: {
|
||||
setPreference(pluginListPreferenceModel.pluginId,
|
||||
pluginListPreferenceModel.preferenceKey,
|
||||
pluginListPreferenceModel.preferenceNewValue)
|
||||
updatePreferenceListDisplayed()
|
||||
}
|
||||
onPreferenceAdded: preferenceItemListModel.reset()
|
||||
setPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,6 @@ Rectangle {
|
||||
|
||||
visible: false
|
||||
|
||||
function updatePluginListDisplayed() {
|
||||
// settings
|
||||
pluginItemListModel.reset()
|
||||
var size = 50 * pluginItemListModel.pluginsCount
|
||||
pluginListView.height = size + 15
|
||||
}
|
||||
|
||||
function openPluginFileSlot(){
|
||||
pluginPathDialog.open()
|
||||
}
|
||||
@@ -52,7 +45,6 @@ Rectangle {
|
||||
loaded = ClientWrapper.pluginModel.loadPlugin(pluginId)
|
||||
if(pluginListPreferencesView.pluginId === pluginId)
|
||||
pluginListPreferencesView.isLoaded = loaded
|
||||
updatePluginListDisplayed()
|
||||
}
|
||||
|
||||
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded){
|
||||
@@ -67,13 +59,11 @@ Rectangle {
|
||||
pluginListPreferencesView.pluginId = pluginId
|
||||
pluginListPreferencesView.isLoaded = isLoaded
|
||||
}
|
||||
pluginListPreferencesView.updatePreferenceListDisplayed()
|
||||
}
|
||||
|
||||
function hidePreferences(){
|
||||
pluginListPreferencesView.pluginId = ""
|
||||
pluginListPreferencesView.visible = false
|
||||
pluginListPreferencesView.updatePreferenceListDisplayed()
|
||||
}
|
||||
|
||||
JamiFileDialog {
|
||||
@@ -97,7 +87,6 @@ Rectangle {
|
||||
onAccepted: {
|
||||
var url = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
|
||||
ClientWrapper.pluginModel.installPlugin(url, true)
|
||||
updatePluginListDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +111,8 @@ Rectangle {
|
||||
id: installButton
|
||||
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.preferredWidth: preferredWidth
|
||||
Layout.preferredHeight: preferredHeight
|
||||
Layout.preferredWidth: JamiTheme.preferredFieldWidth
|
||||
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||
|
||||
color: JamiTheme.buttonTintedBlack
|
||||
hoveredColor: JamiTheme.buttonTintedBlackHovered
|
||||
@@ -149,9 +138,7 @@ Rectangle {
|
||||
Layout.minimumHeight: 0
|
||||
Layout.preferredHeight: childrenRect.height
|
||||
|
||||
model: PluginItemListModel{
|
||||
id: pluginItemListModel
|
||||
}
|
||||
model: PluginAdapter.getPluginSelectableModel()
|
||||
|
||||
delegate: PluginItemDelegate{
|
||||
id: pluginItemDelegate
|
||||
|
||||
@@ -33,9 +33,6 @@ Rectangle {
|
||||
// settings
|
||||
enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled()
|
||||
pluginListSettingsView.visible = enabledplugin.checked
|
||||
if (pluginListSettingsView.visible) {
|
||||
pluginListSettingsView.updatePluginListDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
function slotSetPluginEnabled(state){
|
||||
@@ -114,9 +111,7 @@ Rectangle {
|
||||
slotSetPluginEnabled(checked)
|
||||
|
||||
pluginListSettingsView.visible = checked
|
||||
if (pluginListSettingsView.visible) {
|
||||
pluginListSettingsView.updatePluginListDisplayed()
|
||||
} else {
|
||||
if (!pluginListSettingsView.visible) {
|
||||
ClientWrapper.pluginModel.toggleCallMediaHandler("", true)
|
||||
pluginListSettingsView.hidePreferences()
|
||||
}
|
||||
@@ -144,10 +139,6 @@ Rectangle {
|
||||
Layout.rightMargin: 16
|
||||
Layout.minimumHeight: 0
|
||||
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.";
|
||||
Utils::DeleteStartupLink(TEXT("Ring"));
|
||||
QProcess process;
|
||||
process.start("taskkill", QStringList()
|
||||
<< "/im" << "Ring.exe" << "/f");
|
||||
process.start("taskkill",
|
||||
QStringList() << "/im"
|
||||
<< "Ring.exe"
|
||||
<< "/f");
|
||||
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.
|
||||
* 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
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// returns true if name is valid registered name
|
||||
bool
|
||||
UtilsAdapter::validateRegNameForm(const QString& regName)
|
||||
@@ -1111,3 +1113,11 @@ UtilsAdapter::checkShowPluginsButton()
|
||||
return LRCInstance::pluginModel().getPluginsEnabled()
|
||||
&& (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:
|
||||
void
|
||||
slotOneShotDisconnectConnection()
|
||||
void slotOneShotDisconnectConnection()
|
||||
{
|
||||
if (connection_) {
|
||||
QObject::disconnect(*connection_);
|
||||
@@ -308,11 +307,7 @@ public:
|
||||
, previous(blocked->blockSignals(true))
|
||||
{}
|
||||
~Blocker() { blocked->blockSignals(previous); }
|
||||
T *
|
||||
operator->()
|
||||
{
|
||||
return blocked;
|
||||
}
|
||||
T* operator->() { return blocked; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -365,38 +360,20 @@ public:
|
||||
/// Singleton
|
||||
static UtilsAdapter& instance();
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
getChangeLog()
|
||||
{
|
||||
return Utils::getChangeLog();
|
||||
}
|
||||
Q_INVOKABLE const QString getChangeLog() { return Utils::getChangeLog(); }
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
getProjectCredits()
|
||||
{
|
||||
return Utils::getProjectCredits();
|
||||
}
|
||||
Q_INVOKABLE const QString getProjectCredits() { return Utils::getProjectCredits(); }
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
getVersionStr()
|
||||
{
|
||||
return QString(VERSION_STRING);
|
||||
}
|
||||
Q_INVOKABLE const QString getVersionStr() { return QString(VERSION_STRING); }
|
||||
|
||||
Q_INVOKABLE void
|
||||
setText(QString text)
|
||||
{
|
||||
clipboard_->setText(text, QClipboard::Clipboard);
|
||||
}
|
||||
Q_INVOKABLE void setText(QString text) { clipboard_->setText(text, QClipboard::Clipboard); }
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
qStringFromFile(const QString &filename)
|
||||
Q_INVOKABLE const QString qStringFromFile(const QString& filename)
|
||||
{
|
||||
return Utils::QByteArrayFromFile(filename);
|
||||
}
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
getStyleSheet(const QString &name, const QString &source)
|
||||
Q_INVOKABLE const QString getStyleSheet(const QString& name, const QString& source)
|
||||
{
|
||||
auto simplifiedCSS = source.simplified().replace("'", "\"");
|
||||
QString s = QString::fromLatin1("(function() {"
|
||||
@@ -410,31 +387,17 @@ public:
|
||||
return s;
|
||||
}
|
||||
|
||||
Q_INVOKABLE const QString
|
||||
getCachePath()
|
||||
Q_INVOKABLE const QString getCachePath()
|
||||
{
|
||||
QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
||||
dataDir.cdUp();
|
||||
return dataDir.absolutePath() + "/jami";
|
||||
}
|
||||
Q_INVOKABLE bool
|
||||
createStartupLink()
|
||||
{
|
||||
return Utils::CreateStartupLink(L"Jami");
|
||||
}
|
||||
Q_INVOKABLE QString
|
||||
GetRingtonePath()
|
||||
{
|
||||
return Utils::GetRingtonePath();
|
||||
}
|
||||
Q_INVOKABLE bool
|
||||
checkStartupLink()
|
||||
{
|
||||
return Utils::CheckStartupLink(L"Jami");
|
||||
}
|
||||
Q_INVOKABLE bool createStartupLink() { 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
|
||||
getContactImageString(const QString &accountId, const QString &uid)
|
||||
Q_INVOKABLE const QString getContactImageString(const QString& accountId, const QString& uid)
|
||||
{
|
||||
return Utils::getContactImageString(accountId, uid);
|
||||
}
|
||||
@@ -464,34 +427,26 @@ public:
|
||||
Q_INVOKABLE bool validateRegNameForm(const QString& regName);
|
||||
Q_INVOKABLE QString getRecordQualityString(int value);
|
||||
Q_INVOKABLE QString getCurrentPath();
|
||||
Q_INVOKABLE QString
|
||||
stringSimplifier(QString input)
|
||||
{
|
||||
return input.simplified();
|
||||
}
|
||||
Q_INVOKABLE QString stringSimplifier(QString input) { return input.simplified(); }
|
||||
|
||||
Q_INVOKABLE QString
|
||||
toNativeSeparators(QString inputDir)
|
||||
Q_INVOKABLE QString toNativeSeparators(QString inputDir)
|
||||
{
|
||||
return QDir::toNativeSeparators(inputDir);
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
toFileInfoName(QString inputFileName)
|
||||
Q_INVOKABLE QString toFileInfoName(QString inputFileName)
|
||||
{
|
||||
QFileInfo fi(inputFileName);
|
||||
return fi.fileName();
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
toFileAbsolutepath(QString inputFileName)
|
||||
Q_INVOKABLE QString toFileAbsolutepath(QString inputFileName)
|
||||
{
|
||||
QFileInfo fi(inputFileName);
|
||||
return fi.absolutePath();
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
getAbsPath(QString path)
|
||||
Q_INVOKABLE QString getAbsPath(QString path)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return path.replace("file:///", "").replace("\n", "").replace("\r", "");
|
||||
@@ -500,8 +455,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
Q_INVOKABLE QString
|
||||
getCroppedImageBase64FromFile(QString fileName, int size)
|
||||
Q_INVOKABLE QString getCroppedImageBase64FromFile(QString fileName, int size)
|
||||
{
|
||||
auto image = Utils::cropImage(QImage(fileName));
|
||||
auto croppedImage = image.scaled(size,
|
||||
@@ -513,6 +467,20 @@ public:
|
||||
|
||||
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:
|
||||
QClipboard* clipboard_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user