diff --git a/src/widgets/kpropertiesdialog.h b/src/widgets/kpropertiesdialog.h index 5c25f982..44bfc1a2 100644 --- a/src/widgets/kpropertiesdialog.h +++ b/src/widgets/kpropertiesdialog.h @@ -1,465 +1,465 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis Copyright (c) 1999, 2000 Preston Brown Copyright (c) 2000 Simon Hausmann Copyright (c) 2000 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPROPERTIESDIALOG_H #define KPROPERTIESDIALOG_H #include #include #include "kiowidgets_export.h" #include #include class KPropertiesDialogPlugin; class KJob; namespace KIO { class Job; } /** * @class KPropertiesDialog kpropertiesdialog.h * * The main properties dialog class. * A Properties Dialog is a dialog which displays various information * about a particular file or URL, or several files or URLs. * This main class holds various related classes, which are instantiated in * the form of tab entries in the tabbed dialog that this class provides. * The various tabs themselves will let the user view, and sometimes change, * information about the file or URL. * - * \image html kpropertiesdialog.png "Typical KProperties Dialog" + * \image html kpropertiesdialog.png "Example of KPropertiesDialog" * * The best way to display the properties dialog is to use showDialog(). * Otherwise, you should use (void)new KPropertiesDialog(...) * It will take care of deleting itself when closed. * * If you are looking for more flexibility, see KFileMetaInfo and * KFileMetaInfoWidget. * * This respects the "editfiletype", "run_desktop_files" and "shell_access" * Kiosk action restrictions (see KAuthorized::authorize()). */ class KIOWIDGETS_EXPORT KPropertiesDialog : public KPageDialog { Q_OBJECT public: /** * Determine whether there are any property pages available for the * given file items. * @param _items the list of items to check. * @return true if there are any property pages, otherwise false. */ static bool canDisplay(const KFileItemList &_items); /** * Brings up a Properties dialog, as shown above. * This is the normal constructor for * file-manager type applications, where you have a KFileItem instance * to work with. Normally you will use this * method rather than the one below. * * @param item file item whose properties should be displayed. * @param parent is the parent of the dialog widget. */ explicit KPropertiesDialog(const KFileItem &item, QWidget *parent = nullptr); /** * \overload * * You use this constructor for cases where you have a number of items, * rather than a single item. Be careful which methods you use * when passing a list of files or URLs, since some of them will only * work on the first item in a list. * * @param _items list of file items whose properties should be displayed. * @param parent is the parent of the dialog widget. */ explicit KPropertiesDialog(const KFileItemList &_items, QWidget *parent = nullptr); /** * Brings up a Properties dialog. Convenience constructor for * non-file-manager applications, where you have a QUrl rather than a * KFileItem or KFileItemList. * * @param url the URL whose properties should be displayed * @param parent is the parent of the dialog widget. * * For local files with a known mimetype, simply create a KFileItem * and pass it to the other constructor. */ explicit KPropertiesDialog(const QUrl &url, QWidget *parent = nullptr); /** * Brings up a Properties dialog. Convenience constructor for * non-file-manager applications, where you have a list of QUrls rather * than a KFileItemList. * * @param urls list of URLs whose properties should be displayed (must * contain at least one non-empty URL) * @param parent is the parent of the dialog widget. * * For local files with a known mimetype, simply create a KFileItemList * and pass it to the other constructor. * * @since 5.10 */ explicit KPropertiesDialog(const QList &urls, QWidget *parent = nullptr); /** * Creates a properties dialog for a new .desktop file (whose name * is not known yet), based on a template. Special constructor for * "File / New" in file-manager type applications. * * @param _tempUrl template used for reading only * @param _currentDir directory where the file will be written to * @param _defaultName something to put in the name field, * like mimetype.desktop * @param parent is the parent of the dialog widget. */ KPropertiesDialog(const QUrl &_tempUrl, const QUrl &_currentDir, const QString &_defaultName, QWidget *parent = nullptr); /** * Creates an empty properties dialog (for applications that want use * a standard dialog, but for things not doable via the plugin-mechanism). * * @param title is the string display as the "filename" in the caption of the dialog. * @param parent is the parent of the dialog widget. */ explicit KPropertiesDialog(const QString &title, QWidget *parent = nullptr); /** * Cleans up the properties dialog and frees any associated resources, * including the dialog itself. Note that when a properties dialog is * closed it cleans up and deletes itself. */ virtual ~KPropertiesDialog(); /** * Immediately displays a Properties dialog using constructor with * the same parameters. * On MS Windows, if @p item points to a local file, native (non modal) property * dialog is displayed (@p parent and @p modal are ignored in this case). * * @return true on successful dialog displaying (can be false on win32). */ static bool showDialog(const KFileItem &item, QWidget *parent = nullptr, bool modal = true); /** * Immediately displays a Properties dialog using constructor with * the same parameters. * On MS Windows, if @p _url points to a local file, native (non modal) property * dialog is displayed (@p parent and @p modal are ignored in this case). * * @return true on successful dialog displaying (can be false on win32). */ static bool showDialog(const QUrl &_url, QWidget *parent = nullptr, bool modal = true); /** * Immediately displays a Properties dialog using constructor with * the same parameters. * On MS Windows, if @p _items has one element and this element points * to a local file, native (non modal) property dialog is displayed * (@p parent and @p modal are ignored in this case). * * @return true on successful dialog displaying (can be false on win32). */ static bool showDialog(const KFileItemList &_items, QWidget *parent = nullptr, bool modal = true); /** * Immediately displays a Properties dialog using constructor with * the same parameters. * * On MS Windows, if @p _urls has one element and this element points * to a local file, native (non modal) property dialog is displayed * (@p parent and @p modal are ignored in this case). * * @param urls list of URLs whose properties should be displayed (must * contain at least one non-empty URL) * @param parent is the parent of the dialog widget. * @param modal tells the dialog whether it should be modal. * * @return true on successful dialog displaying (can be false on win32). * * @since 5.10 */ static bool showDialog(const QList &urls, QWidget *parent = nullptr, bool modal = true); /** * Adds a "3rd party" properties plugin to the dialog. Useful * for extending the properties mechanism. * * To create a new plugin type, inherit from the base class KPropertiesDialogPlugin * and implement all the methods. If you define a service .desktop file * for your plugin, you do not need to call insertPlugin(). * * @param plugin is a pointer to the KPropertiesDialogPlugin. The Properties * dialog will do destruction for you. The KPropertiesDialogPlugin \b must * have been created with the KPropertiesDialog as its parent. * @see KPropertiesDialogPlugin */ void insertPlugin(KPropertiesDialogPlugin *plugin); #ifndef KIOWIDGETS_NO_DEPRECATED /** * @deprecated since 5.0, use url() */ KIOWIDGETS_DEPRECATED QUrl kurl() const { return url(); } #endif /** * The URL of the file that has its properties being displayed. * This is only valid if the KPropertiesDialog was created/shown * for one file or URL. * * @return the single URL. */ QUrl url() const; /** * @return the file item for which the dialog is shown * * Warning: this method returns the first item of the list. * This means that you should use this only if you are sure the dialog is used * for a single item. Otherwise, you probably want items() instead. */ KFileItem &item(); /** * @return the items for which the dialog is shown */ KFileItemList items() const; /** * If the dialog is being built from a template, this method * returns the current directory. If no template, it returns QString(). * See the template form of the constructor. * * @return the current directory or QString() */ QUrl currentDir() const; /** * If the dialog is being built from a template, this method * returns the default name. If no template, it returns QString(). * See the template form of the constructor. * @return the default name or QString() */ QString defaultName() const; /** * Updates the item URL (either called by rename or because * a global apps/mimelnk desktop file is being saved) * Can only be called if the dialog applies to a single file or URL. * @param newUrl the new URL */ void updateUrl(const QUrl &newUrl); /** * Renames the item to the specified name. This can only be called if * the dialog applies to a single file or URL. * @param _name new filename, encoded. * \see FilePropsDialogPlugin::applyChanges */ void rename(const QString &_name); /** * To abort applying changes. */ void abortApplying(); /** * Shows the page that was previously set by * setFileSharingPage(), or does nothing if no page * was set yet. * \see setFileSharingPage */ void showFileSharingPage(); /** * Sets the file sharing page. * This page is shown when calling showFileSharingPage(). * * @param page the page to set * \see showFileSharingPage */ void setFileSharingPage(QWidget *page); /** * Call this to make the filename lineedit readonly, to prevent the user * from renaming the file. * \param ro true if the lineedit should be read only */ void setFileNameReadOnly(bool ro); using KPageDialog::buttonBox; public Q_SLOTS: /** * Called when the user presses 'Ok'. * @deprecated since 5.25, use accept() */ KIOWIDGETS_DEPRECATED virtual void slotOk(); /** * Called when the user presses 'Cancel'. * @deprecated since 5.25, use reject() */ KIOWIDGETS_DEPRECATED virtual void slotCancel(); /** * Called when the user presses 'Ok'. * @since 5.25 */ void accept() Q_DECL_OVERRIDE; /** * Called when the user presses 'Cancel' or Esc. * @since 5.25 */ void reject() Q_DECL_OVERRIDE; Q_SIGNALS: /** * This signal is emitted when the Properties Dialog is closed (for * example, with OK or Cancel buttons) */ void propertiesClosed(); /** * This signal is emitted when the properties changes are applied (for * example, with the OK button) */ void applied(); /** * This signal is emitted when the properties changes are aborted (for * example, with the Cancel button) */ void canceled(); /** * Emitted before changes to @p oldUrl are saved as @p newUrl. * The receiver may change @p newUrl to point to an alternative * save location. */ void saveAs(const QUrl &oldUrl, QUrl &newUrl); Q_SIGNALS: void leaveModality(); private: class KPropertiesDialogPrivate; KPropertiesDialogPrivate *const d; Q_DISABLE_COPY(KPropertiesDialog) }; /** * A Plugin in the Properties dialog * This is an abstract class. You must inherit from this class * to build a new kind of tabbed page for the KPropertiesDialog. * A plugin in itself is just a library containing code, not a dialog's page. * It's up to the plugin to insert pages into the parent dialog. * * To make a plugin available, define a service that implements the KPropertiesDialog/Plugin * servicetype, as well as the mimetypes for which the plugin should be created. * For instance, ServiceTypes=KPropertiesDialog/Plugin,text/html,application/x-mymimetype. * * You can also include X-KDE-Protocol=file if you want that plugin * to be loaded only for local files, for instance. */ class KIOWIDGETS_EXPORT KPropertiesDialogPlugin : public QObject { Q_OBJECT public: /** * Constructor * To insert tabs into the properties dialog, use the add methods provided by * KPageDialog (the properties dialog is a KPageDialog). */ KPropertiesDialogPlugin(KPropertiesDialog *_props); virtual ~KPropertiesDialogPlugin(); /** * Applies all changes to the file. * This function is called when the user presses 'Ok'. The last plugin inserted * is called first. */ virtual void applyChanges(); /** * Convenience method for most ::supports methods * @return true if the file is a local, regular, readable, desktop file * @deprecated use KFileItem::isDesktopFile */ #ifndef KIOWIDGETS_NO_DEPRECATED static KIOWIDGETS_DEPRECATED bool isDesktopFile(const KFileItem &_item); #endif void setDirty(bool b); bool isDirty() const; public Q_SLOTS: void setDirty(); // same as setDirty( true ). TODO KDE5: void setDirty(bool dirty=true); Q_SIGNALS: /** * Emit this signal when the user changed anything in the plugin's tabs. * The hosting PropertiesDialog will call applyChanges only if the * PropsPlugin has emitted this signal or if you have called setDirty() before. */ void changed(); protected: /** * Pointer to the dialog */ KPropertiesDialog *properties; /** * Returns the font height. */ int fontHeight() const; private: class KPropertiesDialogPluginPrivate; KPropertiesDialogPluginPrivate *const d; }; #endif diff --git a/src/widgets/kurlrequester.h b/src/widgets/kurlrequester.h index 87a756eb..c42c380e 100644 --- a/src/widgets/kurlrequester.h +++ b/src/widgets/kurlrequester.h @@ -1,386 +1,386 @@ /* This file is part of the KDE libraries Copyright (C) 1999,2000,2001 Carsten Pfeiffer Copyright (C) 2013 Teo Mrnjavac This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2, as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KURLREQUESTER_H #define KURLREQUESTER_H #include "kiowidgets_export.h" #include #include #include #include #include class KComboBox; class KLineEdit; class KUrlCompletion; class QEvent; class QPushButton; class QString; /** * @class KUrlRequester kurlrequester.h * * This class is a widget showing a lineedit and a button, which invokes a * filedialog. File name completion is available in the lineedit. * * The defaults for the filedialog are to ask for one existing local file. * The default filter is "*", i.e. show all files, and the start directory is * the current working directory, or the last directory where a file has been * selected. * * You can change this behavior by using setMode(), setFilter() and setStartDir(). * * The default window modality for the file dialog is Qt::ApplicationModal * - * \image html kurlrequester.png "KDE URL Requester" + * \image html kurlrequester.png "KUrlRequester" * * @short A widget to request a filename/url from the user * @author Carsten Pfeiffer */ class KIOWIDGETS_EXPORT KUrlRequester : public QWidget { Q_OBJECT Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY textChanged USER true) Q_PROPERTY(QString filter READ filter WRITE setFilter) Q_PROPERTY(KFile::Modes mode READ mode WRITE setMode) Q_PROPERTY(QFileDialog::AcceptMode acceptMode READ acceptMode WRITE setAcceptMode) #ifndef KIOWIDGETS_NO_DEPRECATED Q_PROPERTY(QString clickMessage READ clickMessage WRITE setClickMessage) #endif Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(Qt::WindowModality fileDialogModality READ fileDialogModality WRITE setFileDialogModality) public: /** * Constructs a KUrlRequester widget. */ explicit KUrlRequester(QWidget *parent = nullptr); /** * Constructs a KUrlRequester widget with the initial URL @p url. */ explicit KUrlRequester(const QUrl &url, QWidget *parent = nullptr); /** * Special constructor, which creates a KUrlRequester widget with a custom * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit * (or inherited thereof). Note: for geometry management reasons, the * edit-widget is reparented to have the KUrlRequester as parent. */ KUrlRequester(QWidget *editWidget, QWidget *parent); /** * Destructs the KUrlRequester. */ ~KUrlRequester(); /** * @returns the current url in the lineedit. May be malformed, if the user * entered something weird. For local files, ~user or environment variables * are substituted, relative paths will be resolved against startDir() */ QUrl url() const; /** * @returns the current start dir * @since 4.3 */ QUrl startDir() const; /** * @returns the current text in the lineedit or combobox. * This does not do the URL expansion that url() does, it's only provided * for cases where KUrlRequester is used to enter URL-or-something-else, * like KOpenWithDialog where you can type a full command with arguments. * * @since 4.2 */ QString text() const; /** * Sets the mode of the file dialog. * Note: you can only select one file with the filedialog, * so KFile::Files doesn't make much sense. * @see QFileDialog::setFileMode() */ void setMode(KFile::Modes m); /** * Returns the current mode * @see QFileDialog::fileMode() */ KFile::Modes mode() const; /** * Sets the open / save mode of the file dialog. * @see QFileDialog::setAcceptMode() * @since 5.33 */ void setAcceptMode(QFileDialog::AcceptMode m); /** * Returns the current open / save mode * @see QFileDialog::acceptMode() * @since 5.33 */ QFileDialog::AcceptMode acceptMode() const; /** * Sets the filters for the file dialog, separated by \n. * @see QFileDialog::setNameFilters() */ void setFilter(const QString &filter); /** * Returns the filters for the file dialog, separated by \n. * @see QFileDialog::nameFilters() */ QString filter() const; /** * Sets the mimetype filters for the file dialog. * @see QFileDialog::setMimeTypeFilters() * @since 5.31 */ void setMimeTypeFilters(const QStringList &mimeTypes); /** * Returns the mimetype filters for the file dialog. * @see QFileDialog::mimeTypeFilters() * @since 5.31 */ QStringList mimeTypeFilters() const; /** * @returns a pointer to the filedialog. * You can use this to customize the dialog, e.g. to call setLocationLabel * or other things which are not accessible in the KUrlRequester API. * * Never returns 0. This method creates the file dialog on demand. * * @deprecated since 5.0. The dialog will be created anyway when the user * requests it, and will behave according to the properties of KUrlRequester. */ #ifndef KIOWIDGETS_NO_DEPRECATED virtual KIOWIDGETS_DEPRECATED QFileDialog *fileDialog() const; #endif /** * @returns a pointer to the lineedit, either the default one, or the * special one, if you used the special constructor. * * It is provided so that you can e.g. set an own completion object * (e.g. KShellCompletion) into it. */ KLineEdit *lineEdit() const; /** * @returns a pointer to the combobox, in case you have set one using the * special constructor. Returns 0L otherwise. */ KComboBox *comboBox() const; /** * @returns a pointer to the pushbutton. It is provided so that you can * specify an own pixmap or a text, if you really need to. */ QPushButton *button() const; /** * @returns the KUrlCompletion object used in the lineedit/combobox. */ KUrlCompletion *completionObject() const; /** * @returns an object, suitable for use with KEditListWidget. It allows you * to put this KUrlRequester into a KEditListWidget. * Basically, do it like this: * \code * KUrlRequester *req = new KUrlRequester( someWidget ); * [...] * KEditListWidget *editListWidget = new KEditListWidget( req->customEditor(), someWidget ); * \endcode */ const KEditListWidget::CustomEditor &customEditor(); /** * @returns the message set with setClickMessage * @since 4.2 * @deprecated use KUrlRequester::placeholderText instead. */ #ifndef KIOWIDGETS_NO_DEPRECATED KIOWIDGETS_DEPRECATED QString clickMessage() const; #endif /** * Set a click message @p msg * @since 4.2 * @deprecated use KUrlRequester::setPlaceholderText instead. */ #ifndef KIOWIDGETS_NO_DEPRECATED KIOWIDGETS_DEPRECATED void setClickMessage(const QString &msg); #endif /** * @return the message set with setPlaceholderText * @since 5.0 */ QString placeholderText() const; /** * This makes the KUrlRequester line edit display a grayed-out hinting text as long as * the user didn't enter any text. It is often used as indication about * the purpose of the line edit. * @since 5.0 */ void setPlaceholderText(const QString &msg); /** * @returns the window modality of the file dialog set with setFileDialogModality * @since 4.4 */ Qt::WindowModality fileDialogModality() const; /** * Set the window modality for the file dialog to @p modality * Directory selection dialogs are always modal * @since 4.4 */ void setFileDialogModality(Qt::WindowModality modality); public Q_SLOTS: /** * Sets the url in the lineedit to @p url. */ void setUrl(const QUrl &url); /** * Sets the start dir @p startDir. * The start dir is only used when the URL isn't set. * @since 4.3 */ void setStartDir(const QUrl &startDir); /** * Sets the url in the lineedit to @p QUrl::fromLocalFile(path). * This is only for local paths; do not pass a url here. * This method is mostly for "local paths only" url requesters, * for instance those set up with setMode(KFile::File|KFile::ExistingOnly|KFile::LocalOnly) * * @deprecated Use setUrl(QUrl::fromLocalFile(path)) instead. */ #ifndef KIOWIDGETS_NO_DEPRECATED KIOWIDGETS_DEPRECATED void setPath(const QString &path); #endif /** * Sets the current text in the lineedit or combobox. * This is used for cases where KUrlRequester is used to * enter URL-or-something-else, like KOpenWithDialog where you * can type a full command with arguments. * * @see text * @since 4.3 */ void setText(const QString &text); /** * Clears the lineedit/combobox. */ void clear(); Q_SIGNALS: // forwards from LineEdit /** * Emitted when the text in the lineedit changes. * The parameter contains the contents of the lineedit. */ void textChanged(const QString &); /** * Emitted when the text in the lineedit was modified by the user. * Unlike textChanged(), this signal is not emitted when the text is changed programmatically, for example, by calling setText(). * @since 5.21 */ void textEdited(const QString &); /** * Emitted when return or enter was pressed in the lineedit. */ void returnPressed(); /** * Emitted when return or enter was pressed in the lineedit. * The parameter contains the contents of the lineedit. */ void returnPressed(const QString &); /** * Emitted before the filedialog is going to open. Connect * to this signal to "configure" the filedialog, e.g. set the * filefilter, the mode, a preview-widget, etc. It's usually * not necessary to set a URL for the filedialog, as it will * get set properly from the editfield contents. * * If you use multiple KUrlRequesters, you can connect all of them * to the same slot and use the given KUrlRequester pointer to know * which one is going to open. */ void openFileDialog(KUrlRequester *); /** * Emitted when the user changed the URL via the file dialog. * The parameter contains the contents of the lineedit. */ void urlSelected(const QUrl &); protected: void changeEvent(QEvent *e) Q_DECL_OVERRIDE; bool eventFilter(QObject *obj, QEvent *ev) Q_DECL_OVERRIDE; private: class KUrlRequesterPrivate; KUrlRequesterPrivate *const d; Q_DISABLE_COPY(KUrlRequester) Q_PRIVATE_SLOT(d, void _k_slotUpdateUrl()) Q_PRIVATE_SLOT(d, void _k_slotOpenDialog()) Q_PRIVATE_SLOT(d, void _k_slotFileDialogAccepted()) }; class KIOWIDGETS_EXPORT KUrlComboRequester : public KUrlRequester // krazy:exclude=dpointer (For use in Qt Designer) { Q_OBJECT public: /** * Constructs a KUrlRequester widget with a combobox. */ explicit KUrlComboRequester(QWidget *parent = nullptr); private: class Private; Private *const d; }; #endif // KURLREQUESTER_H