[Device] very rough instatiation with device name
This commit is contained in:
parent
51046a8ca1
commit
6db3099e7e
10 changed files with 44 additions and 70 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 805aa0773c9330ac7c8db669845ae7485cb2ce8d
|
Subproject commit fd4f72a6b590a0a07eb1b1dc7842deddcf72d440
|
|
@ -8,10 +8,11 @@
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
Controller::Controller(const score::DocumentContext& document,
|
Controller::Controller(const score::DocumentContext& document,
|
||||||
Scenario::IntervalModel& i)
|
Scenario::IntervalModel& interval,
|
||||||
: bugui::controller<Controller>{"Launchpad_Pro_Standalone"}
|
std::string_view device_name)
|
||||||
|
: bugui::controller<Controller>{device_name}
|
||||||
, doc{document}
|
, doc{document}
|
||||||
, interval{&i}
|
, interval{&interval}
|
||||||
, h_ofset{0.} // initial horizontal ofset
|
, h_ofset{0.} // initial horizontal ofset
|
||||||
, v_ofset{0.} // initial verticalal ofset
|
, v_ofset{0.} // initial verticalal ofset
|
||||||
, h_zoom{.125} // initial horizontal zoom
|
, h_zoom{.125} // initial horizontal zoom
|
||||||
|
@ -20,7 +21,7 @@ Controller::Controller(const score::DocumentContext& document,
|
||||||
// Connet interval signals
|
// Connet interval signals
|
||||||
// adapted from
|
// adapted from
|
||||||
// src/plugins/score-plugin-scenario/Scenario/Process/MiniScenarioView.cpp#18
|
// src/plugins/score-plugin-scenario/Scenario/Process/MiniScenarioView.cpp#18
|
||||||
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*i.processes.begin());
|
auto scnr = qobject_cast<Scenario::ProcessModel*>(&*interval.processes.begin());
|
||||||
|
|
||||||
scnr->intervals.added.connect<&Controller::on_interval_changed>(this);
|
scnr->intervals.added.connect<&Controller::on_interval_changed>(this);
|
||||||
scnr->intervals.removed.connect<&Controller::on_interval_changed>(this);
|
scnr->intervals.removed.connect<&Controller::on_interval_changed>(this);
|
||||||
|
|
|
@ -18,7 +18,8 @@ class SCORE_ADDON_HARDWARE_EXPORT Controller final
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Controller(const score::DocumentContext& document,
|
explicit Controller(const score::DocumentContext& document,
|
||||||
Scenario::IntervalModel& s);
|
Scenario::IntervalModel& interval,
|
||||||
|
std::string_view device_name);
|
||||||
|
|
||||||
void paint(bugui::painter& painter) const override;
|
void paint(bugui::painter& painter) const override;
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,13 @@ DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* paren
|
||||||
, ctrlr{nullptr}
|
, ctrlr{nullptr}
|
||||||
{
|
{
|
||||||
auto& set = m_context.app.settings<Settings::Model>();
|
auto& set = m_context.app.settings<Settings::Model>();
|
||||||
if(set.getEnabled())
|
QString d = set.getDevice();
|
||||||
{
|
if (d != "None") create(d);
|
||||||
create();
|
|
||||||
}
|
|
||||||
|
|
||||||
con(set,
|
con(set,
|
||||||
&Settings::Model::EnabledChanged,
|
&Settings::Model::DeviceChanged,
|
||||||
this,
|
this,
|
||||||
[this] (bool b)
|
&DocumentPlugin::create,
|
||||||
{
|
|
||||||
if (b)
|
|
||||||
create();
|
|
||||||
else
|
|
||||||
cleanup();
|
|
||||||
},
|
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,15 +44,17 @@ void DocumentPlugin::on_documentClosing()
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentPlugin::create()
|
void DocumentPlugin::create(const QString& device_name)
|
||||||
{
|
{
|
||||||
if (ctrlr) cleanup();
|
if (ctrlr) cleanup();
|
||||||
|
|
||||||
|
if (device_name == "None") return;
|
||||||
|
|
||||||
auto& doc = m_context.document.model().modelDelegate();
|
auto& doc = m_context.document.model().modelDelegate();
|
||||||
auto scenar = safe_cast<Scenario::ScenarioDocumentModel*>(&doc);
|
auto scenar = safe_cast<Scenario::ScenarioDocumentModel*>(&doc);
|
||||||
auto cstr = &scenar->baseScenario().interval();
|
auto cstr = &scenar->baseScenario().interval();
|
||||||
|
|
||||||
ctrlr = new Controller{m_context, *cstr};
|
ctrlr = new Controller{m_context, *cstr, device_name.toStdString()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentPlugin::cleanup()
|
void DocumentPlugin::cleanup()
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
Controller* ctrlr;
|
Controller* ctrlr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create();
|
void create(const QString& device_name);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ namespace Settings
|
||||||
{
|
{
|
||||||
namespace Parameters
|
namespace Parameters
|
||||||
{
|
{
|
||||||
SETTINGS_PARAMETER_IMPL(Enabled){QStringLiteral("Hardware/Enabled"), false};
|
SETTINGS_PARAMETER_IMPL(Device){QStringLiteral("Hardware/Device"), "None"};
|
||||||
static auto list()
|
static auto list()
|
||||||
{
|
{
|
||||||
return std::tie(Enabled);
|
return std::tie(Device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@ Model::Model(QSettings& set, const score::ApplicationContext& ctx)
|
||||||
score::setupDefaultSettings(set, Parameters::list(), *this);
|
score::setupDefaultSettings(set, Parameters::list(), *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCORE_SETTINGS_PARAMETER_CPP(bool, Model, Enabled)
|
SCORE_SETTINGS_PARAMETER_CPP(QString, Model, Device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@ namespace Settings
|
||||||
class SCORE_ADDON_HARDWARE_EXPORT Model : public score::SettingsDelegateModel
|
class SCORE_ADDON_HARDWARE_EXPORT Model : public score::SettingsDelegateModel
|
||||||
{
|
{
|
||||||
W_OBJECT(Model)
|
W_OBJECT(Model)
|
||||||
bool m_Enabled = false;
|
QString m_Device = "None";
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Model(QSettings& set, const score::ApplicationContext& ctx);
|
Model(QSettings& set, const score::ApplicationContext& ctx);
|
||||||
|
|
||||||
SCORE_SETTINGS_PARAMETER_HPP(SCORE_ADDON_HARDWARE_EXPORT, bool, Enabled)
|
SCORE_SETTINGS_PARAMETER_HPP(SCORE_ADDON_HARDWARE_EXPORT, QString, Device)
|
||||||
};
|
};
|
||||||
|
|
||||||
SCORE_SETTINGS_PARAMETER(Model, Enabled)
|
SCORE_SETTINGS_PARAMETER(Model, Device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,18 +20,18 @@ Presenter::Presenter(Model& m, View& v, QObject* parent)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// view -> model
|
// view -> model
|
||||||
con(v, &View::enabledChanged, this, [&](auto val) {
|
con(v, &View::deviceChanged, this, [&](auto val) {
|
||||||
if (val != m.getEnabled())
|
if (val != m.getDevice())
|
||||||
{
|
{
|
||||||
m_disp.submit<SetModelEnabled>(this->model(this), val);
|
m_disp.submit<SetModelDevice>(this->model(this), val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// model -> view
|
// model -> view
|
||||||
con(m, &Model::EnabledChanged, &v, &View::setEnabled);
|
con(m, &Model::DeviceChanged, &v, &View::setDevice);
|
||||||
|
|
||||||
// initial value
|
// initial value
|
||||||
v.setEnabled(m.getEnabled());
|
v.setDevice(m.getDevice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,57 +2,39 @@
|
||||||
|
|
||||||
#include <score/widgets/FormWidget.hpp>
|
#include <score/widgets/FormWidget.hpp>
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include <wobjectimpl.h>
|
#include <wobjectimpl.h>
|
||||||
W_OBJECT_IMPL(Hardware::Settings::View)
|
W_OBJECT_IMPL(Hardware::Settings::View)
|
||||||
|
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
namespace Settings
|
namespace Settings
|
||||||
{
|
{
|
||||||
|
|
||||||
View::View()
|
View::View()
|
||||||
{
|
{
|
||||||
m_widg = new score::FormWidget{tr("Hardware")};
|
m_widg = new score::FormWidget{tr("Hardware")};
|
||||||
auto lay = m_widg->layout();
|
auto lay = m_widg->layout();
|
||||||
|
|
||||||
{
|
{
|
||||||
m_enabled = new QCheckBox{tr("Enabled")};
|
m_device = new QComboBox{m_widg};
|
||||||
|
m_device->addItem("None");
|
||||||
|
m_device->addItem("Launchpad_Pro_Standalone");
|
||||||
|
m_device->addItem("Launchpad_Pro_Live");
|
||||||
|
|
||||||
connect(m_enabled, &QCheckBox::stateChanged, this, [&](int t) {
|
connect(m_device,
|
||||||
switch(t)
|
&QComboBox::currentTextChanged,
|
||||||
{
|
this, &View::deviceChanged
|
||||||
case Qt::Unchecked:
|
);
|
||||||
enabledChanged(false);
|
|
||||||
break;
|
|
||||||
case Qt::Checked:
|
|
||||||
enabledChanged(true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
lay->addRow(m_enabled);
|
lay->addRow(m_device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::setEnabled(bool val)
|
void View::setDevice(const QString& device)
|
||||||
{
|
{
|
||||||
switch(m_enabled->checkState())
|
// TODO : implement me
|
||||||
{
|
|
||||||
case Qt::Unchecked:
|
|
||||||
if(val)
|
|
||||||
m_enabled->setChecked(true);
|
|
||||||
break;
|
|
||||||
case Qt::Checked:
|
|
||||||
if(!val)
|
|
||||||
m_enabled->setChecked(false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* View::getWidget()
|
QWidget* View::getWidget()
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
|
#include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
|
||||||
|
|
||||||
#include <Hardware/Settings/Model.hpp>
|
#include <Hardware/Settings/Model.hpp>
|
||||||
class QCheckBox;
|
|
||||||
|
|
||||||
namespace score
|
namespace score
|
||||||
{
|
{
|
||||||
|
@ -12,21 +11,18 @@ namespace Hardware
|
||||||
{
|
{
|
||||||
namespace Settings
|
namespace Settings
|
||||||
{
|
{
|
||||||
|
|
||||||
class View : public score::GlobalSettingsView
|
class View : public score::GlobalSettingsView
|
||||||
{
|
{
|
||||||
W_OBJECT(View)
|
W_OBJECT(View)
|
||||||
public:
|
public:
|
||||||
View();
|
View();
|
||||||
void setEnabled(bool);
|
void setDevice(const QString& device);
|
||||||
|
void deviceChanged(const QString& device) W_SIGNAL(deviceChanged, device);
|
||||||
void enabledChanged(bool b) W_SIGNAL(enabledChanged, b);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* getWidget() override;
|
QWidget* getWidget() override;
|
||||||
score::FormWidget* m_widg{};
|
score::FormWidget* m_widg{};
|
||||||
|
QComboBox* m_device{};
|
||||||
QCheckBox* m_enabled{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue