left sidebar: bouncy command buttons

This commit is contained in:
end-4
2025-05-24 19:00:18 +02:00
parent 76abad2487
commit 2641c79d65
5 changed files with 71 additions and 61 deletions
@@ -271,6 +271,7 @@ int main(int argc, char* argv[]) {
id: suggestions
visible: root.suggestionList.length > 0 && messageInputField.text.length > 0
property int selectedIndex: 0
property int clickIndex: -1
Layout.fillWidth: true
spacing: 5
@@ -283,20 +284,12 @@ int main(int argc, char* argv[]) {
delegate: ApiCommandButton {
id: commandButton
colBackground: suggestions.selectedIndex === index ? Appearance.colors.colLayer2Hover : Appearance.colors.colLayer2
contentItem: RowLayout {
spacing: 5
StyledText {
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.m3colors.m3onSurface
text: modelData.displayName ?? modelData.name
}
StyledText {
visible: modelData.count !== undefined
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.m3colors.m3outline
text: modelData.count ?? ""
}
bounce: false
contentItem: StyledText {
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.m3colors.m3onSurface
horizontalAlignment: Text.AlignHCenter
text: modelData.displayName ?? modelData.name
}
onHoveredChanged: {
@@ -524,20 +517,25 @@ int main(int argc, char* argv[]) {
Item { Layout.fillWidth: true }
Repeater { // Command buttons
id: commandRepeater
model: commandButtonsRow.commandsShown
delegate: ApiCommandButton {
id: commandButton
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
onClicked: {
if(modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
messageInputField.text = commandRepresentation + " "
messageInputField.cursorPosition = messageInputField.text.length
messageInputField.forceActiveFocus()
ButtonGroup {
padding: 0
Repeater { // Command buttons
model: commandButtonsRow.commandsShown
delegate: ApiCommandButton {
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
onClicked: {
if(modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
messageInputField.text = commandRepresentation + " "
messageInputField.cursorPosition = messageInputField.text.length
messageInputField.forceActiveFocus()
}
if (modelData.name === "clear") {
messageInputField.text = ""
}
}
}
}
@@ -308,20 +308,24 @@ Item {
}
delegate: ApiCommandButton {
id: tagButton
colBackground: tagSuggestions.selectedIndex === index ? Appearance.colors.colLayer2Hover : Appearance.colors.colLayer2
bounce: false
contentItem: RowLayout {
anchors.centerIn: parent
spacing: 5
StyledText {
Layout.fillWidth: false
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.m3colors.m3onSurface
horizontalAlignment: Text.AlignRight
text: modelData.displayName ?? modelData.name
}
StyledText {
Layout.fillWidth: false
visible: modelData.count !== undefined
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignLeft
text: modelData.count ?? ""
}
}
@@ -615,22 +619,28 @@ Item {
Item { Layout.fillWidth: true }
Repeater { // Command buttons
id: commandRepeater
model: commandButtonsRow.commandsShown
delegate: ApiCommandButton {
id: tagButton
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
colBackground: Appearance.colors.colLayer2
ButtonGroup {
padding: 0
Repeater { // Command buttons
id: commandRepeater
model: commandButtonsRow.commandsShown
delegate: ApiCommandButton {
id: tagButton
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
colBackground: Appearance.colors.colLayer2
onClicked: {
if(modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
tagInputField.text = commandRepresentation + " "
tagInputField.cursorPosition = tagInputField.text.length
tagInputField.forceActiveFocus()
onClicked: {
if(modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
tagInputField.text = commandRepresentation + " "
tagInputField.cursorPosition = tagInputField.text.length
tagInputField.forceActiveFocus()
}
if (modelData.name === "clear") {
tagInputField.text = ""
}
}
}
}
@@ -6,17 +6,20 @@ import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
RippleButton {
GroupButton {
id: button
property string buttonText
implicitHeight: 30
leftPadding: 10
rightPadding: 10
horizontalPadding: 8
verticalPadding: 6
baseWidth: contentItem.implicitWidth + horizontalPadding * 2
clickedWidth: baseWidth + 20
baseHeight: contentItem.implicitHeight + verticalPadding * 2
colBackground: Appearance.colors.colLayer2
colBackgroundHover: Appearance.colors.colLayer2Hover
colRipple: Appearance.colors.colLayer2Active
colBackgroundActive: Appearance.colors.colLayer2Active
contentItem: StyledText {
horizontalAlignment: Text.AlignHCenter