Skip to content
Snippets Groups Projects
Commit ebc07155 authored by Aline Gondim Santos's avatar Aline Gondim Santos
Browse files

settings: improve plugins view

GitLab: #52
Change-Id: I4ee232092da3b26e4471ccc7c46e57d2d0562856
parent 5e598f53
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ ItemDelegate {
if (index === 0) {
preferenceFilePathDialog.title = qsTr("Select An Image to " + preferenceName)
preferenceFilePathDialog.nameFilters = fileFilters
preferenceFilePathDialog.selectedNameFilter.index = fileFilters.length - 1
preferenceFilePathDialog.open()
}
else
......
......@@ -48,6 +48,7 @@ protected:
signals:
void pluginHandlersUpdateStatus();
void preferenceChanged(QString pluginId);
void pluginUninstalled();
private:
std::unique_ptr<PluginHandlerItemListModel> pluginHandlerListModel_;
......
......@@ -74,10 +74,11 @@ PreferenceItemListModel::data(const QModelIndex& index, int role) const
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 = Utils::isImage(fileExt);
mimeType = mimeType.mid(mimeType.lastIndexOf("/") + 1);
acceptedFiles.append((mimeType.toUpper() + " Files") + " (*." + mimeType + ")");
checkImage |= Utils::isImage(mimeType);
}
acceptedFiles.append(QString("All (*.%1)").arg(mimeTypeList.join(" *.")));
}
}
switch (role) {
......
......@@ -36,85 +36,127 @@ ItemDelegate {
property bool isLoaded: false
signal btnLoadPluginToggled
signal btnPreferencesPluginClicked
RowLayout {
anchors.fill: parent
function btnPreferencesPluginClicked() {
pluginListPreferencesView.pluginName = pluginName
pluginListPreferencesView.pluginIcon = pluginIcon
pluginListPreferencesView.pluginId = pluginId
pluginListPreferencesView.isLoaded = isLoaded
if (!pluginListPreferencesView.visible) {
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
root.height += pluginListPreferencesView.childrenRect.height
} else {
root.height -= pluginListPreferencesView.childrenRect.height
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
}
}
Label {
id: pluginImage
Layout.leftMargin: 8
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
width: 30
background: Rectangle {
color: "transparent"
Image {
anchors.centerIn: parent
source: "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
mipmap: true
width: 32
height: 32
}
}
Connections {
target: enabledplugin
function onHidePreferences() {
root.height = 50
pluginListPreferencesView.visible = false
}
}
ColumnLayout {
anchors.fill: parent
Layout.preferredHeight: childrenRect.height
Label {
id: labelDeviceId
RowLayout {
Layout.fillWidth: true
Layout.leftMargin: 8
color: JamiTheme.textColor
font.pointSize: JamiTheme.settingsFontSize
font.kerning: true
text: pluginName === "" ? pluginId : pluginName
}
Label {
id: pluginImage
Layout.leftMargin: 8
Layout.alignment: Qt.AlignLeft | Qt.AlingVCenter
width: 30
background: Rectangle {
color: "transparent"
Image {
anchors.centerIn: parent
source: "file:" + pluginIcon
sourceSize: Qt.size(256, 256)
mipmap: true
width: 32
height: 32
}
}
}
Switch {
id: loadSwitch
property bool isHovering: false
Layout.rightMargin: 8
width: 20
Label {
id: labelDeviceId
Layout.fillWidth: true
Layout.leftMargin: 8
color: JamiTheme.textColor
ToolTip.visible: hovered
ToolTip.text: qsTr("Load/Unload")
font.pointSize: JamiTheme.settingsFontSize
font.kerning: true
text: pluginName === "" ? pluginId : pluginName
}
checked: isLoaded
onClicked: btnLoadPluginToggled()
Switch {
id: loadSwitch
property bool isHovering: false
Layout.rightMargin: 8
width: 20
background: Rectangle {
id: switchBackground
ToolTip.visible: hovered
ToolTip.text: qsTr("Load/Unload")
color: "transparent"
MouseArea {
id: btnMouseArea
hoverEnabled: true
onReleased: {
loadSwitch.clicked()
}
onEntered: {
loadSwitch.isHovering = true
}
onExited: {
loadSwitch.isHovering = false
checked: isLoaded
onClicked: {
btnLoadPluginToggled()
pluginListPreferencesView.isLoaded = root.isLoaded
}
background: Rectangle {
id: switchBackground
color: "transparent"
MouseArea {
id: btnMouseArea
hoverEnabled: true
onReleased: {
loadSwitch.clicked()
}
onEntered: {
loadSwitch.isHovering = true
}
onExited: {
loadSwitch.isHovering = false
}
}
}
}
}
PushButton {
id: btnPreferencesPlugin
PushButton {
id: btnPreferencesPlugin
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
Layout.rightMargin: 8
source: "qrc:/images/icons/round-settings-24px.svg"
normalColor: JamiTheme.primaryBackgroundColor
imageColor: JamiTheme.textColor
toolTipText: JamiStrings.showHidePrefs
Layout.alignment: Qt.AlingVCenter | Qt.AlignRight
Layout.rightMargin: 8
onClicked: btnPreferencesPluginClicked()
}
}
source: "qrc:/images/icons/round-settings-24px.svg"
normalColor: JamiTheme.primaryBackgroundColor
imageColor: JamiTheme.textColor
toolTipText: JamiStrings.showHidePrefs
PluginListPreferencesView {
id: pluginListPreferencesView
onClicked: btnPreferencesPluginClicked()
Layout.topMargin: 10
Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize
Layout.bottomMargin: JamiTheme.preferredMarginSize
Layout.minimumHeight: 1
Layout.preferredHeight: childrenRect.height
}
}
}
......@@ -48,7 +48,7 @@ Rectangle {
signal uninstalled
Connections{
Connections {
target: PluginAdapter
function onPreferenceChanged(pluginId) {
......@@ -58,7 +58,9 @@ Rectangle {
}
function resetPluginSlot() {
msgDialog.buttonCallBacks = [function () {resetPlugin()}]
msgDialog.buttonCallBacks = [function () {
resetPlugin()
}]
msgDialog.openWithParameters(qsTr("Reset preferences"),
qsTr("Are you sure you wish to reset "+ pluginName +
" preferences?"))
......@@ -79,17 +81,16 @@ Rectangle {
function uninstallPluginSlot() {
msgDialog.buttonCallBacks = [function () {
uninstallPlugin()
root.visible = false
}]
msgDialog.openWithParameters(qsTr("Uninstall plugin"),
qsTr("Are you sure you wish to uninstall " + pluginName + " ?"))
PluginAdapter.pluginHandlersUpdateStatus()
}
function uninstallPlugin() {
PluginModel.uninstallPlugin(pluginId)
uninstalled()
PluginAdapter.pluginUninstalled()
PluginAdapter.pluginHandlersUpdateStatus()
root.visible = false
}
function setPreference(pluginId, preferenceKey, preferenceNewValue)
......@@ -109,11 +110,6 @@ Rectangle {
buttonTitles: [qsTr("Ok"), qsTr("Cancel")]
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
SimpleMessageDialog.ButtonStyle.TintedBlack]
onAccepted: {
uninstallPlugin()
root.visible = false
}
}
ColumnLayout {
......@@ -192,7 +188,7 @@ Rectangle {
id: pluginPreferenceView
Layout.fillWidth: true
Layout.minimumHeight: 0
Layout.minimumHeight: 1
Layout.preferredHeight: childrenRect.height + 30
model: PluginAdapter.getPluginPreferencesModel(pluginId)
......
......@@ -31,12 +31,10 @@ import "../../commoncomponents"
Rectangle {
id: root
property PluginListPreferencesView pluginListPreferencesView
Connections {
target: pluginListPreferencesView
target: PluginAdapter
function onUninstalled() {
function onPluginUninstalled() {
pluginListView.model = PluginAdapter.getPluginSelectableModel()
}
}
......@@ -54,28 +52,8 @@ Rectangle {
PluginModel.unloadPlugin(pluginId)
else
loaded = PluginModel.loadPlugin(pluginId)
if (pluginListPreferencesView.pluginId === pluginId)
pluginListPreferencesView.isLoaded = loaded
PluginAdapter.pluginHandlersUpdateStatus()
}
function openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded) {
if (pluginListPreferencesView.pluginId == pluginId || pluginListPreferencesView.pluginId == "")
pluginListPreferencesView.visible = !pluginListPreferencesView.visible
if (!pluginListPreferencesView.visible) {
pluginListPreferencesView.pluginId = ""
} else {
pluginListPreferencesView.pluginName = pluginName
pluginListPreferencesView.pluginIcon = pluginIcon
pluginListPreferencesView.pluginId = pluginId
pluginListPreferencesView.isLoaded = isLoaded
}
}
function hidePreferences() {
pluginListPreferencesView.pluginId = ""
pluginListPreferencesView.visible = false
return loaded
}
JamiFileDialog {
......@@ -140,6 +118,7 @@ Rectangle {
Layout.fillWidth: true
Layout.minimumHeight: 0
Layout.preferredHeight: childrenRect.height
Layout.bottomMargin: 10
model: PluginAdapter.getPluginSelectableModel()
interactive: false
......@@ -148,7 +127,7 @@ Rectangle {
id: pluginItemDelegate
width: pluginListView.width
height: 50
implicitHeight: 50
pluginName: PluginName
pluginId: PluginId
......@@ -156,15 +135,7 @@ Rectangle {
isLoaded: IsLoaded
onBtnLoadPluginToggled: {
loadPluginSlot(pluginId, isLoaded)
pluginListView.model = PluginAdapter.getPluginSelectableModel()
}
onBtnPreferencesPluginClicked: openPreferencesPluginSlot(pluginName, pluginIcon, pluginId, isLoaded)
background: Rectangle {
anchors.fill: parent
color: JamiTheme.secondaryBackgroundColor
isLoaded = loadPluginSlot(pluginId, isLoaded)
}
}
}
......
......@@ -55,6 +55,8 @@ Rectangle {
ToggleSwitch {
id: enabledplugin
signal hidePreferences
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
Layout.topMargin: JamiTheme.preferredMarginSize
......@@ -69,7 +71,7 @@ Rectangle {
pluginListSettingsView.visible = checked
if (!pluginListSettingsView.visible) {
pluginListSettingsView.hidePreferences()
hidePreferences()
}
}
}
......@@ -82,23 +84,9 @@ Rectangle {
Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize
pluginListPreferencesView: pluginListPreferencesView
Layout.topMargin: JamiTheme.preferredMarginSize
Layout.minimumHeight: 0
Layout.preferredHeight: childrenRect.height
}
PluginListPreferencesView {
id: pluginListPreferencesView
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.fillWidth: true
Layout.leftMargin: JamiTheme.preferredMarginSize
Layout.rightMargin: JamiTheme.preferredMarginSize
Layout.bottomMargin: JamiTheme.preferredMarginSize
Layout.minimumHeight: 0
Layout.preferredHeight: childrenRect.height
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment