Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54651

SwipeDelegate: add swipe.pressed, close(), and completed()

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.7.0
    • Fix Version/s: 5.8.0 Alpha
    • Component/s: Quick: Controls 2
    • Labels:
      None

      Description

      When a side-action takes only part of SwipeDelegate's width, it's hard to know whether the side-action is pressed, because SwipeDelegate::pressed is true when pressing outside the side-action. Furtheremore, if a side-action is non-destructive, it would be nice to be able to close (animated) the swipe when the action is triggered.

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          id: window
      
          width: 360
          height: 360
          visible: true
      
          ListView {
              anchors.fill: parent
      
              model: 100
      
              delegate: SwipeDelegate {
                  id: delegate
                  width: parent.width
                  text: "SwipeDelegate" + index
                  down: pressed || swipe.complete
      
                  onClicked: {
                      if (swipe.complete)
                          swipe.close() // <==
                  }
      
                  swipe.right: Label {
                      x: parent.width - width
                      height: parent.height
                      text: "Action"
                      color: "white"
                      padding: 12
                      background: Rectangle {
                          color: delegate.swipe.pressed ? "darkred" : "red" // <==
                      }
                  }
              }
          }
      }
      

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              mitch_curtis Mitch Curtis
              Reporter:
              jpnurmi J-P Nurmi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes