API Documentation

Documentation for developing SailfishOS applications

Remorse QML Type

Shows prompts that brief allow destructive actions to be canceled More...

Import Statement: import Sailfish.Silica 1.0

Methods

  • itemAction(Item parent, string text, object action, int timeout)
  • popupAction(Page parent, string text, object action, int timeout)

Detailed Description

The Remorse singleton allows destructive actions to be delayed until after a remorse period has elapsed. If a remorse prompt is tapped before this timeout expires, the action is canceled.

When a remorse prompt is activated by the itemAction() function a RemorseItem is created which fills the dimensions specified Item showing a countdown timer and allowing the user to cancel the action.

A prompt activated by the popupAction() function creates a RemorsePopup which is displayed across the top of specified Page showing a countdown timer and allowing the user to cancel the action.

Here is an example employing the Remorse singleton to remove a list item when a delegate is tapped or clear the entire list when a pulley menu option is activated:

 import QtQuick 2.2
 import Sailfish.Silica 1.0

 Page {
     id: page
     SilicaListView {
         anchors.fill: parent
         model: ListModel {
             id: listModel
             Component.onCompleted: {
                 for (var i=0; i<10; i++) {
                     append({"name": "Item " + i})
                 }
             }
         }

         delegate: BackgroundItem {
             id: myDelegate
             width: ListView.view.width

             Label {
                 text: model.name
                 anchors.centerIn: parent
             }

             onClicked: {
                 var idx = index
                 Remorse.itemAction(myDelegate, "Deleting", function() { listModel.remove(idx) })
             }
         }

         PullDownMenu {
             MenuItem {
                 text: "Clear"
                 onClicked: Remorse.popupAction(page, "Clearing", function() { listModel.clear() })
             }
         }
     }
 }

See also RemorseItem and RemorsePopup.

Method Documentation

itemAction(Item parent, string text, object action, int timeout)

Displays the RemorseItem in place of the parent item with the specified text.

Once the timeout has expired action will be called.

timeout is optional. The default value of 5000ms will be used if it is not supplied.

See also RemorseItem.


popupAction(Page parent, string text, object action, int timeout)

Displays a RemorsePopup across the top of parent with the specified text.

Once the timeout has expired action will be called.

timeout is optional. The default value of 5000ms will be used if it is not supplied.

See also RemorsePopup.


We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.