mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-04 04:24:04 -06:00
ENH:displays the publish button based on user permissions
Change-Id: I853506fa61f1f8cf14dfeb4601c8bb5f1a0c5914
This commit is contained in:
parent
d1021e6861
commit
72b4827f85
10 changed files with 93 additions and 20 deletions
|
@ -251,10 +251,11 @@ void BBLTopbar::Init(wxFrame* parent)
|
|||
this->AddStretchSpacer(1);
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
wxBitmap m_publish_bitmap = create_scaled_bitmap("topbar_publish", nullptr, TOPBAR_ICON_SIZE);
|
||||
m_publish_item = this->AddTool(ID_PUBLISH, "", m_publish_bitmap);
|
||||
wxBitmap m_publish_disable_bitmap = create_scaled_bitmap("topbar_publish_disable", nullptr, TOPBAR_ICON_SIZE);
|
||||
m_publish_bitmap = create_scaled_bitmap("topbar_publish", nullptr, TOPBAR_ICON_SIZE);
|
||||
m_publish_item = this->AddTool(ID_PUBLISH, "", m_publish_bitmap);
|
||||
m_publish_disable_bitmap = create_scaled_bitmap("topbar_publish_disable", nullptr, TOPBAR_ICON_SIZE);
|
||||
m_publish_item->SetDisabledBitmap(m_publish_disable_bitmap);
|
||||
this->EnableTool(m_publish_item->GetId(), false);
|
||||
this->AddSpacer(FromDIP(12));
|
||||
#endif
|
||||
|
||||
|
@ -320,6 +321,12 @@ BBLTopbar::~BBLTopbar()
|
|||
m_file_menu = nullptr;
|
||||
}
|
||||
|
||||
void BBLTopbar::show_publish_button(bool show)
|
||||
{
|
||||
this->EnableTool(m_publish_item->GetId(), show);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void BBLTopbar::OnOpenProject(wxAuiToolBarEvent& event)
|
||||
{
|
||||
MainFrame* main_frame = dynamic_cast<MainFrame*>(m_frame);
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
BBLTopbar(wxFrame* parent);
|
||||
void Init(wxFrame *parent);
|
||||
~BBLTopbar();
|
||||
void show_publish_button(bool show);
|
||||
void UpdateToolbarWidth(int width);
|
||||
void Rescale();
|
||||
void OnIconize(wxAuiToolBarEvent& event);
|
||||
|
@ -68,6 +69,9 @@ private:
|
|||
wxAuiToolBarItem* m_redo_item;
|
||||
wxAuiToolBarItem* maximize_btn;
|
||||
|
||||
wxBitmap m_publish_bitmap;
|
||||
wxBitmap m_publish_disable_bitmap;
|
||||
|
||||
wxBitmap maximize_bitmap;
|
||||
wxBitmap window_bitmap;
|
||||
|
||||
|
|
|
@ -3200,6 +3200,12 @@ void GUI_App::request_user_logout()
|
|||
GUI::wxGetApp().sidebar().load_ams_list({});
|
||||
GUI::wxGetApp().remove_user_presets();
|
||||
GUI::wxGetApp().stop_sync_user_preset();
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
wxGetApp().mainframe->topbar()->show_publish_button(false);
|
||||
#else
|
||||
wxGetApp().mainframe->show_publish_button(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3529,6 +3535,21 @@ void GUI_App::on_user_login(wxCommandEvent &evt)
|
|||
GUI::wxGetApp().preset_bundle->update_user_presets_directory(user_id);
|
||||
if (online_login)
|
||||
GUI::wxGetApp().mainframe->show_sync_dialog();
|
||||
|
||||
//show publish button
|
||||
if (m_agent->is_user_login() && mainframe) {
|
||||
int identifier;
|
||||
int result = m_agent->get_user_info(&identifier);
|
||||
auto publish_identifier = identifier & 1;
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
if (result == 0 && publish_identifier >= 0) {
|
||||
mainframe->m_topbar->show_publish_button(publish_identifier == 0 ? false : true);
|
||||
}
|
||||
#else
|
||||
mainframe->show_publish_button(publish_identifier == 0 ? false : true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool GUI_App::is_studio_active()
|
||||
|
|
|
@ -2150,7 +2150,7 @@ void MainFrame::init_menubar_as_editor()
|
|||
// BBS
|
||||
|
||||
//publish menu
|
||||
wxMenu* publishMenu = nullptr;
|
||||
|
||||
if (m_plater) {
|
||||
publishMenu = new wxMenu();
|
||||
add_common_publish_menu_items(publishMenu, this);
|
||||
|
@ -2364,11 +2364,19 @@ void MainFrame::init_menubar_as_editor()
|
|||
m_menubar->Append(editMenu, wxString::Format("&%s", _L("Edit")));
|
||||
if (viewMenu)
|
||||
m_menubar->Append(viewMenu, wxString::Format("&%s", _L("View")));
|
||||
if (publishMenu)
|
||||
m_menubar->Append(publishMenu, wxString::Format("&%s", _L("3D Models")));
|
||||
/*if (publishMenu)
|
||||
m_menubar->Append(publishMenu, wxString::Format("&%s", _L("3D Models")));*/
|
||||
if (helpMenu)
|
||||
m_menubar->Append(helpMenu, wxString::Format("&%s", _L("Help")));
|
||||
SetMenuBar(m_menubar);
|
||||
|
||||
if (wxGetApp().getAgent()->is_user_login()) {
|
||||
int identifier;
|
||||
int result = wxGetApp().getAgent()->get_user_info(&identifier);
|
||||
auto publish_identifier = identifier & 1;
|
||||
show_publish_button(publish_identifier == 0 ? false : true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
|
@ -2388,6 +2396,18 @@ void MainFrame::init_menubar_as_editor()
|
|||
#endif // __APPLE__
|
||||
}
|
||||
|
||||
void MainFrame::show_publish_button(bool show)
|
||||
{
|
||||
if (!m_menubar) return;
|
||||
|
||||
if (show){
|
||||
m_menubar->Insert(4, publishMenu, wxString::Format("&%s", _L("3D Models")));
|
||||
}
|
||||
else {
|
||||
m_menubar->Remove(4);
|
||||
}
|
||||
}
|
||||
|
||||
void MainFrame::open_menubar_item(const wxString& menu_name,const wxString& item_name)
|
||||
{
|
||||
if (m_menubar == nullptr)
|
||||
|
|
|
@ -89,7 +89,9 @@ class MainFrame : public DPIFrame
|
|||
wxString m_qs_last_input_file = wxEmptyString;
|
||||
wxString m_qs_last_output_file = wxEmptyString;
|
||||
wxString m_last_config = wxEmptyString;
|
||||
|
||||
wxMenuBar* m_menubar{ nullptr };
|
||||
wxMenu* publishMenu{ nullptr };
|
||||
|
||||
#if 0
|
||||
wxMenuItem* m_menu_item_repeat { nullptr }; // doesn't used now
|
||||
|
@ -234,6 +236,7 @@ public:
|
|||
BBLTopbar* topbar() { return m_topbar; }
|
||||
|
||||
void update_title();
|
||||
void show_publish_button(bool show);
|
||||
|
||||
void update_title_colour_after_set_title();
|
||||
void show_option(bool show);
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
ModelMallDialog::ModelMallDialog(Plater* plater /*= nullptr*/)
|
||||
:DPIDialog(static_cast<wxWindow*>(nullptr), wxID_ANY, _L("3D Models"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxDIALOG_NO_PARENT|wxMINIMIZE_BOX)
|
||||
:DPIDialog(static_cast<wxWindow*>(nullptr), wxID_ANY, _L("3D Models"), wxDefaultPosition, wxDefaultSize, wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER)
|
||||
{
|
||||
// icon
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
SetSize(MODEL_MALL_PAGE_SIZE);
|
||||
SetMaxSize(MODEL_MALL_PAGE_SIZE);
|
||||
SetMinSize(MODEL_MALL_PAGE_SIZE);
|
||||
SetMinSize(wxSize(MODEL_MALL_PAGE_SIZE.x / 4, MODEL_MALL_PAGE_SIZE.y / 4));
|
||||
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
@ -33,8 +32,7 @@ namespace GUI {
|
|||
m_web_control_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, MODEL_MALL_PAGE_CONTROL_SIZE, wxTAB_TRAVERSAL);
|
||||
m_web_control_panel->SetBackgroundColour(*wxWHITE);
|
||||
m_web_control_panel->SetSize(MODEL_MALL_PAGE_CONTROL_SIZE);
|
||||
m_web_control_panel->SetMaxSize(MODEL_MALL_PAGE_CONTROL_SIZE);
|
||||
m_web_control_panel->SetMinSize(MODEL_MALL_PAGE_CONTROL_SIZE);
|
||||
|
||||
|
||||
wxBoxSizer* m_sizer_web_control = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
|
@ -100,12 +98,10 @@ namespace GUI {
|
|||
|
||||
m_browser->SetSize(MODEL_MALL_PAGE_WEB_SIZE);
|
||||
m_browser->SetMinSize(MODEL_MALL_PAGE_WEB_SIZE);
|
||||
m_browser->SetMaxSize(MODEL_MALL_PAGE_WEB_SIZE);
|
||||
|
||||
m_browser->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ModelMallDialog::OnScriptMessage, this, m_browser->GetId());
|
||||
|
||||
m_sizer_main->Add(m_web_control_panel, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(m_browser, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(m_browser, 1, wxEXPAND, 0);
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
#include "Widgets/Button.hpp"
|
||||
|
||||
|
||||
#define MODEL_MALL_PAGE_SIZE wxSize(FromDIP(1400 * 0.75), FromDIP(1040 * 0.75))
|
||||
#define MODEL_MALL_PAGE_CONTROL_SIZE wxSize(FromDIP(1400 * 0.75), FromDIP(40 * 0.75))
|
||||
#define MODEL_MALL_PAGE_WEB_SIZE wxSize(FromDIP(1400 * 0.75), FromDIP(1000 * 0.75))
|
||||
#define MODEL_MALL_PAGE_SIZE wxSize(FromDIP(1400 * 0.8), FromDIP(1040 * 0.8))
|
||||
#define MODEL_MALL_PAGE_CONTROL_SIZE wxSize(FromDIP(1400 * 0.8), FromDIP(40 * 0.8))
|
||||
#define MODEL_MALL_PAGE_WEB_SIZE wxSize(FromDIP(1400 * 0.8), FromDIP(1000 * 0.8))
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue