[Controller] add recuring template argument
This commit is contained in:
parent
01f6edc127
commit
c52e1599eb
5 changed files with 18 additions and 16 deletions
2
Hardware/3rdparty/bugui
vendored
2
Hardware/3rdparty/bugui
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit c71a9c1e02e3364a16edf3664ca6ef40898b9635
|
Subproject commit 2a725a7eb0ec3262059d7f724d2725e33b03c55f
|
|
@ -1,4 +1,4 @@
|
||||||
#include <score/application/ApplicationContext.hpp>
|
#include <score/application/GUIApplicationContext.hpp>
|
||||||
#include <score/actions/ActionManager.hpp>
|
#include <score/actions/ActionManager.hpp>
|
||||||
#include <Scenario/Application/ScenarioActions.hpp>
|
#include <Scenario/Application/ScenarioActions.hpp>
|
||||||
#include <Process/Style/ScenarioStyle.hpp>
|
#include <Process/Style/ScenarioStyle.hpp>
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
Controller::Controller(const score::DocumentContext& doc)
|
Controller::Controller(const score::DocumentContext& doc)
|
||||||
: bugui::controller{[&doc, this]
|
: bugui::controller<Controller>{[&doc, this]
|
||||||
(bugui::commands com, bool shift)
|
(bugui::commands com, bool shift)
|
||||||
{
|
{
|
||||||
switch (com)
|
switch (com)
|
||||||
|
@ -121,7 +121,7 @@ void Controller::paint(bugui::painter& painter)
|
||||||
// Copied from MiniscenarioView
|
// Copied from MiniscenarioView
|
||||||
auto& skin = Process::Style::instance();
|
auto& skin = Process::Style::instance();
|
||||||
const auto col = skin.IntervalBase().color();
|
const auto col = skin.IntervalBase().color();
|
||||||
painter.set_color(col.red(), col.green(), col.black(), col.alpha());
|
painter.set_color(col.red(), col.green(), col.blue(), col.alpha());
|
||||||
|
|
||||||
for(const Scenario::IntervalModel& c : scenar->intervals)
|
for(const Scenario::IntervalModel& c : scenar->intervals)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
namespace Hardware
|
namespace Hardware
|
||||||
{
|
{
|
||||||
class SCORE_ADDON_HARDWARE_EXPORT Controller
|
class SCORE_ADDON_HARDWARE_EXPORT Controller
|
||||||
: public bugui::controller
|
: public bugui::controller<Controller>
|
||||||
, public QObject
|
, public QObject
|
||||||
{
|
{
|
||||||
W_OBJECT(Controller)
|
W_OBJECT(Controller)
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Hardware
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* parent)
|
DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* parent)
|
||||||
: score::DocumentPlugin{doc, "Hardware::DocumentPlugin", parent}
|
: score::DocumentPlugin{doc, "Hardware::DocumentPlugin", parent}
|
||||||
, hardware{doc}
|
, ctrlr{doc}
|
||||||
{
|
{
|
||||||
auto& set = m_context.app.settings<Settings::Model>();
|
auto& set = m_context.app.settings<Settings::Model>();
|
||||||
if(set.getEnabled())
|
if(set.getEnabled())
|
||||||
|
@ -34,12 +34,13 @@ DocumentPlugin::DocumentPlugin(const score::DocumentContext& doc, QObject* paren
|
||||||
|
|
||||||
con(
|
con(
|
||||||
set, &Settings::Model::EnabledChanged, this,
|
set, &Settings::Model::EnabledChanged, this,
|
||||||
[this](bool b) {
|
[this](bool b)
|
||||||
if(b)
|
{
|
||||||
|
if (b)
|
||||||
create();
|
create();
|
||||||
else
|
else
|
||||||
cleanup();
|
cleanup();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,25 +53,26 @@ void DocumentPlugin::on_documentClosing()
|
||||||
|
|
||||||
void DocumentPlugin::create()
|
void DocumentPlugin::create()
|
||||||
{
|
{
|
||||||
if(cstr)
|
if (cstr) cleanup();
|
||||||
cleanup();
|
|
||||||
|
|
||||||
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);
|
||||||
cstr = &scenar->baseScenario().interval();
|
cstr = &scenar->baseScenario().interval();
|
||||||
|
|
||||||
hardware.setup();
|
ctrlr.setup();
|
||||||
|
|
||||||
// Get Scenario::processModel
|
// Get Scenario::processModel
|
||||||
// adapted from
|
// adapted from
|
||||||
// src/plugins/score-plugin-scenario/Scenario/Document/ScenarioDocument/ScenarioDocumentModel.cpp#67
|
// src/plugins/score-plugin-scenario/Scenario/Document/ScenarioDocument/ScenarioDocumentModel.cpp#67
|
||||||
hardware.setup_scenario(qobject_cast<Scenario::ProcessModel*>(&*cstr->processes.begin()));
|
ctrlr.setup_scenario(
|
||||||
|
qobject_cast<Scenario::ProcessModel*>(
|
||||||
|
&*cstr->processes.begin())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentPlugin::cleanup()
|
void DocumentPlugin::cleanup()
|
||||||
{
|
{
|
||||||
if(!cstr)
|
if (!cstr) return;
|
||||||
return;
|
|
||||||
|
|
||||||
cstr = nullptr;
|
cstr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
void on_documentClosing() override;
|
void on_documentClosing() override;
|
||||||
|
|
||||||
Controller hardware;
|
Controller ctrlr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create();
|
void create();
|
||||||
|
|
Loading…
Add table
Reference in a new issue