score-addon-hardware/Hardware/Settings/Presenter.cpp

53 lines
1.1 KiB
C++
Raw Permalink Normal View History

#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::deviceChanged, this, [&](auto val) {
if (val != m.getDevice())
{
m_disp.submit<SetModelDevice>(this->model(this), val);
}
});
// model -> view
con(m, &Model::DeviceChanged, &v, &View::setDevice);
// initial value
v.setDevice(m.getDevice());
}
}
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"));
}
}
}