#1043 Can set the icon size (or remove them)

This commit is contained in:
remi durand 2021-03-30 20:04:28 +02:00
parent eb8a08dade
commit 603b8c2a2b
3 changed files with 35 additions and 12 deletions

View File

@ -63,6 +63,9 @@ void AppConfig::set_defaults()
if (get("freecad_path").empty())
set("freecad_path", ".");
if (get("tab_icon_size").empty())
set("tab_icon_size", "32");
if (get("color_very_dark").empty())
set("color_very_dark", "0047c7");

View File

@ -365,12 +365,18 @@ void MainFrame::update_layout()
});
// icons for ESettingsLayout::Old
wxImageList* img_list = nullptr;
for (std::string icon_name : {"editor_menu", "layers", "preview_menu", "cog"}) {
const wxBitmap& bmp = create_scaled_bitmap(icon_name, this, 32);
if (img_list == nullptr)
img_list = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
img_list->Add(bmp);
int icon_size = 0;
try {
icon_size = atoi(wxGetApp().app_config->get("tab_icon_size").c_str());
}
catch (std::exception e) {}
if(icon_size >= 8)
for (std::string icon_name : {"editor_menu", "layers", "preview_menu", "cog"}) {
const wxBitmap& bmp = create_scaled_bitmap(icon_name, this, icon_size);
if (img_list == nullptr)
img_list = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
img_list->Add(bmp);
}
m_tabpanel->AssignImageList(img_list);
m_tabpanel->InsertPage(0, new wxPanel(m_tabpanel), _L("3D view"));
m_tabpanel->InsertPage(1, new wxPanel(m_tabpanel), _L("Sliced preview"));
@ -378,12 +384,15 @@ void MainFrame::update_layout()
m_tabpanel->GetPage(0)->SetSizer(new wxBoxSizer(wxVERTICAL));
m_tabpanel->GetPage(1)->SetSizer(new wxBoxSizer(wxVERTICAL));
m_tabpanel->GetPage(2)->SetSizer(new wxBoxSizer(wxVERTICAL));
m_tabpanel->SetPageImage(0, 0);
m_tabpanel->SetPageImage(1, 1);
m_tabpanel->SetPageImage(2, 2);
m_tabpanel->SetPageImage(3, 3);
m_tabpanel->SetPageImage(4, 3);
m_tabpanel->SetPageImage(5, 3);
if (icon_size >= 8)
{
m_tabpanel->SetPageImage(0, 0);
m_tabpanel->SetPageImage(1, 1);
m_tabpanel->SetPageImage(2, 2);
m_tabpanel->SetPageImage(3, 3);
m_tabpanel->SetPageImage(4, 3);
m_tabpanel->SetPageImage(5, 3);
}
m_plater->Reparent(m_tabpanel->GetPage(0));
m_tabpanel->GetPage(0)->GetSizer()->Add(m_plater, 1, wxEXPAND);
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);

View File

@ -304,6 +304,8 @@ void PreferencesDialog::build()
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "";
else if (opt_key.find("color") != std::string::npos)
m_values[opt_key] = boost::any_cast<std::string>(value);
else if (opt_key.find("tab_icon_size") != std::string::npos)
m_values[opt_key] = std::to_string(boost::any_cast<int>(value));
else
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -345,6 +347,15 @@ void PreferencesDialog::build()
def.set_default_value(new ConfigOptionBool{ app_config->get("use_custom_toolbar_size") == "1" });
option = Option(def, "use_custom_toolbar_size");
m_optgroup_gui->append_single_option_line(option);
def.label = L("Tab icon size");
def.type = coInt;
def.tooltip = std::string(L("Size of the tab icons, in pixels. Set to 0 to remove icons."))
+ std::string(L("\nYou have to restart the application before any change will be taken into account."));
def.set_default_value(new ConfigOptionInt{ atoi(app_config->get("tab_icon_size").c_str()) });
option = Option(def, "tab_icon_size");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
}
@ -469,7 +480,7 @@ void PreferencesDialog::accept()
if (it != m_values.end() && app_config->get(key) != it->second) {
m_settings_layout_changed = true;
break;
}
}
}
for (const std::string& key : {"default_action_on_close_application", "default_action_on_select_preset"}) {