Disable composer/upload button when no permission
This commit is contained in:
parent
c2b7b458f9
commit
c4ee77ca15
2
TODO.md
2
TODO.md
|
@ -57,6 +57,7 @@
|
|||
|
||||
- UI
|
||||
- Scrollable popup
|
||||
- HDrawer snapping
|
||||
- Make theme error/etc text colors more like name colors
|
||||
- In account settings, display name field text should be colored
|
||||
- Way to open context menus without a right mouse button
|
||||
|
@ -103,7 +104,6 @@
|
|||
|
||||
- Server selection
|
||||
- Register/Reset for AddAccount page
|
||||
- Prevent using the composer if no permission (power levels)
|
||||
- Prevent using an alias if that user is not in the room or no permission
|
||||
- Spinner when loading past room events
|
||||
|
||||
|
|
|
@ -803,6 +803,7 @@ class MatrixClient(nio.AsyncClient):
|
|||
|
||||
inviter = getattr(room, "inviter", "") or ""
|
||||
levels = room.power_levels
|
||||
our_level = levels.get_user_level(self.user_id)
|
||||
|
||||
self.models[Room, self.user_id][room.room_id] = Room(
|
||||
room_id = room.room_id,
|
||||
|
@ -815,8 +816,8 @@ class MatrixClient(nio.AsyncClient):
|
|||
(room.avatar_url(inviter) or "") if inviter else "",
|
||||
left = left,
|
||||
|
||||
can_invite =
|
||||
levels.users.get(self.user_id, 0) >= levels.defaults.invite,
|
||||
can_invite = our_level >= levels.defaults.invite,
|
||||
can_send_messages = our_level >= levels.defaults.events_default,
|
||||
|
||||
last_event = last_ev,
|
||||
)
|
||||
|
|
|
@ -48,6 +48,7 @@ class Room(ModelItem):
|
|||
typing_members: List[str] = field(default_factory=list)
|
||||
|
||||
can_invite: bool = True
|
||||
can_send_messages: bool = True
|
||||
|
||||
# Event.serialized
|
||||
last_event: Optional[Dict[str, Any]] = field(default=None, repr=False)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
|
@ -23,13 +24,17 @@ ScrollView {
|
|||
|
||||
property alias backgroundColor: textAreaBackground.color
|
||||
property alias placeholderText: textArea.placeholderText
|
||||
property alias text: textArea.text
|
||||
property alias placeholderTextColor: textArea.placeholderTextColor
|
||||
property alias area: textArea
|
||||
property alias text: textArea.text
|
||||
property string disabledText: ""
|
||||
property string disabledTextColor: theme.controls.textArea.disabledText
|
||||
property var focusItemOnTab: null
|
||||
|
||||
|
||||
TextArea {
|
||||
id: textArea
|
||||
enabled: parent.enabled
|
||||
leftPadding: theme.spacing
|
||||
rightPadding: leftPadding
|
||||
topPadding: theme.spacing / 1.5
|
||||
|
@ -45,6 +50,7 @@ ScrollView {
|
|||
|
||||
placeholderTextColor: theme.controls.textArea.placeholderText
|
||||
color: theme.controls.textArea.text
|
||||
|
||||
background: Rectangle {
|
||||
id: textAreaBackground
|
||||
color: theme.controls.textArea.background
|
||||
|
@ -57,5 +63,37 @@ ScrollView {
|
|||
|
||||
KeyNavigation.priority: KeyNavigation.BeforeItem
|
||||
KeyNavigation.tab: focusItemOnTab
|
||||
|
||||
Binding on color {
|
||||
value: "transparent"
|
||||
when: ! textArea.enabled
|
||||
}
|
||||
|
||||
Binding on placeholderTextColor {
|
||||
value: "transparent"
|
||||
when: ! textArea.enabled
|
||||
}
|
||||
|
||||
Behavior on color { HColorAnimation {} }
|
||||
Behavior on placeholderTextColor { HColorAnimation {} }
|
||||
|
||||
HLabel {
|
||||
anchors.fill: parent
|
||||
visible: opacity > 0
|
||||
opacity: parent.enabled ? 0 : 1
|
||||
color: disabledTextColor
|
||||
text: disabledText
|
||||
|
||||
leftPadding: parent.leftPadding
|
||||
rightPadding: parent.rightPadding
|
||||
topPadding: parent.topPadding
|
||||
bottomPadding: parent.bottomPadding
|
||||
|
||||
wrapMode: parent.wrapMode
|
||||
font.family: parent.font.family
|
||||
font.pixelSize: parent.font.pixelSize
|
||||
|
||||
Behavior on opacity { HOpacityAnimator {} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,11 @@ Rectangle {
|
|||
saveName: "composer"
|
||||
saveId: [chat.roomId, writingUserId]
|
||||
|
||||
enabled: chat.roomInfo.can_send_messages
|
||||
disabledText:
|
||||
qsTr("You do not have permission to post in this room")
|
||||
placeholderText: qsTr("Type a message...")
|
||||
|
||||
backgroundColor: "transparent"
|
||||
area.tabStopDistance: 4 * 4 // 4 spaces
|
||||
area.focus: true
|
||||
|
@ -209,6 +213,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
HButton {
|
||||
enabled: chat.roomInfo.can_send_messages
|
||||
icon.name: "upload-file"
|
||||
backgroundColor: theme.chat.composer.uploadButton.background
|
||||
toolTip.text: qsTr("Send files")
|
||||
|
|
|
@ -171,11 +171,13 @@ controls:
|
|||
color text: colors.text
|
||||
color focusedText: colors.text
|
||||
color placeholderText: colors.dimText
|
||||
color disabledText: colors.dimText
|
||||
|
||||
textArea:
|
||||
color background: colors.inputBackground
|
||||
color text: colors.text
|
||||
color placeholderText: controls.textField.placeholderText
|
||||
color disabledText: controls.textField.disabledText
|
||||
|
||||
toolTip:
|
||||
int delay: 500
|
||||
|
|
Loading…
Reference in New Issue
Block a user