This commit is contained in:
Filip Sykala - NTB T15p 2023-01-30 17:44:20 +01:00
commit bd20bd4dc9
9 changed files with 44 additions and 35 deletions

View File

@ -83,8 +83,9 @@ wxBitmapBundle * ModePaletteComboBox::get_bmp(const std::vector<std::string> &pa
return bmp_bndl; return bmp_bndl;
} }
namespace GUI_Descriptions {
void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour) void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour)
{ {
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5); wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5);
sizer->Add(grid_sizer, 0, wxEXPAND); sizer->Add(grid_sizer, 0, wxEXPAND);
@ -127,7 +128,7 @@ void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWi
add_color(mod_colour, wxGetApp().get_label_clr_modified(),wxGetApp().get_label_default_clr_modified(), _L("Value was changed and is not equal to the system value or the last saved preset")); add_color(mod_colour, wxGetApp().get_label_clr_modified(),wxGetApp().get_label_default_clr_modified(), _L("Value was changed and is not equal to the system value or the last saved preset"));
} }
void ButtonsDescription::FillSizerWithModeColorDescriptions( void FillSizerWithModeColorDescriptions(
wxSizer* sizer, wxWindow* parent, wxSizer* sizer, wxWindow* parent,
std::vector<wxColourPickerCtrl**> clr_pickers, std::vector<wxColourPickerCtrl**> clr_pickers,
std::vector<wxColour>& mode_palette) std::vector<wxColour>& mode_palette)
@ -195,7 +196,7 @@ void ButtonsDescription::FillSizerWithModeColorDescriptions(
} }
} }
ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry> &entries) : Dialog::Dialog(wxWindow* parent, const std::vector<ButtonEntry> &entries) :
wxDialog(parent, wxID_ANY, _(L("Buttons And Text Colors Description")), wxDefaultPosition, wxDefaultSize), wxDialog(parent, wxID_ANY, _(L("Buttons And Text Colors Description")), wxDefaultPosition, wxDefaultSize),
m_entries(entries) m_entries(entries)
{ {
@ -207,7 +208,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
main_sizer->Add(grid_sizer, 0, wxEXPAND | wxALL, 20); main_sizer->Add(grid_sizer, 0, wxEXPAND | wxALL, 20);
// Icon description // Icon description
for (const Entry &entry : m_entries) for (const ButtonEntry &entry : m_entries)
{ {
auto icon = new wxStaticBitmap(this, wxID_ANY, entry.bitmap->bmp()); auto icon = new wxStaticBitmap(this, wxID_ANY, entry.bitmap->bmp());
grid_sizer->Add(icon, -1, wxALIGN_CENTRE_VERTICAL); grid_sizer->Add(icon, -1, wxALIGN_CENTRE_VERTICAL);
@ -219,14 +220,14 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
// Text color description // Text color description
wxSizer* sizer = new wxBoxSizer(wxVERTICAL); wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
FillSizerWithTextColorDescriptions(sizer, this, &sys_colour, &mod_colour); GUI_Descriptions::FillSizerWithTextColorDescriptions(sizer, this, &sys_colour, &mod_colour);
main_sizer->Add(sizer, 0, wxEXPAND | wxALL, 20); main_sizer->Add(sizer, 0, wxEXPAND | wxALL, 20);
// Mode color markers description // Mode color markers description
mode_palette = wxGetApp().get_mode_palette(); mode_palette = wxGetApp().get_mode_palette();
wxSizer* mode_sizer = new wxBoxSizer(wxVERTICAL); wxSizer* mode_sizer = new wxBoxSizer(wxVERTICAL);
FillSizerWithModeColorDescriptions(mode_sizer, this, { &simple, &advanced, &expert }, mode_palette); GUI_Descriptions::FillSizerWithModeColorDescriptions(mode_sizer, this, { &simple, &advanced, &expert }, mode_palette);
main_sizer->Add(mode_sizer, 0, wxEXPAND | wxALL, 20); main_sizer->Add(mode_sizer, 0, wxEXPAND | wxALL, 20);
auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL); auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL);
@ -248,6 +249,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
main_sizer->SetSizeHints(this); main_sizer->SetSizeHints(this);
} }
} // GUI_Descriptions
} // GUI } // GUI
} // Slic3r } // Slic3r

View File

@ -35,9 +35,20 @@ protected:
wxBitmapBundle* get_bmp( const std::vector<std::string>& palette); wxBitmapBundle* get_bmp( const std::vector<std::string>& palette);
}; };
namespace GUI_Descriptions {
class ButtonsDescription : public wxDialog struct ButtonEntry {
ButtonEntry(ScalableBitmap *bitmap, const std::string &symbol, const std::string &explanation) : bitmap(bitmap), symbol(symbol), explanation(explanation) {}
ScalableBitmap *bitmap;
std::string symbol;
std::string explanation;
};
class Dialog : public wxDialog
{ {
std::vector<ButtonEntry> m_entries;
wxColourPickerCtrl* sys_colour{ nullptr }; wxColourPickerCtrl* sys_colour{ nullptr };
wxColourPickerCtrl* mod_colour{ nullptr }; wxColourPickerCtrl* mod_colour{ nullptr };
@ -47,25 +58,16 @@ class ButtonsDescription : public wxDialog
std::vector<wxColour> mode_palette; std::vector<wxColour> mode_palette;
public: public:
struct Entry {
Entry(ScalableBitmap *bitmap, const std::string &symbol, const std::string &explanation) : bitmap(bitmap), symbol(symbol), explanation(explanation) {}
ScalableBitmap *bitmap; Dialog(wxWindow* parent, const std::vector<ButtonEntry> &entries);
std::string symbol; ~Dialog() {}
std::string explanation; };
};
ButtonsDescription(wxWindow* parent, const std::vector<Entry> &entries); extern void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour);
~ButtonsDescription() {} extern void FillSizerWithModeColorDescriptions(wxSizer* sizer, wxWindow* parent,
static void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour);
static void FillSizerWithModeColorDescriptions(wxSizer* sizer, wxWindow* parent,
std::vector<wxColourPickerCtrl**> clr_pickers, std::vector<wxColourPickerCtrl**> clr_pickers,
std::vector<wxColour>& mode_palette); std::vector<wxColour>& mode_palette);
} // GUI_Descriptions
private:
std::vector<Entry> m_entries;
};
} // GUI } // GUI
} // Slic3r } // Slic3r

View File

@ -253,7 +253,10 @@ void FileGet::priv::get_perform()
if (file != NULL) if (file != NULL)
fclose(file); fclose(file);
wxCommandEvent* evt = new wxCommandEvent(EVT_DWNLDR_FILE_ERROR); wxCommandEvent* evt = new wxCommandEvent(EVT_DWNLDR_FILE_ERROR);
if (!error.empty())
evt->SetString(GUI::from_u8(error)); evt->SetString(GUI::from_u8(error));
else
evt->SetString(GUI::from_u8(body));
evt->SetInt(m_id); evt->SetInt(m_id);
m_evt_handler->QueueEvent(evt); m_evt_handler->QueueEvent(evt);
}) })

View File

@ -3403,7 +3403,7 @@ void GUI_App::app_updater(bool from_user)
} }
app_data.target_path =dwnld_dlg.get_download_path(); app_data.target_path =dwnld_dlg.get_download_path();
// start download // start download
this->plater_->get_notification_manager()->push_download_progress_notification(_utf8("Download"), std::bind(&AppUpdater::cancel_callback, this->m_app_updater.get())); this->plater_->get_notification_manager()->push_download_progress_notification(GUI::format(_utf8("Downloading %1%"), app_data.target_path.filename().string()), std::bind(&AppUpdater::cancel_callback, this->m_app_updater.get()));
app_data.start_after = dwnld_dlg.run_after_download(); app_data.start_after = dwnld_dlg.run_after_download();
m_app_updater->set_app_data(std::move(app_data)); m_app_updater->set_app_data(std::move(app_data));
m_app_updater->sync_download(); m_app_updater->sync_download();

View File

@ -170,11 +170,11 @@ void GLGizmosManager::reset_all_states()
if (! m_enabled || m_serializing) if (! m_enabled || m_serializing)
return; return;
EType current = get_current_type(); const EType current = get_current_type();
if (current != Undefined) if (current != Undefined)
// close any open gizmo // close any open gizmo
open_gizmo(current); open_gizmo(current);
else
activate_gizmo(Undefined); activate_gizmo(Undefined);
m_hover = Undefined; m_hover = Undefined;
} }

View File

@ -1041,7 +1041,7 @@ void PreferencesDialog::create_settings_text_color_widget()
m_blinkers[opt_key] = new BlinkingBitmap(parent); m_blinkers[opt_key] = new BlinkingBitmap(parent);
wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxVERTICAL); wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
ButtonsDescription::FillSizerWithTextColorDescriptions(stb_sizer, parent, &m_sys_colour, &m_mod_colour); GUI_Descriptions::FillSizerWithTextColorDescriptions(stb_sizer, parent, &m_sys_colour, &m_mod_colour);
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2); sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2);
@ -1068,7 +1068,7 @@ void PreferencesDialog::create_settings_mode_color_widget()
// Mode color markers description // Mode color markers description
m_mode_palette = wxGetApp().get_mode_palette(); m_mode_palette = wxGetApp().get_mode_palette();
ButtonsDescription::FillSizerWithModeColorDescriptions(stb_sizer, parent, { &m_mode_simple, &m_mode_advanced, &m_mode_expert }, m_mode_palette); GUI_Descriptions::FillSizerWithModeColorDescriptions(stb_sizer, parent, { &m_mode_simple, &m_mode_advanced, &m_mode_expert }, m_mode_palette);
auto sizer = new wxBoxSizer(wxHORIZONTAL); auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2); sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2);

View File

@ -194,7 +194,7 @@ void Tab::create_preset_tab()
m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); })); m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); }));
m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); })); m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); }));
m_question_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) { m_question_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) {
ButtonsDescription dlg(this, m_icon_descriptions); GUI_Descriptions::Dialog dlg(this, m_icon_descriptions);
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
wxGetApp().update_label_colours(); wxGetApp().update_label_colours();
}); });

View File

@ -254,7 +254,7 @@ protected:
std::map<std::string, int> m_options_list; std::map<std::string, int> m_options_list;
int m_opt_status_value = 0; int m_opt_status_value = 0;
std::vector<ButtonsDescription::Entry> m_icon_descriptions = {}; std::vector<GUI_Descriptions::ButtonEntry> m_icon_descriptions = {};
bool m_is_modified_values{ false }; bool m_is_modified_values{ false };
bool m_is_nonsys_values{ true }; bool m_is_nonsys_values{ true };

View File

@ -2,6 +2,7 @@
#include <atomic> #include <atomic>
#include <thread> #include <thread>
#include <string>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
@ -14,6 +15,7 @@
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/Utils/Http.hpp" #include "slic3r/Utils/Http.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
@ -214,7 +216,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
} }
boost::filesystem::path tmp_path = dest_path; boost::filesystem::path tmp_path = dest_path;
tmp_path += format(".%1%%2%", get_current_pid(), ".download"); tmp_path += format(".%1%%2%", std::to_string(GUI::GLCanvas3D::timestamp_now()), ".download");
FILE* file; FILE* file;
wxString temp_path_wstring(tmp_path.wstring()); wxString temp_path_wstring(tmp_path.wstring());
file = fopen(temp_path_wstring.c_str(), "wb"); file = fopen(temp_path_wstring.c_str(), "wb");