Files
QIDISlicer/src/slic3r/GUI/PrinterWebView.hpp

162 lines
4.9 KiB
C++
Raw Normal View History

2023-06-10 10:14:12 +08:00
#ifndef slic3r_PrinterWebView_hpp_
#define slic3r_PrinterWebView_hpp_
#include "wx/artprov.h"
#include "wx/cmdline.h"
#include "wx/notifmsg.h"
#include "wx/settings.h"
#include "wx/webview.h"
#if wxUSE_WEBVIEW_EDGE
#include "wx/msw/webview_edge.h"
#endif
#include "wx/webviewarchivehandler.h"
#include "wx/webviewfshandler.h"
#include "wx/numdlg.h"
#include "wx/infobar.h"
#include "wx/filesys.h"
#include "wx/fs_arc.h"
#include "wx/fs_mem.h"
#include "wx/stdpaths.h"
#include <wx/panel.h>
#include <wx/tbarbase.h>
#include "wx/textctrl.h"
#include <wx/timer.h>
2023-09-11 11:10:12 +08:00
//B35
//B45
2023-09-11 11:10:12 +08:00
#if defined __linux__
#include <boost/log/trivial.hpp>
#include <wx/wx.h>
#include <thread>
#include <boost/format.hpp>
2023-09-11 11:10:12 +08:00
#endif
2023-11-27 11:29:19 +08:00
//B45
#include "PrintHostDialogs.hpp"
#include <wx/tokenzr.h>
2023-06-10 10:14:12 +08:00
2024-07-26 14:02:02 +08:00
//B64
2024-07-29 18:44:06 +08:00
#if QDT_RELEASE_TO_PUBLIC
2024-07-29 11:09:50 +08:00
#include "../QIDI/QIDINetwork.hpp"
2024-07-29 18:44:06 +08:00
#endif
2024-07-26 14:02:02 +08:00
#include <boost/thread.hpp>
#include "./Widgets/SwitchButton.hpp"
#include "./Widgets/DeviceButton.hpp"
2023-06-10 10:14:12 +08:00
namespace Slic3r {
namespace GUI {
2023-11-27 11:29:19 +08:00
2023-06-10 10:14:12 +08:00
class PrinterWebView : public wxPanel {
public:
PrinterWebView(wxWindow *parent);
virtual ~PrinterWebView();
2024-07-26 14:02:02 +08:00
wxBoxSizer *init_menu_bar(wxPanel *Panel);
wxBoxSizer *init_login_bar(wxPanel *Panel);
void init_scroll_window(wxPanel *Panel);
void CreatThread();
2023-06-10 10:14:12 +08:00
void load_url(wxString& url);
2024-07-26 14:02:02 +08:00
void load_net_url(std::string url, std::string ip);
2023-06-10 10:14:12 +08:00
void UpdateState();
void OnClose(wxCloseEvent& evt);
2024-07-26 14:02:02 +08:00
void OnZoomButtonClick(wxCommandEvent &event);
void OnRefreshButtonClick(wxCommandEvent &event);
2023-12-04 14:10:31 +08:00
void OnAddButtonClick(wxCommandEvent &event);
void OnDeleteButtonClick(wxCommandEvent &event);
void OnEditButtonClick(wxCommandEvent &event);
2023-11-27 11:29:19 +08:00
2024-07-26 14:02:02 +08:00
void OnLoginButtonClick(wxCommandEvent &event);
2023-11-27 11:29:19 +08:00
void RunScript(const wxString &javascript);
//void OnScriptMessageReceived(wxWebViewEvent &event);
void OnScriptMessage(wxWebViewEvent &evt);
void UpdateLayout();
void OnScroll(wxScrollWinEvent &event);
void OnScrollup(wxScrollWinEvent &event);
void OnScrolldown(wxScrollWinEvent &event);
//void SendRecentList(int images);
2024-07-26 14:02:02 +08:00
void SetButtons(std::vector<DeviceButton *> buttons);
void AddButton(const wxString & device_name,
const wxString & ip,
const wxString & machine_type,
const wxString & fullname,
bool isSelected,
2024-07-26 14:02:02 +08:00
bool isQIDI);
2023-11-27 11:29:19 +08:00
void DeleteButton();
2023-12-04 14:10:31 +08:00
void UnSelectedButton();
2024-07-26 14:02:02 +08:00
void ShowNetPrinterButton();
void ShowLocalPrinterButton();
#if QDT_RELEASE_TO_PUBLIC
void AddNetButton(const Device device);
#endif
2023-12-04 14:10:31 +08:00
2024-07-26 14:02:02 +08:00
void DeleteNetButton();
void RefreshButton();
2024-07-26 14:02:02 +08:00
void SetUpdateHandler(const std::function<void(wxCommandEvent &)> &handler) { m_handlerl = handler; }
void StopStatusThread()
{
m_stopThread = true;
if (m_statusThread.joinable()) {
m_statusThread.join();
}
};
void SetPauseThread(bool status) { m_pauseThread = status; };
void SetPresetChanged(bool status);
void SetLoginStatus(bool status);
std::vector<DeviceButton *> GetButton() { return m_buttons; };
bool GetNetMode() { return m_isNetMode; };
std::vector<DeviceButton *> GetNetButton() { return m_net_buttons; };
2023-11-27 11:29:19 +08:00
2023-06-10 10:14:12 +08:00
private:
2023-12-04 14:10:31 +08:00
wxBoxSizer *leftallsizer;
2024-07-26 14:02:02 +08:00
wxBoxSizer * devicesizer;
wxBoxSizer * allsizer;
2023-11-27 11:29:19 +08:00
bool m_isSimpleMode = false;
2024-07-26 14:02:02 +08:00
bool m_isNetMode = false;
2023-11-27 11:29:19 +08:00
wxButton *arrow_button;
wxStaticText * text_static;
2023-11-27 11:29:19 +08:00
int height = 0;
wxString m_web;
2023-12-04 14:10:31 +08:00
std::function<void(wxCommandEvent &)> m_handlerl;
std::function<void(wxCommandEvent &)> m_delete_handlerl;
2023-11-27 11:29:19 +08:00
wxScrolledWindow * leftScrolledWindow;
2023-12-04 14:10:31 +08:00
wxPanel * leftPanel;
2023-11-27 11:29:19 +08:00
2024-07-26 14:02:02 +08:00
std::vector<DeviceButton *> m_buttons;
std::vector<DeviceButton *> m_net_buttons;
std::string m_select_type;
std::thread m_statusThread;
std::atomic<bool> m_stopThread{false};
std::atomic<bool> m_pauseThread{true};
2023-06-10 10:14:12 +08:00
wxWebView* m_browser;
long m_zoomFactor;
2024-07-26 14:02:02 +08:00
DeviceButton * add_button;
DeviceButton * delete_button;
DeviceButton * edit_button;
DeviceButton * refresh_button;
DeviceButton * login_button;
bool m_isloginin;
SwitchButton * toggleBar;
wxStaticBitmap * staticBitmap;
2023-06-10 10:14:12 +08:00
};
2023-12-04 14:10:31 +08:00
2023-06-10 10:14:12 +08:00
} // GUI
} // Slic3r
#endif /* slic3r_Tab_hpp_ */