mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-06 01:46:08 +08:00
More misc functions (used to live as static functions in Slic3r::GUI perl file).
Passing -DVAR_ABS and -DVAR_ABS_PATH=/path/to/slic3r/var on compile redirects where Slic3r expects to find its var directory.
This commit is contained in:
parent
c1649c4dcf
commit
11716e0f11
@ -1,5 +1,8 @@
|
|||||||
#include "misc_ui.hpp"
|
#include "misc_ui.hpp"
|
||||||
#include <wx/stdpaths.h>
|
#include <wx/stdpaths.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
@ -14,11 +17,18 @@ void check_version(bool manual) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const wxString var(const wxString& in) {
|
const wxString var(const wxString& in) {
|
||||||
|
// TODO replace center string with path to VAR in actual distribution later
|
||||||
|
if (VAR_ABS) {
|
||||||
|
return VAR_ABS_PATH + "/" + in;
|
||||||
|
} else {
|
||||||
|
return bin() + VAR_REL + "/" + in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString bin() {
|
||||||
wxFileName f(wxStandardPaths::Get().GetExecutablePath());
|
wxFileName f(wxStandardPaths::Get().GetExecutablePath());
|
||||||
wxString appPath(f.GetPath());
|
wxString appPath(f.GetPath());
|
||||||
|
return appPath;
|
||||||
// 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.
|
/// Returns the path to Slic3r's default user data directory.
|
||||||
@ -28,7 +38,6 @@ const wxString home(const wxString& in) {
|
|||||||
return wxGetHomeDir() + "/." + in + "/";
|
return wxGetHomeDir() + "/." + in + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString decode_path(const wxString& in) {
|
wxString decode_path(const wxString& in) {
|
||||||
// TODO Stub
|
// TODO Stub
|
||||||
return in;
|
return in;
|
||||||
@ -38,6 +47,21 @@ wxString encode_path(const wxString& in) {
|
|||||||
// TODO Stub
|
// TODO Stub
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void show_error(wxWindow* parent, const wxString& message) {
|
||||||
|
wxMessageDialog(parent, message, _("Error"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title = _("Notice")) {
|
||||||
|
wxMessageDialog(parent, message, title, wxOK | wxICON_INFORMATION).ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fatal_error(wxWindow* parent, const wxString& message) {
|
||||||
|
show_error(parent, message);
|
||||||
|
throw std::runtime_error(message.ToStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sub append_submenu {
|
sub append_submenu {
|
||||||
my ($self, $menu, $string, $description, $submenu, $id, $icon) = @_;
|
my ($self, $menu, $string, $description, $submenu, $id, $icon) = @_;
|
||||||
|
@ -29,16 +29,47 @@ constexpr bool isDev = true;
|
|||||||
constexpr bool isDev = false;
|
constexpr bool isDev = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/// Mostly useful for Linux distro maintainers, this will change where Slic3r assumes
|
||||||
|
/// its ./var directory lives (where its art assets are).
|
||||||
|
/// Define VAR_ABS and VAR_ABS_PATH
|
||||||
|
#ifndef VAR_ABS
|
||||||
|
#define VAR_ABS false
|
||||||
|
#else
|
||||||
|
#define VAR_ABS true
|
||||||
|
#endif
|
||||||
|
#ifndef VAR_ABS_PATH
|
||||||
|
#define VAR_ABS_PATH "/usr/share/Slic3r/var"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef VAR_REL // Redefine on compile
|
||||||
|
#define VAR_REL L"/../var"
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Performs a check via the Internet for a new version of Slic3r.
|
/// Performs a check via the Internet for a new version of Slic3r.
|
||||||
/// If this version of Slic3r was compiled with -DSLIC3R_DEV, check the development
|
/// If this version of Slic3r was compiled with -DSLIC3R_DEV, check the development
|
||||||
/// space instead of release.
|
/// space instead of release.
|
||||||
void check_version(bool manual = false);
|
void check_version(bool manual = false);
|
||||||
|
|
||||||
|
/// Provides a path to Slic3r's var dir.
|
||||||
const wxString var(const wxString& in);
|
const wxString var(const wxString& in);
|
||||||
|
|
||||||
|
/// Provide a path to where Slic3r exec'd from.
|
||||||
|
const wxString bin();
|
||||||
|
|
||||||
/// Always returns path to home directory.
|
/// Always returns path to home directory.
|
||||||
const wxString home(const wxString& in = "Slic3r");
|
const wxString home(const wxString& in = "Slic3r");
|
||||||
|
|
||||||
|
/// Shows an error messagebox
|
||||||
|
void show_error(wxWindow* parent, const wxString& message);
|
||||||
|
|
||||||
|
/// Shows an info messagebox.
|
||||||
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title);
|
||||||
|
|
||||||
|
/// Show an error messagebox and then throw an exception.
|
||||||
|
void fatal_error(wxWindow* parent, const wxString& message);
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void append_menu_item(wxMenu* menu, const wxString& name,const wxString& help, T lambda, int id = wxID_ANY, const wxString& icon = "", const wxString& accel = "") {
|
void append_menu_item(wxMenu* menu, const wxString& name,const wxString& help, T lambda, int id = wxID_ANY, const wxString& icon = "", const wxString& accel = "") {
|
||||||
wxMenuItem* tmp = menu->Append(wxID_ANY, name, help);
|
wxMenuItem* tmp = menu->Append(wxID_ANY, name, help);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user