diff --git a/qml.qrc b/qml.qrc index e6f7b8c6798cc32488b3968973212ed65f92c62a..06ff49145fae2d124de4329b83e033480ece9bbe 100644 --- a/qml.qrc +++ b/qml.qrc @@ -61,7 +61,6 @@ <file>src/commoncomponents/LookupStatusLabel.qml</file> <file>src/commoncomponents/ListViewJami.qml</file> <file>src/commoncomponents/DeleteAccountDialog.qml</file> - <file>src/commoncomponents/MessageBox.qml</file> <file>src/wizardview/WizardView.qml</file> <file>src/wizardview/components/WelcomePage.qml</file> <file>src/wizardview/components/CreateAccountPage.qml</file> @@ -140,5 +139,6 @@ <file>src/mainview/components/UserInfoCallPage.qml</file> <file>src/commoncomponents/BaseDialog.qml</file> <file>src/commoncomponents/ModalPopup.qml</file> + <file>src/commoncomponents/SimpleMessageDialog.qml</file> </qresource> </RCC> diff --git a/src/commoncomponents/MessageBox.qml b/src/commoncomponents/MessageBox.qml deleted file mode 100644 index 16225a0c6e04c2bea19445cf2ee07c0ca87bb36a..0000000000000000000000000000000000000000 --- a/src/commoncomponents/MessageBox.qml +++ /dev/null @@ -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() - } -} diff --git a/src/commoncomponents/SimpleMessageDialog.qml b/src/commoncomponents/SimpleMessageDialog.qml new file mode 100644 index 0000000000000000000000000000000000000000..01a0c72b09c0773f385c9348a762fb5599e34969 --- /dev/null +++ b/src/commoncomponents/SimpleMessageDialog.qml @@ -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() + } + } + } + } + } + } +} diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index 1c37de9e662de23a81b9ea09518c36ccf53d6971..e27965c1a99318e44d8d3c6b75b96e85ebbaffec 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -113,6 +113,8 @@ MainApplication::MainApplication(int& argc, char** argv) void MainApplication::init() { + setWindowIcon(QIcon(":images/jami.ico")); + #ifdef Q_OS_LINUX if (!getenv("QT_QPA_PLATFORMTHEME")) setenv("QT_QPA_PLATFORMTHEME", "gtk3", true); diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 13a3acf79d0cc1a1ed92a254f2d394ba2bc0581c..195e38c014f060e94224b05add017d5e6c077ad2 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -549,7 +549,7 @@ Window { onSettingsViewWindowNeedToShowMainViewWindow: { mainViewWindowSidePanel.refreshAccountComboBox(0) - AccountAdapter.accountChanged(index) + AccountAdapter.accountChanged(0) toggleSettingsView() } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index a286317a2adc7ef6426c493029797215162fdd0a..13846c09565722def98e1e41a047fc47c053d1a4 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -98,12 +98,12 @@ Rectangle { JamiStrings.setPassword } - MessageBox { + SimpleMessageDialog { id: msgDialog - onAccepted: { - setPasswordButtonText() - } + buttonTitles: [qsTr("Ok")] + buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue] + buttonCallBacks: [setPasswordButtonText] } DeleteAccountDialog { @@ -125,7 +125,6 @@ Rectangle { onDoneSignal: { var title = success ? qsTr("Success") : qsTr("Error") - var iconMode = success ? StandardIcon.Information : StandardIcon.Critical var info switch(currentPurpose) { @@ -141,7 +140,7 @@ Rectangle { break } - msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok) + msgDialog.openWithParameters(title, info) } } @@ -166,9 +165,9 @@ Rectangle { if (exportPath.length > 0) { var isSuccessful = AccountAdapter.model.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"") var title = isSuccessful ? qsTr("Success") : qsTr("Error") - var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed - msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok) + + msgDialog.openWithParameters(title,info) } } } diff --git a/src/settingsview/components/LinkedDevices.qml b/src/settingsview/components/LinkedDevices.qml index 76e4127ceccd66100ca672419f19a63b55f8808c..759843d23861ec0a4adeb23ebe5b1faa1dd38a1d 100644 --- a/src/settingsview/components/LinkedDevices.qml +++ b/src/settingsview/components/LinkedDevices.qml @@ -88,17 +88,18 @@ ColumnLayout { onRevokeDeviceWithPassword: revokeDeviceWithIDAndPassword(idOfDevice, password) } - MessageBox { + SimpleMessageDialog { id: revokeDeviceMessageBox property string idOfDev: "" - title:qsTr("Remove Device") - text :qsTr("Are you sure you wish to remove this device?") - icon :StandardIcon.Information - standardButtons: StandardButton.Ok | StandardButton.Cancel + title: qsTr("Remove Device") + description: qsTr("Are you sure you wish to remove this device?") - onAccepted: revokeDeviceWithIDAndPassword(idOfDev,"") + buttonTitles: [qsTr("Ok"), qsTr("Cancel")] + buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue, + SimpleMessageDialog.ButtonStyle.TintedBlack] + buttonCallBacks: [function() {revokeDeviceWithIDAndPassword(idOfDev, "")}] } Label { diff --git a/src/settingsview/components/PluginListPreferencesView.qml b/src/settingsview/components/PluginListPreferencesView.qml index ec066e288b875ab810b176948308d1305ed03990..54c88078a81b517172ff9ade1271603b478d031d 100644 --- a/src/settingsview/components/PluginListPreferencesView.qml +++ b/src/settingsview/components/PluginListPreferencesView.qml @@ -46,7 +46,10 @@ Rectangle { signal uninstalled 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() { @@ -61,7 +64,12 @@ Rectangle { } 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() { @@ -79,13 +87,12 @@ Rectangle { PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) } - MessageDialog { - id: uninstallPluginMessageBox + SimpleMessageDialog { + id: msgDialog - title:qsTr("Uninstall plugin") - text :qsTr("Are you sure you wish to uninstall " + pluginName + " ?") - icon: StandardIcon.Warning - standardButtons: StandardButton.Ok | StandardButton.Cancel + buttonTitles: [qsTr("Ok"), qsTr("Cancel")] + buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue, + SimpleMessageDialog.ButtonStyle.TintedBlack] onAccepted: { 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 { anchors.left: root.left anchors.right: root.right