PlaceholderMessage

Search for usage in LXR

PlaceholderMessage Class Reference
Inheritance diagram for PlaceholderMessage:

Public Types

enum class  Type { Actionable , Informational }
 

Properties

string explanation
 
alias helpfulAction
 
alias hoveredLink
 
PActionIconGroup icon
 
string text
 
int type
 

Signals

void linkActivated (string link)
 
void linkHovered (string link)
 

Detailed Description

A placeholder message indicating that a view is empty.

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

The explanatory text is selectable and can contain clickable links. In this latter case, client code must implement an onLinkactivated: signal handler or the links will not work.

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:

used as a "this view is empty" message
import org.kde.kirigami as Kirigami
ListView {
id: listView
model: [...]
delegate: [...]
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: listView.count === 0
text: "There are no items in this list"
}
}
Used as a "here's how to proceed" message
import org.kde.kirigami as Kirigami
ListView {
id: listView
model: [...]
delegate: [...]
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: listView.count === 0
text: "Add an item to proceed"
helpfulAction: Kirigami.Action {
icon.name: "list-add"
text: "Add item..."
onTriggered: {
[...]
}
}
}
[...]
}
PActionIconGroup icon
This property provides an icon to display above the top text label.
alias helpfulAction
This property holds an action that helps the user proceed.
string text
This property holds the text to show in the placeholder label.
Used as a "there was a problem here" message
import org.kde.kirigami as Kirigami
Kirigami.Page {
id: root
readonly property bool networkConnected: [...]
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: root.networkConnected
icon.name: "network-disconnect"
text: "Unable to load content"
explanation: "Please try again later."
" Visit <a href="https://foo.com/com>this link</a> for more details."
onLinkActivated: link => Qt.openUrlExternally(link)
}
}
string explanation
This property holds the smaller explanatory text to show below the larger title-style text.
import org.kde.kirigami as Kirigami
Used as a "Here's what you do next" button
Kirigami.Page {
id: root
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: root.loading
helpfulAction: Kirigami.Action {
icon.name: "list-add"
text: "Add item..."
onTriggered: {
[...]
}
}
}
}
Since
2.12

Definition at line 119 of file PlaceholderMessage.qml.

Member Enumeration Documentation

◆ Type

enum class PlaceholderMessage::Type
strong

Definition at line 121 of file PlaceholderMessage.qml.

Property Documentation

◆ explanation

string PlaceholderMessage::explanation
read

This property holds the smaller explanatory text to show below the larger title-style text.

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

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

Since
5.80

Definition at line 158 of file PlaceholderMessage.qml.

◆ helpfulAction

alias PlaceholderMessage::helpfulAction
read

This property holds 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; if undefined, no button will appear below the text label.

Since
5.70

Definition at line 183 of file PlaceholderMessage.qml.

◆ hoveredLink

alias PlaceholderMessage::hoveredLink
read

This property holds the link embedded in the explanatory message text that the user is hovering over.

Remarks
This property is read-only

Definition at line 189 of file PlaceholderMessage.qml.

◆ icon

PActionIconGroup PlaceholderMessage::icon
read

This property provides an icon to display above the top text label.

Note
It accepts icon.name and icon.source to set the icon source. It is suggested to use icon.name.

Optional; if undefined, the message will have no icon. Falls back to undefined if the specified icon is not valid or cannot be loaded.

See also
org::kde::kirigami::private::ActionIconGroup
Since
5.70

Definition at line 171 of file PlaceholderMessage.qml.

◆ text

string PlaceholderMessage::text
read

This property holds the text to show in the 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.70

Definition at line 147 of file PlaceholderMessage.qml.

◆ type

int PlaceholderMessage::type
read

This property holds the PlaceholderMessage type.

The type of the message. This can be:

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

default: if a helpfulAction is provided this will be of type Actionable otherwise of type Informational.

Since
5.94

Definition at line 137 of file PlaceholderMessage.qml.

Member Function Documentation

◆ linkActivated

void PlaceholderMessage::linkActivated ( string link)
signal

This signal is emitted when a link is clicked or tapped in the explanatory message text.

Parameters
Theclicked or tapped link.

◆ linkHovered

void PlaceholderMessage::linkHovered ( string link)
signal

This signal is emitted when a link is hovered in the explanatory message text.

Parameters
Thehovered link.

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 Fri Jul 26 2024 11:54:50 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.