1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2001, 2002, 2003 Carsten Pfeiffer <pfeiffer@kde.org>
4 SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8
9#ifndef KFILEPLACEEDITDIALOG_H
10#define KFILEPLACEEDITDIALOG_H
11
12#include "kiofilewidgets_export.h"
13
14#include <KIconLoader>
15#include <QDialog>
16#include <QUrl>
17
18class QCheckBox;
19class QDialogButtonBox;
20class QLineEdit;
21class KIconButton;
22class KUrlRequester;
23
24/*!
25 * \class KFilePlaceEditDialog
26 * \inmodule KIOFileWidgets
27 *
28 * \brief A dialog that allows editing entries of a KFilePlacesModel.
29 *
30 * The dialog offers to configure a given url, label and icon.
31 * See the class-method getInformation() for easy usage.
32 *
33 * \since 5.53
34 */
35class KIOFILEWIDGETS_EXPORT KFilePlaceEditDialog : public QDialog
36{
37 Q_OBJECT
38
39public:
40 /*!
41 * A convenience method to show the dialog and retrieve all the
42 * properties via the given parameters. The parameters are used to
43 * initialize the dialog and then return the user-configured values.
44 *
45 * \a allowGlobal if you set this to true, the dialog will have a checkbox
46 * for the user to decide if he wants the entry to be
47 * available globally or just for the current application.
48 *
49 * \a url the url of the item
50 *
51 * \a label a short, translated description of the item
52 *
53 * \a icon an icon for the item
54 *
55 * \a appLocal tells whether the item should be local for this application
56 * or be available globally
57 *
58 * \a iconSize determines the size of the icon that is shown/selectable
59 *
60 * \a parent the parent-widget for the dialog
61 *
62 * If you leave the icon empty, the default icon for the given url will be
63 * used (KMimeType::pixmapForUrl()).
64 */
65 static bool
66 getInformation(bool allowGlobal, QUrl &url, QString &label, QString &icon, bool isAddingNewPlace, bool &appLocal, int iconSize, QWidget *parent = nullptr);
67
68 /*!
69 * Constructs a KFilePlaceEditDialog.
70 *
71 * \a allowGlobal if you set this to true, the dialog will have a checkbox
72 * for the user to decide if he wants the entry to be
73 * available globally or just for the current application.
74 *
75 * \a url the url of the item
76 *
77 * \a label a short, translated description of the item
78 *
79 * \a icon an icon for the item
80 *
81 * \a appLocal tells whether the item should be local for this application
82 * or be available globally
83 *
84 * \a iconSize determines the size of the icon that is shown/selectable
85 *
86 * \a parent the parent-widget for the dialog
87 *
88 * If you leave the icon empty, the default icon for the given url will be
89 * used (KMimeType::pixmapForUrl()).
90 */
91 KFilePlaceEditDialog(bool allowGlobal,
92 const QUrl &url,
93 const QString &label,
94 const QString &icon,
95 bool isAddingNewPlace,
96 bool appLocal = true,
97 int iconSize = KIconLoader::SizeMedium,
98 QWidget *parent = nullptr);
99
100 ~KFilePlaceEditDialog() override;
101
102 /*!
103 * Returns the configured url
104 */
105 QUrl url() const;
106
107 /*!
108 * Returns the configured label
109 */
110 QString label() const;
111
112 /*!
113 * Returns the configured icon
114 */
115 QString icon() const;
116
117 /*!
118 * Returns whether the item should be local to the application or global.
119 * If allowGlobal was set to false in the constructor, this will always
120 * return true.
121 */
122 bool applicationLocal() const;
123
124public Q_SLOTS:
125 /*!
126 *
127 */
128 void urlChanged(const QString &);
129
130private:
131 /*
132 * The KUrlRequester used for editing the url
133 */
134 KUrlRequester *m_urlEdit;
135 /*
136 * The QLineEdit used for editing the label
137 */
138 QLineEdit *m_labelEdit;
139 /*
140 * The KIconButton to configure the icon
141 */
142 KIconButton *m_iconButton;
143 /*
144 * The QCheckBox to modify the local/global setting
145 */
146 QCheckBox *m_appLocal;
147
148 QDialogButtonBox *m_buttonBox;
149};
150
151#endif // KFILEPLACEEDITDIALOG_H
152

source code of kio/src/filewidgets/kfileplaceeditdialog.h