mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-29 01:02:02 +08:00
AppUpdater: Read option "action" and on value "browser" open url in browser.
Increased min size.
This commit is contained in:
parent
31b88e6741
commit
b7f0b51c3b
@ -3227,7 +3227,7 @@ wxString GUI_App::current_language_code_safe() const
|
||||
|
||||
void GUI_App::open_web_page_localized(const std::string &http_address)
|
||||
{
|
||||
open_browser_with_warning_dialog(http_address + "&lng=" + this->current_language_code_safe(), nullptr, false);
|
||||
open_browser_with_warning_dialog(from_u8(http_address + "&lng=") + this->current_language_code_safe(), nullptr, false);
|
||||
}
|
||||
|
||||
// If we are switching from the FFF-preset to the SLA, we should to control the printed objects if they have a part(s).
|
||||
@ -3701,7 +3701,7 @@ void GUI_App::app_updater(bool from_user)
|
||||
assert(!app_data.target_path.empty());
|
||||
|
||||
// dialog with new version info
|
||||
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version, from_user);
|
||||
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version, from_user, app_data.action == AppUpdaterURLAction::AUUA_OPEN_IN_BROWSER);
|
||||
auto dialog_result = dialog.ShowModal();
|
||||
// checkbox "do not show again"
|
||||
if (dialog.disable_version_check()) {
|
||||
@ -3711,6 +3711,10 @@ void GUI_App::app_updater(bool from_user)
|
||||
if (dialog_result != wxID_OK) {
|
||||
return;
|
||||
}
|
||||
if (app_data.action == AppUpdaterURLAction::AUUA_OPEN_IN_BROWSER) {
|
||||
open_browser_with_warning_dialog(from_u8(app_data.url));
|
||||
return;
|
||||
}
|
||||
// dialog with new version download (installer or app dependent on system) including path selection
|
||||
AppUpdateDownloadDialog dwnld_dlg(*app_data.version, app_data.target_path);
|
||||
dialog_result = dwnld_dlg.ShowModal();
|
||||
|
@ -99,7 +99,7 @@ bool MsgUpdateSlic3r::disable_version_check() const
|
||||
|
||||
wxSize AppUpdateAvailableDialog::AUAD_size;
|
||||
// AppUpdater
|
||||
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user)
|
||||
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user, bool browser_on_next)
|
||||
: MsgDialog(nullptr, _(L("App Update available")), wxString::Format(_(L("New version of %s is available.\nDo you wish to download it?")), SLIC3R_APP_NAME))
|
||||
{
|
||||
auto* versions = new wxFlexGridSizer(1, 0, VERT_SPACING);
|
||||
@ -116,6 +116,12 @@ AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, co
|
||||
}
|
||||
content_sizer->AddSpacer(VERT_SPACING);
|
||||
|
||||
if (browser_on_next)
|
||||
{
|
||||
content_sizer->Add(new wxStaticText(this, wxID_ANY, _(L("Clicking \'Next\' will open a browser window to select your download."))));
|
||||
content_sizer->AddSpacer(VERT_SPACING);
|
||||
}
|
||||
|
||||
AUAD_size = content_sizer->GetSize();
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
class AppUpdateAvailableDialog : public MsgDialog
|
||||
{
|
||||
public:
|
||||
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user);
|
||||
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user, bool browser_on_next);
|
||||
AppUpdateAvailableDialog(AppUpdateAvailableDialog&&) = delete;
|
||||
AppUpdateAvailableDialog(const AppUpdateAvailableDialog&) = delete;
|
||||
AppUpdateAvailableDialog& operator=(AppUpdateAvailableDialog&&) = delete;
|
||||
|
@ -45,7 +45,7 @@ namespace {
|
||||
bool res = GUI::create_process(path, std::wstring(), msg);
|
||||
if (!res) {
|
||||
std::string full_message = GUI::format(_u8L("Running downloaded instaler of %1% has failed:\n%2%"), SLIC3R_APP_NAME, msg);
|
||||
BOOST_LOG_TRIVIAL(error) << full_message; // lm: maybe UI error msg? // dk: bellow. (maybe some general show error evt would be better?)
|
||||
BOOST_LOG_TRIVIAL(error) << full_message;
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_FAILED);
|
||||
evt->SetString(full_message);
|
||||
GUI::wxGetApp().QueueEvent(evt);
|
||||
@ -165,7 +165,7 @@ AppUpdater::priv::priv() :
|
||||
if (!downloads_path.empty()) {
|
||||
m_default_dest_folder = std::move(downloads_path);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "App updater default download path: " << m_default_dest_folder; //lm:Is this an error? // dk: changed to trace
|
||||
BOOST_LOG_TRIVIAL(trace) << "App updater default download path: " << m_default_dest_folder;
|
||||
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
||||
}
|
||||
|
||||
std::string error_message;
|
||||
bool res = http_get_file(data.url, 130 * 1024 * 1024 //2.4.0 windows installer is 65MB //lm:I don't know, but larger. The binaries will grow. // dk: changed to 130, to have 100% more space. We should put this information into version file.
|
||||
bool res = http_get_file(data.url, 256 * 1024 * 1024
|
||||
// on_progress
|
||||
, [&last_gui_progress, expected_size](Http::Progress progress) {
|
||||
// size check
|
||||
@ -333,10 +333,6 @@ void AppUpdater::priv::version_check(const std::string& version_check_url)
|
||||
}
|
||||
, error_message
|
||||
);
|
||||
//lm:In case the internet is not available, it will report no updates if run by user.
|
||||
// We might save a flag that we don't know or try to run the version_check again, reporting
|
||||
// the failure.
|
||||
// dk: changed to download version every time. Dialog will show if m_triggered_by_user.
|
||||
if (!res) {
|
||||
std::string message = GUI::format("Downloading %1% version file has failed:\n%2%", SLIC3R_APP_NAME, error_message);
|
||||
BOOST_LOG_TRIVIAL(error) << message;
|
||||
@ -390,19 +386,21 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
||||
#else
|
||||
"release:linux"
|
||||
#endif
|
||||
//lm:Related to the ifdefs. We should also support BSD, which behaves similar to Linux in most cases.
|
||||
// Unless you have a reason not to, I would consider doing _WIN32, elif __APPLE__, else ... Not just here.
|
||||
// dk: so its ok now or we need to specify BSD?
|
||||
) {
|
||||
for (const auto& data : section.second) {
|
||||
if (data.first == "url") {
|
||||
new_data.url = data.second.data();
|
||||
new_data.target_path = m_default_dest_folder / AppUpdater::get_filename_from_url(new_data.url);
|
||||
BOOST_LOG_TRIVIAL(info) << format("parsing version string: url: %1%", new_data.url);
|
||||
} else if (data.first == "size"){
|
||||
} else if (data.first == "size") {
|
||||
new_data.size = std::stoi(data.second.data());
|
||||
BOOST_LOG_TRIVIAL(info) << format("parsing version string: expected size: %1%", new_data.size);
|
||||
}
|
||||
} else if (data.first == "action") {
|
||||
std::string action = data.second.data();
|
||||
if (action == "browser") {
|
||||
new_data.action = AppUpdaterURLAction::AUUA_OPEN_IN_BROWSER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ namespace Slic3r {
|
||||
std::string get_downloads_path_mac();
|
||||
#endif //__APPLE__
|
||||
|
||||
enum class AppUpdaterURLAction {
|
||||
AUUA_DOWNLOAD,
|
||||
AUUA_OPEN_IN_BROWSER
|
||||
};
|
||||
struct DownloadAppData
|
||||
{
|
||||
std::string url;
|
||||
@ -26,6 +30,7 @@ struct DownloadAppData
|
||||
boost::optional<Semver> version;
|
||||
size_t size;
|
||||
boost::filesystem::path target_path;
|
||||
AppUpdaterURLAction action { AppUpdaterURLAction::AUUA_DOWNLOAD };
|
||||
};
|
||||
|
||||
class AppUpdater
|
||||
|
Loading…
x
Reference in New Issue
Block a user