KIO::AskUserActionInterface Class
class KIO::AskUserActionInterfaceThe AskUserActionInterface class allows a KIO::Job to prompt the user for a decision when e.g. copying directories/files and there is a conflict (e.g. a file with the same name already exists at the destination). More...
Header: | #include <KIO/AskUserActionInterface> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KIO) target_link_libraries(mytarget PRIVATE KF6::KIOCore) |
Since: | 5.78 |
Inherits: | QObject |
Inherited By: |
Public Types
enum | ConfirmationType { DefaultConfirmation, ForceConfirmation } |
enum | DeletionType { Delete, Trash, EmptyTrash, This } |
enum | MessageDialogType { QuestionTwoActions, QuestionTwoActionsCancel, WarningTwoActions, WarningTwoActionsCancel, WarningContinueCancel, …, Erro } |
Public Functions
(since 6.0) virtual void | askIgnoreSslErrors(const QVariantMap &sslErrorData, QWidget *parent) = 0 |
virtual void | askUserDelete(const QList<QUrl> &urls, KIO::AskUserActionInterface::DeletionType deletionType, KIO::AskUserActionInterface::ConfirmationType confirmationType, QWidget *parent = nullptr) = 0 |
virtual void | askUserRename(KJob *job, const QString &title, const QUrl &src, const QUrl &dest, KIO::RenameDialog_Options options, KIO::filesize_t sizeSrc, KIO::filesize_t sizeDest, const QDateTime &ctimeSrc = {}, const QDateTime &ctimeDest = {}, const QDateTime &mtimeSrc = {}, const QDateTime &mtimeDest = {}) = 0 |
virtual void | askUserSkip(KJob *job, KIO::SkipDialog_Options options, const QString &errorText) = 0 |
virtual void | requestUserMessageBox(KIO::AskUserActionInterface::MessageDialogType type, const QString &text, const QString &title, const QString &primaryActionText, const QString &secondatyActionText, const QString &primaryActionIconName = {}, const QString &secondatyActionIconName = {}, const QString &dontAskAgainName = {}, const QString &details = {}, QWidget *parent = nullptr) = 0 |
Signals
void | askIgnoreSslErrorsResult(int result) |
void | askUserDeleteResult(bool allowDelete, const QList<QUrl> &urls, KIO::AskUserActionInterface::DeletionType deletionType, QWidget *parent) |
void | askUserRenameResult(KIO::RenameDialog_Result result, const QUrl &newUrl, KJob *parentJob) |
void | askUserSkipResult(KIO::SkipDialog_Result result, KJob *parentJob) |
void | messageBoxResult(int result) |
Protected Functions
AskUserActionInterface(QObject *parent = nullptr) |
Detailed Description
The methods in this interface are similar to their counterparts in KIO::JobUiDelegateExtension, the main difference is that AskUserActionInterface shows the dialogs using show() or open(), rather than exec(), the latter creates a nested event loop which could lead to crashes.
See also KIO::JobUiDelegateExtension.
Member Type Documentation
enum AskUserActionInterface::ConfirmationType
Deletion confirmation type.
Used by askUserDelete().
Constant | Value | Description |
---|---|---|
KIO::AskUserActionInterface::DefaultConfirmation | 0 | Do not ask if the user has previously set the "Do not ask again" checkbox (which is is shown in the message dialog invoked by askUserDelete()) |
KIO::AskUserActionInterface::ForceConfirmation | 1 | Always ask the user for confirmation |
enum AskUserActionInterface::DeletionType
The type of deletion.
Used by askUserDelete().
Constant | Value | Description |
---|---|---|
KIO::AskUserActionInterface::Delete | 0 | Delete the files/directories directly, i.e. without moving them to Trash |
KIO::AskUserActionInterface::Trash | 1 | Move the files/directories to Trash |
KIO::AskUserActionInterface::EmptyTrash | 2 | Empty the Trash |
KIO::AskUserActionInterface::This (since Qt 5.100) | ? | is the same as Delete, but more text is added to the message to inform the user that moving to Trash was tried but failed due to size constraints. Typical use case is re-asking the user about deleting instead of Trashing. |
enum AskUserActionInterface::MessageDialogType
Constant | Value |
---|---|
KIO::AskUserActionInterface::QuestionTwoActions (since Qt 5.100) | 1 |
KIO::AskUserActionInterface::QuestionTwoActionsCancel (since Qt 5.100) | 2 |
KIO::AskUserActionInterface::WarningTwoActions (since Qt 5.100) | 3 |
KIO::AskUserActionInterface::WarningTwoActionsCancel (since Qt 5.100) | 4 |
KIO::AskUserActionInterface::WarningContinueCancel | 5 |
KIO::AskUserActionInterface::Information | 7 |
KIO::AskUserActionInterface::Erro | ? |
Member Function Documentation
[explicit protected]
AskUserActionInterface::AskUserActionInterface(QObject *parent = nullptr)
Constructor
[pure virtual, since 6.0]
void AskUserActionInterface::askIgnoreSslErrors(const QVariantMap &sslErrorData, QWidget *parent)
This function was introduced in 6.0.
[signal]
void AskUserActionInterface::askIgnoreSslErrorsResult(int result)
[pure virtual]
void AskUserActionInterface::askUserDelete(const QList<QUrl> &urls, KIO::AskUserActionInterface::DeletionType deletionType, KIO::AskUserActionInterface::ConfirmationType confirmationType, QWidget *parent = nullptr)
Ask for confirmation before moving urls (files/directories) to the Trash, emptying the Trash, or directly deleting files (i.e. without moving to Trash).
Note that this method is not called automatically by KIO jobs. It's the application's responsibility to ask the user for confirmation before calling KIO::del() or KIO::trash().
You need to connect to the askUserDeleteResult signal to get the dialog's result (exit code).
urls the urls about to be moved to the Trash or deleted directly
deletionType the type of deletion (Delete for real deletion, Trash otherwise), see the DeletionType enum
confirmationType The type of deletion confirmation, see the ConfirmationType enum. Normally set to DefaultConfirmation
parent the parent widget of the message box
[signal]
void AskUserActionInterface::askUserDeleteResult(bool allowDelete, const QList<QUrl> &urls, KIO::AskUserActionInterface::DeletionType deletionType, QWidget *parent)
Implementations of this interface must emit this signal when the dialog invoked by askUserDelete() finishes, to notify the caller of the user's decision.
allowDelete set to true if the user confirmed the delete operation, otherwise set to false
urls a list of urls to delete/trash
deletionType the deletion type to use, one of KIO::AskUserActionInterface::DeletionType
parent the parent widget passed to askUserDelete(), for request identification
[pure virtual]
void AskUserActionInterface::askUserRename(KJob *job, const QString &title, const QUrl &src, const QUrl &dest, KIO::RenameDialog_Options options, KIO::filesize_t sizeSrc, KIO::filesize_t sizeDest, const QDateTime &ctimeSrc = {}, const QDateTime &ctimeDest = {}, const QDateTime &mtimeSrc = {}, const QDateTime &mtimeDest = {})
Constructs a modal, parent-less "rename" dialog, to prompt the user for a decision in case of conflicts, while copying/moving files. The dialog is shown using open(), rather than exec() (the latter creates a nested eventloop which could lead to crashes). You will need to connect to the askUserRenameResult() signal to get the dialog's result (exit code). The exit code is one of KIO::RenameDialog_Result.
job the job that called this method
title the title for the dialog box
src the URL of the file/dir being copied/moved
dest the URL of the destination file/dir, i.e. the one that already exists
options parameters for the dialog (which buttons to show... etc), OR'ed values
from the KIO::RenameDialog_Options enum
sizeSrc size of the source file
sizeDest size of the destination file
ctimeSrc creation time of the source file
ctimeDest creation time of the destination file
mtimeSrc modification time of the source file
mtimeDest modification time of the destination file
See also KIO::RenameDialog and KIO::RenameDialog_Result.
[signal]
void AskUserActionInterface::askUserRenameResult(KIO::RenameDialog_Result result, const QUrl &newUrl, KJob *parentJob)
Implementations of this interface must emit this signal when the rename dialog finishes, to notify the caller of the dialog's result.
result the exit code from the rename dialog, one of the KIO::RenameDialog_Result enum
newUrl the new destination URL set by the user
parentJob the job that invoked the dialog
[pure virtual]
void AskUserActionInterface::askUserSkip(KJob *job, KIO::SkipDialog_Options options, const QString &errorText)
You need to connect to the askUserSkipResult signal to get the dialog's result.
job the job that called this method
options parameters for the dialog (which buttons to show... etc), OR'ed values from the KIO::SkipDialog_Options enum
error_text the error text to show to the user (usually the string returned by KJob::errorText())
See also KIO::SkipDialog.
[signal]
void AskUserActionInterface::askUserSkipResult(KIO::SkipDialog_Result result, KJob *parentJob)
Implementations of this interface must emit this signal when the skip dialog finishes, to notify the caller of the dialog's result.
result the exit code from the skip dialog, one of the KIO::SkipDialog_Result enum
parentJob the job that invoked the dialog
[signal]
void AskUserActionInterface::messageBoxResult(int result)
Implementations of this interface must emit this signal when the dialog invoked by requestUserMessageBox() finishes, to notify the caller of the dialog's result (exit code).
result the exit code of the dialog, one of KIO::WorkerBase::ButtonCode enum
[pure virtual]
void AskUserActionInterface::requestUserMessageBox(KIO::AskUserActionInterface::MessageDialogType type, const QString &text, const QString &title, const QString &primaryActionText, const QString &secondatyActionText, const QString &primaryActionIconName = {}, const QString &secondatyActionIconName = {}, const QString &dontAskAgainName = {}, const QString &details = {}, QWidget *parent = nullptr)
This function allows for the delegation of user prompts from the KIO worker.
type the desired type of message box, see the MessageDialogType enum
text the message to show to the user
title the title of the message dialog box
primaryActionText the text for the primary action
secondatyActionText the text for the secondary action
primaryActionIconName the icon to show on the primary action
secondatyActionIconName the icon to show on the secondary action
dontAskAgainName the config key name used to store the result from 'Do not ask again' checkbox
details more details about the message shown to the user
parent the parent widget of the dialog