File indexing completed on 2024-12-08 09:41:04
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2001, 2002, 2003 Carsten Pfeiffer <pfeiffer@kde.org> 0004 SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef KFILEPLACEEDITDIALOG_H 0010 #define KFILEPLACEEDITDIALOG_H 0011 0012 #include "kiofilewidgets_export.h" 0013 0014 #include <KIconLoader> 0015 #include <QDialog> 0016 #include <QUrl> 0017 0018 class QCheckBox; 0019 class QDialogButtonBox; 0020 class QLineEdit; 0021 class KIconButton; 0022 class KUrlRequester; 0023 0024 /** 0025 * @class KFilePlaceEditDialog kfileplaceeditdialog.h <KFilePlaceEditDialog> 0026 * 0027 * A dialog that allows editing entries of a KFilePlacesModel. 0028 * The dialog offers to configure a given url, label and icon. 0029 * See the class-method getInformation() for easy usage. 0030 * 0031 * @author Carsten Pfeiffer <pfeiffer@kde.org> 0032 * @since 5.53 0033 */ 0034 class KIOFILEWIDGETS_EXPORT KFilePlaceEditDialog : public QDialog 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 /** 0040 * A convenience method to show the dialog and retrieve all the 0041 * properties via the given parameters. The parameters are used to 0042 * initialize the dialog and then return the user-configured values. 0043 * 0044 * @p allowGlobal if you set this to true, the dialog will have a checkbox 0045 * for the user to decide if he wants the entry to be 0046 * available globally or just for the current application. 0047 * @p url the url of the item 0048 * @p label a short, translated description of the item 0049 * @p icon an icon for the item 0050 * @p appLocal tells whether the item should be local for this application 0051 * or be available globally 0052 * @p iconSize determines the size of the icon that is shown/selectable 0053 * @p parent the parent-widget for the dialog 0054 * 0055 * If you leave the icon empty, the default icon for the given url will be 0056 * used (KMimeType::pixmapForUrl()). 0057 */ 0058 static bool 0059 getInformation(bool allowGlobal, QUrl &url, QString &label, QString &icon, bool isAddingNewPlace, bool &appLocal, int iconSize, QWidget *parent = nullptr); 0060 0061 /** 0062 * Constructs a KFilePlaceEditDialog. 0063 * 0064 * @p allowGlobal if you set this to true, the dialog will have a checkbox 0065 * for the user to decide if he wants the entry to be 0066 * available globally or just for the current application. 0067 * @p url the url of the item 0068 * @p label a short, translated description of the item 0069 * @p icon an icon for the item 0070 * @p appLocal tells whether the item should be local for this application 0071 * or be available globally 0072 * @p iconSize determines the size of the icon that is shown/selectable 0073 * @p parent the parent-widget for the dialog 0074 * 0075 * If you leave the icon empty, the default icon for the given url will be 0076 * used (KMimeType::pixmapForUrl()). 0077 */ 0078 KFilePlaceEditDialog(bool allowGlobal, 0079 const QUrl &url, 0080 const QString &label, 0081 const QString &icon, 0082 bool isAddingNewPlace, 0083 bool appLocal = true, 0084 int iconSize = KIconLoader::SizeMedium, 0085 QWidget *parent = nullptr); 0086 /** 0087 * Destroys the dialog. 0088 */ 0089 ~KFilePlaceEditDialog() override; 0090 0091 /** 0092 * @returns the configured url 0093 */ 0094 QUrl url() const; 0095 0096 /** 0097 * @returns the configured label 0098 */ 0099 QString label() const; 0100 0101 /** 0102 * @returns the configured icon 0103 */ 0104 QString icon() const; 0105 0106 #if KIOFILEWIDGETS_ENABLE_DEPRECATED_SINCE(5, 86) 0107 /** 0108 * @returns whether the item's icon is editable, because all icons are not 0109 * (e.g. the Trash can display two icons, representing its full and empty states, and 0110 * it is simpler to make these icons non-editable rather than to provide an interface to edit them both) 0111 * @deprecated Since 5.86. It was not used anywhere outside KFilePlaceEditDialog 0112 */ 0113 KIOFILEWIDGETS_DEPRECATED_VERSION(5, 86, "Removed since it was never used outside KFilePlaceEditDialog") 0114 bool isIconEditable() const; 0115 #endif 0116 0117 /** 0118 * @returns whether the item should be local to the application or global. 0119 * If allowGlobal was set to false in the constructor, this will always 0120 * return true. 0121 */ 0122 bool applicationLocal() const; 0123 0124 public Q_SLOTS: 0125 void urlChanged(const QString &); 0126 0127 private: 0128 /** 0129 * The KUrlRequester used for editing the url 0130 */ 0131 KUrlRequester *m_urlEdit; 0132 /** 0133 * The QLineEdit used for editing the label 0134 */ 0135 QLineEdit *m_labelEdit; 0136 /** 0137 * The KIconButton to configure the icon 0138 */ 0139 KIconButton *m_iconButton; 0140 /** 0141 * The QCheckBox to modify the local/global setting 0142 */ 0143 QCheckBox *m_appLocal; 0144 0145 QDialogButtonBox *m_buttonBox; 0146 }; 0147 0148 #endif // KFILEPLACEEDITDIALOG_H