mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-05 18:10:40 +08:00
Check for datadir in OnInit().
This commit is contained in:
parent
11716e0f11
commit
a2b2bf11a3
@ -3,6 +3,8 @@
|
|||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#endif
|
#endif
|
||||||
#include <wx/display.h>
|
#include <wx/display.h>
|
||||||
|
#include <wx/filefn.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
@ -10,40 +12,65 @@
|
|||||||
#include "misc_ui.hpp"
|
#include "misc_ui.hpp"
|
||||||
#include "Preset.hpp"
|
#include "Preset.hpp"
|
||||||
|
|
||||||
|
// Logging mechanism
|
||||||
|
#include "Log.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
enum
|
/// Primary initialization and point of entry into the GUI application.
|
||||||
{
|
/// Calls MainFrame and handles preset loading, etc.
|
||||||
ID_Hello = 1
|
|
||||||
};
|
|
||||||
bool App::OnInit()
|
bool App::OnInit()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
this->SetAppName("Slic3r");
|
this->SetAppName("Slic3r");
|
||||||
// TODO: Call a logging function with channel GUI, severity info
|
// TODO: Call a logging function with channel GUI, severity info
|
||||||
|
|
||||||
this->notifier = std::unique_ptr<Notifier>();
|
this->notifier = std::unique_ptr<Notifier>();
|
||||||
|
|
||||||
wxString datadir {decode_path(wxStandardPaths::Get().GetUserDataDir())};
|
datadir = decode_path(wxStandardPaths::Get().GetUserDataDir());
|
||||||
wxString enc_datadir = encode_path(datadir);
|
wxString enc_datadir = encode_path(datadir);
|
||||||
std::cerr << datadir << "\n";
|
|
||||||
|
const wxString& slic3r_ini {datadir + "/slic3r.ini"};
|
||||||
|
const wxString& print_ini {datadir + "/print"};
|
||||||
|
const wxString& printer_ini {datadir + "/printer"};
|
||||||
|
const wxString& material_ini {datadir + "/filament"};
|
||||||
|
|
||||||
|
// if we don't have a datadir or a slic3r.ini, prompt for wizard.
|
||||||
|
bool run_wizard = (wxDirExists(datadir) && wxFileExists(slic3r_ini));
|
||||||
|
|
||||||
|
/* Check to make sure if datadir exists */
|
||||||
|
for (auto& dir : std::vector<wxString> { enc_datadir, print_ini, printer_ini, material_ini }) {
|
||||||
|
if (wxDirExists(dir)) continue;
|
||||||
|
if (!wxMkdir(dir)) {
|
||||||
|
Slic3r::Log::fatal_error(LogChannel, (_("Slic3r was unable to create its data directory at ")+ dir).ToStdWstring());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Call a logging function with channel GUI, severity info for datadir path
|
// TODO: Call a logging function with channel GUI, severity info for datadir path
|
||||||
|
Slic3r::Log::info(LogChannel, (_("Data dir: ") + datadir).ToStdWstring());
|
||||||
|
|
||||||
|
if (wxFileExists(slic3r_ini)) {
|
||||||
|
/*
|
||||||
|
my $ini = eval { Slic3r::Config->read_ini("$datadir/slic3r.ini") };
|
||||||
|
if ($ini) {
|
||||||
|
$last_version = $ini->{_}{version};
|
||||||
|
$ini->{_}{$_} = $Settings->{_}{$_}
|
||||||
|
for grep !exists $ini->{_}{$_}, keys %{$Settings->{_}};
|
||||||
|
$Settings = $ini;
|
||||||
|
}
|
||||||
|
delete $Settings->{_}{mode}; # handle legacy
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
/* Check to make sure if datadir exists
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Load settings
|
|
||||||
this->gui_config->save_settings();
|
this->gui_config->save_settings();
|
||||||
|
|
||||||
|
// Load presets
|
||||||
this->load_presets();
|
this->load_presets();
|
||||||
|
|
||||||
|
|
||||||
wxImage::AddHandler(new wxPNGHandler());
|
wxImage::AddHandler(new wxPNGHandler());
|
||||||
MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize, this->gui_config);
|
MainFrame *frame = new MainFrame( "Slic3r", wxDefaultPosition, wxDefaultSize, this->gui_config);
|
||||||
this->SetTopWindow(frame);
|
this->SetTopWindow(frame);
|
||||||
frame->Show( true );
|
|
||||||
|
|
||||||
// Load init bundle
|
// Load init bundle
|
||||||
//
|
//
|
||||||
@ -56,7 +83,7 @@ bool App::OnInit()
|
|||||||
&& (!$Settings->{_}{last_version_check} || (time - $Settings->{_}{last_version_check}) >= 86400);
|
&& (!$Settings->{_}{last_version_check} || (time - $Settings->{_}{last_version_check}) >= 86400);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// run callback functions during idle
|
// run callback functions during idle on the main frame
|
||||||
/*
|
/*
|
||||||
EVT_IDLE($frame, sub {
|
EVT_IDLE($frame, sub {
|
||||||
while (my $cb = shift @cb) {
|
while (my $cb = shift @cb) {
|
||||||
|
@ -36,6 +36,8 @@ private:
|
|||||||
|
|
||||||
void load_presets();
|
void load_presets();
|
||||||
|
|
||||||
|
wxString datadir {""};
|
||||||
|
const std::string LogChannel {"GUI"}; //< Which log these messages should go to.
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user