mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Menu_bar and preset_tabs are in main window now
This commit is contained in:
parent
e86f149cbd
commit
8b582bbcd1
12 changed files with 489 additions and 219 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "slic3r/Utils/Http.hpp"
|
||||
#include "slic3r/Config/Version.hpp"
|
||||
#include "slic3r/Config/Snapshot.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
using Slic3r::GUI::Config::Index;
|
||||
|
@ -90,7 +91,6 @@ struct Updates
|
|||
|
||||
struct PresetUpdater::priv
|
||||
{
|
||||
int version_online_event;
|
||||
std::vector<Index> index_db;
|
||||
|
||||
bool enabled_version_check;
|
||||
|
@ -105,7 +105,7 @@ struct PresetUpdater::priv
|
|||
bool cancel;
|
||||
std::thread thread;
|
||||
|
||||
priv(int version_online_event);
|
||||
priv();
|
||||
|
||||
void set_download_prefs(AppConfig *app_config);
|
||||
bool get_file(const std::string &url, const fs::path &target_path) const;
|
||||
|
@ -120,15 +120,14 @@ struct PresetUpdater::priv
|
|||
static void copy_file(const fs::path &from, const fs::path &to);
|
||||
};
|
||||
|
||||
PresetUpdater::priv::priv(int version_online_event) :
|
||||
version_online_event(version_online_event),
|
||||
PresetUpdater::priv::priv() :
|
||||
had_config_update(false),
|
||||
cache_path(fs::path(Slic3r::data_dir()) / "cache"),
|
||||
rsrc_path(fs::path(resources_dir()) / "profiles"),
|
||||
vendor_path(fs::path(Slic3r::data_dir()) / "vendor"),
|
||||
cancel(false)
|
||||
{
|
||||
set_download_prefs(GUI::get_app_config());
|
||||
set_download_prefs(GUI::wxGetApp().app_config);
|
||||
check_install_indices();
|
||||
index_db = std::move(Index::load_db());
|
||||
}
|
||||
|
@ -209,9 +208,11 @@ void PresetUpdater::priv::sync_version() const
|
|||
.on_complete([&](std::string body, unsigned /* http_status */) {
|
||||
boost::trim(body);
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body;
|
||||
wxCommandEvent* evt = new wxCommandEvent(version_online_event);
|
||||
evt->SetString(body);
|
||||
GUI::get_app()->QueueEvent(evt);
|
||||
// wxCommandEvent* evt = new wxCommandEvent(version_online_event);
|
||||
// evt->SetString(body);
|
||||
// GUI::get_app()->QueueEvent(evt);
|
||||
GUI::wxGetApp().app_config->set("version_online", body);
|
||||
GUI::wxGetApp().app_config->save();
|
||||
})
|
||||
.perform_sync();
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
|
|||
if (updates.incompats.size() > 0) {
|
||||
if (snapshot) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Taking a snapshot...";
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_DOWNGRADE);
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_DOWNGRADE);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Deleting %1% incompatible bundles") % updates.incompats.size();
|
||||
|
@ -408,7 +409,7 @@ void PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
|
|||
else if (updates.updates.size() > 0) {
|
||||
if (snapshot) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Taking a snapshot...";
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::get_app_config(), Snapshot::SNAPSHOT_UPGRADE);
|
||||
SnapshotDB::singleton().take_snapshot(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_UPGRADE);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Performing %1% updates") % updates.updates.size();
|
||||
|
@ -466,8 +467,8 @@ void PresetUpdater::priv::copy_file(const fs::path &source, const fs::path &targ
|
|||
}
|
||||
|
||||
|
||||
PresetUpdater::PresetUpdater(int version_online_event) :
|
||||
p(new priv(version_online_event))
|
||||
PresetUpdater::PresetUpdater() :
|
||||
p(new priv())
|
||||
{}
|
||||
|
||||
|
||||
|
@ -485,7 +486,7 @@ PresetUpdater::~PresetUpdater()
|
|||
|
||||
void PresetUpdater::sync(PresetBundle *preset_bundle)
|
||||
{
|
||||
p->set_download_prefs(GUI::get_app_config());
|
||||
p->set_download_prefs(GUI::wxGetApp().app_config);
|
||||
if (!p->enabled_version_check && !p->enabled_config_update) { return; }
|
||||
|
||||
// Copy the whole vendors data for use in the background thread
|
||||
|
@ -509,7 +510,7 @@ void PresetUpdater::slic3r_update_notify()
|
|||
return;
|
||||
}
|
||||
|
||||
auto* app_config = GUI::get_app_config();
|
||||
auto* app_config = GUI::wxGetApp().app_config;
|
||||
const auto ver_slic3r = Semver::parse(SLIC3R_VERSION);
|
||||
const auto ver_online_str = app_config->get("version_online");
|
||||
const auto ver_online = Semver::parse(ver_online_str);
|
||||
|
@ -601,7 +602,7 @@ bool PresetUpdater::config_update() const
|
|||
p->perform_updates(std::move(updates));
|
||||
|
||||
// Reload global configuration
|
||||
auto *app_config = GUI::get_app_config();
|
||||
auto *app_config = GUI::wxGetApp().app_config;
|
||||
GUI::get_preset_bundle()->load_presets(*app_config);
|
||||
GUI::load_current_presets();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue