You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
6.7 KiB
237 lines
6.7 KiB
/*!
|
|
@class QtMvvm::SettingsViewModel
|
|
|
|
It's a ready made viewmodel to show a settings dialog. See @ref settings_xml. To show the
|
|
dialog, call show from another ViewModel or the CoreApp:
|
|
|
|
@code{.cpp}
|
|
show<QtMvvm::SettingsViewModel>();
|
|
@endcode
|
|
|
|
@sa @ref images_page
|
|
*/
|
|
|
|
/*!
|
|
@property QtMvvm::SettingsViewModel::accessor
|
|
|
|
@default{`nullptr` (Initialized by onInit())}
|
|
|
|
This acccessor is used by all the methods that access settings. This makes it possible to
|
|
simply change the backend that the viewmodel should operate on without reimplementing it, and
|
|
also makes it possible for change signals to be used to dynamically update the gui if the
|
|
settings values change.
|
|
|
|
@accessors{
|
|
@readAc{accessor()}
|
|
@writeAc{setAccessor()}
|
|
@notifyAc{accessorChanged()}
|
|
}
|
|
|
|
@sa ISettingsAccessor, SettingsViewModel::showParams
|
|
*/
|
|
|
|
/*!
|
|
@property QtMvvm::SettingsViewModel::canRestoreDefaults
|
|
|
|
@default{`true`}
|
|
|
|
Restoring defaults is only allowed if both this property and the attribute of the settings XML
|
|
are true.
|
|
|
|
@accessors{
|
|
@readAc{canRestoreDefaults()}
|
|
@constantAc
|
|
}
|
|
|
|
@sa @ref settings_xml_elements_config_attribs
|
|
*/
|
|
|
|
/*!
|
|
@property QtMvvm::SettingsViewModel::restoreConfig
|
|
|
|
@default{<i>A basic question messagebox</i>}
|
|
|
|
If you want to modify the text or options, you can replace the messagebox with another dialog.
|
|
|
|
@accessors{
|
|
@readAc{restoreConfig()}
|
|
@constantAc
|
|
}
|
|
*/
|
|
|
|
/*!
|
|
@property QtMvvm::SettingsViewModel::settingsSetupLoader
|
|
|
|
@default{<i>Injected</i>}
|
|
|
|
Do not set this property yourself. It is automatically injected when showing the viewmodel.
|
|
You can use the ServiceRegistry::registerInterface if you need to use a loader different from
|
|
the default one.
|
|
|
|
@accessors{
|
|
@readAc{settingsSetupLoader()}
|
|
@writeAc{setSettingsSetupLoader()}
|
|
@notifyAc{settingsSetupLoaderChanged()}
|
|
}
|
|
|
|
@sa #QTMVVM_INJECT
|
|
*/
|
|
|
|
/*!
|
|
@var QtMvvm::SettingsViewModel::paramAccessor
|
|
|
|
<b>Value:</b> `"accessor"`
|
|
|
|
@sa SettingsViewModel::showParams
|
|
*/
|
|
|
|
/*!
|
|
@var QtMvvm::SettingsViewModel::paramSettings
|
|
|
|
<b>Value:</b> `"settings"`
|
|
|
|
@sa SettingsViewModel::showParams
|
|
*/
|
|
|
|
/*!
|
|
@var QtMvvm::SettingsViewModel::paramSetupFile
|
|
|
|
<b>Value:</b> `"setupFile"`
|
|
|
|
@sa SettingsViewModel::showParams
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::showParams(ISettingsAccessor*, const QString &)
|
|
|
|
@param accessor The ISettingsAccessor to operate on. Can be null to use the default accessor
|
|
(QSettingsAccessor)
|
|
@param setupFile The path to a file to be used to create the settings. Can be empty to use the
|
|
default path
|
|
@return A paramater hash to be passed to ViewModel::show
|
|
|
|
It's a shortcut to generate parameters for the show methods to show a settings viewmodel. Use
|
|
them as:
|
|
|
|
@code{.cpp}
|
|
show<QtMvvm::SettingsViewModel>(QtMvvm::SettingsViewModel::showParams(...));
|
|
@endcode
|
|
|
|
@note Unless you need to explicitly set the settings or setup file a normal show without any
|
|
parameters will just do fine.
|
|
|
|
@sa ViewModel::show, SettingsViewModel::paramAccessor, SettingsViewModel::paramSetupFile
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::showParams(QSettings*, const QString &)
|
|
|
|
@param settings The QSettings to operate on. Can be null to use the default settings
|
|
@param setupFile The path to a file to be used to create the settings. Can be empty to use the
|
|
default path
|
|
@return A paramater hash to be passed to ViewModel::show
|
|
|
|
This internally creates a QSettingsAccessor that operates on the given settings and sets it
|
|
as the SettingsViewModel::accessor.
|
|
|
|
It's a shortcut to generate parameters for the show methods to show a settings viewmodel. Use
|
|
them as:
|
|
|
|
@code{.cpp}
|
|
show<QtMvvm::SettingsViewModel>(QtMvvm::SettingsViewModel::showParams(...));
|
|
@endcode
|
|
|
|
@note Unless you need to explicitly set the settings or setup file a normal show without any
|
|
parameters will just do fine.
|
|
|
|
@sa ViewModel::show, SettingsViewModel::paramSettings, SettingsViewModel::paramSetupFile
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::loadSetup
|
|
|
|
@param frontend The name of the current frontend
|
|
@returns The loaded settings setup
|
|
|
|
If loading fails an empty setup is returned. Logging is performed internally, so you can just
|
|
proceed without error checking and show an empty settings dialog.
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::loadValue
|
|
|
|
@param key The full key of the settings entry to be loaded
|
|
@param defaultValue a default value to return in case the value is not found in the settings
|
|
@returns The value found under the given key
|
|
|
|
You can override this method if you want to support loading and saving settings from something
|
|
different than a ISettingsAccessor
|
|
|
|
@sa SettingsViewModel::saveValue, SettingsViewModel::resetValue
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::saveValue
|
|
|
|
@param key The full key of the settings entry to be saved
|
|
@param value The value to be stored under the key
|
|
|
|
You can override this method if you want to support loading and saving settings from something
|
|
different than a ISettingsAccessor. if you do so, you must emit the valueChanged() signal
|
|
from this method to indicate that the data was changed.
|
|
|
|
@sa SettingsViewModel::loadValue, SettingsViewModel::resetValue
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::resetValue
|
|
|
|
@param key The full key of the settings entry to be resetted
|
|
|
|
You can override this method if you want to support loading and saving settings from something
|
|
different than a ISettingsAccessor. if you do so, you must emit the valueChanged() signal
|
|
from this method to indicate that the data was changed.
|
|
|
|
@sa SettingsViewModel::loadValue, SettingsViewModel::saveValue
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::resetAll
|
|
|
|
@param setup The setup to search for keys to be resetted
|
|
|
|
You can call this method from your gui to perform a complete reset of all the settings that
|
|
are visible in the gui. Internally, the method will use SettingsViewModel::restoreConfig to
|
|
create a dialog that asks the user for confirmation, and if he accepts, remove the value of
|
|
all SettingsElements::Entry elements that can be found in the setup by calling resetValue().
|
|
|
|
If the user accepted the dialog and data was successfully reset, the resetAccepted() signal
|
|
is emitted so the gui can close itself.
|
|
|
|
@sa SettingsViewModel::restoreConfig, SettingsViewModel::resetAccepted,
|
|
SettingsViewModel::resetValue
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::callAction
|
|
|
|
@param key The key of the entry that triggered the action
|
|
@param parameters A map with additional parameters for the action call
|
|
|
|
This method is called by the GUI when an entry with the
|
|
@ref settings_xml_types_action "action" type is pressed by the user. The key is what would
|
|
normally be used as the settings key. The parameters are deduced from the settings XML. See
|
|
the type documentation for more details.
|
|
|
|
@sa @ref settings_xml_types_action
|
|
*/
|
|
|
|
/*!
|
|
@fn QtMvvm::SettingsViewModel::resetAccepted
|
|
|
|
This signal is emitted as the result of a resetAll() that was accepted by the user. As a
|
|
reaction, the settings gui implementation should close itself.
|
|
|
|
@sa SettingsViewModel::resetAll
|
|
*/
|
|
|
|
|