Make rescan asynchronous in manual partitioning, and use ScanningDialog
This commit is contained in:
parent
a1e4667ebe
commit
523c25f1e2
@ -26,6 +26,7 @@
|
|||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
#include "gui/CreatePartitionDialog.h"
|
#include "gui/CreatePartitionDialog.h"
|
||||||
#include "gui/EditExistingPartitionDialog.h"
|
#include "gui/EditExistingPartitionDialog.h"
|
||||||
|
#include "gui/ScanningDialog.h"
|
||||||
|
|
||||||
#include "ui_PartitionPage.h"
|
#include "ui_PartitionPage.h"
|
||||||
#include "ui_CreatePartitionTableDialog.h"
|
#include "ui_CreatePartitionTableDialog.h"
|
||||||
@ -43,6 +44,8 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
@ -188,13 +191,33 @@ PartitionPage::onDeleteClicked()
|
|||||||
m_core->deletePartition( model->device(), partition );
|
m_core->deletePartition( model->device(), partition );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionPage::onRevertClicked()
|
PartitionPage::onRevertClicked()
|
||||||
{
|
{
|
||||||
|
ScanningDialog* rescanningDialog =
|
||||||
|
new ScanningDialog( tr( "Scanning storage devices..." ), this );
|
||||||
|
rescanningDialog->show();
|
||||||
|
|
||||||
|
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
||||||
|
connect( watcher, &QFutureWatcher< void >::finished,
|
||||||
|
this, [ watcher, rescanningDialog ]
|
||||||
|
{
|
||||||
|
watcher->deleteLater();
|
||||||
|
rescanningDialog->hide();
|
||||||
|
rescanningDialog->deleteLater();
|
||||||
|
} );
|
||||||
|
|
||||||
|
QFuture< void > future = QtConcurrent::run( [ this ]
|
||||||
|
{
|
||||||
|
QMutexLocker locker( &m_revertMutex );
|
||||||
|
|
||||||
int oldIndex = m_ui->deviceComboBox->currentIndex();
|
int oldIndex = m_ui->deviceComboBox->currentIndex();
|
||||||
m_core->revert();
|
m_core->revertAllDevices();
|
||||||
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice();
|
||||||
|
} );
|
||||||
|
watcher->setFuture( future );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
class Ui_PartitionPage;
|
class Ui_PartitionPage;
|
||||||
@ -59,6 +60,8 @@ private:
|
|||||||
void editExistingPartition( Device*, Partition* );
|
void editExistingPartition( Device*, Partition* );
|
||||||
void updateBootLoaderInstallPath();
|
void updateBootLoaderInstallPath();
|
||||||
void updateFromCurrentDevice();
|
void updateFromCurrentDevice();
|
||||||
|
|
||||||
|
QMutex m_revertMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITIONPAGE_H
|
#endif // PARTITIONPAGE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user