Improve chatbar actions
Introduce a new type BusyAction that wraps Kirigami.Action with the added isBusy property. This makes QML a bit happier
This commit is contained in:
committed by
Tobias Fella
parent
ec36d519b1
commit
c69db9d375
@@ -74,11 +74,11 @@ QQC2.Control {
|
|||||||
* Each of these will be visualised in the ChatBar so new actions can be added
|
* Each of these will be visualised in the ChatBar so new actions can be added
|
||||||
* by appending to this list.
|
* by appending to this list.
|
||||||
*/
|
*/
|
||||||
property list<Kirigami.Action> actions: [
|
property list<BusyAction> actions: [
|
||||||
Kirigami.Action {
|
BusyAction {
|
||||||
id: attachmentAction
|
id: attachmentAction
|
||||||
|
|
||||||
property bool isBusy: root.currentRoom && root.currentRoom.hasFileUploading
|
isBusy: root.currentRoom && root.currentRoom.hasFileUploading
|
||||||
|
|
||||||
// Matrix does not allow sending attachments in replies
|
// Matrix does not allow sending attachments in replies
|
||||||
visible: _private.chatBarCache.replyId.length === 0 && _private.chatBarCache.attachmentPath.length === 0
|
visible: _private.chatBarCache.replyId.length === 0 && _private.chatBarCache.attachmentPath.length === 0
|
||||||
@@ -94,10 +94,10 @@ QQC2.Control {
|
|||||||
|
|
||||||
tooltip: text
|
tooltip: text
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
BusyAction {
|
||||||
id: emojiAction
|
id: emojiAction
|
||||||
|
|
||||||
property bool isBusy: false
|
isBusy: false
|
||||||
|
|
||||||
visible: !Kirigami.Settings.isMobile
|
visible: !Kirigami.Settings.isMobile
|
||||||
icon.name: "smiley"
|
icon.name: "smiley"
|
||||||
@@ -114,10 +114,10 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
tooltip: text
|
tooltip: text
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
BusyAction {
|
||||||
id: mapButton
|
id: mapButton
|
||||||
icon.name: "mark-location-symbolic"
|
icon.name: "mark-location-symbolic"
|
||||||
property bool isBusy: false
|
isBusy: false
|
||||||
text: i18nc("@action:button", "Send a Location")
|
text: i18nc("@action:button", "Send a Location")
|
||||||
displayHint: QQC2.AbstractButton.IconOnly
|
displayHint: QQC2.AbstractButton.IconOnly
|
||||||
|
|
||||||
@@ -128,10 +128,10 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
tooltip: text
|
tooltip: text
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
BusyAction {
|
||||||
id: pollButton
|
id: pollButton
|
||||||
icon.name: "amarok_playcount"
|
icon.name: "amarok_playcount"
|
||||||
property bool isBusy: false
|
isBusy: false
|
||||||
text: i18nc("@action:button", "Create a Poll")
|
text: i18nc("@action:button", "Create a Poll")
|
||||||
displayHint: QQC2.AbstractButton.IconOnly
|
displayHint: QQC2.AbstractButton.IconOnly
|
||||||
|
|
||||||
@@ -142,10 +142,10 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
tooltip: text
|
tooltip: text
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
BusyAction {
|
||||||
id: sendAction
|
id: sendAction
|
||||||
|
|
||||||
property bool isBusy: false
|
isBusy: false
|
||||||
|
|
||||||
icon.name: "document-send"
|
icon.name: "document-send"
|
||||||
text: i18nc("@action:button", "Send message")
|
text: i18nc("@action:button", "Send message")
|
||||||
@@ -363,6 +363,8 @@ QQC2.Control {
|
|||||||
Repeater {
|
Repeater {
|
||||||
model: root.actions
|
model: root.actions
|
||||||
delegate: QQC2.ToolButton {
|
delegate: QQC2.ToolButton {
|
||||||
|
id: actionDelegate
|
||||||
|
required property BusyAction modelData
|
||||||
icon.name: modelData.isBusy ? "" : (modelData.icon.name.length > 0 ? modelData.icon.name : modelData.icon.source)
|
icon.name: modelData.isBusy ? "" : (modelData.icon.name.length > 0 ? modelData.icon.name : modelData.icon.source)
|
||||||
onClicked: modelData.trigger()
|
onClicked: modelData.trigger()
|
||||||
|
|
||||||
@@ -373,7 +375,7 @@ QQC2.Control {
|
|||||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||||
|
|
||||||
contentItem: PieProgressBar {
|
contentItem: PieProgressBar {
|
||||||
visible: modelData.isBusy
|
visible: actionDelegate.modelData.isBusy
|
||||||
progress: root.currentRoom.fileUploadingProgress
|
progress: root.currentRoom.fileUploadingProgress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,4 +573,8 @@ QQC2.Control {
|
|||||||
textField.text = textField.text.substr(0, initialCursorPosition) + text + textField.text.substr(initialCursorPosition);
|
textField.text = textField.text.substr(0, initialCursorPosition) + text + textField.text.substr(initialCursorPosition);
|
||||||
textField.cursorPosition = initialCursorPosition + text.length;
|
textField.cursorPosition = initialCursorPosition + text.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component BusyAction : Kirigami.Action {
|
||||||
|
required property bool isBusy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user