MauiKit File Browsing

OpenWithDialog.qml
1/*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2020 camilo <chiguitar@unal.edu.co>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick
20import QtQuick.Layouts
21import QtQuick.Controls
22
23import org.mauikit.controls as Maui
24import org.mauikit.filebrowsing as FB
25
26/**
27 * @inherit org::mauikit::control::PopupPage
28 * A dialog with a list of services -that can handled the associated list of URLs.
29 * @see urls
30 *
31 * This control inherits from MauiKit PopupPage, to checkout its inherited properties refer to docs.
32 *
33 * The services listed can open the file type of the file URLs.
34 *
35 * @image html openwithdialog.png "Example"
36 *
37 * @code
38 * Maui.Page
39 * {
40 * Maui.Controls.showCSD: true
41 * anchors.fill: parent
42 *
43 * Button
44 * {
45 * anchors.centerIn: parent
46 * text: "Open"
47 * onClicked: _dialog.open()
48 * }
49 *
50 * FB.OpenWithDialog
51 * {
52 * id: _dialog
53 * urls: ["/home/camiloh/Pictures/blend_by_rashadisrazzi_d8ttd59/2K.png"]
54 * }
55 * }
56 * @endcode
57 *
58 * <a href="https://invent.kde.org/maui/mauikit-filebrowser/examples/OpenWithDialog.qml">You can find a more complete example at this link.</a>
59 */
60Maui.PopupPage
61{
62 id: control
64 /**
65 * @brief List of file URLs to look for associated services.
66 * @property var OpenWithDialog::urls
67 */
68 property alias urls : _openWithList.urls
69
70 widthHint: 0.9
71 maxWidth: 350
72 persistent: false
73
74 page.title: i18nd("mauikitfilebrowsing", "Open with")
75 headBar.visible: false
76 actions: Action
77 {
78 Maui.Controls.status: Maui.Controls.Negative
79 text: i18n("Cancel")
80 onTriggered: control.close()
81 }
82
83 stack: Maui.ListBrowser
84 {
85 id: _list
86 Layout.fillWidth: true
87 Layout.fillHeight: true
88
89 header: Pane
90 {
91 width: parent.width
92 background: null
93
94 contentItem: Item
95 {
96 implicitHeight: 150
97
98 Maui.GridItemTemplate
99 {
100 readonly property var itemInfo : FB.FM.getFileInfo( control.urls[0])
101
102 anchors.fill: parent
103 anchors.margins: Maui.Style.space.tiny
104 iconSizeHint: Maui.Style.iconSizes.huge
105 fillMode: Image.PreserveAspectFit
106 iconSource: itemInfo.icon
107 imageSource: itemInfo.thumbnail
108 text1: i18np("1 item", "%1 items", control.urls.length)
109 }
110 }
111 }
112
113 model: Maui.BaseModel
114 {
115 list: FB.OpenWithModel
116 {
117 id: _openWithList
118 }
119 }
120
121 delegate: Maui.ListBrowserDelegate
122 {
123 width: ListView.view.width
124 hoverEnabled: true
125
126 label1.text: model.label
127 label2.text: model.comment
128
129 iconSource: model.icon
130 iconSizeHint: Maui.Style.iconSizes.big
131
132 onClicked:
133 {
134 _list.currentIndex = index
135 _openWithList.openWith(index)
136 close()
137 }
138 }
139 }
140}
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & close()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:55:53 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.