File indexing completed on 2024-10-06 04:25:59
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 K3BEMPTYDISCWAITER_H 0008 #define K3BEMPTYDISCWAITER_H 0009 0010 #include "k3bjobhandler.h" 0011 #include "k3bdiskinfo.h" 0012 0013 #include <QCloseEvent> 0014 #include <QDialog> 0015 0016 0017 /** 0018 * Tests for an empty cd in a given device. 0019 * 0020 * Use the static wait methods. 0021 * 0022 * @author Sebastian Trueg 0023 */ 0024 namespace K3b { 0025 0026 namespace Device { 0027 class Device; 0028 } 0029 0030 class EmptyDiscWaiter : public QDialog, public JobHandler 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 ~EmptyDiscWaiter() override; 0036 0037 /** 0038 * the same as waitForEmptyDisc( false ); 0039 */ 0040 int exec() override; 0041 0042 /** 0043 * @reimplemented from JobHandler 0044 * \internal do not use! 0045 */ 0046 Device::MediaType waitForMedium( Device::Device*, 0047 Device::MediaStates mediaState = Device::STATE_EMPTY, 0048 Device::MediaTypes mediaType = Device::MEDIA_WRITABLE_CD, 0049 const K3b::Msf& minMediaSize = K3b::Msf(), 0050 const QString& message = QString() ) override; 0051 0052 /** 0053 * @reimplemented from JobHandler 0054 */ 0055 bool questionYesNo( const QString& text, 0056 const QString& caption = QString(), 0057 const KGuiItem& buttonYes = KStandardGuiItem::ok(), 0058 const KGuiItem& buttonNo = KStandardGuiItem::cancel() ) override; 0059 0060 /** 0061 * reimplemented from JobHandler 0062 */ 0063 void blockingInformation( const QString& text, 0064 const QString& caption = QString() ) override; 0065 0066 /** 0067 * Starts the emptydiskwaiter. 0068 * 0069 * \param mediaState a bitwise combination of the Device::State enum 0070 * \param mediaType a bitwise combination of the Device::MediaType enum 0071 * \return the found MediaType on success, MEDIA_UNKNOWN if canceled 0072 */ 0073 static Device::MediaType wait( Device::Device* device, 0074 Device::MediaStates mediaState, 0075 Device::MediaTypes mediaType = Device::MEDIA_WRITABLE_CD, 0076 const K3b::Msf& minMediaSize = K3b::Msf(), 0077 const QString& message = QString(), 0078 QWidget* parent = 0 ); 0079 0080 protected Q_SLOTS: 0081 void slotCancel(); 0082 void slotEject(); 0083 void slotLoad(); 0084 void slotMediumChanged( K3b::Device::Device* ); 0085 void showDialog(); 0086 void continueWaiting(); 0087 void slotErasingFinished( bool ); 0088 0089 protected: 0090 /** 0091 * Use the static wait methods. 0092 */ 0093 explicit EmptyDiscWaiter( Device::Device* device, QWidget* parent = 0 ); 0094 0095 Device::MediaType waitForDisc( Device::MediaStates mediaState = Device::STATE_EMPTY, 0096 Device::MediaTypes mediaType = Device::MEDIA_WRITABLE_CD, 0097 const K3b::Msf& minMediaSize = K3b::Msf(), 0098 const QString& message = QString() ); 0099 0100 0101 /** 0102 * Nobody closes this dialog but itself! 0103 */ 0104 void closeEvent( QCloseEvent *e ) override { e->ignore(); } 0105 0106 Q_SIGNALS: 0107 void leaveModality(); 0108 0109 private: 0110 void enterLoop(); 0111 void finishWaiting( Device::MediaType ); 0112 void prepareErasingDialog(); 0113 0114 QWidget* parentWidgetToUse(); 0115 0116 class Private; 0117 Private* d; 0118 }; 0119 } 0120 0121 0122 #endif