mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Factor some common stuff into the MainWindow class.
This commit is contained in:
@@ -44,6 +44,7 @@ cxxlibrary(
|
||||
name="guilib",
|
||||
srcs=[
|
||||
"./main.cc",
|
||||
"./mainwindow.cc",
|
||||
"./drivecomponent.cc",
|
||||
"./formatcomponent.cc",
|
||||
"./fluxcomponent.cc",
|
||||
@@ -56,6 +57,7 @@ cxxlibrary(
|
||||
"drivecomponent.h": "./drivecomponent.h",
|
||||
"formatcomponent.h": "./formatcomponent.h",
|
||||
"datastore.h": "./datastore.h",
|
||||
"mainwindow.h": "./mainwindow.h",
|
||||
},
|
||||
cflags=["-fPIC"],
|
||||
deps=[
|
||||
@@ -73,7 +75,6 @@ cxxprogram(
|
||||
"./mainwindow-imager.cc",
|
||||
"./fluxvisualiserwidget.cc",
|
||||
"./imagevisualiserwidget.cc",
|
||||
"./mainwindow.h",
|
||||
],
|
||||
cflags=["-fPIC"],
|
||||
ldflags=["$(QT5_EXTRA_LIBS)"],
|
||||
|
||||
@@ -20,12 +20,15 @@ public:
|
||||
public:
|
||||
void setDiskData(std::shared_ptr<const DiskFlux> diskData) override {}
|
||||
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> trackData) override {
|
||||
key_t key = {trackData->trackInfo->physicalTrack, trackData->trackInfo->physicalSide};
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> trackData) override
|
||||
{
|
||||
key_t key = {trackData->trackInfo->physicalTrack,
|
||||
trackData->trackInfo->physicalSide};
|
||||
_tracks[key] = trackData;
|
||||
}
|
||||
|
||||
void setImageData(std::shared_ptr<const Image> imageData) override {
|
||||
void setImageData(std::shared_ptr<const Image> imageData) override
|
||||
{
|
||||
clear();
|
||||
_loadedSectors = *imageData;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ private:
|
||||
public:
|
||||
MainWindowImpl()
|
||||
{
|
||||
setupUi(this);
|
||||
_driveComponent = DriveComponent::create(this);
|
||||
_formatComponent = FormatComponent::create(this);
|
||||
_fluxComponent = FluxComponent::create(this);
|
||||
@@ -33,25 +32,10 @@ public:
|
||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
||||
|
||||
_progressWidget = new QProgressBar();
|
||||
_progressWidget->setMinimum(0);
|
||||
_progressWidget->setMaximum(100);
|
||||
_progressWidget->setEnabled(false);
|
||||
_progressWidget->setAlignment(Qt::AlignRight);
|
||||
statusbar->addPermanentWidget(_progressWidget);
|
||||
|
||||
_stopWidget = new QToolButton();
|
||||
_stopWidget->setText("Stop");
|
||||
statusbar->addPermanentWidget(_stopWidget);
|
||||
|
||||
connect(readDiskButton,
|
||||
&QAbstractButton::clicked,
|
||||
this,
|
||||
&MainWindowImpl::readDisk);
|
||||
connect(_stopWidget,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&MainWindowImpl::emergencyStop);
|
||||
|
||||
setState(STATE_IDLE);
|
||||
}
|
||||
@@ -144,12 +128,6 @@ private:
|
||||
W_SLOT(readDisk)
|
||||
|
||||
private:
|
||||
void emergencyStop()
|
||||
{
|
||||
::emergencyStop = true;
|
||||
}
|
||||
W_SLOT(emergencyStop)
|
||||
|
||||
void setState(int state)
|
||||
{
|
||||
_stopWidget->setEnabled(state != STATE_IDLE);
|
||||
@@ -163,26 +141,11 @@ private:
|
||||
}
|
||||
W_SLOT(setState)
|
||||
|
||||
private:
|
||||
void runThen(
|
||||
std::function<void()> workCb, std::function<void()> completionCb)
|
||||
{
|
||||
QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this);
|
||||
watcher->setFuture(safeRunOnWorkerThread(workCb));
|
||||
connect(watcher, &QFutureWatcher<void>::finished, completionCb);
|
||||
connect(watcher,
|
||||
&QFutureWatcher<void>::finished,
|
||||
watcher,
|
||||
&QFutureWatcher<void>::deleteLater);
|
||||
}
|
||||
|
||||
private:
|
||||
DriveComponent* _driveComponent;
|
||||
FormatComponent* _formatComponent;
|
||||
FluxComponent* _fluxComponent;
|
||||
ImageComponent* _imageComponent;
|
||||
QAbstractButton* _stopWidget;
|
||||
QProgressBar* _progressWidget;
|
||||
std::shared_ptr<const DiskFlux> _currentDisk;
|
||||
int _state;
|
||||
};
|
||||
|
||||
44
src/gui2/mainwindow.cc
Normal file
44
src/gui2/mainwindow.cc
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "lib/globals.h"
|
||||
#include "lib/config.h"
|
||||
#include "lib/readerwriter.h"
|
||||
#include "lib/utils.h"
|
||||
#include "globals.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
W_OBJECT_IMPL(MainWindow)
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
_progressWidget = new QProgressBar();
|
||||
_progressWidget->setMinimum(0);
|
||||
_progressWidget->setMaximum(100);
|
||||
_progressWidget->setEnabled(false);
|
||||
_progressWidget->setAlignment(Qt::AlignRight);
|
||||
statusbar->addPermanentWidget(_progressWidget);
|
||||
|
||||
_stopWidget = new QToolButton();
|
||||
_stopWidget->setText("Stop");
|
||||
statusbar->addPermanentWidget(_stopWidget);
|
||||
|
||||
connect(_stopWidget,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
[&]()
|
||||
{
|
||||
::emergencyStop = true;
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::runThen(
|
||||
std::function<void()> workCb, std::function<void()> completionCb)
|
||||
{
|
||||
QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this);
|
||||
watcher->setFuture(safeRunOnWorkerThread(workCb));
|
||||
connect(watcher, &QFutureWatcher<void>::finished, completionCb);
|
||||
connect(watcher,
|
||||
&QFutureWatcher<void>::finished,
|
||||
watcher,
|
||||
&QFutureWatcher<void>::deleteLater);
|
||||
}
|
||||
@@ -5,10 +5,23 @@
|
||||
|
||||
class MainWindow : public QMainWindow, public Ui_MainWindow
|
||||
{
|
||||
W_OBJECT(MainWindow)
|
||||
|
||||
public:
|
||||
static std::unique_ptr<MainWindow> create();
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
public:
|
||||
virtual void logMessage(std::shared_ptr<const AnyLogMessage> message) = 0;
|
||||
virtual void collectConfig() = 0;
|
||||
|
||||
protected:
|
||||
void runThen(
|
||||
std::function<void()> workCb, std::function<void()> completionCb);
|
||||
|
||||
protected:
|
||||
QAbstractButton* _stopWidget;
|
||||
QProgressBar* _progressWidget;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user