2 #include "ExplorationWorker.hpp"
4 #include <Device/Protocol/DeviceInterface.hpp>
6 #include <Explorer/Explorer/DeviceExplorerWidget.hpp>
8 #include <score/widgets/MessageBox.hpp>
10 #include <QApplication>
15 class DeviceExplorerWidget;
20 template <
typename OnSuccess>
23 QThread* thread =
new QThread;
30 template <
typename OnSuccess_t>
35 , m_success{std::move(success)}
38 thread, &QThread::started, worker,
39 [&]() { on_start(); },
40 Qt::QueuedConnection);
43 worker, &ExplorationWorker::finished,
this, &ExplorationWorkerWrapper::on_finish,
44 Qt::QueuedConnection);
47 worker, &ExplorationWorker::failed,
this, &ExplorationWorkerWrapper::on_fail,
48 Qt::QueuedConnection);
53 m_widget.blockGUI(
true);
54 worker->moveToThread(thread);
70 worker->node = worker->dev.refresh();
73 catch(std::runtime_error& e)
75 worker->failed(e.what());
81 m_widget.blockGUI(
false);
82 m_success(std::move(worker->node));
87 void on_fail(
const QString& str)
90 QApplication::activeWindow(), QObject::tr(
"Unable to refresh the device"),
91 QObject::tr(
"Unable to refresh the device: ") + worker->dev.settings().name
92 + QObject::tr(
".\nCause: ") + str);
94 m_widget.blockGUI(
false);
101 worker->deleteLater();
106 template <
typename OnSuccess_t>
107 static auto make_worker(
Definition: DeviceInterface.hpp:66
The ExplorationWorker class.
Definition: ExplorationWorker.hpp:23
Definition: ExplorationWorkerWrapper.hpp:22