mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-02-01 00:18:44 +03:00
PRUSA 2.7.0
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "GLCanvas3D.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
|
||||
#include "Widgets/SpinInput.hpp"
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -56,13 +57,33 @@ namespace GUI {
|
||||
|
||||
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
|
||||
DPIDialog(parent, wxID_ANY, _L("Preferences"), wxDefaultPosition,
|
||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
#ifdef __WXOSX__
|
||||
isOSX = true;
|
||||
#endif
|
||||
build();
|
||||
|
||||
wxSize sz = GetSize();
|
||||
bool is_scrollbar_shown = false;
|
||||
|
||||
const size_t pages_cnt = tabs->GetPageCount();
|
||||
for (size_t tab_id = 0; tab_id < pages_cnt; tab_id++) {
|
||||
wxSizer* tab_sizer = tabs->GetPage(tab_id)->GetSizer();
|
||||
wxScrolledWindow* scrolled = static_cast<wxScrolledWindow*>(tab_sizer->GetItem(size_t(0))->GetWindow());
|
||||
scrolled->SetScrollRate(0, 5);
|
||||
|
||||
is_scrollbar_shown |= scrolled->GetScrollLines(wxVERTICAL) > 0;
|
||||
}
|
||||
|
||||
if (is_scrollbar_shown)
|
||||
sz.x += 2*em_unit();
|
||||
#ifdef __WXGTK__
|
||||
// To correct Layout of wxScrolledWindow we need at least small change of size
|
||||
else
|
||||
sz.x += 1;
|
||||
#endif
|
||||
SetSize(sz);
|
||||
m_highlighter.set_timer_owner(this, 0);
|
||||
}
|
||||
|
||||
@@ -106,6 +127,11 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
|
||||
for (const std::string& opt_key : {"suppress_hyperlinks", "downloader_url_registered"})
|
||||
m_optgroup_other->set_value(opt_key, app_config->get_bool(opt_key));
|
||||
|
||||
for (const std::string& opt_key : { "default_action_on_close_application"
|
||||
,"default_action_on_new_project"
|
||||
,"default_action_on_select_preset" })
|
||||
m_optgroup_general->set_value(opt_key, app_config->get(opt_key) == "none");
|
||||
m_optgroup_general->set_value("default_action_on_dirty_project", app_config->get("default_action_on_dirty_project").empty());
|
||||
// update colors for color pickers of the labels
|
||||
update_color(m_sys_colour, wxGetApp().get_label_clr_sys());
|
||||
update_color(m_mod_colour, wxGetApp().get_label_clr_modified());
|
||||
@@ -126,11 +152,17 @@ static std::shared_ptr<ConfigOptionsGroup>create_options_tab(const wxString& tit
|
||||
tabs->AddPage(tab, _(title));
|
||||
tab->SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto scrolled = new wxScrolledWindow(tab);
|
||||
|
||||
// Sizer in the scrolled area
|
||||
auto* scrolled_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
scrolled->SetSizer(scrolled_sizer);
|
||||
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(scrolled, 1, wxEXPAND);
|
||||
sizer->SetSizeHints(tab);
|
||||
tab->SetSizer(sizer);
|
||||
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(tab);
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(scrolled);
|
||||
optgroup->label_width = 40;
|
||||
optgroup->set_config_category_and_type(title, int(Preset::TYPE_PREFERENCES));
|
||||
return optgroup;
|
||||
@@ -143,6 +175,7 @@ static void activate_options_tab(std::shared_ptr<ConfigOptionsGroup> optgroup)
|
||||
wxBoxSizer* sizer = static_cast<wxBoxSizer*>(static_cast<wxPanel*>(optgroup->parent())->GetSizer());
|
||||
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
|
||||
optgroup->parent()->Layout();
|
||||
// apply sercher
|
||||
wxGetApp().sidebar().get_searcher().append_preferences_options(optgroup->get_lines());
|
||||
}
|
||||
@@ -204,7 +237,7 @@ void PreferencesDialog::build()
|
||||
#ifdef _WIN32
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
#else
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
//SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif
|
||||
const wxFont& font = wxGetApp().normal_font();
|
||||
SetFont(font);
|
||||
@@ -215,7 +248,12 @@ void PreferencesDialog::build()
|
||||
tabs = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
|
||||
#else
|
||||
tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL |wxNB_NOPAGETHEME | wxNB_DEFAULT );
|
||||
tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#ifdef __linux__
|
||||
tabs->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
|
||||
e.Skip();
|
||||
CallAfter([this]() { tabs->GetCurrentPage()->Layout(); });
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Add "General" tab
|
||||
@@ -280,10 +318,6 @@ void PreferencesDialog::build()
|
||||
L("If enabled, sets QIDISlicer as default application to open .stl files."),
|
||||
app_config->get_bool("associate_stl"));
|
||||
|
||||
append_bool_option(m_optgroup_general, "associate_step",
|
||||
L("Associate .stp files to QIDISlicer"),
|
||||
L("If enabled, sets QIDISlicer as default application to open .stp files."),
|
||||
app_config->get_bool("associate_step"));
|
||||
#endif // _WIN32
|
||||
|
||||
m_optgroup_general->append_separator();
|
||||
@@ -364,6 +398,10 @@ void PreferencesDialog::build()
|
||||
L("Associate .gcode files to QIDISlicer G-code Viewer"),
|
||||
L("If enabled, sets QIDISlicer G-code Viewer as default application to open .gcode files."),
|
||||
app_config->get_bool("associate_gcode"));
|
||||
append_bool_option(m_optgroup_general, "associate_bgcode",
|
||||
L("Associate .bgcode files to PrusaSlicer G-code Viewer"),
|
||||
L("If enabled, sets PrusaSlicer G-code Viewer as default application to open .bgcode files."),
|
||||
app_config->get_bool("associate_bgcode"));
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -513,13 +551,20 @@ void PreferencesDialog::build()
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
append_bool_option(m_optgroup_gui, "tabs_as_menu",
|
||||
L("Set settings tabs as menu items (experimental)"),
|
||||
L("Set settings tabs as menu items"),
|
||||
L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."),
|
||||
app_config->get_bool("tabs_as_menu"));
|
||||
#endif
|
||||
|
||||
m_optgroup_gui->append_separator();
|
||||
/*
|
||||
append_bool_option(m_optgroup_gui, "suppress_round_corners",
|
||||
L("Suppress round corners for controls (experimental)"),
|
||||
L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."),
|
||||
app_config->get("suppress_round_corners") == "1");
|
||||
|
||||
m_optgroup_gui->append_separator();
|
||||
*/
|
||||
append_bool_option(m_optgroup_gui, "show_hints",
|
||||
L("Show \"Tip of the day\" notification after start"),
|
||||
L("If enabled, useful hints are displayed at startup."),
|
||||
@@ -586,7 +631,7 @@ void PreferencesDialog::build()
|
||||
activate_options_tab(m_optgroup_other);
|
||||
|
||||
create_downloader_path_sizer();
|
||||
// create_settings_font_widget();
|
||||
create_settings_font_widget();
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
// Add "Render" tab
|
||||
@@ -606,10 +651,11 @@ void PreferencesDialog::build()
|
||||
|
||||
activate_options_tab(m_optgroup_render);
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Add "Dark Mode" tab
|
||||
m_optgroup_dark_mode = create_options_tab(_L("Dark mode (experimental)"), tabs);
|
||||
m_optgroup_dark_mode = create_options_tab(_L("Dark mode"), tabs);
|
||||
m_optgroup_dark_mode->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
|
||||
if (auto it = m_values.find(opt_key); it != m_values.end()) {
|
||||
m_values.erase(it); // we shouldn't change value, if some of those parameters were selected, and then deselected
|
||||
@@ -635,7 +681,6 @@ void PreferencesDialog::build()
|
||||
|
||||
activate_options_tab(m_optgroup_dark_mode);
|
||||
#endif //_WIN32
|
||||
}
|
||||
|
||||
// update alignment of the controls for all tabs
|
||||
update_ctrls_alignment();
|
||||
@@ -644,6 +689,8 @@ void PreferencesDialog::build()
|
||||
sizer->Add(tabs, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
|
||||
|
||||
auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
wxGetApp().SetWindowVariantForButton(buttons->GetAffirmativeButton());
|
||||
wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton());
|
||||
this->Bind(wxEVT_BUTTON, &PreferencesDialog::accept, this, wxID_OK);
|
||||
this->Bind(wxEVT_BUTTON, &PreferencesDialog::revert, this, wxID_CANCEL);
|
||||
|
||||
@@ -699,7 +746,7 @@ void PreferencesDialog::accept(wxEvent&)
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled", "font_size" };
|
||||
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled", "font_pt_size", "suppress_round_corners" };
|
||||
|
||||
for (const std::string& option : options_to_recreate_GUI) {
|
||||
if (m_values.find(option) != m_values.end()) {
|
||||
@@ -880,7 +927,7 @@ void PreferencesDialog::refresh_og(std::shared_ptr<ConfigOptionsGroup> og)
|
||||
{
|
||||
og->parent()->Layout();
|
||||
tabs->Layout();
|
||||
this->layout();
|
||||
// this->layout();
|
||||
}
|
||||
|
||||
void PreferencesDialog::create_icon_size_slider()
|
||||
@@ -1058,24 +1105,29 @@ void PreferencesDialog::create_settings_font_widget()
|
||||
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title));
|
||||
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
||||
const std::string opt_key = "font_size";
|
||||
const std::string opt_key = "font_pt_size";
|
||||
m_blinkers[opt_key] = new BlinkingBitmap(parent);
|
||||
|
||||
wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxHORIZONTAL);
|
||||
|
||||
wxStaticText* font_example = new wxStaticText(parent, wxID_ANY, "Application text");
|
||||
int val = wxGetApp().normal_font().GetPointSize();
|
||||
wxSpinCtrl* size_sc = new wxSpinCtrl(parent, wxID_ANY, format_wxstr("%1%", val), wxDefaultPosition, wxSize(15*em_unit(), -1), wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
|
||||
SpinInput* size_sc = new SpinInput(parent, format_wxstr("%1%", val), "", wxDefaultPosition, wxSize(15 * em_unit(), -1), wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
|
||||
#ifdef _WIN32
|
||||
| wxBORDER_SIMPLE
|
||||
#endif
|
||||
, 8, 20);
|
||||
, 8, wxGetApp().get_max_font_pt_size());
|
||||
wxGetApp().UpdateDarkUI(size_sc);
|
||||
|
||||
auto apply_font = [this, font_example, opt_key](const int val, const wxFont& font) {
|
||||
auto apply_font = [this, font_example, opt_key, stb_sizer](const int val, const wxFont& font) {
|
||||
font_example->SetFont(font);
|
||||
m_values[opt_key] = format("%1%", val);
|
||||
stb_sizer->Layout();
|
||||
#ifdef __linux__
|
||||
CallAfter([this]() { refresh_og(m_optgroup_other); });
|
||||
#else
|
||||
refresh_og(m_optgroup_other);
|
||||
#endif
|
||||
};
|
||||
|
||||
auto change_value = [size_sc, apply_font](wxCommandEvent& evt) {
|
||||
|
||||
Reference in New Issue
Block a user