mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-27 15:49:52 -05:00
Outside the Design tab an agent had 175 commands, 50 of them in the tool list. There are now 118, named by what they act on (`object_`, `plate_`, `preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes its target and values in the call, acts on the selection when it names no target and says what it acted on; an old name is refused. Printers and system filaments install and uninstall, preferences read and write, plugins enable, reload, uninstall and refresh, and objects reorder, with no dialog to drive. The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the rows these commands share with the menus are fixed. For a person: an object row that cannot run says why instead of "Select an object first.", rows that failed no longer claim success, Duplicate Plate can be undone, and Refresh Plugins picked while a refresh runs now runs after it instead of beside it.
141 lines
5.9 KiB
C++
141 lines
5.9 KiB
C++
#ifndef slic3r_GUI_FileArchiveDialog_hpp_
|
|
#define slic3r_GUI_FileArchiveDialog_hpp_
|
|
|
|
#include "GUI_Utils.hpp"
|
|
#include "libslic3r/miniz_extension.hpp"
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <wx/string.h>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <cstddef>
|
|
#include <wx/variant.h>
|
|
#include <wx/event.h>
|
|
#include <wx/gdicmn.h>
|
|
#include <miniz.h>
|
|
#include <utility>
|
|
#include <wx/sizer.h>
|
|
#include <wx/wx.h>
|
|
#include <wx/dataview.h>
|
|
#include <slic3r/GUI/Widgets/Button.hpp>
|
|
#include "wxExtensions.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
class ArchiveViewCtrl;
|
|
|
|
class ArchiveViewNode
|
|
{
|
|
public:
|
|
ArchiveViewNode(const wxString& name) : m_name(name) {}
|
|
|
|
std::vector<std::shared_ptr<ArchiveViewNode>>& get_children() { return m_children; }
|
|
void set_parent(std::shared_ptr<ArchiveViewNode> parent) { m_parent = parent; }
|
|
// On Linux, get_parent cannot just return size of m_children. ItemAdded would than crash.
|
|
std::shared_ptr<ArchiveViewNode> get_parent() const { return m_parent; }
|
|
bool is_container() const { return m_container; }
|
|
void set_container(bool is_container) { m_container = is_container; }
|
|
wxString get_name() const { return m_name; }
|
|
void set_name(const wxString& name) { m_name = name; }
|
|
bool get_toggle() const { return m_toggle; }
|
|
void set_toggle(bool toggle) { m_toggle = toggle; }
|
|
bool get_is_folder() const { return m_folder; }
|
|
void set_is_folder(bool is_folder) { m_folder = is_folder; }
|
|
void set_fullpath(boost::filesystem::path path) { m_fullpath = path; }
|
|
boost::filesystem::path get_fullpath() const { return m_fullpath; }
|
|
void set_size(size_t size) { m_size = size; }
|
|
size_t get_size() const { return m_size; }
|
|
|
|
private:
|
|
wxString m_name;
|
|
std::shared_ptr<ArchiveViewNode> m_parent { nullptr };
|
|
std::vector<std::shared_ptr<ArchiveViewNode>> m_children;
|
|
|
|
bool m_toggle { false };
|
|
bool m_folder { false };
|
|
boost::filesystem::path m_fullpath;
|
|
bool m_container { false };
|
|
size_t m_size { 0 };
|
|
};
|
|
|
|
class ArchiveViewModel : public wxDataViewModel
|
|
{
|
|
public:
|
|
ArchiveViewModel(wxWindow* parent);
|
|
~ArchiveViewModel();
|
|
|
|
/* wxDataViewItem AddFolder(wxDataViewItem& parent, wxString name);
|
|
wxDataViewItem AddFile(wxDataViewItem& parent, wxString name);*/
|
|
|
|
std::shared_ptr<ArchiveViewNode> AddFile(std::shared_ptr<ArchiveViewNode> parent,const wxString& name, bool container);
|
|
|
|
wxString GetColumnType(unsigned int col) const override;
|
|
unsigned int GetColumnCount() const override { return 2; }
|
|
|
|
void Rescale();
|
|
void Delete(const wxDataViewItem& item);
|
|
void Clear();
|
|
|
|
wxDataViewItem GetParent(const wxDataViewItem& item) const override;
|
|
unsigned int GetChildren(const wxDataViewItem& parent, wxDataViewItemArray& array) const override;
|
|
|
|
void SetAssociatedControl(ArchiveViewCtrl* ctrl) { m_ctrl = ctrl; }
|
|
|
|
void GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned int col) const override;
|
|
bool SetValue(const wxVariant& variant, const wxDataViewItem& item, unsigned int col) override;
|
|
|
|
void untoggle_folders(const wxDataViewItem& item);
|
|
|
|
bool IsEnabled(const wxDataViewItem& item, unsigned int col) const override;
|
|
bool IsContainer(const wxDataViewItem& item) const override;
|
|
// Is the container just a header or an item with all columns
|
|
// In our case it is an item with all columns
|
|
bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const override { return true; }
|
|
|
|
protected:
|
|
wxWindow* m_parent { nullptr };
|
|
ArchiveViewCtrl* m_ctrl { nullptr };
|
|
std::vector<std::shared_ptr<ArchiveViewNode>> m_top_children;
|
|
};
|
|
|
|
class ArchiveViewCtrl : public wxDataViewCtrl
|
|
{
|
|
public:
|
|
ArchiveViewCtrl(wxWindow* parent, wxSize size);
|
|
~ArchiveViewCtrl();
|
|
|
|
ArchiveViewModel* get_model() const {return m_model; }
|
|
protected:
|
|
ArchiveViewModel* m_model;
|
|
};
|
|
|
|
|
|
// Whether `path`, an entry of a ZIP archive, is a model file the archive's file list offers: a file named .stl, .obj,
|
|
// .amf, .3mf, .step or .stp, outside the __MACOSX folder macOS adds to an archive.
|
|
bool is_archive_model(const boost::filesystem::path& path);
|
|
|
|
class FileArchiveDialog : public DPIDialog
|
|
{
|
|
public:
|
|
FileArchiveDialog(wxWindow* parent_window, mz_zip_archive* archive, std::vector<std::pair<boost::filesystem::path, size_t>>& selected_paths_w_size);
|
|
|
|
protected:
|
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
|
|
|
void on_open_button();
|
|
void on_all_button();
|
|
void on_none_button();
|
|
|
|
wxBoxSizer* create_btn_sizer();
|
|
|
|
// chosen files are written into this vector and returned to caller via reference.
|
|
// path in archive and decompressed size. The size can be used to distinguish between files with same path.
|
|
std::vector<std::pair<boost::filesystem::path,size_t>>& m_selected_paths_w_size;
|
|
ArchiveViewCtrl* m_avc;
|
|
std::vector<Button*> m_button_list;
|
|
};
|
|
|
|
} // namespace GU
|
|
} // namespace Slic3r
|
|
#endif // slic3r_GUI_FileArchiveDialog_hpp_
|