KIO

kopenwithdialog.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef OPENWITHDIALOG_H
9#define OPENWITHDIALOG_H
10
11#include "kiowidgets_export.h"
12
13#include <KService>
14#include <QDialog>
15#include <QUrl>
16
17class KOpenWithDialogPrivate;
18
19/**
20 * @class KOpenWithDialog kopenwithdialog.h <KOpenWithDialog>
21 *
22 * "Open With" dialog box.
23 *
24 * @note To let the user choose an application and run it immediately,
25 * use simpler KRun::displayOpenWithDialog().
26 *
27 * If the Kiosk "shell_access" action is not authorized (see
28 * KAuthorized::authorize()), arbitrary commands are not allowed; instead, the
29 * user must browse to and choose an executable.
30 *
31 * @author David Faure <faure@kde.org>
32 */
33class KIOWIDGETS_EXPORT KOpenWithDialog : public QDialog
34{
35 Q_OBJECT
36public:
37 /**
38 * Create a dialog that asks for a application to open a given
39 * URL(s) with.
40 *
41 * @param urls the URLs that should be opened. The list can be empty,
42 * if the dialog is used to choose an application but not for some particular URLs.
43 * @param parent parent widget
44 */
45 explicit KOpenWithDialog(const QList<QUrl> &urls, QWidget *parent = nullptr);
46
47 /**
48 * Create a dialog that asks for a application to open a given
49 * URL(s) with.
50 *
51 * @param urls is the URL that should be opened
52 * @param text appears as a label on top of the entry box. Leave empty for default text (since 5.20).
53 * @param value is the initial value of the line
54 * @param parent parent widget
55 */
56 KOpenWithDialog(const QList<QUrl> &urls, const QString &text, const QString &value, QWidget *parent = nullptr);
57
58 /**
59 * Create a dialog to select a service for a given MIME type.
60 * Note that this dialog doesn't apply to URLs.
61 *
62 * @param mimeType the MIME type we want to choose an application for.
63 * @param value is the initial value of the line
64 * @param parent parent widget
65 */
66 KOpenWithDialog(const QString &mimeType, const QString &value, QWidget *parent = nullptr);
67
68 /**
69 * Create a dialog that asks for a application for opening a given
70 * URL (or more than one), when we already know the MIME type of the URL(s).
71 *
72 * @param urls is the URLs that should be opened
73 * @param mimeType the MIME type of the URL
74 * @param text appears as a label on top of the entry box.
75 * @param value is the initial value of the line
76 * @param parent parent widget
77 * @since 5.71
78 */
79 KOpenWithDialog(const QList<QUrl> &urls, const QString &mimeType, const QString &text, const QString &value, QWidget *parent = nullptr);
80
81 /**
82 * Create a dialog to select an application
83 * Note that this dialog doesn't apply to URLs.
84 *
85 * @param parent parent widget
86 */
87 KOpenWithDialog(QWidget *parent = nullptr);
88
89 /**
90 * Destructor
91 */
92 ~KOpenWithDialog() override;
93
94 /**
95 * @return the text the user entered
96 */
97 QString text() const;
98 /**
99 * Hide the "Do not &close when command exits" Checkbox
100 */
101 void hideNoCloseOnExit();
102 /**
103 * Hide the "Run in &terminal" Checkbox
104 */
105 void hideRunInTerminal();
106 /**
107 * @return the chosen service in the application tree
108 * Can be null, if the user typed some text and didn't select a service.
109 */
110 KService::Ptr service() const;
111 /**
112 * Set whether a new .desktop file should be created if the user selects an
113 * application for which no corresponding .desktop file can be found.
114 *
115 * Regardless of this setting a new .desktop file may still be created if
116 * the user has chosen to remember the file association.
117 *
118 * The default is false: no .desktop files are created.
119 */
120 void setSaveNewApplications(bool b);
121
122public Q_SLOTS: // TODO KDE5: move all those slots to the private class!
123 void slotSelected(const QString &_name, const QString &_exec);
124 void slotHighlighted(const QString &_name, const QString &_exec);
125 void slotTextChanged();
126 void slotTerminalToggled(bool);
127
128protected Q_SLOTS:
129 /**
130 * Reimplemented from QDialog::accept()
131 */
132 void accept() override;
133
134private:
135 bool eventFilter(QObject *object, QEvent *event) override;
136
137 friend class KOpenWithDialogPrivate;
138 std::unique_ptr<KOpenWithDialogPrivate> const d;
139
140 Q_DISABLE_COPY(KOpenWithDialog)
141};
142
143#endif
"Open With" dialog box.
virtual void accept()
virtual bool eventFilter(QObject *o, QEvent *e) override
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:50:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.