[repo] probably way to much copy from score_plugin_remotecontrol
This commit is contained in:
parent
8cdc113508
commit
42f28e2b2f
17 changed files with 310 additions and 37 deletions
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
project(score_addon_hardware LANGUAGES CXX)
|
||||
|
||||
if(NOT TARGET score_lib_base)
|
||||
include(ScoreExternalAddon)
|
||||
|
@ -9,26 +9,34 @@ if(NOT TARGET libremidi)
|
|||
return()
|
||||
endif()
|
||||
|
||||
project(score_addon_hardware LANGUAGES CXX)
|
||||
|
||||
score_common_setup()
|
||||
|
||||
set(HDRS
|
||||
"Hardware/ApplicationPlugin.hpp"
|
||||
# "Hardware/Hardware.hpp"
|
||||
# "Hardware/Controller.hpp"
|
||||
# "Hardware/MidiController.hpp"
|
||||
|
||||
"Hardware/Hardware.hpp"
|
||||
"Hardware/Controller.hpp"
|
||||
"Hardware/MidiController.hpp"
|
||||
"Hardware/Settings/Model.hpp"
|
||||
"Hardware/Settings/Presenter.hpp"
|
||||
"Hardware/Settings/View.hpp"
|
||||
"Hardware/Settings/Factory.hpp"
|
||||
|
||||
"Hardware/ApplicationPlugin.hpp"
|
||||
|
||||
"score_addon_hardware.hpp"
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Hardware/ApplicationPlugin.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Hardware.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Controller.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/MidiController.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Hardware.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Controller.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Hardware/MidiController.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Settings/Model.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Settings/Presenter.cpp"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/Hardware/Settings/View.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Hardware/ApplicationPlugin.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/score_addon_hardware.cpp"
|
||||
)
|
||||
|
@ -39,3 +47,5 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
|
|||
score_plugin_scenario
|
||||
libremidi
|
||||
)
|
||||
|
||||
setup_score_plugin(${PROJECT_NAME})
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "ApplicationPlugin.hpp"
|
||||
#include <score/tools/IdentifierGeneration.hpp>
|
||||
|
||||
#include <Hardware/ApplicationPlugin.hpp>
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
ApplicationPlugin::ApplicationPlugin(const score::GUIApplicationPlugin& app)
|
||||
ApplicationPlugin::ApplicationPlugin(const score::GUIApplicationContext& app)
|
||||
: GUIApplicationPlugin{app}
|
||||
{ }
|
||||
}
|
||||
|
|
|
@ -7,5 +7,6 @@ namespace Hardware
|
|||
class ApplicationPlugin final : public score::GUIApplicationPlugin
|
||||
{
|
||||
public:
|
||||
ApplicationPlugin(const score::GUIApplicationPlugin& app);
|
||||
ApplicationPlugin(const score::GUIApplicationContext& app);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CONTROLLER_HPP
|
||||
#define CONTROLLER_HPP
|
||||
|
||||
namespace RemoteControl
|
||||
namespace Hardware
|
||||
{
|
||||
|
||||
struct Controller
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Hardware.hpp"
|
||||
|
||||
namespace RemoteControl
|
||||
namespace Hardware
|
||||
{
|
||||
Hardware::Hardware(const score::DocumentContext& doc)
|
||||
: m_dev{doc.plugin<Explorer::DeviceDocumentPlugin>()}
|
||||
|
@ -142,4 +142,4 @@ void Hardware::draw_intervals()
|
|||
}
|
||||
}
|
||||
|
||||
W_OBJECT_IMPL(RemoteControl::Hardware)
|
||||
W_OBJECT_IMPL(Hardware::Hardware)
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#ifndef HARDWARE_HPP
|
||||
#define HARDWARE_HPP
|
||||
#pragma once
|
||||
|
||||
#include <score_plugin_remotecontrol_export.h>
|
||||
// #include <score_addon_hardware_export.h>
|
||||
|
||||
#include <Scenario/Document/Interval/IntervalModel.hpp>
|
||||
#include <Scenario/Process/ScenarioModel.hpp>
|
||||
|
||||
#include "MidiController.hpp"
|
||||
|
||||
namespace RemoteControl
|
||||
namespace Hardware
|
||||
{
|
||||
class SCORE_PLUGIN_REMOTECONTROL_EXPORT Hardware
|
||||
class /*SCORE_PLUGIN_HARDWARE_EXPORT*/ Hardware
|
||||
: public QObject
|
||||
{
|
||||
W_OBJECT(Hardware)
|
||||
|
@ -38,4 +37,3 @@ private:
|
|||
};
|
||||
}
|
||||
|
||||
#endif // HARDWARE_HPP
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "MidiController.hpp"
|
||||
|
||||
namespace RemoteControl {
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
MidiController::MidiController()
|
||||
: grid{GRID}
|
||||
, previous_grid{BLACK}
|
||||
|
|
|
@ -44,9 +44,8 @@ namespace Explorer
|
|||
class DeviceDocumentPlugin;
|
||||
}
|
||||
|
||||
namespace RemoteControl
|
||||
namespace Hardware
|
||||
{
|
||||
|
||||
class MidiController : public Controller
|
||||
{
|
||||
public:
|
||||
|
|
15
Hardware/Settings/Factory.hpp
Normal file
15
Hardware/Settings/Factory.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include <score/plugins/settingsdelegate/SettingsDelegateFactory.hpp>
|
||||
|
||||
#include <Hardware/Settings/Model.hpp>
|
||||
#include <Hardware/Settings/Presenter.hpp>
|
||||
#include <Hardware/Settings/View.hpp>
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
SCORE_DECLARE_SETTINGS_FACTORY(
|
||||
Factory, Model, Presenter, View, "995020ed-304a-42b5-8e3b-eb050a7305ed")
|
||||
}
|
||||
}
|
28
Hardware/Settings/Model.cpp
Normal file
28
Hardware/Settings/Model.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include "Model.hpp"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <wobjectimpl.h>
|
||||
W_OBJECT_IMPL(Hardware::Settings::Model)
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
namespace Parameters
|
||||
{
|
||||
SETTINGS_PARAMETER_IMPL(Enabled){QStringLiteral("Hardware/Enabled"), false};
|
||||
static auto list()
|
||||
{
|
||||
return std::tie(Enabled);
|
||||
}
|
||||
}
|
||||
|
||||
Model::Model(QSettings& set, const score::ApplicationContext& ctx)
|
||||
{
|
||||
score::setupDefaultSettings(set, Parameters::list(), *this);
|
||||
}
|
||||
|
||||
SCORE_SETTINGS_PARAMETER_CPP(bool, Model, Enabled)
|
||||
}
|
||||
}
|
25
Hardware/Settings/Model.hpp
Normal file
25
Hardware/Settings/Model.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include <score/plugins/settingsdelegate/SettingsDelegateModel.hpp>
|
||||
|
||||
#include <score_addon_hardware_export.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
class SCORE_ADDON_HARDWARE_EXPORT Model : public score::SettingsDelegateModel
|
||||
{
|
||||
W_OBJECT(Model)
|
||||
bool m_Enabled = false;
|
||||
|
||||
public:
|
||||
Model(QSettings& set, const score::ApplicationContext& ctx);
|
||||
|
||||
SCORE_SETTINGS_PARAMETER_HPP(SCORE_ADDON_HARDWARE_EXPORT, bool, Enabled)
|
||||
};
|
||||
|
||||
SCORE_SETTINGS_PARAMETER(Model, Enabled)
|
||||
}
|
||||
}
|
52
Hardware/Settings/Presenter.cpp
Normal file
52
Hardware/Settings/Presenter.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include "Presenter.hpp"
|
||||
|
||||
#include "Model.hpp"
|
||||
#include "View.hpp"
|
||||
|
||||
#include <score/command/Command.hpp>
|
||||
#include <score/command/Dispatchers/ICommandDispatcher.hpp>
|
||||
#include <score/command/SettingsCommand.hpp>
|
||||
#include <score/widgets/SetIcons.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
Presenter::Presenter(Model& m, View& v, QObject* parent)
|
||||
: score::GlobalSettingsPresenter{m, v, parent}
|
||||
{
|
||||
{
|
||||
// view -> model
|
||||
con(v, &View::enabledChanged, this, [&](auto val) {
|
||||
if (val != m.getEnabled())
|
||||
{
|
||||
m_disp.submit<SetModelEnabled>(this->model(this), val);
|
||||
}
|
||||
});
|
||||
|
||||
// model -> view
|
||||
con(m, &Model::EnabledChanged, &v, &View::setEnabled);
|
||||
|
||||
// initial value
|
||||
v.setEnabled(m.getEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
QString Presenter::settingsName()
|
||||
{
|
||||
return tr("Hardware");
|
||||
}
|
||||
|
||||
QIcon Presenter::settingsIcon()
|
||||
{
|
||||
return makeIcons(
|
||||
QStringLiteral(":/icons/settings_remote_control_on.png"),
|
||||
QStringLiteral(":/icons/settings_remote_control_off.png"),
|
||||
QStringLiteral(":/icons/settings_remote_control_off.png"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
24
Hardware/Settings/Presenter.hpp
Normal file
24
Hardware/Settings/Presenter.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <score/plugins/settingsdelegate/SettingsDelegatePresenter.hpp>
|
||||
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
class Model;
|
||||
class View;
|
||||
class Presenter : public score::GlobalSettingsPresenter
|
||||
{
|
||||
public:
|
||||
using model_type = Model;
|
||||
using view_type = View;
|
||||
Presenter(Model&, View&, QObject* parent);
|
||||
|
||||
private:
|
||||
QString settingsName() override;
|
||||
QIcon settingsIcon() override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
64
Hardware/Settings/View.cpp
Normal file
64
Hardware/Settings/View.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include "View.hpp"
|
||||
|
||||
#include <score/widgets/FormWidget.hpp>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QFormLayout>
|
||||
|
||||
#include <wobjectimpl.h>
|
||||
W_OBJECT_IMPL(Hardware::Settings::View)
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
View::View()
|
||||
{
|
||||
m_widg = new score::FormWidget{tr("Hardware")};
|
||||
auto lay = m_widg->layout();
|
||||
|
||||
{
|
||||
m_enabled = new QCheckBox{tr("Enabled")};
|
||||
|
||||
connect(m_enabled, &QCheckBox::stateChanged, this, [&](int t) {
|
||||
switch(t)
|
||||
{
|
||||
case Qt::Unchecked:
|
||||
enabledChanged(false);
|
||||
break;
|
||||
case Qt::Checked:
|
||||
enabledChanged(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
lay->addRow(m_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void View::setEnabled(bool val)
|
||||
{
|
||||
switch(m_enabled->checkState())
|
||||
{
|
||||
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()
|
||||
{
|
||||
return m_widg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
33
Hardware/Settings/View.hpp
Normal file
33
Hardware/Settings/View.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
|
||||
|
||||
#include <Hardware/Settings/Model.hpp>
|
||||
class QCheckBox;
|
||||
|
||||
namespace score
|
||||
{
|
||||
class FormWidget;
|
||||
}
|
||||
namespace Hardware
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
class View : public score::GlobalSettingsView
|
||||
{
|
||||
W_OBJECT(View)
|
||||
public:
|
||||
View();
|
||||
void setEnabled(bool);
|
||||
|
||||
void enabledChanged(bool b) W_SIGNAL(enabledChanged, b);
|
||||
|
||||
private:
|
||||
QWidget* getWidget() override;
|
||||
score::FormWidget* m_widg{};
|
||||
|
||||
QCheckBox* m_enabled{};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
|
@ -1,12 +1,18 @@
|
|||
#include "score_addon_hardware.hpp"
|
||||
#include "Hardware/ApplicationPlugin.hpp"
|
||||
|
||||
#include <score/plugins/FactorySetup.hpp>
|
||||
|
||||
#include <Hardware/ApplicationPlugin.hpp>
|
||||
#include <Hardware/Settings/Factory.hpp>
|
||||
|
||||
#include <score_plugin_scenario.hpp>
|
||||
|
||||
score_addon_hardware::score_addon_hardware() { }
|
||||
|
||||
score_addon_hardware::~score_addon_hardware() { }
|
||||
|
||||
score::GUIApplicationPlugin *score_addon_hardware::make_guiApplicationPlugin(
|
||||
const score::GUIApplicationContext& app) const
|
||||
score::GUIApplicationPlugin* score_addon_hardware::make_guiApplicationPlugin(
|
||||
const score::GUIApplicationContext& app)
|
||||
{
|
||||
return new Hardware::ApplicationPlugin{app};
|
||||
}
|
||||
|
@ -14,6 +20,21 @@ score::GUIApplicationPlugin *score_addon_hardware::make_guiApplicationPlugin(
|
|||
std::vector<std::unique_ptr<score::InterfaceListBase>>
|
||||
score_addon_hardware::factoryFamilies()
|
||||
{
|
||||
return make_ptr_vector<
|
||||
score::InterfaceListBase>();
|
||||
return make_ptr_vector<score::InterfaceListBase>();
|
||||
}
|
||||
|
||||
std::vector<score::InterfaceBase*> score_addon_hardware::factories(
|
||||
const score::ApplicationContext& ctx, const score::InterfaceKey& key) const
|
||||
{
|
||||
return instantiate_factories<
|
||||
score::ApplicationContext,
|
||||
FW<score::SettingsDelegateFactory, Hardware::Settings::Factory>>(ctx, key);
|
||||
}
|
||||
|
||||
auto score_addon_hardware::required() const -> std::vector<score::PluginKey>
|
||||
{
|
||||
return {score_plugin_scenario::static_key()};
|
||||
}
|
||||
|
||||
#include <score/plugins/PluginInstances.hpp>
|
||||
SCORE_EXPORT_PLUGIN(score_addon_hardware)
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <score/application/ApplicationContext.hpp>
|
||||
#include <score/plugins//Interface.hpp>
|
||||
#include <score/plugins/qt_interfaces/PluginRequirements_QtInterface.hpp>
|
||||
#include <score/plugins/Interface.hpp>
|
||||
#include <score/plugins/qt_interfaces/FactoryFamily_QtInterface.hpp>
|
||||
#include <score/plugins/qt_interfaces/FactoryInterface_QtInterface.hpp>
|
||||
#include <score/plugins/qt_interfaces/GUIApplicationPlugin_QtInterface.hpp>
|
||||
#include <score/plugins/qt_interfaces/PluginRequirements_QtInterface.hpp>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class score_addon_hardware final
|
||||
: public score::Plugin_QtInterface
|
||||
, public score::FactoryList_QtInterface
|
||||
|
@ -22,9 +24,9 @@ public:
|
|||
|
||||
private:
|
||||
score::GUIApplicationPlugin*
|
||||
make_guiApplicationPlugin(const score::GUIApplicationContext& app) const;
|
||||
make_guiApplicationPlugin(const score::GUIApplicationContext& app) override;
|
||||
|
||||
std::vector<std::unique_ptr<score::InterfaceBase>> factoryFamilies() override;
|
||||
std::vector<std::unique_ptr<score::InterfaceListBase>> factoryFamilies() override;
|
||||
|
||||
std::vector<score::InterfaceBase*> factories(
|
||||
const score::ApplicationContext& ctx,
|
||||
|
@ -32,4 +34,3 @@ private:
|
|||
|
||||
std::vector<score::PluginKey> required() const override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue