Skip to content

Commit

Permalink
ENH: add publish to makerworld menuitem and remove the original button
Browse files Browse the repository at this point in the history
jira: new

Change-Id: I253018cf93d8379de1eaff146420103c0d876e16
  • Loading branch information
LiZ-Li-BBL authored and lanewei120 committed Oct 15, 2024
1 parent e3b774c commit 5dbc617
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 37 deletions.
2 changes: 0 additions & 2 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3212,8 +3212,6 @@ void GUI_App::update_label_colours_from_appconfig()

void GUI_App::update_publish_status()
{
mainframe->show_publish_button(has_model_mall());

mainframe->m_webview->ResetWholePage();
}

Expand Down
54 changes: 21 additions & 33 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,12 +951,6 @@ void MainFrame::update_title()
return;
}

void MainFrame::show_publish_button(bool show)
{
m_publish_btn->Show(show);
Layout();
}

void MainFrame::show_calibration_button(bool show)
{
#ifdef __APPLE__
Expand Down Expand Up @@ -1562,17 +1556,14 @@ wxBoxSizer* MainFrame::create_side_tools()
m_slice_select = eSlicePlate;
m_print_select = ePrintPlate;

m_publish_btn = new Button(this, _L("Upload"), "bar_publish", 0, FromDIP(16));
m_slice_btn = new SideButton(this, _L("Slice plate"), "");
m_slice_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14));
m_print_btn = new SideButton(this, _L("Print plate"), "");
m_print_option_btn = new SideButton(this, "", "sidebutton_dropdown", 0, FromDIP(14));

update_side_button_style();
m_publish_btn->Hide();
m_slice_option_btn->Enable();
m_print_option_btn->Enable();
sizer->Add(m_publish_btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
sizer->Add(FromDIP(15), 0, 0, 0, 0);
sizer->Add(m_slice_option_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
sizer->Add(m_slice_btn, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(1));
Expand All @@ -1583,23 +1574,6 @@ wxBoxSizer* MainFrame::create_side_tools()

sizer->Layout();

m_publish_btn->Bind(wxEVT_BUTTON, [this](auto& e) {
CallAfter([this] {
wxGetApp().open_publish_page_dialog();

if (!wxGetApp().getAgent()) {
BOOST_LOG_TRIVIAL(info) << "publish: no agent";
return;
}

// record
json j;
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent)
agent->track_event("enter_model_mall", j.dump());
});
});

m_slice_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
{
//this->m_plater->select_view_3D("Preview");
Expand Down Expand Up @@ -1989,13 +1963,6 @@ void MainFrame::update_side_button_style()
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal)
);

m_publish_btn->SetMinSize(wxSize(FromDIP(125), FromDIP(24)));
m_publish_btn->SetCornerRadius(FromDIP(12));
m_publish_btn->SetBackgroundColor(m_btn_bg_enable);
m_publish_btn->SetBorderColor(m_btn_bg_enable);
m_publish_btn->SetBackgroundColour(wxColour(59,68,70));
m_publish_btn->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));

m_slice_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Left, FromDIP(15));
m_slice_btn->SetCornerRadius(FromDIP(12));
m_slice_btn->SetExtraSize(wxSize(FromDIP(38), FromDIP(10)));
Expand Down Expand Up @@ -2419,6 +2386,27 @@ void MainFrame::init_menubar_as_editor()

append_submenu(fileMenu, export_menu, wxID_ANY, _L("Export"), "");

// Publish to MakerWorld
append_menu_item(
fileMenu, wxID_ANY, _L("Publish to MakerWorld"), _L("Publish to MakerWorld"),
[this](wxCommandEvent &) {
CallAfter([this] {
wxGetApp().open_publish_page_dialog();

if (!wxGetApp().getAgent()) {
BOOST_LOG_TRIVIAL(info) << "publish: no agent";
return;
}

// record
json j;
NetworkAgent *agent = GUI::wxGetApp().getAgent();
if (agent) agent->track_event("enter_model_mall", j.dump());
});
},
"", nullptr,
[this](){ return wxGetApp().has_model_mall(); }, this);

fileMenu->AppendSeparator();

#ifndef __APPLE__
Expand Down
2 changes: 0 additions & 2 deletions src/slic3r/GUI/MainFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ class MainFrame : public DPIFrame
void update_title();
void set_max_recent_count(int max);

void show_publish_button(bool show);
void show_calibration_button(bool show);

void update_title_colour_after_set_title();
Expand Down Expand Up @@ -385,7 +384,6 @@ class MainFrame : public DPIFrame
// BBS
mutable int m_print_select{ ePrintAll };
mutable int m_slice_select{ eSliceAll };
Button* m_publish_btn{ nullptr };
SideButton* m_slice_btn{ nullptr };
SideButton* m_slice_option_btn{ nullptr };
SideButton* m_print_btn{ nullptr };
Expand Down

0 comments on commit 5dbc617

Please sign in to comment.