Rename some filers and folder for clarity

This commit is contained in:
miruka
2019-12-18 04:44:19 -04:00
parent 127f724357
commit 2bdf21d528
137 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,75 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
HPopup {
id: popup
onAboutToShow: okClicked = false
signal ok()
signal cancel()
default property alias boxData: box.body
property alias box: box
property bool fillAvailableHeight: false
property alias summary: summary
property alias details: details
property string okText: qsTr("OK")
property bool okEnabled: true
property bool okClicked: false
Binding on height {
value: popup.maximumPreferredHeight
when: popup.fillAvailableHeight
}
HBox {
id: box
implicitWidth: Math.min(
window.width - popup.leftMargin - popup.rightMargin,
theme.controls.popup.defaultWidth,
)
fillAvailableHeight: popup.fillAvailableHeight
clickButtonOnEnter: "ok"
buttonModel: [
{ name: "ok", text: okText, iconName: "ok", enabled: okEnabled},
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
]
buttonCallbacks: ({
ok: button => { okClicked = true; popup.ok(); popup.close() },
cancel: button => {
okClicked = false; popup.cancel(); popup.close()
},
})
Binding on height {
value: popup.maximumPreferredHeight
when: popup.fillAvailableHeight
}
HLabel {
id: summary
wrapMode: Text.Wrap
font.bold: true
visible: Boolean(text)
Layout.fillWidth: true
}
HLabel {
id: details
wrapMode: Text.Wrap
visible: Boolean(text)
Layout.fillWidth: true
}
}
}

View File

@@ -0,0 +1,17 @@
import QtQuick 2.12
BoxPopup {
summary.text: qsTr("Clear this room's messages?")
details.text: qsTr(
"The messages will only be removed on your side. " +
"They will be available again after you restart the application."
)
okText: qsTr("Clear")
box.focusButton: "ok"
onOk: py.callClientCoro(userId, "clear_events", [roomId])
property string userId: ""
property string roomId: ""
}

View File

@@ -0,0 +1,36 @@
import QtQuick 2.12
BoxPopup {
id: popup
summary.text: qsTr("Leave <i>%1</i> and lose the history?").arg(roomName)
summary.textFormat: Text.StyledText
details.text: qsTr(
"You will not be able to see the messages you received in " +
"this room anymore.\n\n" +
"If all members forget the room, it will be removed from the servers."
)
okText: qsTr("Forget")
box.focusButton: "ok"
onOk: py.callClientCoro(userId, "room_forget", [roomId], () => {
if (window.uiState.page === "Chat/Chat.qml" &&
window.uiState.pageProperties.userId === userId &&
window.uiState.pageProperties.roomId === roomId)
{
pageLoader.showPage("Default")
Qt.callLater(popup.destroy)
}
})
onCancel: canDestroy = true
onClosed: if (canDestroy) Qt.callLater(popup.destroy)
property string userId: ""
property string roomId: ""
property string roomName: ""
property bool canDestroy: false
}

View File

@@ -0,0 +1,120 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
BoxPopup {
id: popup
// fillAvailableHeight: true
summary.text: qsTr("Invite members to <i>%1</i>").arg(roomName)
summary.textFormat: Text.StyledText
okText: qsTr("Invite")
okEnabled: invitingAllowed && Boolean(inviteArea.text.trim())
onOpened: inviteArea.area.forceActiveFocus()
onInvitingAllowedChanged:
if (! invitingAllowed && inviteFuture) inviteFuture.cancel()
box.buttonCallbacks: ({
ok: button => {
button.loading = true
const inviteesLeft = inviteArea.text.trim().split(/\s+/).filter(
user => ! successfulInvites.includes(user)
)
inviteFuture = py.callClientCoro(
userId,
"room_mass_invite",
[roomId, ...inviteesLeft],
([successes, errors]) => {
if (errors.length < 1) {
popup.close()
return
}
successfulInvites = successes
failedInvites = errors
button.loading = false
}
)
},
cancel: button => {
if (inviteFuture) inviteFuture.cancel()
popup.close()
},
})
property string userId
property string roomId
property string roomName
property bool invitingAllowed: true
property var inviteFuture: null
property var successfulInvites: []
property var failedInvites: []
HScrollableTextArea {
id: inviteArea
focusItemOnTab: box.firstButton
area.placeholderText:
qsTr("User IDs (e.g. @bob:matrix.org @alice:localhost)")
Layout.fillWidth: true
Layout.fillHeight: true
}
HLabel {
id: errorMessage
visible: Layout.maximumHeight > 0
wrapMode: Text.Wrap
color: theme.colors.errorText
text:
invitingAllowed ?
allErrors :
qsTr("You do not have permission to invite members in this room")
Layout.maximumHeight: text ? implicitHeight : 0
Layout.fillWidth: true
readonly property string allErrors: {
// TODO: handle these: real user not found
const lines = []
for (let [user, error] of failedInvites) {
const type = py.getattr(
py.getattr(error, "__class__"), "__name__",
)
lines.push(
type === "InvalidUserId" ?
qsTr("%1 is not a valid user ID, expected format is " +
"@username:homeserver").arg(user) :
type === "UserNotFound" ?
qsTr("%1 not found, please verify the entered user ID")
.arg(user) :
type === "MatrixUnsupportedRoomVersion" ?
qsTr("%1's server does not support this room's version")
.arg(user) :
type === "MatrixForbidden" ?
qsTr("%1 is banned from this room")
.arg(user) :
qsTr("Unknown error while inviting %1: %2 - %3")
.arg(user).arg(type).arg(py.getattr(error, "args"))
)
}
return lines.join("\n\n")
}
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}

View File

@@ -0,0 +1,19 @@
import QtQuick 2.12
BoxPopup {
summary.text: qsTr("Leave <i>%1</i>?").arg(roomName)
summary.textFormat: Text.StyledText
details.text: qsTr(
"If this room is private, you will not be able to rejoin it."
)
okText: qsTr("Leave")
box.focusButton: "ok"
onOk: py.callClientCoro(userId, "room_leave", [roomId], leftCallback)
property string userId: ""
property string roomId: ""
property string roomName: ""
property var leftCallback: null
}

View File

@@ -0,0 +1,104 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
BoxPopup {
id: popup
okEnabled: Boolean(passwordField.text)
onAboutToShow: {
okClicked = false
acceptedPassword = ""
passwordValid = null
errorMessage.text = ""
}
onOpened: passwordField.forceActiveFocus()
property bool validateWhileTyping: false
property string acceptedPassword: ""
property var passwordValid: null
property alias field: passwordField
function verifyPassword(pass, callback) {
// Can be reimplemented when using this component.
// Pass to the callback true on success, false on invalid password,
// or a custom error message string.
callback(true)
}
box.buttonCallbacks: ({
ok: button => {
let password = passwordField.text
okClicked = true
button.loading = true
errorMessage.text = ""
verifyPassword(password, result => {
if (result === true) {
passwordValid = true
popup.acceptedPassword = password
popup.close()
} else if (result === false) {
passwordValid = false
} else {
errorMessage.text = result
}
button.loading = false
})
},
cancel: button => { popup.close() },
})
HRowLayout {
spacing: theme.spacing
Layout.fillWidth: true
HTextField {
id: passwordField
placeholderText: qsTr("Passphrase")
echoMode: TextInput.Password
focus: true
error: passwordValid === false
onTextChanged: passwordValid =
validateWhileTyping ? verifyPassword(text) : null
Layout.fillWidth: true
}
HIcon {
visible: Layout.preferredWidth > 0
svgName: passwordValid ? "ok" : "cancel"
colorize: passwordValid ?
theme.colors.positiveBackground :
theme.colors.negativeBackground
Layout.preferredWidth:
passwordValid === null ||
(validateWhileTyping && ! okClicked && ! passwordValid) ?
0 :implicitWidth
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
}
HLabel {
id: errorMessage
wrapMode: Text.Wrap
color: theme.colors.errorText
visible: Layout.maximumHeight > 0
Layout.maximumHeight: text ? implicitHeight : 0
Behavior on Layout.maximumHeight { HNumberAnimation {} }
Layout.fillWidth: true
}
}

View File

@@ -0,0 +1,60 @@
import QtQuick 2.12
BoxPopup {
id: popup
summary.text: qsTr("Backup your decryption keys before signing out?")
details.text: qsTr(
"Signing out will delete your device's information and the keys " +
"required to decrypt messages in encrypted rooms.\n\n" +
"You can export your keys to a passphrase-protected file " +
"before signing out.\n\n" +
"This will allow you to restore access to your messages when " +
"you sign in again, by importing this file in your account settings."
)
box.focusButton: "ok"
box.buttonModel: [
{ name: "ok", text: qsTr("Export keys"), iconName: "export-keys" },
{ name: "signout", text: qsTr("Sign out now"), iconName: "sign-out",
iconColor: theme.colors.middleBackground },
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
]
box.buttonCallbacks: ({
ok: button => {
utils.makeObject(
"Dialogs/ExportKeys.qml",
mainUI,
{ userId },
obj => {
button.loading = Qt.binding(() => obj.exporting)
obj.done.connect(() => {
box.buttonCallbacks["signout"](button)
})
obj.dialog.open()
}
)
},
signout: button => {
okClicked = true
popup.ok()
if ((modelSources["Account"] || []).length < 2) {
pageLoader.showPage("AddAccount/AddAccount")
} else if (window.uiState.pageProperties.userId === userId) {
pageLoader.showPage("Default")
}
py.callCoro("logout_client", [userId])
popup.close()
},
cancel: button => { okClicked = false; popup.cancel(); popup.close() },
})
property string userId: ""
}