Preferences: notify_relese option with Choice type Field.
OptionsGroup:: Added possibility of the right alignment of the controls + Added separator line to Preferences
This commit is contained in:
parent
405a7e84d6
commit
ac6259e387
9 changed files with 275 additions and 66 deletions
src/slic3r/GUI
|
@ -8,8 +8,38 @@
|
|||
#include <wx/notebook.h>
|
||||
#include "Notebook.hpp"
|
||||
#include "ButtonsDescription.hpp"
|
||||
#include "OG_CustomCtrl.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values& enum_keys_map)
|
||||
{
|
||||
t_config_enum_names names;
|
||||
int cnt = 0;
|
||||
for (const auto& kvp : enum_keys_map)
|
||||
cnt = std::max(cnt, kvp.second);
|
||||
cnt += 1;
|
||||
names.assign(cnt, "");
|
||||
for (const auto& kvp : enum_keys_map)
|
||||
names[kvp.second] = kvp.first;
|
||||
return names;
|
||||
}
|
||||
|
||||
#define CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NAME) \
|
||||
static t_config_enum_names s_keys_names_##NAME = enum_names_from_keys_map(s_keys_map_##NAME); \
|
||||
template<> const t_config_enum_values& ConfigOptionEnum<NAME>::get_enum_values() { return s_keys_map_##NAME; } \
|
||||
template<> const t_config_enum_names& ConfigOptionEnum<NAME>::get_enum_names() { return s_keys_names_##NAME; }
|
||||
|
||||
|
||||
|
||||
static const t_config_enum_values s_keys_map_NotifyReleaseMode = {
|
||||
{"all", NotifyReleaseAll},
|
||||
{"release", NotifyReleaseOnly},
|
||||
{"none", NotifyReleaseNone},
|
||||
};
|
||||
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NotifyReleaseMode)
|
||||
|
||||
namespace GUI {
|
||||
|
||||
PreferencesDialog::PreferencesDialog(wxWindow* parent, int selected_tab) :
|
||||
|
@ -39,7 +69,7 @@ static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& tit
|
|||
|
||||
static void activate_options_tab(std::shared_ptr<ConfigOptionsGroup> optgroup)
|
||||
{
|
||||
optgroup->activate();
|
||||
optgroup->activate([](){}, wxALIGN_RIGHT);
|
||||
optgroup->update_visibility(comSimple);
|
||||
wxBoxSizer* sizer = static_cast<wxBoxSizer*>(static_cast<wxPanel*>(optgroup->parent())->GetSizer());
|
||||
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
|
@ -116,6 +146,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "version_check");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
|
||||
// Please keep in sync with ConfigWizard
|
||||
def.label = L("Export sources full pathnames to 3mf and amf");
|
||||
def.type = coBool;
|
||||
|
@ -141,6 +173,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
m_optgroup_general->append_single_option_line(option);
|
||||
#endif // _WIN32
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
|
||||
// Please keep in sync with ConfigWizard
|
||||
def.label = L("Update built-in Presets automatically");
|
||||
def.type = coBool;
|
||||
|
@ -165,6 +199,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "show_incompatible_presets");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
|
||||
def.label = L("Show drop project dialog");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("When checked, whenever dragging and dropping a project file on the application, shows a dialog asking to select the action to take on the file to load.");
|
||||
|
@ -172,7 +208,6 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "show_drop_project_dialog");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
|
||||
#if __APPLE__
|
||||
def.label = L("Allow just a single PrusaSlicer instance");
|
||||
def.type = coBool;
|
||||
|
@ -186,6 +221,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "single_instance");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
|
||||
def.label = L("Ask for unsaved changes when closing application or loading new project");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("Always ask for unsaved changes, when: \n"
|
||||
|
@ -230,6 +267,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
m_optgroup_general->append_single_option_line(option);
|
||||
#endif
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
|
||||
// Show/Hide splash screen
|
||||
def.label = L("Show splash screen");
|
||||
def.type = coBool;
|
||||
|
@ -291,7 +330,15 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
m_optgroup_gui->m_on_change = [this, tabs](t_config_option_key opt_key, boost::any value) {
|
||||
if (opt_key == "suppress_hyperlinks")
|
||||
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "";
|
||||
else
|
||||
else if (opt_key == "notify_release") {
|
||||
int val_int = boost::any_cast<int>(value);
|
||||
for (const auto& item : s_keys_map_NotifyReleaseMode) {
|
||||
if (item.second == val_int) {
|
||||
m_values[opt_key] = item.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
|
||||
|
||||
if (opt_key == "use_custom_toolbar_size") {
|
||||
|
@ -300,6 +347,8 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
tabs->Layout();
|
||||
this->layout();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
def.label = L("Sequential slider applied only to top layer");
|
||||
|
@ -361,7 +410,9 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "tabs_as_menu");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
#endif
|
||||
|
||||
|
||||
m_optgroup_gui->append_separator();
|
||||
|
||||
def.label = L("Show \"Tip of the day\" notification after start");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("If enabled, useful hints are displayed at startup.");
|
||||
|
@ -369,6 +420,24 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "show_hints");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
|
||||
ConfigOptionDef def_enum;
|
||||
def_enum.label = L("Notify about new releases");
|
||||
def_enum.type = coEnum;
|
||||
def_enum.tooltip = L("You will be notified about new release after startup acordingly: All = Regular release and alpha / beta releases. Release only = regular release.");
|
||||
def_enum.enum_keys_map = &ConfigOptionEnum<NotifyReleaseMode>::get_enum_values();
|
||||
def_enum.enum_values.push_back("all");
|
||||
def_enum.enum_values.push_back("release");
|
||||
def_enum.enum_values.push_back("none");
|
||||
def_enum.enum_labels.push_back(L("All"));
|
||||
def_enum.enum_labels.push_back(L("Release only"));
|
||||
def_enum.enum_labels.push_back(L("None"));
|
||||
def_enum.mode = comSimple;
|
||||
def_enum.set_default_value(new ConfigOptionEnum<NotifyReleaseMode>(static_cast<NotifyReleaseMode>(s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release")))));
|
||||
option = Option(def_enum, "notify_release");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
|
||||
m_optgroup_gui->append_separator();
|
||||
|
||||
def.label = L("Use custom size for toolbar icons");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("If enabled, you can change size of toolbar icons manually.");
|
||||
|
@ -376,15 +445,12 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
option = Option(def, "use_custom_toolbar_size");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
|
||||
def.label = L("Notify about testing releases");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("If enabled, you will be notified about alpha / beta releases available for download.");
|
||||
def.set_default_value(new ConfigOptionBool{ app_config->get("notify_testing_release") == "1" });
|
||||
option = Option(def, "notify_testing_release");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
}
|
||||
|
||||
activate_options_tab(m_optgroup_gui);
|
||||
// set Field for notify_release to its value to activate the object
|
||||
boost::any val = s_keys_map_NotifyReleaseMode.at(app_config->get("notify_release"));
|
||||
m_optgroup_gui->get_field("notify_release")->set_value(val, false);
|
||||
|
||||
if (is_editor) {
|
||||
create_icon_size_slider();
|
||||
|
@ -413,6 +479,9 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
}
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
// update alignment of the controls for all tabs
|
||||
update_ctrls_alignment();
|
||||
|
||||
if (selected_tab < tabs->GetPageCount())
|
||||
tabs->SetSelection(selected_tab);
|
||||
|
||||
|
@ -432,6 +501,20 @@ void PreferencesDialog::build(size_t selected_tab)
|
|||
this->CenterOnParent();
|
||||
}
|
||||
|
||||
void PreferencesDialog::update_ctrls_alignment()
|
||||
{
|
||||
int max_ctrl_width{ 0 };
|
||||
std::initializer_list og_list = { m_optgroup_general.get(), m_optgroup_camera.get(), m_optgroup_gui.get() };
|
||||
for (auto og : og_list) {
|
||||
if (int max = og->custom_ctrl->get_max_win_width();
|
||||
max_ctrl_width < max)
|
||||
max_ctrl_width = max;
|
||||
}
|
||||
if (max_ctrl_width)
|
||||
for (auto og : og_list)
|
||||
og->custom_ctrl->set_max_win_width(max_ctrl_width);
|
||||
}
|
||||
|
||||
void PreferencesDialog::accept(wxEvent&)
|
||||
{
|
||||
// if (m_values.find("no_defaults") != m_values.end()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue