mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Drive configuration panes are now mostly there.
This commit is contained in:
@@ -53,22 +53,23 @@ cxxprogram(
|
||||
ldflags=["$(QT5_EXTRA_LIBS)"],
|
||||
deps=[
|
||||
"+fl2_proto_lib",
|
||||
"+fmt_lib",
|
||||
"+lib",
|
||||
"+protobuf_lib",
|
||||
"+protocol",
|
||||
"+z_lib",
|
||||
".+Qt5Concurrent",
|
||||
".+Qt5Widgets",
|
||||
".+userinterface",
|
||||
"dep/adflib",
|
||||
"dep/fatfs",
|
||||
"dep/hfsutils",
|
||||
"dep/libusbp",
|
||||
"dep/verdigris",
|
||||
"extras+icons",
|
||||
"+lib",
|
||||
"lib+config_proto_lib",
|
||||
"src/formats",
|
||||
"src/gui/drivetypes",
|
||||
"+z_lib",
|
||||
"+fmt_lib",
|
||||
"+protobuf_lib",
|
||||
".+Qt5Widgets",
|
||||
".+Qt5Concurrent",
|
||||
".+userinterface",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>230</height>
|
||||
<height>224</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_4"/>
|
||||
<widget class="QLineEdit" name="portLineEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
@@ -25,7 +25,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBox_4">
|
||||
<widget class="QComboBox" name="driveComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -42,7 +42,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBox_5">
|
||||
<widget class="QComboBox" name="driveTypeComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -59,7 +59,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QRadioButton" name="radioButton_11">
|
||||
<widget class="QRadioButton" name="defaultSampleTimeCheckbox">
|
||||
<property name="text">
|
||||
<string>Default for format</string>
|
||||
</property>
|
||||
@@ -68,14 +68,14 @@
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_10">
|
||||
<widget class="QRadioButton" name="customSampleTimeCheckBox">
|
||||
<property name="text">
|
||||
<string>Custom:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_2">
|
||||
<widget class="QSpinBox" name="customSampleTimeSpinbox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -105,7 +105,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<widget class="QCheckBox" name="highDensityToggle">
|
||||
<property name="text">
|
||||
<string>High density disk inserted</string>
|
||||
</property>
|
||||
|
||||
@@ -7,16 +7,31 @@
|
||||
#include "fluxConfigurationForm.h"
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class DriveComponentImpl : public DriveComponent
|
||||
class DriveComponentImpl : public DriveComponent, public QObject
|
||||
{
|
||||
private:
|
||||
W_OBJECT(DriveComponentImpl)
|
||||
|
||||
public:
|
||||
class ConfigurationForm : public QStandardItem
|
||||
{
|
||||
public:
|
||||
ConfigurationForm(QIcon icon, const std::string text):
|
||||
QStandardItem(icon, QString::fromStdString(text))
|
||||
ConfigurationForm(
|
||||
DriveComponentImpl* dci, QIcon icon, const std::string text):
|
||||
QStandardItem(icon, QString::fromStdString(text)),
|
||||
_dci(dci)
|
||||
{
|
||||
_widget = new QWidget();
|
||||
}
|
||||
|
||||
public:
|
||||
QWidget* widget() const
|
||||
{
|
||||
return _widget;
|
||||
}
|
||||
|
||||
protected:
|
||||
DriveComponentImpl* _dci;
|
||||
QWidget* _widget;
|
||||
};
|
||||
|
||||
class FluxConfigurationForm :
|
||||
@@ -24,73 +39,111 @@ private:
|
||||
public Ui_fluxConfigurationForm
|
||||
{
|
||||
public:
|
||||
FluxConfigurationForm():
|
||||
ConfigurationForm(QIcon(":/ui/extras/fluxfile.png"), "Flux file")
|
||||
FluxConfigurationForm(DriveComponentImpl* dci):
|
||||
ConfigurationForm(
|
||||
dci, QIcon(":/ui/extras/fluxfile.png"), "Flux file")
|
||||
{
|
||||
setupUi(_widget);
|
||||
}
|
||||
};
|
||||
|
||||
class DetectedDriveConfigurationForm :
|
||||
class DriveConfigurationForm :
|
||||
public ConfigurationForm,
|
||||
public Ui_driveConfigurationForm
|
||||
{
|
||||
public:
|
||||
DetectedDriveConfigurationForm(
|
||||
const std::string& type, const std::string& id):
|
||||
ConfigurationForm(QIcon(":/ui/extras/hardware.png"),
|
||||
fmt::format("{}\n{}", type, id))
|
||||
DriveConfigurationForm(
|
||||
DriveComponentImpl* dci, QIcon icon, const std::string& label):
|
||||
ConfigurationForm(dci, icon, label)
|
||||
{
|
||||
setupUi(_widget);
|
||||
}
|
||||
};
|
||||
|
||||
class ManualDriveConfigurationForm : public DriveConfigurationForm
|
||||
{
|
||||
public:
|
||||
ManualDriveConfigurationForm(DriveComponentImpl* dci):
|
||||
DriveConfigurationForm(dci,
|
||||
QIcon(":/ui/extras/hardware.png"),
|
||||
"Greaseweazle\n(configured manually)")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DetectedDriveConfigurationForm : public DriveConfigurationForm
|
||||
{
|
||||
public:
|
||||
DetectedDriveConfigurationForm(DriveComponentImpl* dci,
|
||||
const std::string& type,
|
||||
const std::string& id, std::shared_ptr<CandidateDevice>& device):
|
||||
DriveConfigurationForm(dci,
|
||||
QIcon(":/ui/extras/hardware.png"),
|
||||
fmt::format("{}\n{}", type, id)),
|
||||
_device(device)
|
||||
{
|
||||
portLineEdit->setEnabled(false);
|
||||
portLineEdit->setText(QString::fromStdString(_device->serialPort));
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<CandidateDevice>& _device;
|
||||
};
|
||||
|
||||
public:
|
||||
DriveComponentImpl(MainWindow* mainWindow): _mainWindow(mainWindow)
|
||||
{
|
||||
_mainWindow->connect(_mainWindow->deviceSelectionComboBox,
|
||||
QOverload<int>::of(&QComboBox::activated),
|
||||
[this](int index)
|
||||
{
|
||||
onDeviceIndexChanged(index);
|
||||
});
|
||||
this,
|
||||
&DriveComponentImpl::onDeviceIndexChanged);
|
||||
|
||||
_devicesModel.setColumnCount(1);
|
||||
_mainWindow->deviceSelectionComboBox->setModel(&_devicesModel);
|
||||
|
||||
_devicesModel.appendRow(new FluxConfigurationForm());
|
||||
_devicesModel.appendRow(
|
||||
new QStandardItem(QIcon(":/ui/extras/hardware.png"),
|
||||
"Greaseweazle\n(manually configured)"));
|
||||
addForm(new FluxConfigurationForm(this));
|
||||
addForm(new ManualDriveConfigurationForm(this));
|
||||
|
||||
auto devices = runOnWorkerThread(findUsbDevices).result();
|
||||
for (const auto& it : devices)
|
||||
{
|
||||
_devicesModel.appendRow(new DetectedDriveConfigurationForm(
|
||||
getDeviceName(it->type), it->serial));
|
||||
}
|
||||
fmt::print("device count = {}\n", devices.size());
|
||||
for (auto& it : devices)
|
||||
addForm(new DetectedDriveConfigurationForm(
|
||||
this, getDeviceName(it->type), it->serial, it));
|
||||
|
||||
onDeviceIndexChanged(0);
|
||||
}
|
||||
|
||||
private:
|
||||
void onDeviceIndexChanged(int index)
|
||||
void addForm(ConfigurationForm* form)
|
||||
{
|
||||
fmt::print("value changed {}\n", index);
|
||||
_forms.append(form);
|
||||
_devicesModel.appendRow(form);
|
||||
|
||||
container()->layout()->addWidget(form->widget());
|
||||
form->widget()->hide();
|
||||
}
|
||||
|
||||
public:
|
||||
void setDriveConfigurationPane(QWidget* active) override
|
||||
void onDeviceIndexChanged(int index)
|
||||
{
|
||||
for (auto* w :
|
||||
_mainWindow->driveConfigurationContainer->findChildren<QWidget*>())
|
||||
w->setVisible(w == active);
|
||||
for (int i = 0; i < _forms.size(); i++)
|
||||
_forms[i]->widget()->setVisible(i == index);
|
||||
}
|
||||
W_SLOT(onDeviceIndexChanged)
|
||||
|
||||
public:
|
||||
QWidget* container() const
|
||||
{
|
||||
return _mainWindow->driveConfigurationContainer;
|
||||
}
|
||||
|
||||
private:
|
||||
MainWindow* _mainWindow;
|
||||
QStandardItemModel _devicesModel;
|
||||
QList<ConfigurationForm*> _forms;
|
||||
};
|
||||
|
||||
W_OBJECT_IMPL(DriveComponentImpl)
|
||||
|
||||
std::unique_ptr<DriveComponent> DriveComponent::create(MainWindow* mainWindow)
|
||||
{
|
||||
return std::make_unique<DriveComponentImpl>(mainWindow);
|
||||
|
||||
@@ -4,9 +4,6 @@ class MainWindow;
|
||||
|
||||
class DriveComponent
|
||||
{
|
||||
public:
|
||||
virtual void setDriveConfigurationPane(QWidget* active) = 0;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<DriveComponent> create(MainWindow* mainWindow);
|
||||
};
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include "lib/globals.h"
|
||||
#include "userinterface.h"
|
||||
#include "wobjectdefs.h"
|
||||
#include "wobjectimpl.h"
|
||||
#include <QtWidgets>
|
||||
#include <QThreadPool>
|
||||
#include <QtConcurrent>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user