launch/installwizard_copy.h

61 lines
1.2 KiB
C++

#ifndef INSTALLWIZARD_COPY_H
#define INSTALLWIZARD_COPY_H
#include <QMutex>
#include <QThread>
#include <QWizardPage>
namespace Ui {
class InstallWizard_Copy;
}
class CopyWorker : public QObject
{
Q_OBJECT
public:
CopyWorker();
void cancel();
public slots:
void copy(const QString &source, const QString &destination);
signals:
void progressChanged(qint64 bytesWritten, qint64 bytesTotal);
void errorMessage(const QString &message);
void copyFinished();
private:
static const int bufferSize = 32 * 1024;
char buffer[bufferSize];
bool isCancelled;
QMutex cancelMutex;
};
class InstallWizard_Copy : public QWizardPage
{
Q_OBJECT
public:
explicit InstallWizard_Copy(QWidget *parent = 0);
~InstallWizard_Copy();
virtual void initializePage();
virtual bool isComplete() const;
void cancel();
private slots:
void setCopyProgress(qint64 bytesWritten, qint64 bytesTotal);
void setCopyErrorMessage(const QString &message);
void finishCopy();
signals:
void copy(const QString &source, const QString &destination);
private:
Ui::InstallWizard_Copy *ui;
CopyWorker *copyWorker;
QThread copyThread;
bool isCopyFinished;
};
#endif // INSTALLWIZARD_COPY_H