Refactoring of DownloaderUtils (remove including ConfigWizard_private.hpp))

This commit is contained in:
David Kocik 2023-02-06 15:31:01 +01:00
parent ee0871880f
commit 41ab733cd8
7 changed files with 46 additions and 51 deletions

View File

@ -1315,10 +1315,12 @@ PageUpdate::PageUpdate(ConfigWizard *parent)
box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); });
}
namespace DownloaderUtils
{
namespace {
#ifdef _WIN32
wxString get_downloads_path()
{
wxString ret;
@ -1330,7 +1332,6 @@ namespace DownloaderUtils
CoTaskMemFree(path);
return ret;
}
#elif __APPLE__
wxString get_downloads_path()
{
@ -1348,9 +1349,8 @@ namespace DownloaderUtils
}
return wxString();
}
#endif
}
Worker::Worker(wxWindow* parent)
: wxBoxSizer(wxHORIZONTAL)
, m_parent(parent)
@ -1432,16 +1432,16 @@ PageDownloader::PageDownloader(ConfigWizard* parent)
)));
#endif
box_allow_downloads->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent& event) { this->downloader->allow(event.IsChecked()); });
box_allow_downloads->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent& event) { this->m_downloader->allow(event.IsChecked()); });
downloader = new DownloaderUtils::Worker(this);
append(downloader);
downloader->allow(box_allow_value);
m_downloader = new DownloaderUtils::Worker(this);
append(m_downloader);
m_downloader->allow(box_allow_value);
}
bool PageDownloader::on_finish_downloader() const
{
return downloader->on_finish();
return m_downloader->on_finish();
}
bool DownloaderUtils::Worker::perform_register(const std::string& path_override/* = {}*/)

View File

@ -14,6 +14,36 @@ class PresetUpdater;
namespace GUI {
namespace DownloaderUtils {
class Worker : public wxBoxSizer
{
wxWindow* m_parent{ nullptr };
wxTextCtrl* m_input_path{ nullptr };
bool downloader_checked{ false };
#ifdef __linux__
bool perform_registration_linux{ false };
#endif // __linux__
void deregister();
public:
Worker(wxWindow* parent);
~Worker() {}
void allow(bool allow_) { downloader_checked = allow_; }
bool is_checked() const { return downloader_checked; }
wxString path_name() const { return m_input_path ? m_input_path->GetValue() : wxString(); }
void set_path_name(wxString name);
void set_path_name(const std::string& name);
bool on_finish();
bool perform_register(const std::string& path_override = {});
#ifdef __linux__
bool get_perform_registration_linux() { return perform_registration_linux; }
#endif // __linux__
};
}
class ConfigWizard: public DPIDialog
{

View File

@ -418,44 +418,10 @@ struct PageUpdate: ConfigWizardPage
PageUpdate(ConfigWizard *parent);
};
namespace DownloaderUtils {
wxString get_downloads_path();
class Worker : public wxBoxSizer
{
wxWindow* m_parent {nullptr};
wxTextCtrl* m_input_path {nullptr};
bool downloader_checked {false};
#ifdef __linux__
bool perform_registration_linux { false };
#endif // __linux__
void deregister();
public:
Worker(wxWindow* parent);
~Worker(){}
void allow(bool allow_) { downloader_checked = allow_; }
bool is_checked() const { return downloader_checked; }
wxString path_name() const { return m_input_path ? m_input_path->GetValue() : wxString(); }
void set_path_name(wxString name);
void set_path_name(const std::string& name);
bool on_finish();
bool perform_register(const std::string& path_override = {});
#ifdef __linux__
bool get_perform_registration_linux() { return perform_registration_linux; }
#endif // __linux__
};
}
struct PageDownloader : ConfigWizardPage
{
DownloaderUtils::Worker* downloader{ nullptr };
DownloaderUtils::Worker* m_downloader { nullptr };
PageDownloader(ConfigWizard* parent);

View File

@ -79,7 +79,6 @@
#include "DesktopIntegrationDialog.hpp"
#include "SendSystemInfoDialog.hpp"
#include "Downloader.hpp"
#include "ConfigWizard_private.hpp"
#include "BitmapCache.hpp"
#include "Notebook.hpp"
@ -3081,8 +3080,8 @@ void GUI_App::show_downloader_registration_dialog()
), SLIC3R_APP_NAME, SLIC3R_VERSION)
, true, wxYES_NO);
if (msg.ShowModal() == wxID_YES) {
auto downloader = new DownloaderUtils::Worker(nullptr);
downloader->perform_register(app_config->get("url_downloader_dest"));
auto downloader_worker = new DownloaderUtils::Worker(nullptr);
downloader_worker->perform_register(app_config->get("url_downloader_dest"));
#ifdef __linux__
if (downloader->get_perform_registration_linux())
DesktopIntegrationDialog::perform_desktop_integration(true);

View File

@ -10,7 +10,7 @@
#include "ButtonsDescription.hpp"
#include "OG_CustomCtrl.hpp"
#include "GLCanvas3D.hpp"
#include "ConfigWizard_private.hpp"
#include "ConfigWizard.hpp"
#include <boost/dll/runtime_symbol_info.hpp>