gui2/tfile_dialog: Allow callers to set a custom label for the OK button
This commit is contained in:
parent
6e1f6bb686
commit
fc593270dc
2 changed files with 22 additions and 0 deletions
|
@ -95,6 +95,7 @@ REGISTER_DIALOG(file_dialog)
|
|||
tfile_dialog::tfile_dialog()
|
||||
: title_(_("Find File"))
|
||||
, msg_()
|
||||
, ok_label_()
|
||||
, current_entry_()
|
||||
, current_dir_()
|
||||
, read_only_(false)
|
||||
|
@ -151,6 +152,7 @@ void tfile_dialog::pre_show(twindow& window)
|
|||
{
|
||||
tcontrol& title = find_widget<tcontrol>(&window, "title", false);
|
||||
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
|
||||
tcontrol& ok = find_widget<tcontrol>(&window, "ok", false);
|
||||
|
||||
title.set_label(title_);
|
||||
|
||||
|
@ -161,6 +163,12 @@ void tfile_dialog::pre_show(twindow& window)
|
|||
message.set_use_markup(true);
|
||||
}
|
||||
|
||||
if(ok_label_.empty()) {
|
||||
ok.set_label(save_mode_ ? _("Save") : _("Open"));
|
||||
} else {
|
||||
ok.set_label(ok_label_);
|
||||
}
|
||||
|
||||
tlistbox& filelist = find_widget<tlistbox>(&window, "filelist", false);
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
|
|
|
@ -145,9 +145,23 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OK button label.
|
||||
*
|
||||
* By default, "Save" is used when save_mode is enabled, and "Open" otherwise.
|
||||
* Calling this method with an empty string will reset the label to the
|
||||
* default.
|
||||
*/
|
||||
tfile_dialog& set_ok_label(const std::string& value)
|
||||
{
|
||||
ok_label_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string title_;
|
||||
std::string msg_;
|
||||
std::string ok_label_;
|
||||
|
||||
std::string current_entry_;
|
||||
std::string current_dir_;
|
||||
|
|
Loading…
Add table
Reference in a new issue