GCode viewer using the proper layout when started as a standalone application

This commit is contained in:
enricoturri1966 2020-09-08 11:40:06 +02:00
parent 8579184d70
commit ab556a398b
16 changed files with 341 additions and 115 deletions

View file

@ -179,6 +179,11 @@ std::string AppConfig::load()
void AppConfig::save()
{
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
if (!m_save_enabled)
return;
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
// The config is first written to a file with a PID suffix and then moved
// to avoid race conditions with multiple instances of Slic3r
const auto path = config_path();

View file

@ -18,6 +18,9 @@ public:
AppConfig() :
m_dirty(false),
m_orig_version(Semver::invalid()),
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
m_save_enabled(true),
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
m_legacy_datadir(false)
{
this->reset();
@ -157,6 +160,10 @@ public:
bool get_mouse_device_swap_yz(const std::string& name, bool& swap) const
{ return get_3dmouse_device_numeric_value(name, "swap_yz", swap); }
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
void enable_save(bool enable) { m_save_enabled = enable; }
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
static const std::string SECTION_FILAMENTS;
static const std::string SECTION_MATERIALS;
@ -183,6 +190,10 @@ private:
bool m_dirty;
// Original version found in the ini file before it was overwritten
Semver m_orig_version;
#if ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
// Whether or not calls to save() should take effect
bool m_save_enabled;
#endif // ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION
// Whether the existing version is before system profiles & configuration updating
bool m_legacy_datadir;
};

View file

@ -59,5 +59,6 @@
#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 (0 && ENABLE_GCODE_VIEWER)
#define ENABLE_GCODE_VIEWER_AS_STANDALONE_APPLICATION (1 && ENABLE_GCODE_VIEWER)
#endif // _prusaslicer_technologies_h_