mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-05 14:43:39 +02:00
dialog: remove MessageDialog to jami customized style
Change-Id: I67230d9395a1f25214692a24f099d4306b6b1dc9
This commit is contained in:
parent
87a4602b9a
commit
3409d00193
8 changed files with 161 additions and 75 deletions
2
qml.qrc
2
qml.qrc
|
@ -61,7 +61,6 @@
|
||||||
<file>src/commoncomponents/LookupStatusLabel.qml</file>
|
<file>src/commoncomponents/LookupStatusLabel.qml</file>
|
||||||
<file>src/commoncomponents/ListViewJami.qml</file>
|
<file>src/commoncomponents/ListViewJami.qml</file>
|
||||||
<file>src/commoncomponents/DeleteAccountDialog.qml</file>
|
<file>src/commoncomponents/DeleteAccountDialog.qml</file>
|
||||||
<file>src/commoncomponents/MessageBox.qml</file>
|
|
||||||
<file>src/wizardview/WizardView.qml</file>
|
<file>src/wizardview/WizardView.qml</file>
|
||||||
<file>src/wizardview/components/WelcomePage.qml</file>
|
<file>src/wizardview/components/WelcomePage.qml</file>
|
||||||
<file>src/wizardview/components/CreateAccountPage.qml</file>
|
<file>src/wizardview/components/CreateAccountPage.qml</file>
|
||||||
|
@ -140,5 +139,6 @@
|
||||||
<file>src/mainview/components/UserInfoCallPage.qml</file>
|
<file>src/mainview/components/UserInfoCallPage.qml</file>
|
||||||
<file>src/commoncomponents/BaseDialog.qml</file>
|
<file>src/commoncomponents/BaseDialog.qml</file>
|
||||||
<file>src/commoncomponents/ModalPopup.qml</file>
|
<file>src/commoncomponents/ModalPopup.qml</file>
|
||||||
|
<file>src/commoncomponents/SimpleMessageDialog.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2020 by Savoir-faire Linux
|
|
||||||
* Author: Yang Wang <yang.wang@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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick.Controls 2.14
|
|
||||||
import QtQuick.Layouts 1.14
|
|
||||||
import QtQuick.Controls.Styles 1.4
|
|
||||||
import QtQuick.Dialogs 1.3
|
|
||||||
|
|
||||||
MessageDialog {
|
|
||||||
id: messageBox
|
|
||||||
|
|
||||||
visible: false
|
|
||||||
modality: Qt.NonModal
|
|
||||||
width: 300
|
|
||||||
height: 200
|
|
||||||
|
|
||||||
function openWithParameters(titleToDisplay, infoToDisplay, infoIconMode = StandardIcon.Information, buttons = StandardButton.Ok){
|
|
||||||
title = titleToDisplay
|
|
||||||
text = infoToDisplay
|
|
||||||
icon = infoIconMode
|
|
||||||
standardButtons = buttons
|
|
||||||
messageBox.open()
|
|
||||||
}
|
|
||||||
}
|
|
128
src/commoncomponents/SimpleMessageDialog.qml
Normal file
128
src/commoncomponents/SimpleMessageDialog.qml
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020 by Savoir-faire Linux
|
||||||
|
* Author: Mingrui Zhang <mingrui.zhang@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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.14
|
||||||
|
import QtQuick.Layouts 1.14
|
||||||
|
import net.jami.Models 1.0
|
||||||
|
import net.jami.Adapters 1.0
|
||||||
|
|
||||||
|
BaseDialog {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// TODO: make MaterialButton ButtonStyle
|
||||||
|
enum ButtonStyle {
|
||||||
|
TintedBlue,
|
||||||
|
TintedBlack,
|
||||||
|
TintedRed
|
||||||
|
}
|
||||||
|
|
||||||
|
property var buttonTitles: []
|
||||||
|
property var buttonCallBacks: []
|
||||||
|
property var buttonStyles: []
|
||||||
|
property alias description: descriptionText.text
|
||||||
|
|
||||||
|
function openWithParameters(title, info) {
|
||||||
|
root.title = title
|
||||||
|
descriptionText.text = info
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Rectangle {
|
||||||
|
id: simpleMessageDialogContentRect
|
||||||
|
|
||||||
|
implicitWidth: Math.max(JamiTheme.preferredDialogWidth,
|
||||||
|
buttonTitles.length * (JamiTheme.preferredFieldWidth / 2
|
||||||
|
+ JamiTheme.preferredMarginSize))
|
||||||
|
implicitHeight: JamiTheme.preferredDialogHeight / 2
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: descriptionText
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
Layout.preferredWidth: JamiTheme.preferredDialogWidth - JamiTheme.preferredMarginSize
|
||||||
|
Layout.topMargin: JamiTheme.preferredMarginSize
|
||||||
|
|
||||||
|
font.pointSize: JamiTheme.menuFontSize - 2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: JamiTheme.preferredMarginSize
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||||
|
Layout.bottomMargin: JamiTheme.preferredMarginSize
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: buttonTitles.length
|
||||||
|
MaterialButton {
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Layout.preferredWidth: JamiTheme.preferredFieldWidth / 2
|
||||||
|
Layout.preferredHeight: JamiTheme.preferredFieldHeight
|
||||||
|
|
||||||
|
color: {
|
||||||
|
switch(buttonStyles[modelData]) {
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlue:
|
||||||
|
return JamiTheme.buttonTintedBlue
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlack:
|
||||||
|
return JamiTheme.buttonTintedBlack
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedRed:
|
||||||
|
return JamiTheme.buttonTintedRed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hoveredColor: {
|
||||||
|
switch(buttonStyles[modelData]) {
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlue:
|
||||||
|
return JamiTheme.buttonTintedBlueHovered
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlack:
|
||||||
|
return JamiTheme.buttonTintedBlackHovered
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedRed:
|
||||||
|
return JamiTheme.buttonTintedRedHovered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pressedColor: {
|
||||||
|
switch(buttonStyles[modelData]) {
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlue:
|
||||||
|
return JamiTheme.buttonTintedBluePressed
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedBlack:
|
||||||
|
return JamiTheme.buttonTintedBlackPressed
|
||||||
|
case SimpleMessageDialog.ButtonStyle.TintedRed:
|
||||||
|
return JamiTheme.buttonTintedRedPressed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outlined: true
|
||||||
|
|
||||||
|
text: buttonTitles[modelData]
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (buttonCallBacks[modelData])
|
||||||
|
buttonCallBacks[modelData]()
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -113,6 +113,8 @@ MainApplication::MainApplication(int& argc, char** argv)
|
||||||
void
|
void
|
||||||
MainApplication::init()
|
MainApplication::init()
|
||||||
{
|
{
|
||||||
|
setWindowIcon(QIcon(":images/jami.ico"));
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
if (!getenv("QT_QPA_PLATFORMTHEME"))
|
if (!getenv("QT_QPA_PLATFORMTHEME"))
|
||||||
setenv("QT_QPA_PLATFORMTHEME", "gtk3", true);
|
setenv("QT_QPA_PLATFORMTHEME", "gtk3", true);
|
||||||
|
|
|
@ -549,7 +549,7 @@ Window {
|
||||||
|
|
||||||
onSettingsViewWindowNeedToShowMainViewWindow: {
|
onSettingsViewWindowNeedToShowMainViewWindow: {
|
||||||
mainViewWindowSidePanel.refreshAccountComboBox(0)
|
mainViewWindowSidePanel.refreshAccountComboBox(0)
|
||||||
AccountAdapter.accountChanged(index)
|
AccountAdapter.accountChanged(0)
|
||||||
toggleSettingsView()
|
toggleSettingsView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,12 +98,12 @@ Rectangle {
|
||||||
JamiStrings.setPassword
|
JamiStrings.setPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox {
|
SimpleMessageDialog {
|
||||||
id: msgDialog
|
id: msgDialog
|
||||||
|
|
||||||
onAccepted: {
|
buttonTitles: [qsTr("Ok")]
|
||||||
setPasswordButtonText()
|
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue]
|
||||||
}
|
buttonCallBacks: [setPasswordButtonText]
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteAccountDialog {
|
DeleteAccountDialog {
|
||||||
|
@ -125,7 +125,6 @@ Rectangle {
|
||||||
|
|
||||||
onDoneSignal: {
|
onDoneSignal: {
|
||||||
var title = success ? qsTr("Success") : qsTr("Error")
|
var title = success ? qsTr("Success") : qsTr("Error")
|
||||||
var iconMode = success ? StandardIcon.Information : StandardIcon.Critical
|
|
||||||
|
|
||||||
var info
|
var info
|
||||||
switch(currentPurpose) {
|
switch(currentPurpose) {
|
||||||
|
@ -141,7 +140,7 @@ Rectangle {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok)
|
msgDialog.openWithParameters(title, info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,9 +165,9 @@ Rectangle {
|
||||||
if (exportPath.length > 0) {
|
if (exportPath.length > 0) {
|
||||||
var isSuccessful = AccountAdapter.model.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"")
|
var isSuccessful = AccountAdapter.model.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"")
|
||||||
var title = isSuccessful ? qsTr("Success") : qsTr("Error")
|
var title = isSuccessful ? qsTr("Success") : qsTr("Error")
|
||||||
var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical
|
|
||||||
var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed
|
var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed
|
||||||
msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok)
|
|
||||||
|
msgDialog.openWithParameters(title,info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,17 +88,18 @@ ColumnLayout {
|
||||||
onRevokeDeviceWithPassword: revokeDeviceWithIDAndPassword(idOfDevice, password)
|
onRevokeDeviceWithPassword: revokeDeviceWithIDAndPassword(idOfDevice, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox {
|
SimpleMessageDialog {
|
||||||
id: revokeDeviceMessageBox
|
id: revokeDeviceMessageBox
|
||||||
|
|
||||||
property string idOfDev: ""
|
property string idOfDev: ""
|
||||||
|
|
||||||
title: qsTr("Remove Device")
|
title: qsTr("Remove Device")
|
||||||
text :qsTr("Are you sure you wish to remove this device?")
|
description: qsTr("Are you sure you wish to remove this device?")
|
||||||
icon :StandardIcon.Information
|
|
||||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
||||||
|
|
||||||
onAccepted: revokeDeviceWithIDAndPassword(idOfDev,"")
|
buttonTitles: [qsTr("Ok"), qsTr("Cancel")]
|
||||||
|
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
|
||||||
|
SimpleMessageDialog.ButtonStyle.TintedBlack]
|
||||||
|
buttonCallBacks: [function() {revokeDeviceWithIDAndPassword(idOfDev, "")}]
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|
|
@ -46,7 +46,10 @@ Rectangle {
|
||||||
signal uninstalled
|
signal uninstalled
|
||||||
|
|
||||||
function resetPluginSlot() {
|
function resetPluginSlot() {
|
||||||
resetPluginMessageBox.open()
|
msgDialog.buttonCallBacks = [function () {resetPlugin()}]
|
||||||
|
msgDialog.openWithParameters(qsTr("Reset preferences"),
|
||||||
|
qsTr("Are you sure you wish to reset "+ pluginName +
|
||||||
|
" preferences?"))
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetPlugin() {
|
function resetPlugin() {
|
||||||
|
@ -61,7 +64,12 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPluginSlot() {
|
function uninstallPluginSlot() {
|
||||||
uninstallPluginMessageBox.open()
|
msgDialog.buttonCallBacks = [function () {
|
||||||
|
uninstallPlugin()
|
||||||
|
root.visible = false
|
||||||
|
}]
|
||||||
|
msgDialog.openWithParameters(qsTr("Uninstall plugin"),
|
||||||
|
qsTr("Are you sure you wish to uninstall " + pluginName + " ?"))
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPlugin() {
|
function uninstallPlugin() {
|
||||||
|
@ -79,13 +87,12 @@ Rectangle {
|
||||||
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog {
|
SimpleMessageDialog {
|
||||||
id: uninstallPluginMessageBox
|
id: msgDialog
|
||||||
|
|
||||||
title:qsTr("Uninstall plugin")
|
buttonTitles: [qsTr("Ok"), qsTr("Cancel")]
|
||||||
text :qsTr("Are you sure you wish to uninstall " + pluginName + " ?")
|
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue,
|
||||||
icon: StandardIcon.Warning
|
SimpleMessageDialog.ButtonStyle.TintedBlack]
|
||||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
uninstallPlugin()
|
uninstallPlugin()
|
||||||
|
@ -93,17 +100,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog {
|
|
||||||
id: resetPluginMessageBox
|
|
||||||
|
|
||||||
title:qsTr("Reset preferences")
|
|
||||||
text :qsTr("Are you sure you wish to reset "+ pluginName + " preferences?")
|
|
||||||
icon: StandardIcon.Warning
|
|
||||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
||||||
|
|
||||||
onAccepted: resetPlugin()
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.left: root.left
|
anchors.left: root.left
|
||||||
anchors.right: root.right
|
anchors.right: root.right
|
||||||
|
|
Loading…
Add table
Reference in a new issue