Adding apply/discard/reset functionality to settings dialog

This commit is contained in:
Dan Paulat 2022-12-22 00:16:59 -06:00
parent a6974e31a2
commit 87f611e026
10 changed files with 276 additions and 13 deletions

View file

@ -0,0 +1,67 @@
#pragma once
#include <memory>
class QAbstractButton;
class QWidget;
namespace scwx
{
namespace qt
{
namespace settings
{
class SettingsInterfaceBase
{
public:
explicit SettingsInterfaceBase();
~SettingsInterfaceBase();
SettingsInterfaceBase(const SettingsInterfaceBase&) = delete;
SettingsInterfaceBase& operator=(const SettingsInterfaceBase&) = delete;
SettingsInterfaceBase(SettingsInterfaceBase&&) noexcept;
SettingsInterfaceBase& operator=(SettingsInterfaceBase&&) noexcept;
/**
* Sets the current value of the associated settings variable to the staged
* value.
*
* @return true if the staged value was committed, false if no staged value
* is present.
*/
virtual bool Commit() = 0;
/**
* Clears the staged value of the associated settings variable.
*/
virtual void Reset() = 0;
/**
* Stages the default value of the associated settings variable.
*/
virtual void StageDefault() = 0;
/**
* Sets the edit widget from the settings dialog.
*
* @param widget Edit widget
*/
virtual void SetEditWidget(QWidget* widget) = 0;
/**
* Sets the reset button from the settings dialog.
*
* @param button Reset button
*/
virtual void SetResetButton(QAbstractButton* button) = 0;
private:
class Impl;
std::unique_ptr<Impl> p;
};
} // namespace settings
} // namespace qt
} // namespace scwx