Add a pointer to the device-controller-plugin. The main window will always be

owned by the GUI thread, and the GUI thread is loading the plugin. Hence the
worker-thread does not block itself when inside a QT slot.
This commit is contained in:
Gerhard Hoffmann 2023-09-06 09:07:45 +02:00
parent c065b57f0c
commit 9531a08b4a
2 changed files with 8 additions and 3 deletions

View File

@ -3,21 +3,22 @@
#include "worker.h"
#include "utils.h"
#include "progress_event.h"
#include "plugins/interfaces.h"
#include <QDateTime>
#include <QMessageBox>
#include <QDebug>
#include <QScrollBar>
MainWindow::MainWindow(Worker *worker, QWidget *parent)
MainWindow::MainWindow(hwinf *hw, Worker *worker, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_hw(hw)
, m_worker(worker)
, m_width(70)
, m_progressRunning(false)
, m_progressValue(0) {
this->setStatusBar(new QStatusBar(this));
QFont f;
f.setStyleHint(QFont::Monospace);

View File

@ -11,6 +11,7 @@ QT_END_NAMESPACE
#include "worker.h"
class hwinf;
class MainWindow : public QMainWindow {
Q_OBJECT
@ -18,13 +19,15 @@ protected:
void customEvent(QEvent *event) override;
public:
MainWindow(Worker *worker, QWidget *parent = nullptr);
MainWindow(hwinf *hw, Worker *worker, QWidget *parent = nullptr);
~MainWindow();
static const int START_PROGRESS_LOOP = -1;
static const int STOP_PROGRESS_LOOP = -2;
int progressValue() const { return m_progressValue; }
hwinf *getPlugin() { return m_hw; }
hwinf const *getPlugin() const { return m_hw; }
public slots:
void onAppendText(QString, QString suffix = "");
@ -43,6 +46,7 @@ private:
void scrollDownTextEdit();
Ui::MainWindow *ui;
hwinf *m_hw;
Worker *m_worker;
int m_width;
QTimer *m_startTimer;