[vlc-commits] [Git][videolan/vlc][master] qml: get rid of the state group in `SearchBox`
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Thu Sep 24 11:04:48 UTC 2026
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
7fc1ae98 by Fatih Uzunoglu at 2026-09-24T12:55:37+02:00
qml: get rid of the state group in `SearchBox`
`Popup` has its own states, it is not a good
idea to have a state group just to reflect
the `Popup`'s state. Besides, it also can
get mistakenly desynchronized with the `Popup`'s
own state.
This is applicable since 86533cd6.
- - - - -
1 changed file:
- modules/gui/qt/widgets/qml/SearchBox.qml
Changes:
=====================================
modules/gui/qt/widgets/qml/SearchBox.qml
=====================================
@@ -52,75 +52,17 @@ FocusScope {
property bool popBelow: true
property alias toggleButton: iconButton
property alias textField: textField
- readonly property bool expanded: (expandedState.state === "expanded")
+ readonly property bool expanded: popup.visible
// public functions
function expandAndFocus() {
- expandedState.state = "expanded"
+ popup.open()
textField.forceActiveFocus(Qt.ShortcutFocusReason)
}
function retract() {
- expandedState.state = ""
- }
-
- StateGroup {
- id: expandedState
-
- state: ""
-
- states: [
- State {
- name: "expanded"
-
- PropertyChanges {
- target: popup
- explicit: true
- height: popup.implicitHeight
- }
-
- PropertyChanges {
- target: iconButton
- checked: true
- }
- },
- State {
- name: ""
-
- PropertyChanges {
- target: textField
- text: ""
- }
-
- PropertyChanges {
- target: popup
- height: 0.0
- }
-
- PropertyChanges {
- target: iconButton
- focus: true
- checked: false
- }
- }
- ]
-
- transitions: Transition {
- id: transition
-
- from: ""; to: "expanded"
- reversible: true
-
- onRunningChanged: {
- if (running)
- textField.clip = true
- else
- textField.clip = false
- }
-
- NumberAnimation { property: "height"; easing.type: Easing.InOutSine; duration: VLCStyle.duration_long; }
- }
+ popup.close()
}
readonly property ColorContext colorContext: ColorContext {
@@ -138,13 +80,14 @@ FocusScope {
description: qsTr("Filter")
focus: true
+ checked: popup.visible
Navigation.parentItem: root
Navigation.downItem: root.popBelow ? textField : null
Navigation.upItem: root.popBelow ? null : textField
onClicked: {
- if (expandedState.state == "")
+ if (!popup.visible)
expandAndFocus()
else
root.retract()
@@ -169,17 +112,48 @@ FocusScope {
}
height: 0
- visible: (height > 0)
onOpened: {
textField.forceActiveFocus(iconButton.focusReason)
}
onClosed: {
- root.retract()
- textField.focus = false
- focus = false
- iconButton.focus = true
+ iconButton.forceActiveFocus(iconButton.focusReason)
+ }
+
+ onAboutToHide: {
+ textField.text = ""
+ }
+
+ component EnterExitTransition : Transition {
+ id: transition
+
+ property alias to: animation.to
+
+ NumberAnimation {
+ id: animation
+
+ property: "height"
+ easing.type: Easing.InOutSine
+ duration: VLCStyle.duration_long
+ }
+
+ onRunningChanged: {
+ if (running)
+ textField.clip = true
+ else
+ textField.clip = false
+ }
+ }
+
+ enter: EnterExitTransition {
+ // NOTE: It is intentional that `from` is not used.
+ to: popup.implicitHeight
+ }
+
+ exit: EnterExitTransition {
+ // NOTE: It is intentional that `from` is not used.
+ to: 0.0
}
contentItem: TextFieldExt {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7fc1ae989078a5df2a10acf0df7e498365703a0c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7fc1ae989078a5df2a10acf0df7e498365703a0c
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list