mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-21 20:18:17 +08:00
Docker icon on OSX
This commit is contained in:
parent
48e5f53663
commit
e407b79c94
@ -55,7 +55,6 @@
|
|||||||
#define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1)
|
#define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1)
|
||||||
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
||||||
#define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER)
|
||||||
#define ENABLE_GCODE_VIEWER_TASKBAR_ICON (0 && ENABLE_GCODE_VIEWER)
|
|
||||||
#define ENABLE_GCODE_APP_CONFIG (1 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_APP_CONFIG (1 && ENABLE_GCODE_VIEWER)
|
||||||
#define ENABLE_GCODE_DRAG_AND_DROP_GCODE_FILES (1 && ENABLE_GCODE_VIEWER)
|
#define ENABLE_GCODE_DRAG_AND_DROP_GCODE_FILES (1 && ENABLE_GCODE_VIEWER)
|
||||||
|
|
||||||
|
@ -49,6 +49,35 @@ enum class ERescaleTarget
|
|||||||
SettingsDialog
|
SettingsDialog
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
class PrusaSlicerTaskBarIcon : public wxTaskBarIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrusaSlicerTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE) : wxTaskBarIcon(iconType) {}
|
||||||
|
void OnLeftButtonDClick(wxTaskBarIconEvent&) { wxMessageBox("Doubleclick on docker icon"); }
|
||||||
|
wxMenu *CreatePopupMenu() override {
|
||||||
|
wxMenu *menu = new wxMenu;
|
||||||
|
int id;
|
||||||
|
auto *item = menu->Append(id = wxNewId(), "&Test menu");
|
||||||
|
menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) { wxMessageBox("Test menu"); }, id);
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
class GCodeViewerTaskBarIcon : public wxTaskBarIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GCodeViewerTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE) : wxTaskBarIcon(iconType) {}
|
||||||
|
void OnLeftButtonDClick(wxTaskBarIconEvent&) { wxMessageBox("Doubleclick on docker icon"); }
|
||||||
|
wxMenu *CreatePopupMenu() override {
|
||||||
|
wxMenu *menu = new wxMenu;
|
||||||
|
int id;
|
||||||
|
auto *item = menu->Append(id = wxNewId(), "&Test menu");
|
||||||
|
menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) { wxMessageBox("Test menu"); }, id);
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
MainFrame::MainFrame() :
|
MainFrame::MainFrame() :
|
||||||
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"),
|
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"),
|
||||||
m_printhost_queue_dlg(new PrintHostQueueDialog(this))
|
m_printhost_queue_dlg(new PrintHostQueueDialog(this))
|
||||||
@ -64,27 +93,20 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
// Font is already set in DPIFrame constructor
|
// Font is already set in DPIFrame constructor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#ifdef __APPLE__
|
||||||
if (wxTaskBarIcon::IsAvailable()) {
|
// Initialize the docker task bar icon.
|
||||||
#if defined(__WXOSX__) && wxOSX_USE_COCOA
|
switch (wxGetApp().get_app_mode()) {
|
||||||
m_taskbar_icon = new wxTaskBarIcon(wxTBI_DOCK);
|
default:
|
||||||
#else
|
case GUI_App::EAppMode::Editor:
|
||||||
m_taskbar_icon = new wxTaskBarIcon();
|
m_taskbar_icon = std::make_unique<PrusaSlicerTaskBarIcon>(wxTBI_DOCK);
|
||||||
#endif
|
|
||||||
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer");
|
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer");
|
||||||
|
break;
|
||||||
m_taskbar_icon->Bind(wxEVT_TASKBAR_CLICK, [this](wxTaskBarIconEvent& evt) {
|
case GUI_App::EAppMode::GCodeViewer:
|
||||||
wxString msg = _L("You pressed the icon in taskbar for ") + "\n";
|
m_taskbar_icon = std::make_unique<GCodeViewerTaskBarIcon>(wxTBI_DOCK);
|
||||||
if (m_mode == EMode::Editor)
|
m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicerGCodeViewer_128px.png"), wxBITMAP_TYPE_PNG), "G-code Viewer");
|
||||||
msg += wxString(SLIC3R_APP_NAME);
|
break;
|
||||||
else
|
|
||||||
msg += wxString(SLIC3R_APP_NAME) + "-GCode viewer";
|
|
||||||
|
|
||||||
wxMessageDialog dialog(nullptr, msg, _("Taskbar icon clicked"), wxOK);
|
|
||||||
dialog.ShowModal();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#endif // __APPLE__
|
||||||
|
|
||||||
// Load the icon either from the exe, or from the ico file.
|
// Load the icon either from the exe, or from the ico file.
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
@ -288,13 +310,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
|
||||||
MainFrame::~MainFrame()
|
|
||||||
{
|
|
||||||
delete m_taskbar_icon;
|
|
||||||
}
|
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
|
||||||
|
|
||||||
void MainFrame::update_layout()
|
void MainFrame::update_layout()
|
||||||
{
|
{
|
||||||
auto restore_to_creation = [this]() {
|
auto restore_to_creation = [this]() {
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/filehistory.h>
|
#include <wx/filehistory.h>
|
||||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#ifdef __APPLE__
|
||||||
#include <wx/taskbar.h>
|
#include <wx/taskbar.h>
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#endif __APPLE__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -141,11 +141,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MainFrame();
|
MainFrame();
|
||||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
|
||||||
~MainFrame();
|
|
||||||
#else
|
|
||||||
~MainFrame() = default;
|
~MainFrame() = default;
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
|
||||||
|
|
||||||
void update_layout();
|
void update_layout();
|
||||||
|
|
||||||
@ -202,9 +198,9 @@ public:
|
|||||||
wxProgressDialog* m_progress_dialog { nullptr };
|
wxProgressDialog* m_progress_dialog { nullptr };
|
||||||
std::shared_ptr<ProgressStatusBar> m_statusbar;
|
std::shared_ptr<ProgressStatusBar> m_statusbar;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#ifdef __APPLE__
|
||||||
wxTaskBarIcon* m_taskbar_icon{ nullptr };
|
std::unique_ptr<wxTaskBarIcon> m_taskbar_icon;
|
||||||
#endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
|
#endif // __APPLE__
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void* m_hDeviceNotify { nullptr };
|
void* m_hDeviceNotify { nullptr };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user