mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	ENABLE_GCODE_VIEWER -> Experimental taskbar icon
This commit is contained in:
		
							parent
							
								
									e22e85e8e2
								
							
						
					
					
						commit
						93921dc7c8
					
				
					 3 changed files with 50 additions and 0 deletions
				
			
		|  | @ -58,6 +58,7 @@ | |||
| #define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1) | ||||
| #define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER) | ||||
| #define ENABLE_GCODE_VIEWER_DATA_CHECKING (0 && ENABLE_GCODE_VIEWER) | ||||
| #define ENABLE_GCODE_VIEWER_TASKBAR_ICON (1 && ENABLE_GCODE_VIEWER) | ||||
| 
 | ||||
| #define TIME_ESTIMATE_NONE 0 | ||||
| #define TIME_ESTIMATE_DEFAULT 1 | ||||
|  |  | |||
|  | @ -93,6 +93,28 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S | |||
|     // Font is already set in DPIFrame constructor
 | ||||
| */ | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
|     if (wxTaskBarIcon::IsAvailable()) { | ||||
| #if defined(__WXOSX__) && wxOSX_USE_COCOA | ||||
|         m_taskbar_icon = new wxTaskBarIcon(wxTBI_DOCK); | ||||
| #else | ||||
|         m_taskbar_icon = new wxTaskBarIcon(); | ||||
| #endif | ||||
|         m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer"); | ||||
| 
 | ||||
|         m_taskbar_icon->Bind(wxEVT_TASKBAR_CLICK, [this](wxTaskBarIconEvent& evt) { | ||||
|             wxString msg = _L("You pressed the icon in taskbar for ") + "\n"; | ||||
|             if (m_mode == EMode::Editor) | ||||
|                 msg += wxString(SLIC3R_APP_NAME); | ||||
|             else | ||||
|                 msg += wxString(SLIC3R_APP_NAME) + "-GCode viewer"; | ||||
| 
 | ||||
|             wxMessageDialog dialog(nullptr, msg, _("Taskbar icon clicked"), wxOK); | ||||
|             dialog.ShowModal(); | ||||
|             }); | ||||
|     } | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
|     SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG)); | ||||
| //    // Load the icon either from the exe, or from the ico file.
 | ||||
| //#if _WIN32
 | ||||
|  | @ -255,6 +277,14 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
| MainFrame::~MainFrame() | ||||
| { | ||||
|     if (m_taskbar_icon != nullptr) | ||||
|         delete m_taskbar_icon; | ||||
| } | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
| void MainFrame::update_layout() | ||||
| { | ||||
|     auto restore_to_creation = [this]() { | ||||
|  | @ -1388,6 +1418,10 @@ void MainFrame::set_mode(EMode mode) | |||
|         m_plater->Thaw(); | ||||
| 
 | ||||
|         SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG)); | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
|         if (m_taskbar_icon  != nullptr) | ||||
|             m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer"); | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
|         break; | ||||
|     } | ||||
|  | @ -1435,6 +1469,10 @@ void MainFrame::set_mode(EMode mode) | |||
|         m_plater->Thaw(); | ||||
| 
 | ||||
|         SetIcon(wxIcon(Slic3r::var("PrusaSlicerGCodeViewer_128px.png"), wxBITMAP_TYPE_PNG)); | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
|         if (m_taskbar_icon != nullptr) | ||||
|             m_taskbar_icon->SetIcon(wxIcon(Slic3r::var("PrusaSlicer_128px.png"), wxBITMAP_TYPE_PNG), "PrusaSlicer-GCode viewer"); | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
|         break; | ||||
|     } | ||||
|  |  | |||
|  | @ -7,6 +7,9 @@ | |||
| #include <wx/settings.h> | ||||
| #include <wx/string.h> | ||||
| #include <wx/filehistory.h> | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
| #include <wx/taskbar.h> | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
| #include <string> | ||||
| #include <map> | ||||
|  | @ -160,7 +163,11 @@ protected: | |||
| 
 | ||||
| public: | ||||
|     MainFrame(); | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
|     ~MainFrame(); | ||||
| #else | ||||
|     ~MainFrame() = default; | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
|     void update_layout(); | ||||
| 
 | ||||
|  | @ -219,6 +226,10 @@ public: | |||
|     wxProgressDialog*   m_progress_dialog { nullptr }; | ||||
|     std::shared_ptr<ProgressStatusBar>  m_statusbar; | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_TASKBAR_ICON | ||||
|     wxTaskBarIcon* m_taskbar_icon{ nullptr }; | ||||
| #endif // ENABLE_GCODE_VIEWER_TASKBAR_ICON
 | ||||
| 
 | ||||
| #ifdef _WIN32 | ||||
|     void*				m_hDeviceNotify { nullptr }; | ||||
|     uint32_t  			m_ulSHChangeNotifyRegister { 0 }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966