File indexing completed on 2024-10-06 04:26:00
0001 /* 0002 SPDX-FileCopyrightText: 1998-2010 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 0007 #ifndef _K3B_JOB_PROGRESSDIALOG_H_ 0008 #define _K3B_JOB_PROGRESSDIALOG_H_ 0009 0010 0011 #include "k3bdebuggingoutputfile.h" 0012 #include "k3bdebuggingoutputcache.h" 0013 #include "k3bjobhandler.h" 0014 0015 #include <QElapsedTimer> 0016 #include <QDialog> 0017 0018 class KSqueezedTextLabel; 0019 class QCloseEvent; 0020 class QFrame; 0021 class QGridLayout; 0022 class QKeyEvent; 0023 class QLabel; 0024 class QProgressBar; 0025 class QShowEvent; 0026 class QElapsedTimer; 0027 0028 namespace K3b { 0029 class Job; 0030 class ThemedLabel; 0031 0032 class JobProgressDialog : public QDialog, public JobHandler 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit JobProgressDialog( QWidget* parent = 0, 0038 bool showSubProgress = true ); 0039 ~JobProgressDialog() override; 0040 0041 virtual void setJob( Job* job ); 0042 void setExtraInfo( QWidget *extra ); 0043 0044 /** 0045 * This will show the dialog and then start the given job or 0046 * if job == 0 the job set with setJob 0047 * Use instead of exec() 0048 */ 0049 int startJob( Job* job = 0 ); 0050 0051 QSize sizeHint() const override; 0052 0053 /** 0054 * @reimplemented from JobHandler 0055 */ 0056 Device::MediaType waitForMedium( Device::Device*, 0057 Device::MediaStates mediaState = Device::STATE_EMPTY, 0058 Device::MediaTypes mediaType = Device::MEDIA_WRITABLE_CD, 0059 const K3b::Msf& minMediaSize = K3b::Msf(), 0060 const QString& message = QString() ) override; 0061 0062 /** 0063 * @reimplemented from JobHandler 0064 */ 0065 bool questionYesNo( const QString& text, 0066 const QString& caption = QString(), 0067 const KGuiItem& buttonYes = KStandardGuiItem::ok(), 0068 const KGuiItem& buttonNo = KStandardGuiItem::cancel() ) override; 0069 0070 /** 0071 * reimplemented from JobHandler 0072 */ 0073 void blockingInformation( const QString& text, 0074 const QString& caption = QString() ) override; 0075 0076 protected Q_SLOTS: 0077 virtual void slotProcessedSize( int processed, int size ); 0078 virtual void slotProcessedSubSize( int processed, int size ); 0079 virtual void slotInfoMessage( const QString& infoString, int type ); 0080 virtual void slotDebuggingOutput( const QString&, const QString& ); 0081 virtual void slotNewSubTask(const QString& name); 0082 virtual void slotNewTask(const QString& name); 0083 virtual void slotFinished(bool); 0084 virtual void slotCanceled(); 0085 virtual void slotStarted(); 0086 0087 /** 0088 * \reimpl from QDialog 0089 */ 0090 void reject() override; 0091 0092 void slotShowDebuggingOutput(); 0093 0094 void slotProgress( int ); 0095 0096 virtual void slotThemeChanged(); 0097 0098 protected: 0099 bool event( QEvent* event ) override; 0100 void showEvent( QShowEvent* e ) override; 0101 void closeEvent( QCloseEvent* e ) override; 0102 void keyPressEvent( QKeyEvent* e ) override; 0103 0104 void setupGUI(); 0105 0106 ThemedLabel* m_labelJob; 0107 ThemedLabel* m_labelJobDetails; 0108 ThemedLabel* m_labelTask; 0109 QLabel* m_labelRemainingTime; 0110 QLabel* m_labelElapsedTime; 0111 KSqueezedTextLabel* m_labelSubTask; 0112 QLabel* m_labelSubProcessedSize; 0113 QProgressBar* m_progressSubPercent; 0114 QLabel* m_labelProcessedSize; 0115 QProgressBar* m_progressPercent; 0116 QFrame* m_frameExtraInfo; 0117 ThemedLabel* m_pixLabel; 0118 QPushButton* m_cancelButton; 0119 QPushButton* m_showDbgOutButton; 0120 QPushButton* m_closeButton; 0121 0122 QGridLayout* m_frameExtraInfoLayout; 0123 0124 private: 0125 class Private; 0126 Private* d; 0127 0128 Job* m_job; 0129 QElapsedTimer m_timer; 0130 qint64 m_lastProgressUpdateTime; 0131 0132 DebuggingOutputFile m_logFile; 0133 DebuggingOutputCache m_logCache; 0134 0135 bool m_bCanceled; 0136 0137 QString m_plainCaption; 0138 }; 0139 } 0140 0141 #endif