ConvergentContextMenu

Search for usage in LXR

ConvergentContextMenu Class Reference

Properties

listTAction actions
 
Item headerContentItem
 

Signals

void closed ()
 

Public Member Functions

void popup (parent=null, position=null)
 

Detailed Description

Menu popup that appears as a tradional menu on desktop and as a bottom drawer mobile.

ConvergentContextMenu uses abstract Controls.Action and Kirigami.Action to build the traditional menu on desktopn and the bottom drawer on mobile. Most properties of Kirigami.Action are supported including nested actions.

import QtQuick.Controls as Controls
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.components as Components
import org.kde.kirigamiaddons.formcard as FormCard
Components.ConvergentContextMenu {
id: root
headerContentItem: RowLayout {
spacing: Kirigami.Units.smallSpacing
Kirigami.Avatar { ... }
Kirigami.Heading {
level: 2
text: "Room Name"
}
}
Controls.Action {
text: i18nc("@action:inmenu", "Simple Action")
}
Kirigami.Action {
text: i18nc("@action:inmenu", "Nested Action")
Controls.Action { ... }
Controls.Action { ... }
Controls.Action { ... }
}
Kirigami.Action {
text: i18nc("@action:inmenu", "Nested Action with Multiple Choices")
Kirigami.Action {
text: i18nc("@action:inmenu", "Follow Global Settings")
checkable: true
autoExclusive: true // Since KF 6.10
}
Kirigami.Action {
text: i18nc("@action:inmenu", "Enabled")
checkable: true
autoExclusive: true // Since KF 6.10
}
Kirigami.Action {
text: i18nc("@action:inmenu", "Disabled")
checkable: true
autoExclusive: true // Since KF 6.10
}
}
// custom FormCard delegate only supported on mobile
Kirigami.Action {
visible: Kirigami.Settings.isMobile
displayComponent: FormCard.FormButtonDelegate { ... }
}
}
QString i18nc(const char *context, const char *text, const TYPE &arg...)

{qml}

When creating a menu for a ListView, avoid creating a ConvergentContextMenu for each delegate and instead create a global ConvergentContextMenu for the ListView or use a Component and dynamically instanciate the context menu on demand:

import QtQuick
import QtQuick.Controls as Controls
import org.kde.kirigamiaddons.components as Addons
ListView {
model: 10
delegate: Controls.ItemDelegate {
text: index
function openContextMenu(): void {
const item = menu.createObject(Controls.Overlay.overlay, {
index,
});
item.popup();
}
onPressAndHold: openContextMenu()
// Since Qt 6.9
Controls.ContextMenu.onRequested: (position) => openContextMenu()
// Before Qt 6.9
TapHandler {
acceptedButtons: Qt.RightButton
onSingleTapped: (eventPoint, button) => {
openContextMenu();
}
}
}
Component {
id: menu
Addons.ConvergentContextMenu {
required property int index
Controls.Action {
text: i18nc("@action:inmenu", "Action 1")
}
Kirigami.Action {
text: i18nc("@action:inmenu", "Action 2")
Controls.Action {
text: i18nc("@action:inmenu", "Sub-action")
}
}
}
}
}

{qml}

Since
1.7.0.

Definition at line 142 of file ConvergentContextMenu.qml.

Property Documentation

◆ actions

listTAction ConvergentContextMenu::actions
read

This property holds the list of actions.

This can be either tradional action from QtQuick.Controls or a Kirigami.Action with sub actions.

Remarks
This is the default property

Definition at line 149 of file ConvergentContextMenu.qml.

◆ headerContentItem

Item ConvergentContextMenu::headerContentItem
read

Optional item which will be displayed as header of the internal ButtonDrawer.

Note: This is only displayed on the first level of the ContextMenu mobile mode.

Definition at line 155 of file ConvergentContextMenu.qml.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:11 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.