Add room context menu with Leave/Decline invite

This commit is contained in:
miruka 2019-08-21 14:58:57 -04:00
parent fea2178461
commit 6067c8ec96
5 changed files with 56 additions and 21 deletions

20
TODO.md
View File

@ -13,16 +13,19 @@
- Hide when window too small - Hide when window too small
- Also save/load its size - Also save/load its size
- Is auto-sizing actually needed, or can we just set a default manual size? - Is auto-sizing actually needed, or can we just set a default manual size?
- Reducable room sidepane, swipe to show full-window
- When qml syntax highlighting supports ES6 string interpolation, use them - When qml syntax highlighting supports ES6 string interpolation, use them
- Fixes - Fixes
- Reloading config files (cache) - Reloading config files (cache)
- Run import in thread and AsyncClient.olm functions, they block async loop - Run import in thread and AsyncClient.olm functions, they block async loop
- Handle import keys errors - Handle import keys errors
- Show error box if uploading avatar fails
- Don't strip user spacing in html - Don't strip user spacing in html
- Keyboard flicking against top/bottom edge
- Do something when access token is invalid - Do something when access token is invalid
- Keyboard flicking against top/bottom edge
- Message position after daybreak delegate (fixed by commit 57b1313 ?) - Message position after daybreak delegate (fixed by commit 57b1313 ?)
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342) - [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb` - Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
@ -49,13 +52,12 @@
- When starting a long task, e.g. importing keys, quitting the page, - When starting a long task, e.g. importing keys, quitting the page,
and coming back, show the buttons as still loading until operation is done and coming back, show the buttons as still loading until operation is done
- Make invite/left banners look better in column mode - Make invite/left banners look better in column mode
- Responses - Replies
- Messages editing - Messages editing
- Code highlighting - Code highlighting
- Support GIF avatars - Support GIF avatars
- When reduced, show the full-window sidepane instead of Default page
- Adapt shortcuts flicking speed to font size and DPI - Adapt shortcuts flicking speed to font size and DPI
- Show error box if uploading avatar fails
- EditAccount page: - EditAccount page:
- Remove account from client - Remove account from client
- state: Set UI state page to Default.qml when account is removed - state: Set UI state page to Default.qml when account is removed
@ -66,22 +68,20 @@
- Add an explanation tooltip - Add an explanation tooltip
- Prevent sending messages with an user not in room - Prevent sending messages with an user not in room
- Support \ escaping - Support \ escaping
- Improve avatar tooltips position, add stuff to room tooltips (last msg?) - Accept drag and dropping a picture to set avatar
- Accept drag and dropping a picture in account settings to set avatar
- Improve avatar tooltips position, add stuff to room tooltips (last msg?)
- Show something when connection is lost or 429s happen - Show something when connection is lost or 429s happen
- "Rejoin" LeftBanner button if room is public - "Rejoin" LeftBanner button if room is public
- Daybreak color - Daybreak color
- Conversation breaks: show time of first new msg after break instead of big - Conversation breaks: show time of first new msg after break instead of big
blank space blank space
- Replies
- Sidepane - Sidepane
- Header back button when reduced - Header back button when reduced
- Better look for arrows and option button when collapsed - Better look for arrows and option button when collapsed
- Way to put it back to auto-sizing (snap) - Show it when hovering/hitting focus keybind on the left when collapsed
- Show it when hovering on the left when collapsed/reduced
- Ability to drag on any place of the pane to resize - Ability to drag on any place of the pane to resize
- Reducable room sidepane, swipe to show full-window
- Invite to room - Invite to room
- Server selection - Server selection

5
src/qml/Base/HMenu.qml Normal file
View File

@ -0,0 +1,5 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
Menu {
}

View File

@ -0,0 +1,5 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
MenuItem {
}

View File

@ -20,6 +20,8 @@ HButton {
readonly property alias rightInfo: rightInfo readonly property alias rightInfo: rightInfo
readonly property alias subtitle: subtitle readonly property alias subtitle: subtitle
property HMenu contextMenu: HMenu {}
property Item image property Item image
property Item details: HColumnLayout { property Item details: HColumnLayout {
@ -75,14 +77,6 @@ HButton {
onActivated: view.currentIndex = model.index onActivated: view.currentIndex = model.index
onClicked: {
view.highlightRangeMode = ListView.NoHighlightRange
view.highlightMoveDuration = 0
activated()
view.highlightRangeMode = ListView.ApplyRange
view.highlightMoveDuration = theme.animationDuration
}
Timer { Timer {
interval: 100 interval: 100
@ -91,4 +85,25 @@ HButton {
// Component.onCompleted won't work for this // Component.onCompleted won't work for this
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
} }
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {
view.highlightRangeMode = ListView.NoHighlightRange
view.highlightMoveDuration = 0
activated()
view.highlightRangeMode = ListView.ApplyRange
view.highlightMoveDuration = theme.animationDuration
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: if (contextMenu.count > 0) contextMenu.popup()
}
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onLongPressed: if (contextMenu.count > 0) contextMenu.popup()
}
} }

View File

@ -18,6 +18,9 @@ HTileDelegate {
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
readonly property bool invited:
model.data.inviter_id && ! model.data.left
readonly property var eventDate: readonly property var eventDate:
model.data.last_event ? model.data.last_event.date : null model.data.last_event ? model.data.last_event.date : null
@ -38,9 +41,7 @@ HTileDelegate {
svgName: "invite-received" svgName: "invite-received"
visible: Layout.maximumWidth > 0 visible: Layout.maximumWidth > 0
Layout.maximumWidth: Layout.maximumWidth: invited ? implicitWidth : 0
model.data.inviter_id && ! model.data.left ?
implicitWidth : 0
Behavior on Layout.maximumWidth { HNumberAnimation {} } Behavior on Layout.maximumWidth { HNumberAnimation {} }
} }
@ -74,4 +75,13 @@ HTileDelegate {
ev.sender_name, ev.sender_id ev.sender_name, ev.sender_id
) + ": " + ev.inline_content ) + ": " + ev.inline_content
} }
contextMenu: HMenu {
HMenuItem {
text: invited ? qsTr("&Decline invite") : qsTr("&Leave")
onTriggered: py.callClientCoro(
model.user_id, "room_leave", [model.data.room_id]
)
}
}
} }