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

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

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P2: Important
    • 5.8.0 Alpha
    • 5.7.0
    • Quick: Controls 2
    • 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

          For Gerrit Dashboard: QTBUG-54651
          # Subject Branch Project Status CR V

          Activity

            People

              mitch_curtis Mitch Curtis
              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