ChangeValueDisplays now have ConfirmInterface and ErrorHandlerInterface

This commit is contained in:
feedc0de committed 2021-12-29 22:24:31 +01:00
1 parent a279559e76
commit ec002d6058
11 files changed
+52 -37

No files matched your search

+12 -7
View File
@@ -3,25 +3,29 @@
// local includes
#include "actioninterface.h"
#include "accessorinterface.h"
#include "confirminterface.h"
#include "errorhandlerinterface.h"
namespace espgui {
template<typename T>
class SetValueAction : public virtual ActionInterface
{
public:
SetValueAction(T value, AccessorInterface<T> &accessorInterface, ActionInterface &actionInterface) :
SetValueAction(T value,AccessorInterface<T> &accessorInterface,
ConfirmInterface &confirmInterface, ErrorHandlerInterface &errorHandlerInterface) :
m_value{value},
m_accessorInterface{accessorInterface},
m_actionInterface{actionInterface}
m_confirmInterface{confirmInterface},
m_errorHandlerInterface{errorHandlerInterface}
{
}
void triggered() override
{
// TODO: implement error handling and show popup in case of error
m_accessorInterface.setValue(m_value);
m_actionInterface.triggered();
if (auto result = m_accessorInterface.setValue(m_value); result)
m_confirmInterface.confirm();
else
m_errorHandlerInterface.errorOccured(std::move(result).error());
}
T value() const { return m_value; }
@@ -29,6 +33,7 @@ public:
private:
const T m_value;
AccessorInterface<T> &m_accessorInterface;
ActionInterface &m_actionInterface;
ConfirmInterface &m_confirmInterface;
ErrorHandlerInterface &m_errorHandlerInterface;
};
} // namespace espgui