mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-13 02:41:16 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
#ifndef slic3r_Downloader_hpp_
|
|
#define slic3r_Downloader_hpp_
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <string>
|
|
#include <wx/event.h>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <cstddef>
|
|
#include <wx/wx.h>
|
|
|
|
namespace Slic3r::GUI { class FileGet; }
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
class NotificationManager;
|
|
|
|
enum DownloadState
|
|
{
|
|
DownloadPending = 0,
|
|
DownloadOngoing,
|
|
DownloadStopped,
|
|
DownloadDone,
|
|
DownloadError,
|
|
DownloadPaused,
|
|
DownloadStateUnknown
|
|
};
|
|
|
|
enum DownloaderUserAction
|
|
{
|
|
DownloadUserCanceled,
|
|
DownloadUserPaused,
|
|
DownloadUserContinued,
|
|
DownloadUserOpenedFolder
|
|
};
|
|
|
|
class Download {
|
|
public:
|
|
Download(int ID, std::string url, wxEvtHandler* evt_handler, const boost::filesystem::path& dest_folder);
|
|
void start();
|
|
void cancel();
|
|
void pause();
|
|
void resume();
|
|
|
|
int get_id() const { return m_id; }
|
|
boost::filesystem::path get_final_path() const { return m_final_path; }
|
|
std::string get_filename() const { return m_filename; }
|
|
DownloadState get_state() const { return m_state; }
|
|
void set_state(DownloadState state) { m_state = state; }
|
|
std::string get_dest_folder() { return m_dest_folder.string(); }
|
|
private:
|
|
const int m_id;
|
|
std::string m_filename;
|
|
boost::filesystem::path m_final_path;
|
|
boost::filesystem::path m_dest_folder;
|
|
std::shared_ptr<FileGet> m_file_get;
|
|
DownloadState m_state { DownloadState::DownloadPending };
|
|
};
|
|
|
|
class Downloader : public wxEvtHandler {
|
|
public:
|
|
Downloader();
|
|
|
|
bool get_initialized() { return m_initialized; }
|
|
void init(const boost::filesystem::path& dest_folder)
|
|
{
|
|
m_dest_folder = dest_folder;
|
|
m_initialized = true;
|
|
}
|
|
void start_download(const std::string& full_url);
|
|
// cancel = false -> just pause
|
|
bool user_action_callback(DownloaderUserAction action, int id);
|
|
private:
|
|
bool m_initialized { false };
|
|
|
|
std::vector<std::unique_ptr<Download>> m_downloads;
|
|
boost::filesystem::path m_dest_folder;
|
|
|
|
size_t m_next_id { 0 };
|
|
size_t get_next_id() { return ++m_next_id; }
|
|
|
|
void on_progress(wxCommandEvent& event);
|
|
void on_error(wxCommandEvent& event);
|
|
void on_complete(wxCommandEvent& event);
|
|
void on_name_change(wxCommandEvent& event);
|
|
void on_paused(wxCommandEvent& event);
|
|
void on_canceled(wxCommandEvent& event);
|
|
|
|
void set_download_state(int id, DownloadState state);
|
|
/*
|
|
bool is_in_state(int id, DownloadState state) const;
|
|
DownloadState get_download_state(int id) const;
|
|
bool cancel_download(int id);
|
|
bool pause_download(int id);
|
|
bool resume_download(int id);
|
|
bool delete_download(int id);
|
|
wxString get_path_of(int id) const;
|
|
wxString get_folder_path_of(int id) const;
|
|
*/
|
|
};
|
|
|
|
}
|
|
}
|
|
#endif |