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