NEW: check privacy update
Change-Id: I260fbc20cdddbdadd38f1470a2e7050ee1ed14cd Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
b1a310cf74
commit
240d106d58
|
@ -0,0 +1,24 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<link rel="stylesheet" href="./main.css" />
|
||||
<script src="./main.js"></script>
|
||||
</head>
|
||||
<body style="background-color: #F8F8F8;">
|
||||
<div class="container markdown-body" id="contents"></div>
|
||||
</body>
|
||||
<script>
|
||||
const resizeOberver = new ResizeObserver((entities) => {
|
||||
const height = entities[0].contentRect.height
|
||||
document.title = height.toFixed()
|
||||
})
|
||||
resizeOberver.observe(document.querySelector('#contents'))
|
||||
window.showMarkdownFile = function (file) {
|
||||
$.get(file, function( data ) {
|
||||
window.showMarkdown(encodeURIComponent(data));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
|
@ -257,6 +257,10 @@ void AppConfig::set_defaults()
|
|||
set("mouse_supported", "mouse left/mouse middle/mouse right");
|
||||
}
|
||||
|
||||
if (get("privacy_version").empty()) {
|
||||
set("privacy_version", "00.00.00.00");
|
||||
}
|
||||
|
||||
if (get("rotate_view").empty()) {
|
||||
set("rotate_view", "none/mouse left");
|
||||
}
|
||||
|
|
|
@ -364,6 +364,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/PublishDialog.hpp
|
||||
GUI/RecenterDialog.cpp
|
||||
GUI/RecenterDialog.hpp
|
||||
GUI/PrivacyUpdateDialog.cpp
|
||||
GUI/PrivacyUpdateDialog.hpp
|
||||
GUI/BonjourDialog.cpp
|
||||
GUI/BonjourDialog.hpp
|
||||
GUI/BindDialog.cpp
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
#include "WebDownPluginDlg.hpp"
|
||||
#include "WebGuideDialog.hpp"
|
||||
#include "ReleaseNote.hpp"
|
||||
#include "PrivacyUpdateDialog.hpp"
|
||||
#include "ModelMall.hpp"
|
||||
|
||||
//#ifdef WIN32
|
||||
|
@ -1125,6 +1126,10 @@ void GUI_App::post_init()
|
|||
|
||||
//BBS: check new version
|
||||
this->check_new_version();
|
||||
//BBS: check privacy version
|
||||
if (is_user_login())
|
||||
this->check_privacy_version(0);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1663,7 +1668,7 @@ void GUI_App::init_networking_callbacks()
|
|||
if (m_agent) {
|
||||
//set callbacks
|
||||
m_agent->set_on_user_login_fn([this](int online_login, bool login) {
|
||||
GUI::wxGetApp().request_user_login(online_login);
|
||||
GUI::wxGetApp().request_user_handle(online_login);
|
||||
});
|
||||
|
||||
m_agent->set_on_server_connected_fn([this]() {
|
||||
|
@ -1995,6 +2000,14 @@ void GUI_App::init_http_extra_header()
|
|||
m_agent->set_extra_http_header(extra_headers);
|
||||
}
|
||||
|
||||
void GUI_App::update_http_extra_header()
|
||||
{
|
||||
std::map<std::string, std::string> extra_headers = get_extra_header();
|
||||
Slic3r::Http::set_extra_headers(extra_headers);
|
||||
if (m_agent)
|
||||
m_agent->set_extra_http_header(extra_headers);
|
||||
}
|
||||
|
||||
std::string GUI_App::get_local_models_path()
|
||||
{
|
||||
std::string local_path = "";
|
||||
|
@ -2344,6 +2357,9 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
Bind(EVT_SET_SELECTED_MACHINE, &GUI_App::on_set_selected_machine, this);
|
||||
Bind(EVT_USER_LOGIN, &GUI_App::on_user_login, this);
|
||||
Bind(EVT_USER_LOGIN_HANDLE, &GUI_App::on_user_login_handle, this);
|
||||
Bind(EVT_CHECK_PRIVACY_VER, &GUI_App::on_check_privacy_update, this);
|
||||
Bind(EVT_CHECK_PRIVACY_SHOW, &GUI_App::show_check_privacy_dlg, this);
|
||||
|
||||
Bind(EVT_SHOW_IP_DIALOG, &GUI_App::show_ip_address_enter_dialog_handler, this);
|
||||
|
||||
|
@ -3354,6 +3370,13 @@ bool GUI_App::check_login()
|
|||
return result;
|
||||
}
|
||||
|
||||
void GUI_App::request_user_handle(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_USER_LOGIN_HANDLE);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
|
||||
void GUI_App::request_user_login(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_USER_LOGIN);
|
||||
|
@ -3718,7 +3741,7 @@ void GUI_App::on_set_selected_machine(wxCommandEvent &evt)
|
|||
dev->set_selected_machine(m_agent->get_user_selected_machine());
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login(wxCommandEvent &evt)
|
||||
void GUI_App::on_user_login_handle(wxCommandEvent &evt)
|
||||
{
|
||||
if (!m_agent) { return; }
|
||||
|
||||
|
@ -3760,6 +3783,14 @@ void GUI_App::on_user_login(wxCommandEvent &evt)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::on_user_login(wxCommandEvent &evt)
|
||||
{
|
||||
if (!m_agent) { return; }
|
||||
int online_login = evt.GetInt();
|
||||
// check privacy before handle
|
||||
check_privacy_version(online_login);
|
||||
}
|
||||
|
||||
bool GUI_App::is_studio_active()
|
||||
{
|
||||
auto curr_time = std::chrono::system_clock::now();
|
||||
|
@ -3889,6 +3920,113 @@ void GUI_App::set_skip_version(bool skip)
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::show_check_privacy_dlg(wxCommandEvent& evt)
|
||||
{
|
||||
int online_login = evt.GetInt();
|
||||
PrivacyUpdateDialog privacy_dlg(this->mainframe, wxID_ANY, _L("Privacy Policy"));
|
||||
privacy_dlg.Bind(EVT_PRIVACY_UPDATE_CONFIRM, [this, online_login](wxCommandEvent &e) {
|
||||
app_config->set("privacy_version", privacy_version_info.version_str);
|
||||
app_config->set_bool("privacy_update_checked", true);
|
||||
app_config->save();
|
||||
request_user_handle(online_login);
|
||||
});
|
||||
privacy_dlg.Bind(EVT_PRIVACY_UPDATE_CANCEL, [this](wxCommandEvent &e) {
|
||||
app_config->set_bool("privacy_update_checked", false);
|
||||
app_config->save();
|
||||
if (m_agent) {
|
||||
m_agent->user_logout();
|
||||
}
|
||||
});
|
||||
|
||||
privacy_dlg.set_text(privacy_version_info.description);
|
||||
privacy_dlg.on_show();
|
||||
}
|
||||
|
||||
void GUI_App::on_show_check_privacy_dlg(int online_login)
|
||||
{
|
||||
auto evt = new wxCommandEvent(EVT_CHECK_PRIVACY_SHOW);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
}
|
||||
|
||||
bool GUI_App::check_privacy_update()
|
||||
{
|
||||
if (privacy_version_info.version_str.empty() || privacy_version_info.description.empty()
|
||||
|| privacy_version_info.url.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string local_privacy_ver = app_config->get("privacy_version");
|
||||
auto curr_version = Semver::parse(local_privacy_ver);
|
||||
auto remote_version = Semver::parse(privacy_version_info.version_str);
|
||||
if (curr_version && remote_version) {
|
||||
if (*remote_version > *curr_version || app_config->get("privacy_update_checked") != "true") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GUI_App::on_check_privacy_update(wxCommandEvent& evt)
|
||||
{
|
||||
int online_login = evt.GetInt();
|
||||
bool result = check_privacy_update();
|
||||
if (result)
|
||||
on_show_check_privacy_dlg(online_login);
|
||||
else
|
||||
request_user_handle(online_login);
|
||||
}
|
||||
|
||||
void GUI_App::check_privacy_version(int online_login)
|
||||
{
|
||||
update_http_extra_header();
|
||||
std::string query_params = "?policy/privacy=00.00.00.00";
|
||||
std::string url = get_http_url(app_config->get_country_code()) + query_params;
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
|
||||
http.header("accept", "application/json")
|
||||
.timeout_connect(TIMEOUT_CONNECT)
|
||||
.timeout_max(TIMEOUT_RESPONSE)
|
||||
.on_complete([this, online_login](std::string body, unsigned) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("message")) {
|
||||
if (j["message"].get<std::string>() == "success") {
|
||||
if (j.contains("resources")) {
|
||||
for (auto it = j["resources"].begin(); it != j["resources"].end(); it++) {
|
||||
if (it->contains("type")) {
|
||||
if ((*it)["type"] == std::string("policy/privacy")
|
||||
&& it->contains("version")
|
||||
&& it->contains("description")
|
||||
&& it->contains("url")
|
||||
&& it->contains("force_update")) {
|
||||
privacy_version_info.version_str = (*it)["version"].get<std::string>();
|
||||
privacy_version_info.description = (*it)["description"].get<std::string>();
|
||||
privacy_version_info.url = (*it)["url"].get<std::string>();
|
||||
privacy_version_info.force_upgrade = (*it)["force_update"].get<bool>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CallAfter([this, online_login]() {
|
||||
auto evt = new wxCommandEvent(EVT_CHECK_PRIVACY_VER);
|
||||
evt->SetInt(online_login);
|
||||
wxQueueEvent(this, evt);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
request_user_handle(online_login);
|
||||
}
|
||||
})
|
||||
.on_error([this, online_login](std::string body, std::string error, unsigned int status) {
|
||||
request_user_handle(online_login);
|
||||
BOOST_LOG_TRIVIAL(error) << "check privacy version error" << body;
|
||||
}).perform();
|
||||
}
|
||||
|
||||
void GUI_App::no_new_version()
|
||||
{
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION);
|
||||
|
|
|
@ -280,6 +280,7 @@ private:
|
|||
ZUserLogin* login_dlg { nullptr };
|
||||
|
||||
VersionInfo version_info;
|
||||
VersionInfo privacy_version_info;
|
||||
static std::string version_display;
|
||||
HMSQuery *hms_query { nullptr };
|
||||
|
||||
|
@ -395,7 +396,8 @@ public:
|
|||
void get_login_info();
|
||||
bool is_user_login();
|
||||
|
||||
void request_user_login(int online_login);
|
||||
void request_user_login(int online_login = 0);
|
||||
void request_user_handle(int online_login = 0);
|
||||
void request_user_logout();
|
||||
int request_user_unbind(std::string dev_id);
|
||||
std::string handle_web_request(std::string cmd);
|
||||
|
@ -410,6 +412,7 @@ public:
|
|||
void on_http_error(wxCommandEvent &evt);
|
||||
void on_set_selected_machine(wxCommandEvent& evt);
|
||||
void on_user_login(wxCommandEvent &evt);
|
||||
void on_user_login_handle(wxCommandEvent& evt);
|
||||
void enable_user_preset_folder(bool enable);
|
||||
|
||||
// BBS
|
||||
|
@ -434,6 +437,12 @@ public:
|
|||
void start_http_server();
|
||||
void stop_http_server();
|
||||
|
||||
void on_show_check_privacy_dlg(int online_login = 0);
|
||||
void show_check_privacy_dlg(wxCommandEvent& evt);
|
||||
void on_check_privacy_update(wxCommandEvent &evt);
|
||||
bool check_privacy_update();
|
||||
void check_privacy_version(int online_login = 0);
|
||||
|
||||
static bool catch_error(std::function<void()> cb, const std::string& err);
|
||||
|
||||
void persist_window_geometry(wxTopLevelWindow *window, bool default_maximized = false);
|
||||
|
@ -593,6 +602,7 @@ private:
|
|||
//BBS set extra header for http request
|
||||
std::map<std::string, std::string> get_extra_header();
|
||||
void init_http_extra_header();
|
||||
void update_http_extra_header();
|
||||
bool check_older_app_config(Semver current_version, bool backup);
|
||||
void copy_older_config();
|
||||
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
||||
|
|
|
@ -71,6 +71,9 @@ namespace GUI {
|
|||
wxDEFINE_EVENT(EVT_SELECT_TAB, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_HTTP_ERROR, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_USER_LOGIN, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_USER_LOGIN_HANDLE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_CHECK_PRIVACY_VER, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_CHECK_PRIVACY_SHOW, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_SHOW_IP_DIALOG, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_SET_SELECTED_MACHINE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_UPDATE_PRESET_CB, SimpleEvent);
|
||||
|
|
|
@ -373,6 +373,9 @@ public:
|
|||
|
||||
wxDECLARE_EVENT(EVT_HTTP_ERROR, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_USER_LOGIN, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_USER_LOGIN_HANDLE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_CHECK_PRIVACY_VER, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_CHECK_PRIVACY_SHOW, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_SHOW_IP_DIALOG, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_SET_SELECTED_MACHINE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_UPDATE_PRESET_CB, SimpleEvent);
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
#include "PrivacyUpdateDialog.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
#include <wx/dcgraph.h>
|
||||
#include <slic3r/GUI/I18N.hpp>
|
||||
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_PRIVACY_UPDATE_CONFIRM, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_PRIVACY_UPDATE_CANCEL, wxCommandEvent);
|
||||
|
||||
static std::string url_encode(const std::string& value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
PrivacyUpdateDialog::PrivacyUpdateDialog(wxWindow* parent, wxWindowID id, const wxString& title, enum ButtonStyle btn_style, const wxPoint& pos, const wxSize& size, long style)
|
||||
:DPIDialog(parent, id, title, pos, size, style)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(540), 1));
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
wxBoxSizer* m_sizer_right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_sizer_right->Add(0, 0, 1, wxTOP, FromDIP(15));
|
||||
//webview
|
||||
m_vebview_release_note = CreateTipView(this);
|
||||
if (m_vebview_release_note == nullptr) {
|
||||
wxLogError("Could not init m_browser");
|
||||
return;
|
||||
}
|
||||
m_vebview_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
|
||||
m_vebview_release_note->SetSize(wxSize(FromDIP(540), FromDIP(340)));
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(540), FromDIP(340)));
|
||||
|
||||
fs::path ph(data_dir());
|
||||
ph /= "resources/tooltip/privacyupdate.html";
|
||||
if (!fs::exists(ph)) {
|
||||
ph = resources_dir();
|
||||
ph /= "tooltip/privacyupdate.html";
|
||||
}
|
||||
auto url = ph.string();
|
||||
std::replace(url.begin(), url.end(), '\\', '/');
|
||||
url = "file:///" + url;
|
||||
m_vebview_release_note->LoadURL(from_u8(url));
|
||||
m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15));
|
||||
|
||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(220, 220, 220), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
m_vebview_release_note->Bind(wxEVT_WEBVIEW_LOADED, [this](auto& e) {
|
||||
#else
|
||||
m_vebview_release_note->Bind(wxEVT_WEBVIEW_NAVIGATED, [this](auto& e) {
|
||||
#endif
|
||||
if (!m_mkdown_text.empty()) {
|
||||
ShowReleaseNote(m_mkdown_text);
|
||||
}
|
||||
});
|
||||
|
||||
m_button_ok = new Button(this, _L("Accept"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour("#FFFFFE"));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(wxSize(-1, FromDIP(36)));
|
||||
m_button_ok->SetMinSize(wxSize(-1, FromDIP(36)));
|
||||
m_button_ok->SetCornerRadius(FromDIP(3));
|
||||
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_PRIVACY_UPDATE_CONFIRM, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
m_button_cancel = new Button(this, _L("Log Out"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(*wxWHITE);
|
||||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(-1, FromDIP(36)));
|
||||
m_button_cancel->SetMinSize(wxSize(-1, FromDIP(36)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(3));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_PRIVACY_UPDATE_CANCEL);
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) {e.Veto(); });
|
||||
|
||||
if (btn_style != CONFIRM_AND_CANCEL)
|
||||
m_button_cancel->Hide();
|
||||
else
|
||||
m_button_cancel->Show();
|
||||
|
||||
sizer_button->Add(m_button_cancel, 1, wxALL | wxEXPAND, FromDIP(10));
|
||||
sizer_button->Add(m_button_ok, 1, wxALL | wxEXPAND, FromDIP(10));
|
||||
|
||||
m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(5));
|
||||
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(10));
|
||||
|
||||
m_sizer_main->Add(m_sizer_right, 0, wxBOTTOM | wxEXPAND, FromDIP(5));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
CenterOnParent();
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::OnLoaded(wxWebViewEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::OnTitleChanged(wxWebViewEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
void PrivacyUpdateDialog::OnError(wxWebViewEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
wxWebView* PrivacyUpdateDialog::CreateTipView(wxWindow* parent)
|
||||
{
|
||||
wxWebView* tipView = WebView::CreateWebView(parent, "");
|
||||
tipView->Bind(wxEVT_WEBVIEW_LOADED, &PrivacyUpdateDialog::OnLoaded, this);
|
||||
tipView->Bind(wxEVT_WEBVIEW_NAVIGATED, &PrivacyUpdateDialog::OnTitleChanged, this);
|
||||
tipView->Bind(wxEVT_WEBVIEW_ERROR, &PrivacyUpdateDialog::OnError, this);
|
||||
return tipView;
|
||||
}
|
||||
|
||||
bool PrivacyUpdateDialog::ShowReleaseNote(std::string content)
|
||||
{
|
||||
auto script = "window.showMarkdown('" + url_encode(content) + "', true);";
|
||||
RunScript(script);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::RunScript(std::string script)
|
||||
{
|
||||
WebView::RunScript(m_vebview_release_note, script);
|
||||
script.clear();
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::on_show()
|
||||
{
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
this->ShowModal();
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::on_hide()
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::update_btn_label(wxString ok_btn_text, wxString cancel_btn_text)
|
||||
{
|
||||
m_button_ok->SetLabel(ok_btn_text);
|
||||
m_button_cancel->SetLabel(cancel_btn_text);
|
||||
rescale();
|
||||
}
|
||||
|
||||
PrivacyUpdateDialog::~PrivacyUpdateDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
rescale();
|
||||
}
|
||||
|
||||
void PrivacyUpdateDialog::rescale()
|
||||
{
|
||||
m_button_ok->Rescale();
|
||||
m_button_cancel->Rescale();
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef slic3r_GUI_PrivacyUpdateDialog_hpp_
|
||||
#define slic3r_GUI_PrivacyUpdateDialog_hpp_
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/WebView.hpp"
|
||||
#include <wx/webview.h>
|
||||
#include <wx/simplebook.h>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDECLARE_EVENT(EVT_PRIVACY_UPDATE_CONFIRM, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_PRIVACY_UPDATE_CANCEL, wxCommandEvent);
|
||||
|
||||
class PrivacyUpdateDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
enum ButtonStyle {
|
||||
ONLY_CONFIRM = 0,
|
||||
CONFIRM_AND_CANCEL = 1,
|
||||
MAX_STYLE_NUM = 2
|
||||
};
|
||||
PrivacyUpdateDialog(
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxEmptyString,
|
||||
enum ButtonStyle btn_style = CONFIRM_AND_CANCEL,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxPD_APP_MODAL| wxCAPTION
|
||||
);
|
||||
wxWebView* CreateTipView(wxWindow* parent);
|
||||
void OnLoaded(wxWebViewEvent& event);
|
||||
void OnTitleChanged(wxWebViewEvent& event);
|
||||
void OnError(wxWebViewEvent& event);
|
||||
bool ShowReleaseNote(std::string content);
|
||||
void RunScript(std::string script);
|
||||
void set_text(std::string str) { m_mkdown_text = str; };
|
||||
void on_show();
|
||||
void on_hide();
|
||||
void update_btn_label(wxString ok_btn_text, wxString cancel_btn_text);
|
||||
void rescale();
|
||||
~PrivacyUpdateDialog();
|
||||
void on_dpi_changed(const wxRect& suggested_rect);
|
||||
|
||||
wxBoxSizer* m_sizer_main;
|
||||
wxWebView* m_vebview_release_note{ nullptr };
|
||||
Label* m_staticText_release_note{ nullptr };
|
||||
Button* m_button_ok;
|
||||
Button* m_button_cancel;
|
||||
std::string m_mkdown_text;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
|
@ -302,7 +302,7 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
|||
|
||||
|
||||
fs::path ph(data_dir());
|
||||
ph /= "resources/tooltip/common/releasenote.html";
|
||||
ph /= "resources/tooltip/releasenote.html";
|
||||
if (!fs::exists(ph)) {
|
||||
ph = resources_dir();
|
||||
ph /= "tooltip/releasenote.html";
|
||||
|
@ -526,7 +526,7 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, cons
|
|||
SetBackgroundColour(*wxWHITE);
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(400), 1));
|
||||
m_line_top->SetBackgroundColour(*wxWHITE);
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
|
@ -713,7 +713,7 @@ ConfirmBeforeSendDialog::ConfirmBeforeSendDialog(wxWindow* parent, wxWindowID id
|
|||
SetBackgroundColour(*wxWHITE);
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(400), 1));
|
||||
m_line_top->SetBackgroundColour(*wxWHITE);
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
|
|
Loading…
Reference in New Issue