File indexing completed on 2024-04-21 03:56:17

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2000 Stephan Kulow <coolo@kde.org>
0004     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0005     SPDX-FileCopyrightText: 2006, 2007 Kevin Ottens <ervin@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #ifndef KDIALOGJOBUIDELEGATE_H
0011 #define KDIALOGJOBUIDELEGATE_H
0012 
0013 #include <KJobUiDelegate>
0014 #include <kjobwidgets_export.h>
0015 
0016 #include <memory>
0017 
0018 /**
0019  * @class KDialogJobUiDelegate kdialogjobuidelegate.h KDialogJobUiDelegate
0020  *
0021  * A UI delegate using KMessageBox for interaction (showing errors and warnings).
0022  *
0023  * The KMessageBox will use window as a parent in an application-modal.
0024  */
0025 class KJOBWIDGETS_EXPORT KDialogJobUiDelegate : public KJobUiDelegate
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     /**
0031      * Constructs a new KDialogJobUiDelegate.
0032      */
0033     KDialogJobUiDelegate();
0034 
0035     /**
0036      * Constructs a new KDialogJobUiDelegate.
0037      * @param flags allows to enable automatic error/warning handling
0038      * @param window the window associated with this delegate, see setWindow.
0039      * @since 5.70
0040      */
0041     explicit KDialogJobUiDelegate(KJobUiDelegate::Flags flags, QWidget *window);
0042 
0043     /**
0044      * Destroys the KDialogJobUiDelegate.
0045      */
0046     ~KDialogJobUiDelegate() override;
0047 
0048 public:
0049     /**
0050      * @reimp
0051      */
0052     bool setJob(KJob *job) override;
0053 
0054     /**
0055      * Associate this delegate with a window given by @p window.
0056      * Needed for dialog boxes to respect stacking order, centering to parent, focus going back to parent after closing...
0057      * @param window the window to associate to
0058      * @see window()
0059      */
0060     virtual void setWindow(QWidget *window);
0061 
0062     /**
0063      * Returns the window this delegate is associated with.
0064      * @return the associated window
0065      * @see setWindow()
0066      */
0067     QWidget *window() const;
0068 
0069     /**
0070      * Updates the last user action timestamp to the given time.
0071      * See KApplication::updateUserTimestamp().
0072      */
0073     void updateUserTimestamp(unsigned long time);
0074 
0075     /**
0076      * @internal
0077      */
0078     unsigned long userTimestamp() const;
0079 
0080     void showErrorMessage() override;
0081 
0082 protected Q_SLOTS:
0083     void slotWarning(KJob *job, const QString &message) override;
0084 
0085 private:
0086     std::unique_ptr<class KDialogJobUiDelegatePrivate> const d;
0087 };
0088 
0089 #endif