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:
parent
c065b57f0c
commit
9531a08b4a
@ -3,21 +3,22 @@
|
|||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "progress_event.h"
|
#include "progress_event.h"
|
||||||
|
#include "plugins/interfaces.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
MainWindow::MainWindow(hwinf *hw, Worker *worker, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
|
, m_hw(hw)
|
||||||
, m_worker(worker)
|
, m_worker(worker)
|
||||||
, m_width(70)
|
, m_width(70)
|
||||||
, m_progressRunning(false)
|
, m_progressRunning(false)
|
||||||
, m_progressValue(0) {
|
, m_progressValue(0) {
|
||||||
|
|
||||||
|
|
||||||
this->setStatusBar(new QStatusBar(this));
|
this->setStatusBar(new QStatusBar(this));
|
||||||
QFont f;
|
QFont f;
|
||||||
f.setStyleHint(QFont::Monospace);
|
f.setStyleHint(QFont::Monospace);
|
||||||
|
@ -11,6 +11,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
|
|
||||||
|
class hwinf;
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -18,13 +19,15 @@ protected:
|
|||||||
void customEvent(QEvent *event) override;
|
void customEvent(QEvent *event) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(Worker *worker, QWidget *parent = nullptr);
|
MainWindow(hwinf *hw, Worker *worker, QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
static const int START_PROGRESS_LOOP = -1;
|
static const int START_PROGRESS_LOOP = -1;
|
||||||
static const int STOP_PROGRESS_LOOP = -2;
|
static const int STOP_PROGRESS_LOOP = -2;
|
||||||
|
|
||||||
int progressValue() const { return m_progressValue; }
|
int progressValue() const { return m_progressValue; }
|
||||||
|
hwinf *getPlugin() { return m_hw; }
|
||||||
|
hwinf const *getPlugin() const { return m_hw; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAppendText(QString, QString suffix = "");
|
void onAppendText(QString, QString suffix = "");
|
||||||
@ -43,6 +46,7 @@ private:
|
|||||||
void scrollDownTextEdit();
|
void scrollDownTextEdit();
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
hwinf *m_hw;
|
||||||
Worker *m_worker;
|
Worker *m_worker;
|
||||||
int m_width;
|
int m_width;
|
||||||
QTimer *m_startTimer;
|
QTimer *m_startTimer;
|
||||||
|
Loading…
Reference in New Issue
Block a user