mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-28 13:22:06 +00:00
fix: add resolution for undefined conflicts
This commit is contained in:
@@ -4965,13 +4965,17 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
|
||||
break;
|
||||
case -3:
|
||||
text = _u8L("Cloud sync conflict: a preset with the same name was previously deleted from the cloud.\n"
|
||||
"Do you want to push this new copy to the cloud?");
|
||||
"Delete will delete your local preset. Force push overwrites it with your local preset.");
|
||||
break;
|
||||
default:
|
||||
text = _u8L("Cloud sync conflict: there was an unexpected or unidentified preset conflict.\n"
|
||||
"Pull downloads the cloud copy. Force push overwrites it with your local preset.");
|
||||
break;
|
||||
};
|
||||
|
||||
plater->get_notification_manager()->push_orca_sync_conflict_notification(
|
||||
text,
|
||||
conflict_code == -3 ? nullptr : std::function<bool(wxEvtHandler*)>{[this](wxEvtHandler*) {
|
||||
text, conflict_code,
|
||||
[this](wxEvtHandler*) {
|
||||
// Runs on the GUI thread (on_http_error is a queued wx event); restart_sync_user_preset()
|
||||
// already joins the old sync thread off the UI thread, so no extra thread is needed here.
|
||||
if (is_closing() || !m_agent || !preset_bundle)
|
||||
@@ -4979,7 +4983,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
|
||||
BOOST_LOG_TRIVIAL(info) << "Pulling Orca Cloud settings to resolve sync conflict.";
|
||||
restart_sync_user_preset();
|
||||
return true;
|
||||
}},
|
||||
},
|
||||
[this, conflict_setting_id](wxEvtHandler*) {
|
||||
if (mainframe == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -2416,18 +2416,12 @@ void NotificationManager::OrcaSyncConflictNotification::render_text(ImGuiWrapper
|
||||
}
|
||||
|
||||
const float action_y = starting_y + m_endlines.size() * shift_y;
|
||||
std::string pull_text = "";
|
||||
float padding = 0.f;
|
||||
|
||||
if (m_pull_callback) {
|
||||
pull_text = _u8L("Pull");
|
||||
padding = ImGui::CalcTextSize((pull_text + " ").c_str()).x;
|
||||
render_hyperlink_action(imgui, x_offset, action_y, pull_text, "##orca_sync_pull",
|
||||
[this] { if (m_pull_callback && m_pull_callback(m_evt_handler)) close(); });
|
||||
}
|
||||
const std::string pull_text = conflict_code == -3 ? _u8L("Delete") : _u8L("Pull");
|
||||
render_hyperlink_action(imgui, x_offset, action_y, pull_text, "##orca_sync_pull",
|
||||
[this] { if (m_pull_callback && m_pull_callback(m_evt_handler)) close(); });
|
||||
if (m_force_push_callback) {
|
||||
const std::string force_push_text = _u8L("Force push");
|
||||
const float force_x = x_offset + padding;
|
||||
const float force_x = x_offset + ImGui::CalcTextSize((pull_text + " ").c_str()).x;
|
||||
render_hyperlink_action(imgui, force_x, action_y, force_push_text, "##orca_sync_force_push",
|
||||
[this] { if (m_force_push_callback && m_force_push_callback(m_evt_handler)) close(); });
|
||||
}
|
||||
@@ -2443,13 +2437,14 @@ void NotificationManager::push_shared_profiles_notification(const std::string& e
|
||||
}
|
||||
|
||||
void NotificationManager::push_orca_sync_conflict_notification(const std::string& text,
|
||||
int conflict_code,
|
||||
std::function<bool(wxEvtHandler*)> pull_callback,
|
||||
std::function<bool(wxEvtHandler*)> force_push_callback)
|
||||
{
|
||||
close_notification_of_type(NotificationType::OrcaSyncConflict);
|
||||
NotificationData data{ NotificationType::OrcaSyncConflict, NotificationLevel::WarningNotificationLevel, 0, text };
|
||||
push_notification_data(std::make_unique<NotificationManager::OrcaSyncConflictNotification>(
|
||||
data, m_id_provider, m_evt_handler, std::move(pull_callback), std::move(force_push_callback)), 0);
|
||||
data, m_id_provider, m_evt_handler, std::move(pull_callback), std::move(force_push_callback), conflict_code), 0);
|
||||
}
|
||||
|
||||
void NotificationManager::push_download_URL_progress_notification(size_t id, const std::string& text, std::function<bool(DownloaderUserAction, int)> user_action_callback)
|
||||
|
||||
@@ -279,6 +279,7 @@ public:
|
||||
// Shared profiles available for selected printer
|
||||
void push_shared_profiles_notification(const std::string& explore_url);
|
||||
void push_orca_sync_conflict_notification(const std::string& text,
|
||||
int conflict_code,
|
||||
std::function<bool(wxEvtHandler*)> pull_callback,
|
||||
std::function<bool(wxEvtHandler*)> force_push_callback);
|
||||
|
||||
@@ -905,10 +906,12 @@ private:
|
||||
public:
|
||||
OrcaSyncConflictNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler,
|
||||
std::function<bool(wxEvtHandler*)> pull_callback,
|
||||
std::function<bool(wxEvtHandler*)> force_push_callback)
|
||||
std::function<bool(wxEvtHandler*)> force_push_callback,
|
||||
int conflict_code)
|
||||
: PopNotification(n, id_provider, evt_handler)
|
||||
, m_pull_callback(std::move(pull_callback))
|
||||
, m_force_push_callback(std::move(force_push_callback))
|
||||
, conflict_code(conflict_code)
|
||||
{
|
||||
m_multiline = true;
|
||||
}
|
||||
@@ -920,6 +923,7 @@ private:
|
||||
|
||||
std::function<bool(wxEvtHandler*)> m_pull_callback;
|
||||
std::function<bool(wxEvtHandler*)> m_force_push_callback;
|
||||
int conflict_code;
|
||||
};
|
||||
class SlicingProgressNotification;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user