File indexing completed on 2024-04-28 09:43:52
0001 /* 0002 SPDX-FileCopyrightText: 2019 Farid Boudedja <farid.boudedja@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef MAINWINDOW_H 0008 #define MAINWINDOW_H 0009 0010 #include "usbdevice.h" 0011 #include "externalprogressbar.h" 0012 #include "isoverifier.h" 0013 0014 #include <QMainWindow> 0015 #include <QLabel> 0016 #include <QComboBox> 0017 #include <QPushButton> 0018 #include <QProgressBar> 0019 #include <QStackedWidget> 0020 #include <KPixmapSequenceOverlayPainter> 0021 0022 class FetchIsoJob; 0023 class IsoLineEdit; 0024 0025 class MainWindow : public QMainWindow 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit MainWindow(QWidget *parent = nullptr); 0031 0032 public slots: 0033 void scheduleEnumFlashDevices(); 0034 void showInputDialog(const QString &title, const QString &body); 0035 0036 signals: 0037 void inputTextReady(bool ok, const QString &text); 0038 void downloadProgressChanged(int percentage); 0039 void verificationResult(bool verified); 0040 0041 private: 0042 QLabel *m_busyLabel; 0043 QWidget *m_busyWidget; 0044 QLabel *m_isoImageSizeLabel; 0045 IsoLineEdit *m_isoImageLineEdit; 0046 QComboBox *m_usbDriveComboBox; 0047 QPushButton *m_createButton; 0048 QPushButton *m_cancelButton; 0049 QProgressBar *m_progressBar; 0050 QStackedWidget *m_centralStackedWidget; 0051 KPixmapSequenceOverlayPainter *m_busySpinner; 0052 FetchIsoJob *m_fetchIso = nullptr; 0053 0054 QString m_isoImagePath; 0055 quint64 m_isoImageSize; 0056 QString m_lastOpenedDir; 0057 bool m_isWriting; 0058 bool m_enumFlashDevicesWaiting; 0059 ExternalProgressBar m_externalProgressBar; 0060 0061 void setupUi(); 0062 QWidget* createFormWidget(); 0063 QWidget* createConfirmWidget(); 0064 QWidget* createProgressWidget(); 0065 QWidget* createSuccessWidget(); 0066 void preprocessIsoImage(const QString& isoImagePath); 0067 void cleanUp(); 0068 void enumFlashDevices(); 0069 void writeToDevice(bool zeroing); 0070 0071 void dragEnterEvent(QDragEnterEvent* event) override; 0072 void dropEvent(QDropEvent* event) override; 0073 void closeEvent(QCloseEvent* event) override; 0074 0075 static void addFlashDeviceCallback(void* cbParam, UsbDevice* device); 0076 0077 private slots: 0078 void openIsoImage(); 0079 void writeIsoImage(); 0080 void updateProgressBar(int increment); 0081 void showWritingProgress(); 0082 void hideWritingProgress(); 0083 void showErrorMessage(const QString &message); 0084 void showSuccessMessage(); 0085 void showConfirmMessage(); 0086 void showIsoVerificationResult(IsoVerifier::VerifyResult result, const QString &error); 0087 void openUrl(const QUrl &url); 0088 }; 0089 0090 #endif // MAINWINDOW_H