Warning, file /frameworks/kio/src/core/askuseractioninterface.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2020 Ahmad Samir <a.samirh78@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef ASKUSERACTIONINTERFACE_H 0009 #define ASKUSERACTIONINTERFACE_H 0010 0011 #include <kio/jobuidelegateextension.h> // RenameDialog_Result, SkipDialog_Result 0012 #include <kiocore_export.h> 0013 0014 #include <QObject> 0015 #include <QUrl> 0016 0017 #include <memory> 0018 0019 class KJob; 0020 0021 namespace KIO 0022 { 0023 class AskUserActionInterfacePrivate; 0024 0025 /** 0026 * @class KIO::AskUserActionInterface askuseractioninterface.h <KIO/AskUserActionInterface> 0027 * 0028 * @brief The AskUserActionInterface class allows a KIO::Job to prompt the user 0029 * for a decision when e.g.\ copying directories/files and there is a conflict 0030 * (e.g.\ a file with the same name already exists at the destination). 0031 * 0032 * The methods in this interface are similar to their counterparts in 0033 * KIO::JobUiDelegateExtension, the main difference is that AskUserActionInterface 0034 * shows the dialogs using show() or open(), rather than exec(), the latter creates 0035 * a nested event loop which could lead to crashes. 0036 * 0037 * @sa KIO::JobUiDelegateExtension 0038 * 0039 * @since 5.78 0040 */ 0041 class KIOCORE_EXPORT AskUserActionInterface : public QObject 0042 { 0043 Q_OBJECT 0044 0045 protected: 0046 /** 0047 * Constructor 0048 */ 0049 explicit AskUserActionInterface(QObject *parent = nullptr); 0050 0051 public: 0052 /** 0053 * Destructor 0054 */ 0055 ~AskUserActionInterface() override; 0056 0057 /** 0058 * @relates KIO::RenameDialog 0059 * 0060 * Constructs a modal, parent-less "rename" dialog, to prompt the user for a decision 0061 * in case of conflicts, while copying/moving files. The dialog is shown using open(), 0062 * rather than exec() (the latter creates a nested eventloop which could lead to crashes). 0063 * You will need to connect to the askUserRenameResult() signal to get the dialog's result 0064 * (exit code). The exit code is one of KIO::RenameDialog_Result. 0065 * 0066 * @see KIO::RenameDialog_Result enum. 0067 * 0068 * @param job the job that called this method 0069 * @param title the title for the dialog box 0070 * @param src the URL of the file/dir being copied/moved 0071 * @param dest the URL of the destination file/dir, i.e. the one that already exists 0072 * @param options parameters for the dialog (which buttons to show... etc), OR'ed values 0073 * from the KIO::RenameDialog_Options enum 0074 * @param sizeSrc size of the source file 0075 * @param sizeDest size of the destination file 0076 * @param ctimeSrc creation time of the source file 0077 * @param ctimeDest creation time of the destination file 0078 * @param mtimeSrc modification time of the source file 0079 * @param mtimeDest modification time of the destination file 0080 */ 0081 virtual void askUserRename(KJob *job, 0082 const QString &title, 0083 const QUrl &src, 0084 const QUrl &dest, 0085 KIO::RenameDialog_Options options, 0086 KIO::filesize_t sizeSrc, 0087 KIO::filesize_t sizeDest, 0088 const QDateTime &ctimeSrc = {}, 0089 const QDateTime &ctimeDest = {}, 0090 const QDateTime &mtimeSrc = {}, 0091 const QDateTime &mtimeDest = {}) = 0; 0092 0093 /** 0094 * @relates KIO::SkipDialog 0095 * 0096 * You need to connect to the askUserSkipResult signal to get the dialog's 0097 * result. 0098 * 0099 * @param job the job that called this method 0100 * @param options parameters for the dialog (which buttons to show... etc), OR'ed 0101 * values from the KIO::SkipDialog_Options enum 0102 * @param error_text the error text to show to the user (usually the string returned 0103 * by KJob::errorText()) 0104 */ 0105 virtual void askUserSkip(KJob *job, KIO::SkipDialog_Options options, const QString &errorText) = 0; 0106 0107 /** 0108 * The type of deletion. 0109 * 0110 * Used by askUserDelete(). 0111 */ 0112 enum DeletionType { 0113 Delete, /// Delete the files/directories directly, i.e. without moving them to Trash 0114 Trash, /// Move the files/directories to Trash 0115 EmptyTrash, /// Empty the Trash 0116 /** 0117 * This is the same as Delete, but more text is added to the message to inform 0118 * the user that moving to Trash was tried but failed due to size constraints. 0119 * Typical use case is re-asking the user about deleting instead of Trashing. 0120 * @since 5.100 0121 */ 0122 DeleteInsteadOfTrash, 0123 }; 0124 0125 /** 0126 * Deletion confirmation type. 0127 * 0128 * Used by askUserDelete(). 0129 */ 0130 enum ConfirmationType { 0131 DefaultConfirmation, ///< Do not ask if the user has previously set the "Do not ask again" 0132 ///< checkbox (which is is shown in the message dialog invoked by askUserDelete()) 0133 ForceConfirmation, ///< Always ask the user for confirmation 0134 }; 0135 0136 /** 0137 * Ask for confirmation before moving @p urls (files/directories) to the Trash, 0138 * emptying the Trash, or directly deleting files (i.e. without moving to Trash). 0139 * 0140 * Note that this method is not called automatically by KIO jobs. It's the 0141 * application's responsibility to ask the user for confirmation before calling 0142 * KIO::del() or KIO::trash(). 0143 * 0144 * You need to connect to the askUserDeleteResult signal to get the dialog's result 0145 * (exit code). 0146 * 0147 * @param urls the urls about to be moved to the Trash or deleted directly 0148 * @param deletionType the type of deletion (Delete for real deletion, Trash otherwise), 0149 * see the DeletionType enum 0150 * @param confirmationType The type of deletion confirmation, see the ConfirmationType enum. 0151 * Normally set to DefaultConfirmation 0152 * @param parent the parent widget of the message box 0153 */ 0154 virtual void askUserDelete(const QList<QUrl> &urls, 0155 DeletionType deletionType, 0156 ConfirmationType confirmationType, 0157 QWidget *parent = nullptr) = 0; // TODO KF6: replace QWidget* with QObject* 0158 0159 enum MessageDialogType { 0160 QuestionTwoActions = 1, ///< @since 5.100 0161 QuestionTwoActionsCancel = 2, ///< @since 5.100 0162 WarningTwoActions = 3, ///< @since 5.100 0163 WarningTwoActionsCancel = 4, ///< @since 5.100 0164 WarningContinueCancel = 5, 0165 SSLMessageBox = 6, 0166 Information = 7, 0167 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 97) 0168 Sorry ///< @deprecated Since 5.97, use Error. 0169 KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 97, "Use Error.") = 8, 0170 #endif 0171 Error = 9, 0172 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 100) 0173 QuestionYesNo ///< @deprecated Since 5.100, use QuestionTwoActions. 0174 KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use QuestionTwoActions.") = QuestionTwoActions, 0175 QuestionYesNoCancel ///< @deprecated Since 5.100, use QuestionTwoActionsCancel. 0176 KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use QuestionTwoActionsCancel.") = QuestionTwoActionsCancel, 0177 WarningYesNo ///< @deprecated Since 5.100, use WarningTwoActions. 0178 KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use WarningTwoActions.") = WarningTwoActions, 0179 WarningYesNoCancel ///< @deprecated Since 5.100, use WarningTwoActionsCancel. 0180 KIOCORE_ENUMERATOR_DEPRECATED_VERSION(5, 100, "Use WarningTwoActionsCancel.") = WarningTwoActionsCancel, 0181 #endif 0182 }; 0183 0184 /** 0185 * This function allows for the delegation of user prompts from the KIO worker. 0186 * 0187 * @param type the desired type of message box, see the MessageDialogType enum 0188 * @param text the message to show to the user 0189 * @param title the title of the message dialog box 0190 * @param primaryActionText the text for the primary action 0191 * @param secondatyActionText the text for the secondary action 0192 * @param primaryActionIconName the icon to show on the primary action 0193 * @param secondatyActionIconName the icon to show on the secondary action 0194 * @param dontAskAgainName the config key name used to store the result from 0195 * 'Do not ask again' checkbox 0196 * @param details more details about the message shown to the user 0197 * @param sslMetaData SSL information primarily used by the SSLMessageBox dialog 0198 * @param parent the parent widget of the dialog 0199 */ 0200 virtual void requestUserMessageBox(MessageDialogType type, 0201 const QString &text, 0202 const QString &title, 0203 const QString &primaryActionText, 0204 const QString &secondatyActionText, 0205 const QString &primaryActionIconName = {}, 0206 const QString &secondatyActionIconName = {}, 0207 const QString &dontAskAgainName = {}, 0208 const QString &details = {}, 0209 const KIO::MetaData &sslMetaData = {}, 0210 QWidget *parent = nullptr) = 0; // TODO KF6: replace QWidget* with QObject*, document "widget or window" 0211 0212 Q_SIGNALS: 0213 /** 0214 * Implementations of this interface must emit this signal when the rename dialog 0215 * finishes, to notify the caller of the dialog's result. 0216 * 0217 * @param result the exit code from the rename dialog, one of the KIO::RenameDialog_Result 0218 * enum 0219 * @param newUrl the new destination URL set by the user 0220 * @param parentJob the job that invoked the dialog 0221 */ 0222 void askUserRenameResult(KIO::RenameDialog_Result result, const QUrl &newUrl, KJob *parentJob); 0223 0224 /** 0225 * Implementations of this interface must emit this signal when the skip dialog 0226 * finishes, to notify the caller of the dialog's result. 0227 * 0228 * @param result the exit code from the skip dialog, one of the KIO::SkipDialog_Result enum 0229 * @param parentJob the job that invoked the dialog 0230 */ 0231 void askUserSkipResult(KIO::SkipDialog_Result result, KJob *parentJob); 0232 0233 /** 0234 * Implementations of this interface must emit this signal when the dialog invoked 0235 * by askUserDelete() finishes, to notify the caller of the user's decision. 0236 * 0237 * @param allowDelete set to true if the user confirmed the delete operation, otherwise 0238 * set to false 0239 * @param urls a list of urls to delete/trash 0240 * @param deletionType the deletion type to use, one of KIO::AskUserActionInterface::DeletionType 0241 * @param parent the parent widget passed to askUserDelete(), for request identification 0242 */ 0243 void askUserDeleteResult(bool allowDelete, 0244 const QList<QUrl> &urls, 0245 KIO::AskUserActionInterface::DeletionType deletionType, 0246 QWidget *parent); // TODO KF6: replace QWidget* with QObject* 0247 0248 /** 0249 * Implementations of this interface must emit this signal when the dialog invoked 0250 * by requestUserMessageBox() finishes, to notify the caller of the dialog's result 0251 * (exit code). 0252 * 0253 * @param result the exit code of the dialog, one of KIO::WorkerBase::ButtonCode enum 0254 */ 0255 void messageBoxResult(int result); // TODO KF6: add a QObject* to identify requests? Or return an int from the request method and pass it back here? 0256 0257 private: 0258 std::unique_ptr<AskUserActionInterfacePrivate> d; 0259 }; 0260 0261 } // namespace KIO 0262 0263 #endif // ASKUSERACTIONINTERFACE_H