Add callback support to ScanningDialog statics.
This commit is contained in:
parent
50ef1f1b70
commit
5df78cc513
@ -51,6 +51,7 @@ void
|
|||||||
ScanningDialog::run( const QFuture< void >& future,
|
ScanningDialog::run( const QFuture< void >& future,
|
||||||
const QString& text,
|
const QString& text,
|
||||||
const QString& windowTitle,
|
const QString& windowTitle,
|
||||||
|
const std::function< void() >& callback,
|
||||||
QWidget* parent )
|
QWidget* parent )
|
||||||
{
|
{
|
||||||
ScanningDialog* theDialog =
|
ScanningDialog* theDialog =
|
||||||
@ -61,11 +62,12 @@ ScanningDialog::run( const QFuture< void >& future,
|
|||||||
|
|
||||||
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
||||||
connect( watcher, &QFutureWatcher< void >::finished,
|
connect( watcher, &QFutureWatcher< void >::finished,
|
||||||
theDialog, [ watcher, theDialog ]
|
theDialog, [ watcher, theDialog, callback ]
|
||||||
{
|
{
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
theDialog->hide();
|
theDialog->hide();
|
||||||
theDialog->deleteLater();
|
theDialog->deleteLater();
|
||||||
|
callback();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
watcher->setFuture( future );
|
watcher->setFuture( future );
|
||||||
@ -73,11 +75,14 @@ ScanningDialog::run( const QFuture< void >& future,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScanningDialog::run( const QFuture< void >& future, QWidget* parent )
|
ScanningDialog::run( const QFuture< void >& future,
|
||||||
|
const std::function< void() >& callback,
|
||||||
|
QWidget* parent )
|
||||||
{
|
{
|
||||||
ScanningDialog::run( future,
|
ScanningDialog::run( future,
|
||||||
tr( "Scanning storage devices..." ),
|
tr( "Scanning storage devices..." ),
|
||||||
tr( "Partitioning" ),
|
tr( "Partitioning" ),
|
||||||
|
callback,
|
||||||
parent );
|
parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class ScanningDialog : public QDialog
|
class ScanningDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -33,9 +35,11 @@ public:
|
|||||||
static void run( const QFuture< void >& future,
|
static void run( const QFuture< void >& future,
|
||||||
const QString& text,
|
const QString& text,
|
||||||
const QString& windowTitle,
|
const QString& windowTitle,
|
||||||
|
const std::function< void() >& callback = []{},
|
||||||
QWidget* parent = nullptr );
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
static void run( const QFuture< void >& future,
|
static void run( const QFuture< void >& future,
|
||||||
|
const std::function< void() >& callback = []{},
|
||||||
QWidget* parent = nullptr );
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user