mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 15:51:10 -06:00
FIX:fixed appconfig is not saved when switching dark mode
Change-Id: I77fc3808309a23497000c34b6047a359d12c4622
This commit is contained in:
parent
4a5c473058
commit
eca5897a25
22 changed files with 84 additions and 26 deletions
|
@ -47,11 +47,7 @@ CopyrightsDialog::CopyrightsDialog()
|
|||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
this->SetFont(wxGetApp().normal_font());
|
||||
#ifdef _WIN32
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
#else
|
||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif
|
||||
this->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
@ -66,6 +62,7 @@ CopyrightsDialog::CopyrightsDialog()
|
|||
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(40 * em_unit(), 20 * em_unit()), wxHW_SCROLLBAR_AUTO);
|
||||
m_html->SetMinSize(wxSize(FromDIP(870),FromDIP(520)));
|
||||
m_html->SetBackgroundColour(*wxWHITE);
|
||||
wxFont font = get_default_font(this);
|
||||
const int fs = font.GetPointSize();
|
||||
const int fs2 = static_cast<int>(1.2f*fs);
|
||||
|
@ -81,6 +78,7 @@ CopyrightsDialog::CopyrightsDialog()
|
|||
SetSizer(sizer);
|
||||
sizer->SetSizeHints(this);
|
||||
CenterOnParent();
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
void CopyrightsDialog::fill_entries()
|
||||
|
|
|
@ -316,9 +316,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
|
|||
+ (grayscale ? "-gs" : "")
|
||||
+ new_color;
|
||||
|
||||
auto it = m_map.find(bitmap_key);
|
||||
/*auto it = m_map.find(bitmap_key);
|
||||
if (it != m_map.end())
|
||||
return it->second;
|
||||
return it->second;*/
|
||||
|
||||
// map of color replaces
|
||||
std::map<std::string, std::string> replaces;
|
||||
|
@ -329,6 +329,8 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
|
|||
//replaces["\"#ACACAC\""] = "\"#54545A\"";
|
||||
replaces["\"#CECECE\""] = "\"#54545B\"";
|
||||
replaces["\"#6B6B6B\""] = "\"#818182\"";
|
||||
replaces["\"#909090\""] = "\"#FFFFFF\"";
|
||||
replaces["\"#00FF00\""] = "\"#FF0000\"";
|
||||
}
|
||||
//if (!new_color.empty())
|
||||
// replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <wx/progdlg.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -116,6 +117,7 @@ CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj)
|
|||
#endif //APPLE
|
||||
|
||||
check_func_supported();
|
||||
wxGetApp().UpdateDarkUIWin(this);
|
||||
}
|
||||
|
||||
void CameraPopup::sdcard_absent_hint()
|
||||
|
|
|
@ -2752,6 +2752,8 @@ static void update_dark_children_ui(wxWindow* window, bool just_buttons_update =
|
|||
{
|
||||
/*bool is_btn = dynamic_cast<wxButton*>(window) != nullptr;
|
||||
is_btn = false;*/
|
||||
if (!window) return;
|
||||
|
||||
wxGetApp().UpdateDarkUI(window);
|
||||
|
||||
auto children = window->GetChildren();
|
||||
|
@ -2774,6 +2776,16 @@ void GUI_App::UpdateDlgDarkUI(wxDialog* dlg)
|
|||
#endif
|
||||
update_dark_children_ui(dlg);
|
||||
}
|
||||
|
||||
void GUI_App::UpdateFrameDarkUI(wxFrame* dlg)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
NppDarkMode::SetDarkExplorerTheme(dlg->GetHWND());
|
||||
NppDarkMode::SetDarkTitleBar(dlg->GetHWND());
|
||||
#endif
|
||||
update_dark_children_ui(dlg);
|
||||
}
|
||||
|
||||
void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -3133,14 +3145,18 @@ void GUI_App::update_ui_from_settings()
|
|||
//UpdateDlgDarkUI(&mainframe->m_settings_dialog);
|
||||
//mainframe->m_settings_dialog.Refresh();
|
||||
//mainframe->m_settings_dialog.Update();
|
||||
|
||||
if (mainframe) {
|
||||
#ifdef __WINDOWS__
|
||||
mainframe->force_color_changed();
|
||||
update_scrolls(mainframe);
|
||||
update_scrolls(&mainframe->m_settings_dialog);
|
||||
mainframe->force_color_changed();
|
||||
update_scrolls(mainframe);
|
||||
update_scrolls(&mainframe->m_settings_dialog);
|
||||
#endif //_MSW_DARK_MODE
|
||||
update_dark_children_ui(mainframe);
|
||||
update_dark_children_ui(mainframe);
|
||||
}
|
||||
}
|
||||
mainframe->update_ui_from_settings();
|
||||
|
||||
if (mainframe) {mainframe->update_ui_from_settings();}
|
||||
}
|
||||
|
||||
void GUI_App::persist_window_geometry(wxTopLevelWindow *window, bool default_maximized)
|
||||
|
|
|
@ -326,6 +326,7 @@ public:
|
|||
void UpdateDarkUIWin(wxWindow* win);
|
||||
// update color mode for whole dialog including all children
|
||||
void UpdateDlgDarkUI(wxDialog* dlg);
|
||||
void UpdateFrameDarkUI(wxFrame* dlg);
|
||||
// update color mode for DataViewControl
|
||||
void UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited = false);
|
||||
// update color mode for panel including all static texts controls
|
||||
|
|
|
@ -268,6 +268,13 @@ void update_dark_ui(wxWindow* window)
|
|||
}
|
||||
#endif
|
||||
|
||||
void update_dark_config()
|
||||
{
|
||||
wxSystemAppearance app = wxSystemSettings::GetAppearance();
|
||||
GUI::wxGetApp().app_config->set("dark_color_mode", app.IsDark() ? "1" : "0");
|
||||
GUI::wxGetApp().app_config->save();
|
||||
}
|
||||
|
||||
|
||||
CheckboxFileDialog::ExtraPanel::ExtraPanel(wxWindow *parent)
|
||||
: wxPanel(parent, wxID_ANY)
|
||||
|
|
|
@ -82,6 +82,7 @@ wxFont get_default_font_for_dpi(const wxWindow* window, int dpi);
|
|||
inline wxFont get_default_font(const wxWindow* window) { return get_default_font_for_dpi(window, get_dpi_for_window(window)); }
|
||||
|
||||
bool check_dark_mode();
|
||||
void update_dark_config();
|
||||
#ifdef _WIN32
|
||||
void update_dark_ui(wxWindow* window);
|
||||
#endif
|
||||
|
@ -188,8 +189,9 @@ public:
|
|||
|
||||
this->Bind(wxEVT_SYS_COLOUR_CHANGED, [this](wxSysColourChangedEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
update_dark_config();
|
||||
on_sys_color_changed();
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
if (std::is_same<wxDialog, P>::value) {
|
||||
|
|
|
@ -1804,6 +1804,7 @@ void MainFrame::on_sys_color_changed()
|
|||
|
||||
// update Plater
|
||||
wxGetApp().plater()->sys_color_changed();
|
||||
m_monitor->on_sys_color_changed();
|
||||
|
||||
// update Tabs
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
|
|
|
@ -40,7 +40,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
b->SetTextColor(StateColor(
|
||||
std::make_pair(0x3B4446, (int) StateColor::Checked),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(0xACACAC, (int) StateColor::Normal)
|
||||
std::make_pair(0xABACAC, (int) StateColor::Normal)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,7 @@ namespace GUI {
|
|||
|
||||
void ModelMallDialog::on_show(wxShowEvent& event)
|
||||
{
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
if (event.IsShown()) {
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
|
|
@ -245,6 +245,11 @@ wxWindow* MonitorPanel::create_side_tools()
|
|||
return panel;
|
||||
}
|
||||
|
||||
void MonitorPanel::on_sys_color_changed()
|
||||
{
|
||||
m_status_info_panel->on_sys_color_changed();
|
||||
}
|
||||
|
||||
void MonitorPanel::msw_rescale()
|
||||
{
|
||||
init_bitmap();
|
||||
|
|
|
@ -130,7 +130,8 @@ public:
|
|||
void set_default();
|
||||
wxWindow* create_side_tools();
|
||||
|
||||
void msw_rescale();
|
||||
void on_sys_color_changed();
|
||||
void msw_rescale();
|
||||
|
||||
void select_machine(std::string machine_sn);
|
||||
void on_update_all(wxMouseEvent &event);
|
||||
|
|
|
@ -49,7 +49,6 @@ ButtonsListCtrl::ButtonsListCtrl(wxWindow *parent, wxBoxSizer* side_tools) :
|
|||
// BBS: disable custom paint
|
||||
//this->Bind(wxEVT_PAINT, &ButtonsListCtrl::OnPaint, this);
|
||||
Bind(wxEVT_SYS_COLOUR_CHANGED, [this](auto& e){
|
||||
auto a = 10;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ void ParamsDialog::Popup()
|
|||
#ifdef __WIN32__
|
||||
Reparent(wxGetApp().mainframe);
|
||||
#endif
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Center();
|
||||
Show();
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
|
|||
input_title->Wrap(-1);
|
||||
|
||||
auto input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, DESIGN_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled));
|
||||
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled), std::pair<wxColour, int>(*wxWHITE, StateColor::Enabled));
|
||||
input->SetBackgroundColor(input_bg);
|
||||
input->GetTextCtrl()->SetValue(app_config->get(param));
|
||||
|
||||
|
@ -840,8 +840,11 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
auto item_downloads = create_item_downloads(page,50,"download_path");
|
||||
|
||||
//dark mode
|
||||
#ifdef _WIN32
|
||||
auto title_darkmode = create_item_title(_L("Dark Mode"), page, _L("Dark Mode"));
|
||||
auto item_darkmode = create_item_darkmode_checkbox(_L("Enable Dark mode"), page,_L("Enable Dark mode"), 50, "dark_color_mode");
|
||||
#endif
|
||||
|
||||
|
||||
sizer_page->Add(title_general_settings, 0, wxEXPAND, 0);
|
||||
sizer_page->Add(item_language, 0, wxTOP, FromDIP(3));
|
||||
|
@ -863,8 +866,10 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
sizer_page->Add(title_downloads, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_downloads, 0, wxEXPAND, FromDIP(3));
|
||||
|
||||
#ifdef _WIN32
|
||||
sizer_page->Add(title_darkmode, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_darkmode, 0, wxEXPAND, FromDIP(3));
|
||||
#endif
|
||||
|
||||
|
||||
page->SetSizer(sizer_page);
|
||||
|
|
|
@ -437,6 +437,7 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, cons
|
|||
m_sizer_main->Fit(this);
|
||||
|
||||
CenterOnParent();
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
}
|
||||
|
||||
void SecondaryCheckDialog::update_text(wxString text)
|
||||
|
@ -470,6 +471,7 @@ void SecondaryCheckDialog::update_text(wxString text)
|
|||
|
||||
void SecondaryCheckDialog::on_show()
|
||||
{
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
// recover button color
|
||||
wxMouseEvent evt_ok(wxEVT_LEFT_UP);
|
||||
m_button_ok->GetEventHandler()->ProcessEvent(evt_ok);
|
||||
|
@ -477,7 +479,7 @@ void SecondaryCheckDialog::on_show()
|
|||
m_button_cancel->GetEventHandler()->ProcessEvent(evt_cancel);
|
||||
|
||||
this->Show();
|
||||
this->SetFocus();
|
||||
this->SetFocus();
|
||||
}
|
||||
|
||||
void SecondaryCheckDialog::on_hide()
|
||||
|
|
|
@ -38,7 +38,7 @@ static const wxColour BUTTON_NORMAL2_COL = wxColour(206, 206, 206);
|
|||
static const wxColour BUTTON_PRESS_COL = wxColour(172, 172, 172);
|
||||
static const wxColour BUTTON_HOVER_COL = wxColour(0, 174, 66);
|
||||
|
||||
static const wxColour DISCONNECT_TEXT_COL = wxColour(172, 172, 172);
|
||||
static const wxColour DISCONNECT_TEXT_COL = wxColour(171, 172, 172);
|
||||
static const wxColour NORMAL_TEXT_COL = wxColour(48,58,60);
|
||||
static const wxColour NORMAL_FAN_TEXT_COL = wxColour(107, 107, 107);
|
||||
static const wxColour WARNING_INFO_BG_COL = wxColour(255, 111, 0);
|
||||
|
@ -2770,6 +2770,13 @@ void StatusPanel::set_hold_count(int& count)
|
|||
count = COMMAND_TIMEOUT;
|
||||
}
|
||||
|
||||
void StatusPanel::on_sys_color_changed()
|
||||
{
|
||||
m_bitmap_speed.msw_rescale();
|
||||
m_bitmap_speed_active.msw_rescale();
|
||||
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
|
||||
}
|
||||
|
||||
void StatusPanel::msw_rescale()
|
||||
{
|
||||
init_bitmaps();
|
||||
|
@ -2817,6 +2824,9 @@ void StatusPanel::msw_rescale()
|
|||
m_tempCtrl_frame->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||
m_tempCtrl_frame->Rescale();
|
||||
|
||||
m_bitmap_speed.msw_rescale();
|
||||
m_bitmap_speed_active.msw_rescale();
|
||||
|
||||
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
|
||||
m_switch_speed->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_speed->Rescale();
|
||||
|
@ -2833,6 +2843,7 @@ void StatusPanel::msw_rescale()
|
|||
m_ams_control->msw_rescale();
|
||||
// m_filament_step->Rescale();
|
||||
|
||||
|
||||
m_calibration_btn->SetMinSize(wxSize(-1, FromDIP(26)));
|
||||
m_calibration_btn->Rescale();
|
||||
|
||||
|
|
|
@ -394,6 +394,7 @@ public:
|
|||
|
||||
void set_hold_count(int& count);
|
||||
|
||||
void on_sys_color_changed();
|
||||
void msw_rescale();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1849,6 +1849,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
|
|||
|
||||
void AMSControl::msw_rescale()
|
||||
{
|
||||
m_button_ams_setting_normal.msw_rescale();
|
||||
m_button_ams_setting_hover.msw_rescale();
|
||||
m_button_ams_setting_press.msw_rescale();
|
||||
m_extruder->msw_rescale();
|
||||
m_button_extruder_back->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
m_button_extruder_feed->SetMinSize(wxSize(-1, FromDIP(24)));
|
||||
|
|
|
@ -35,6 +35,8 @@ static std::map<wxColour, wxColour> gDarkColors{
|
|||
{"#F0F0F1", "#404040"},
|
||||
{"#9E9E9E", "#53545A"},
|
||||
{"#D7E8DE", "#1F2B27"},
|
||||
{"#2B3436", "#808080"},
|
||||
{"#ABABAB", "#ABABAB"},
|
||||
//{"#F0F0F0", "#3E3E44"},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue