Add static concurrent support to ScanningDialog.
This commit is contained in:
parent
d28946040f
commit
e1140b6fa8
@ -22,12 +22,17 @@
|
|||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
|
|
||||||
ScanningDialog::ScanningDialog(const QString& text, QWidget* parent)
|
ScanningDialog::ScanningDialog( const QString& text,
|
||||||
|
const QString& windowTitle,
|
||||||
|
QWidget* parent )
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
{
|
{
|
||||||
setModal( true );
|
setModal( true );
|
||||||
|
setWindowTitle( windowTitle );
|
||||||
|
|
||||||
QHBoxLayout* dialogLayout = new QHBoxLayout;
|
QHBoxLayout* dialogLayout = new QHBoxLayout;
|
||||||
setLayout( dialogLayout );
|
setLayout( dialogLayout );
|
||||||
@ -41,6 +46,31 @@ ScanningDialog::ScanningDialog(const QString& text, QWidget* parent)
|
|||||||
dialogLayout->addWidget( rescanningLabel );
|
dialogLayout->addWidget( rescanningLabel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScanningDialog::run( const QFuture< void >& future,
|
||||||
|
const QString& text,
|
||||||
|
const QString& windowTitle,
|
||||||
|
QWidget* parent )
|
||||||
|
{
|
||||||
|
ScanningDialog* theDialog =
|
||||||
|
new ScanningDialog( text,
|
||||||
|
windowTitle,
|
||||||
|
parent );
|
||||||
|
theDialog->show();
|
||||||
|
|
||||||
|
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
||||||
|
connect( watcher, &QFutureWatcher< void >::finished,
|
||||||
|
theDialog, [ watcher, theDialog ]
|
||||||
|
{
|
||||||
|
watcher->deleteLater();
|
||||||
|
theDialog->hide();
|
||||||
|
theDialog->deleteLater();
|
||||||
|
} );
|
||||||
|
|
||||||
|
watcher->setFuture( future );
|
||||||
|
}
|
||||||
|
|
||||||
void ScanningDialog::setVisible(bool visible)
|
void ScanningDialog::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
QDialog::setVisible( visible );
|
QDialog::setVisible( visible );
|
||||||
|
@ -20,13 +20,20 @@
|
|||||||
#define SCANNINGDIALOG_H
|
#define SCANNINGDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QFuture>
|
||||||
|
|
||||||
class ScanningDialog : public QDialog
|
class ScanningDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ScanningDialog( const QString& text, QWidget* parent = nullptr );
|
explicit ScanningDialog( const QString& text,
|
||||||
|
const QString& windowTitle,
|
||||||
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
static void run( const QFuture< void >& future,
|
||||||
|
const QString& text,
|
||||||
|
const QString& windowTitle,
|
||||||
|
QWidget* parent = nullptr );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setVisible( bool visible ) override;
|
void setVisible( bool visible ) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user