Create Printables tab

This commit is contained in:
David Kocik 2024-08-20 12:24:07 +02:00 committed by Lukas Matena
parent da79ad4937
commit e8de4b7199
3 changed files with 42 additions and 4 deletions

View File

@ -803,6 +803,7 @@ void MainFrame::create_preset_tabs()
m_connect_webview = new ConnectWebViewPanel(m_tabpanel);
m_printer_webview = new PrinterWebViewPanel(m_tabpanel, L"");
m_printables_webview = new WebViewPanel(m_tabpanel, GUI::from_u8("https://www.printables.com"), { "_prusaSlicer" });
// new created tabs have to be hidden by default
m_connect_webview->Hide();
m_printer_webview->Hide();
@ -849,6 +850,33 @@ void MainFrame::show_connect_tab(const wxString& url)
m_connect_webview->load_url(url);
}
void MainFrame::add_printables_webview_tab()
{
if (m_printables_webview_added) {
return;
}
int n = m_tabpanel->FindPage(m_connect_webview) + 1;
wxWindow* page = m_printables_webview;
const wxString text(L"Printables");
const std::string bmp_name = "";
bool bSelect = false;
m_tabpanel->InsertNewPage(n, page, text, bmp_name, bSelect);
m_printables_webview->load_default_url_delayed();
m_printables_webview_added = true;
}
void MainFrame::remove_printables_webview_tab()
{
if (!m_printables_webview_added) {
return;
}
int n = m_tabpanel->FindPage(m_printables_webview);
if (m_tabpanel->GetSelection() == n)
m_tabpanel->SetSelection(0);
m_tabpanel->RemovePage(size_t(n));
m_printables_webview_added = false;
}
void MainFrame::show_printer_webview_tab(DynamicPrintConfig* dpc)
{
// if physical printer is selected

View File

@ -47,6 +47,7 @@ class PreferencesDialog;
class GalleryDialog;
class ConnectWebViewPanel;
class PrinterWebViewPanel;
class WebViewPanel;
enum QuickSlice
{
@ -98,10 +99,12 @@ class MainFrame : public DPIFrame
size_t m_last_selected_tab;
Search::OptionsSearcher m_searcher;
ConnectWebViewPanel* m_connect_webview{ nullptr };
bool m_connect_webview_added{ false };
PrinterWebViewPanel* m_printer_webview{ nullptr };
bool m_printer_webview_added{ false };
ConnectWebViewPanel* m_connect_webview{ nullptr };
bool m_connect_webview_added{ false };
WebViewPanel* m_printables_webview{ nullptr };
bool m_printables_webview_added{ false };
PrinterWebViewPanel* m_printer_webview{ nullptr };
bool m_printer_webview_added{ false };
std::string get_base_name(const wxString &full_name, const char *extension = nullptr) const;
std::string get_dir_name(const wxString &full_name) const;
@ -218,6 +221,9 @@ public:
void remove_connect_webview_tab();
void show_connect_tab(const wxString &url);
void add_printables_webview_tab();
void remove_printables_webview_tab();
void show_printer_webview_tab(DynamicPrintConfig* dpc);
void add_printer_webview_tab(const wxString& url);

View File

@ -921,6 +921,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->notification_manager->close_notification_of_type(NotificationType::UserAccountID);
this->notification_manager->push_notification(NotificationType::UserAccountID, NotificationManager::NotificationLevel::ImportantNotificationLevel, text);
this->main_frame->remove_connect_webview_tab();
this->main_frame->remove_printables_webview_tab();
this->main_frame->refresh_account_menu(true);
// Update sidebar printer status
sidebar->update_printer_presets_combobox();
@ -946,6 +947,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->notification_manager->push_notification(NotificationType::UserAccountID, NotificationManager::NotificationLevel::ImportantNotificationLevel, text);
}
this->main_frame->add_connect_webview_tab();
this->main_frame->add_printables_webview_tab();
// Update User name in TopBar
this->main_frame->refresh_account_menu();
wxGetApp().update_wizard_login_page();
@ -959,6 +961,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->notification_manager->close_notification_of_type(NotificationType::UserAccountID);
this->notification_manager->push_notification(NotificationType::UserAccountID, NotificationManager::NotificationLevel::WarningNotificationLevel, _u8L("Failed to connect to Prusa Account."));
this->main_frame->remove_connect_webview_tab();
this->main_frame->remove_printables_webview_tab();
// Update User name in TopBar
this->main_frame->refresh_account_menu(true);
// Update sidebar printer status
@ -972,6 +975,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->notification_manager->close_notification_of_type(NotificationType::UserAccountID);
this->notification_manager->push_notification(NotificationType::UserAccountID, NotificationManager::NotificationLevel::WarningNotificationLevel, _u8L("Failed to connect to Prusa Account."));
this->main_frame->remove_connect_webview_tab();
this->main_frame->remove_printables_webview_tab();
// Update User name in TopBar
this->main_frame->refresh_account_menu(true);
// Update sidebar printer status