PlaceholderMessage

Search for usage in LXR

PlaceholderMessage Class Reference

Public Types

enum class  Type { Actionable , Informational }
 

Properties

string explanation
 
TAction helpfulAction
 
string iconName
 
string text
 
int type
 

Detailed Description

A placeholder message indicating that a list view is empty.

The message comprises a label with lightened text, an optional icon above the text, and an optional button below the text which can be used to easily show the user what to do next to add content to the view.

The top-level component is a ColumnLayout, so additional components items can simply be added as child items and they will be positioned sanely.

Example usage:

Shows how to use PlaceholderMessage to implement a "this view is empty" message
import QtQuick
import org.kde.plasma.extras as PlasmaExtras
ListView {
id: listView
model: [...]
delegate: [...]
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: listView.count == 0
text: "There are no items in this list"
}
}
A placeholder message indicating that a list view is empty.
Shows how to use PlaceholderMessage to implement a "here's how to proceed" message
import QtQuick
import QtQuick.Controls as QQC2
import org.kde.plasma.extras as PlasmaExtras
ListView {
id: listView
model: [...]
delegate: [...]
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: listView.count == 0
text: "Add an item to proceed"
helpfulAction: QQC2.Action {
icon.name: "list-add"
text: "Add item..."
onTriggered: {
[...]
}
}
}
[...]
}
TAction helpfulAction
helpfulAction: QtQuickControls2 Action An action that helps the user proceed.
string text
text: string The text to show as a placeholder label
Shows how to use PlaceholderMessage to implement a "there was a problem here" message
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
PlasmaComponents3.Page {
id: root
readonly property bool networkConnected: [...]
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: root.networkConnected
iconName: "network-disconnect"
text: "Unable to load content
explanation: "Please try again later"
}
}
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
Shows how to use PlaceholderMessage to implement a loading indicator
PlasmaComponents3.Page {
id: root
readonly property bool loading: [...]
readonly property int completionStatus: [...]
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.gridUnit * 4)
visible: root.loading
iconName: "my-awesome-app-icon"
text: "Loading this awesome app"
PlasmaComponents3.ProgressBar {
Layout.preferredWidth: Kirigami.Units.gridUnit * 20
value: root.completionStatus
from: 0
to: 100
}
}
}
import QtQuick.Controls as QQC2
import org.kde.plasma.components as PlasmaComponents3
import org.kde.plasma.extras as PlasmaExtras
Shows how to use PlaceholderMessage to implement a "Here's what you do next" button
PlasmaComponents3.Page {
id: root
PlasmaExtras.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: root.loading
icon.name: "list-add"
text: "Add item..."
onTriggered: {
[...]
}
}
}
}
Since
5.72

Definition at line 147 of file PlaceholderMessage.qml.

Member Enumeration Documentation

◆ Type

enum class PlaceholderMessage::Type
strong

Definition at line 149 of file PlaceholderMessage.qml.

Property Documentation

◆ explanation

string PlaceholderMessage::explanation
read

explanation: string Smaller explanatory text to show below the larger title-style text

Useful for providing a user-friendly explanation for how to proceed.

Optional; if not defined, the message will have no supplementary explanatory text.

Since
5.80

Definition at line 185 of file PlaceholderMessage.qml.

◆ helpfulAction

TAction PlaceholderMessage::helpfulAction
read

helpfulAction: QtQuickControls2 Action An action that helps the user proceed.

Typically used to guide the user to the next step for adding content or items to an empty view.

Optional

Since
5.72

Definition at line 207 of file PlaceholderMessage.qml.

◆ iconName

string PlaceholderMessage::iconName
read

iconName: string The icon to show above the text label.

Optional Falls back to undefined if the specified icon is not valid or cannot be loaded.

Since
5.72
See also
Icon::source

Definition at line 197 of file PlaceholderMessage.qml.

◆ text

string PlaceholderMessage::text
read

text: string The text to show as a placeholder label

Optional; if not defined, the message will have no large text label text. If both text: and explanation: are omitted, the message will have no text and only an icon, action button, and/or other custom content.

Since
5.72

Definition at line 173 of file PlaceholderMessage.qml.

◆ type

int PlaceholderMessage::type
read

The type of the message.

This can be:

  • PlasmaExtras.PlaceholderMessage.Type.Actionable: Makes it more attention-getting. Useful when the user is expected to interact with the message.
  • PlasmaExtras.PlaceholderMessage.Type.Informational: Makes it less prominent. Useful when the message in only informational.

By default if an helpfulAction is provided this will be of type Actionable otherwise of type Informational.

Since
5.94

Definition at line 162 of file PlaceholderMessage.qml.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Nov 17 2024 19:23:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.