Add a function to always save dialog fields.
Sometimes it's wanted to always save the fields when the dialog closes, this option allows that.
This commit is contained in:
parent
231c8929b1
commit
0c15dfc0d8
2 changed files with 17 additions and 1 deletions
|
@ -64,7 +64,7 @@ bool tdialog::show(CVideo& video, const unsigned auto_close_time)
|
|||
*/
|
||||
events::discard(SDL_EVENTMASK(DOUBLE_CLICK_EVENT));
|
||||
|
||||
if(retval_ == twindow::OK) {
|
||||
if(retval_ == twindow::OK || always_save_fields_) {
|
||||
finalize_fields(*window);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ class tdialog
|
|||
public:
|
||||
tdialog() :
|
||||
retval_(0),
|
||||
always_save_fields_(false),
|
||||
fields_(),
|
||||
focus_(),
|
||||
restore_(true)
|
||||
|
@ -160,6 +161,11 @@ public:
|
|||
|
||||
int get_retval() const { return retval_; }
|
||||
|
||||
void set_always_save_fields(const bool always_save_fields)
|
||||
{
|
||||
always_save_fields_ = always_save_fields;
|
||||
}
|
||||
|
||||
void set_restore(const bool restore) { restore_ = restore; }
|
||||
|
||||
protected:
|
||||
|
@ -338,6 +344,16 @@ private:
|
|||
/** Returns the window exit status, 0 means not shown. */
|
||||
int retval_;
|
||||
|
||||
/**
|
||||
* Always save the fields upon closing.
|
||||
*
|
||||
* Normally fields are only saved when the twindow::OK button is pressed.
|
||||
* With this flag set is always saves. Be careful with the flag since it
|
||||
* also updates upon canceling, which can be a problem when the field sets
|
||||
* a preference.
|
||||
*/
|
||||
bool always_save_fields_;
|
||||
|
||||
/**
|
||||
* Contains the automatically managed fields.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue