mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-02 18:20:45 +08:00
added misc utility functions for the UI, including functions to get user home (for slic3r directory) and path to var.
This commit is contained in:
parent
7211acc32d
commit
137716b8a3
@ -2,14 +2,17 @@
|
||||
#define GUI_HPP
|
||||
#include "MainFrame.hpp"
|
||||
#include "Notifier.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
// Friendly indices for the preset lists.
|
||||
enum class PresetID {
|
||||
PRINT = 0,
|
||||
FILAMENT = 1,
|
||||
PRINTER = 2
|
||||
};
|
||||
using preset_list = std::vector<std::string>;
|
||||
|
||||
class App: public wxApp
|
||||
{
|
||||
@ -22,7 +25,7 @@ public:
|
||||
private:
|
||||
std::shared_ptr<Settings> gui_config; // GUI-specific configuration options
|
||||
Notifier* notifier;
|
||||
|
||||
std::vector<preset_list> presets { preset_list(), preset_list(), preset_list() };
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
@ -15,6 +15,11 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
|
||||
{
|
||||
// Set icon to either the .ico if windows or png for everything else.
|
||||
if (the_os == OS::Windows)
|
||||
this->SetIcon(wxIcon(var("Slic3r.ico"), wxBITMAP_TYPE_ICO));
|
||||
else
|
||||
this->SetIcon(wxIcon(var("Slic3r_128px.png"), wxBITMAP_TYPE_PNG));
|
||||
|
||||
|
||||
this->init_tabpanel();
|
||||
this->init_menubar();
|
||||
|
@ -11,5 +11,20 @@ void check_version(bool manual) {
|
||||
|
||||
#endif
|
||||
|
||||
const wxString var(const wxString& in) {
|
||||
wxFileName f(wxStandardPaths::Get().GetExecutablePath());
|
||||
wxString appPath(f.GetPath());
|
||||
|
||||
// replace center string with path to VAR in actual distribution later
|
||||
return appPath + "/../var/" + in;
|
||||
}
|
||||
|
||||
/// Returns the path to Slic3r's default user data directory.
|
||||
const wxString home(const wxString& in) {
|
||||
if (the_os == OS::Windows)
|
||||
return wxGetHomeDir() + "/" + in + "/";
|
||||
return wxGetHomeDir() + "/." + in + "/";
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
|
@ -1,15 +1,44 @@
|
||||
#ifndef MISC_UI_HPP
|
||||
#define MISC_UI_HPP
|
||||
|
||||
#include <wx/wxprec.h>
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
/// Common static (that is, free-standing) functions, not part of an object hierarchy.
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
enum class OS { Linux, Mac, Windows } ;
|
||||
// constants to reduce the proliferation of macros in the rest of the code
|
||||
#ifdef __WIN32
|
||||
constexpr OS the_os = OS::Windows;
|
||||
#elif __APPLE__
|
||||
constexpr OS the_os = OS::Mac;
|
||||
#elif __linux__
|
||||
constexpr OS the_os = OS::Linux;
|
||||
#endif
|
||||
|
||||
#ifdef SLIC3R_DEV
|
||||
constexpr bool isDev = true;
|
||||
#else
|
||||
constexpr bool isDev = false;
|
||||
#endif
|
||||
|
||||
/// Performs a check via the Internet for a new version of Slic3r.
|
||||
/// If this version of Slic3r was compiled with SLIC3R_DEV, check the development
|
||||
/// If this version of Slic3r was compiled with -DSLIC3R_DEV, check the development
|
||||
/// space instead of release.
|
||||
void check_version(bool manual = false);
|
||||
|
||||
const wxString var(const wxString& in);
|
||||
|
||||
/// Always returns path to home directory.
|
||||
const wxString home(const wxString& in = "Slic3r");
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif // MISC_UI_HPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user