mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 15:51:10 -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 {
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ func_check_user_task_report NetworkAgent::check_user_task_report_ptr = n
|
|||
func_get_user_print_info NetworkAgent::get_user_print_info_ptr = nullptr;
|
||||
func_get_printer_firmware NetworkAgent::get_printer_firmware_ptr = nullptr;
|
||||
func_get_task_plate_index NetworkAgent::get_task_plate_index_ptr = nullptr;
|
||||
func_get_user_info NetworkAgent::get_user_info_ptr = nullptr;
|
||||
func_get_slice_info NetworkAgent::get_slice_info_ptr = nullptr;
|
||||
func_query_bind_status NetworkAgent::query_bind_status_ptr = nullptr;
|
||||
func_modify_printer_name NetworkAgent::modify_printer_name_ptr = nullptr;
|
||||
|
@ -226,6 +227,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
get_user_print_info_ptr = reinterpret_cast<func_get_user_print_info>(get_network_function("bambu_network_get_user_print_info"));
|
||||
get_printer_firmware_ptr = reinterpret_cast<func_get_printer_firmware>(get_network_function("bambu_network_get_printer_firmware"));
|
||||
get_task_plate_index_ptr = reinterpret_cast<func_get_task_plate_index>(get_network_function("bambu_network_get_task_plate_index"));
|
||||
get_user_info_ptr = reinterpret_cast<func_get_user_info>(get_network_function("bambu_network_get_user_info"));
|
||||
get_slice_info_ptr = reinterpret_cast<func_get_slice_info>(get_network_function("bambu_network_get_slice_info"));
|
||||
query_bind_status_ptr = reinterpret_cast<func_query_bind_status>(get_network_function("bambu_network_query_bind_status"));
|
||||
modify_printer_name_ptr = reinterpret_cast<func_modify_printer_name>(get_network_function("bambu_network_modify_printer_name"));
|
||||
|
@ -320,6 +322,7 @@ int NetworkAgent::unload_network_module()
|
|||
get_user_print_info_ptr = nullptr;
|
||||
get_printer_firmware_ptr = nullptr;
|
||||
get_task_plate_index_ptr = nullptr;
|
||||
get_user_info_ptr = nullptr;
|
||||
get_slice_info_ptr = nullptr;
|
||||
query_bind_status_ptr = nullptr;
|
||||
modify_printer_name_ptr = nullptr;
|
||||
|
@ -1002,6 +1005,17 @@ int NetworkAgent::get_task_plate_index(std::string task_id, int* plate_index)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_user_info(int* identifier)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && get_user_info_ptr) {
|
||||
ret = get_user_info_ptr(network_agent, identifier);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::get_slice_info(std::string project_id, std::string profile_id, int plate_index, std::string* slice_json)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -66,6 +66,7 @@ typedef int (*func_check_user_task_report)(void *agent, int* task_id, bool* prin
|
|||
typedef int (*func_get_user_print_info)(void *agent, unsigned int* http_code, std::string* http_body);
|
||||
typedef int (*func_get_printer_firmware)(void *agent, std::string dev_id, unsigned* http_code, std::string* http_body);
|
||||
typedef int (*func_get_task_plate_index)(void *agent, std::string task_id, int* plate_index);
|
||||
typedef int (*func_get_user_info)(void *agent, int* identifier);
|
||||
typedef int (*func_get_slice_info)(void *agent, std::string project_id, std::string profile_id, int plate_index, std::string* slice_json);
|
||||
typedef int (*func_query_bind_status)(void *agent, std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
|
||||
typedef int (*func_modify_printer_name)(void *agent, std::string dev_id, std::string dev_name);
|
||||
|
@ -148,6 +149,7 @@ public:
|
|||
int get_user_print_info(unsigned int* http_code, std::string* http_body);
|
||||
int get_printer_firmware(std::string dev_id, unsigned* http_code, std::string* http_body);
|
||||
int get_task_plate_index(std::string task_id, int* plate_index);
|
||||
int get_user_info(int* identifier);
|
||||
int get_slice_info(std::string project_id, std::string profile_id, int plate_index, std::string* slice_json);
|
||||
int query_bind_status(std::vector<std::string> query_list, unsigned int* http_code, std::string* http_body);
|
||||
int modify_printer_name(std::string dev_id, std::string dev_name);
|
||||
|
@ -220,6 +222,7 @@ private:
|
|||
static func_get_user_print_info get_user_print_info_ptr;
|
||||
static func_get_printer_firmware get_printer_firmware_ptr;
|
||||
static func_get_task_plate_index get_task_plate_index_ptr;
|
||||
static func_get_user_info get_user_info_ptr;
|
||||
static func_get_slice_info get_slice_info_ptr;
|
||||
static func_query_bind_status query_bind_status_ptr;
|
||||
static func_modify_printer_name modify_printer_name_ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue