Commit 9eba0881 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳 Committed by LNJ

Add settings and functionality to change password on server

parent a95a2ab2
......@@ -7,6 +7,7 @@
<file alias="qml/AboutDialog.qml">src/qml/AboutDialog.qml</file>
<file alias="qml/GlobalDrawer.qml">src/qml/GlobalDrawer.qml</file>
<file alias="qml/EmptyChatPage.qml">src/qml/EmptyChatPage.qml</file>
<file alias="qml/elements/SubRequestAcceptSheet.qml">src/qml/elements/SubRequestAcceptSheet.qml</file>
<file alias="qml/elements/RosterAddContactSheet.qml">src/qml/elements/RosterAddContactSheet.qml</file>
<file alias="qml/elements/RosterRemoveContactSheet.qml">src/qml/elements/RosterRemoveContactSheet.qml</file>
......@@ -25,6 +26,11 @@
<file alias="qml/elements/EmojiPicker.qml">src/qml/elements/EmojiPicker.qml</file>
<file alias="qml/elements/TextAvatar.qml">src/qml/elements/TextAvatar.qml</file>
<file alias="qml/settings/SettingsItem.qml">src/qml/settings/SettingsItem.qml</file>
<file alias="qml/settings/SettingsPage.qml">src/qml/settings/SettingsPage.qml</file>
<file alias="qml/settings/SettingsSheet.qml">src/qml/settings/SettingsSheet.qml</file>
<file alias="qml/settings/ChangePassword.qml">src/qml/settings/ChangePassword.qml</file>
<file alias="qtquickcontrols2.conf">misc/qtquickcontrols2.conf</file>
</qresource>
</RCC>
......@@ -26,6 +26,8 @@
<file alias="tab-close.svg">3rdparty/breeze-icons/icons/actions/22/tab-close.svg</file>
<file alias="password-show-on.svg">3rdparty/breeze-icons/icons/actions/22/password-show-on.svg</file>
<file alias="password-show-off.svg">3rdparty/breeze-icons/icons/actions/22/password-show-off.svg</file>
<file alias="preferences-other.svg">3rdparty/breeze-icons/icons/actions/22/preferences-other.svg</file>
<file alias="window-close.svg">3rdparty/breeze-icons/icons/actions/16/window-close.svg</file>
</qresource>
<qresource prefix="/icons/breeze/actions/16">
......
......@@ -30,43 +30,55 @@
import org.kde.kirigami 2.0 as Kirigami
import im.kaidan.kaidan 1.0
import "settings"
Kirigami.GlobalDrawer {
id: globalDrawer
title: "Kaidan"
titleIcon: kaidan.utils.getResourcePath("images/kaidan.svg");
bannerImageSource: kaidan.utils.getResourcePath("images/banner.png");
// make drawer floating (overlay)
modal: true
// start with closed drawer
drawerOpen: false
// show open button on the left side
handleVisible: true
titleIcon: kaidan.utils.getResourcePath("images/kaidan.svg")
bannerImageSource: kaidan.utils.getResourcePath("images/banner.png")
SettingsSheet {
id: settingsSheet
}
actions: [
Kirigami.Action {
text: qsTr("Invite friends")
iconName: "mail-invitation"
onTriggered: {
kaidan.utils.copyToClipboard("https://i.kaidan.im/#" + kaidan.jid)
passiveNotification(qsTr("Invitation link copied to clipboard"))
kaidan.utils.copyToClipboard(
"https://i.kaidan.im/#" + kaidan.jid)
passiveNotification(
qsTr("Invitation link copied to clipboard"))
}
},
Kirigami.Action {
text: qsTr("Log out")
iconName: "system-shutdown"
onTriggered: {
// disconnect (open log in page)
kaidan.mainDisconnect(true)
}
},
Kirigami.Action {
text: qsTr("Settings")
iconName: "settings-configure"
onTriggered: {
// open settings page
if (Kirigami.Settings.isMobile)
pageStack.layers.push(settingsPage)
else
settingsSheet.open()
}
},
Kirigami.Action {
text: qsTr("Log out")
iconName: "system-shutdown"
onTriggered: {
// disconnect (open log in page)
kaidan.mainDisconnect(true);
}
},
Kirigami.Action {
text: qsTr("About")
iconName: "help-about"
onTriggered: {
// open about sheet
aboutDialog.open();
}
}
Kirigami.Action {
text: qsTr("About")
iconName: "help-about"
onTriggered: {
// open about sheet
aboutDialog.open()
}
}
]
}
......@@ -34,11 +34,11 @@ import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
Kirigami.OverlaySheet {
property string jid;
property string jid
onSheetOpenChanged: {
infoLabel.text = qsTr("Do you really want to delete the contact " +
"<b>%1</b> from your roster?").arg(jid);
infoLabel.text = qsTr("Do you really want to delete the contact "
+ "<b>%1</b> from your roster?").arg(jid)
}
ColumnLayout {
......@@ -70,8 +70,8 @@ Kirigami.OverlaySheet {
Controls.Button {
text: qsTr("Delete")
onClicked: {
kaidan.removeContact(jid);
close();
kaidan.removeContact(jid)
close()
}
Layout.fillWidth: true
}
......
......@@ -34,6 +34,7 @@ import org.kde.kirigami 2.3 as Kirigami
import StatusBar 0.1
import im.kaidan.kaidan 1.0
import "elements"
import "settings"
Kirigami.ApplicationWindow {
id: root
......@@ -61,7 +62,7 @@ Kirigami.ApplicationWindow {
// when the window was closed, disconnect from jabber server
onClosing: {
kaidan.mainDisconnect();
kaidan.mainDisconnect()
}
// load all pages
......@@ -69,6 +70,7 @@ Kirigami.ApplicationWindow {
Component {id: loginPage; LoginPage {}}
Component {id: rosterPage; RosterPage {}}
Component {id: emptyChatPage; EmptyChatPage {}}
Component {id: settingsPage; SettingsPage {}}
function passiveNotification(text) {
showPassiveNotification(text, "long")
......@@ -78,7 +80,7 @@ Kirigami.ApplicationWindow {
// close all pages (we don't know on which page we're on,
// thus we don't use replace)
while (pageStack.depth > 0)
pageStack.pop();
pageStack.pop()
// toggle global drawer
globalDrawer.enabled = false
......
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.3 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.4 as Kirigami
import im.kaidan.kaidan 1.0
Kirigami.Page {
topPadding: 0
Controls.BusyIndicator {
id: busyIndicator
visible: false
anchors.centerIn: parent
width: 60
height: 60
}
ColumnLayout {
id: content
anchors.fill: parent
spacing: 0
Kirigami.Heading {
Layout.alignment: Qt.Top
level: 2
text: qsTr("Change password")
}
Kirigami.FormLayout {
Layout.fillWidth: true
Controls.TextField {
id: oldPassword
echoMode: TextInput.Password
selectByMouse: true
Kirigami.FormData.label: qsTr("Current password:")
}
Controls.TextField {
id: password1
echoMode: TextInput.Password
selectByMouse: true
Kirigami.FormData.label: qsTr("New password:")
}
Controls.TextField {
id: password2
echoMode: TextInput.Password
selectByMouse: true
Kirigami.FormData.label: qsTr("New password (repeat):")
}
}
Kirigami.InlineMessage {
type: Kirigami.MessageType.Warning
visible: password1.text !== password2.text
text: qsTr("New passwords do not match.")
anchors.left: parent.left
anchors.right: parent.right
showCloseButton: true
}
Kirigami.InlineMessage {
id: currentPasswordInvalidMessage
visible: false
type: Kirigami.MessageType.Warning
text: qsTr("Current password is invalid.")
anchors.left: parent.left
anchors.right: parent.right
showCloseButton: true
}
Kirigami.InlineMessage {
visible: kaidan.connectionState !== Enums.StateConnected
type: Kirigami.MessageType.Error
text: qsTr("You need to be connected to change your password.")
anchors.left: parent.left
anchors.right: parent.right
}
Controls.Label {
Layout.fillWidth: true
text: qsTr("After changing your password, you will need to reenter "
+ "it on all your other devices.")
textFormat: Text.PlainText
wrapMode: Text.WordWrap
}
RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Controls.Button {
text: qsTr("Cancel")
onClicked: stack.pop()
Layout.fillWidth: true
}
Controls.Button {
text: qsTr("Change")
Layout.fillWidth: true
enabled: {
password1.text === password2.text && password1.text !== ""
&& kaidan.connectionState === Enums.StateConnected
}
onClicked: {
if (oldPassword.text !== kaidan.password) {
currentPasswordInvalidMessage.visible = true
return
}
kaidan.changePassword(password1.text)
content.visible = false
busyIndicator.visible = true
}
}
}
}
function handleChangeResult() {
busyIndicator.visible = false
stack.pop()
}
Component.onCompleted: {
kaidan.passwordChangeSucceeded.connect(handleChangeResult)
kaidan.passwordChangeFailed.connect(handleChangeResult)
}
Component.onDestruction: {
kaidan.passwordChangeSucceeded.disconnect(handleChangeResult)
kaidan.passwordChangeFailed.disconnect(handleChangeResult)
}
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
Kirigami.BasicListItem {
property string name
property string description
reserveSpaceForIcon: false
RowLayout {
ColumnLayout {
Kirigami.Heading {
text: name
textFormat: Text.PlainText
elide: Text.ElideRight
maximumLineCount: 1
level: 2
Layout.fillWidth: true
Layout.maximumHeight: Kirigami.Units.gridUnit * 1.5
}
Controls.Label {
Layout.fillWidth: true
text: description
wrapMode: Text.WordWrap
textFormat: Text.PlainText
font.pixelSize: 14
}
}
}
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.3 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.3 as Kirigami
import im.kaidan.kaidan 1.0
/**
* The settings page contains options to configure Kaidan.
*
* It is used on a new layer on mobile and inside of a Sheet on desktop.
*/
Kirigami.Page {
title: qsTr("Settings")
leftPadding: 0
topPadding: 0
rightPadding: 0
bottomPadding: 0
Controls.StackView {
id: stack
anchors.fill: parent
initialItem: settingsContent
clip: true
}
Component {
id: settingsContent
ColumnLayout {
spacing: 0
SettingsItem {
Layout.alignment: Qt.AlignTop
name: qsTr("Change password")
description: qsTr("Changes your account's password. You will need to re-enter it on your other devices.")
onClicked: stack.push(changePassword)
icon: "lock"
reserveSpaceForIcon: true
}
}
}
Component {id: changePassword; ChangePassword {}}
}
/*
* Kaidan - A user-friendly XMPP client for every device!
*
* Copyright (C) 2016-2019 Kaidan developers and contributors
* (see the LICENSE file for a full list of copyright authors)
*
* Kaidan 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.
*
* In addition, as a special exception, the author of Kaidan gives
* permission to link the code of its release with the OpenSSL
* project's "OpenSSL" library (or with modified versions of it that
* use the same license as the "OpenSSL" library), and distribute the
* linked executables. You must obey the GNU General Public License in
* all respects for all of the code used other than "OpenSSL". If you
* modify this file, you may extend this exception to your version of
* the file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
* Kaidan 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 Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.0 as Kirigami
/**
* This sheet is used on desktop systems instead of a new layer. It doesn't
* fill the complete width, so it looks a bit nicer on large screens.
*/
Kirigami.OverlaySheet {
ColumnLayout {
Kirigami.Heading {
Layout.fillWidth: true
text: settingsPage.title
}
SettingsPage {
Layout.preferredHeight: root.height * 0.9
Layout.maximumHeight: 500
id: settingsPage
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment