Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.hk>2019-02-18 16:03:02 +0300
committerVojtech Kral <vojtech@kral.hk>2019-02-19 16:49:17 +0300
commit08f1459ab75e8a9fbd0986444e4734f51a93cd2f (patch)
tree1b55b2b6f3a17210db4e0946e2d2dec2c628ea3c /src/slic3r/GUI/PrintHostDialogs.cpp
parent35b4777e0eb7f5f110fe76f714d08c5e14432162 (diff)
Printhost: Persist upload path & start print checkbox (re-add lost code)
Fixes #1219 Fixes #1004 Fixes #1106 Fixes #1678
Diffstat (limited to 'src/slic3r/GUI/PrintHostDialogs.cpp')
-rw-r--r--src/slic3r/GUI/PrintHostDialogs.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp
index d6b5f3469..6dfa11889 100644
--- a/src/slic3r/GUI/PrintHostDialogs.cpp
+++ b/src/slic3r/GUI/PrintHostDialogs.cpp
@@ -15,6 +15,7 @@
#include "GUI.hpp"
#include "GUI_App.hpp"
+#include "AppConfig.hpp"
#include "MsgDialog.hpp"
#include "I18N.hpp"
#include "../Utils/PrintHost.hpp"
@@ -24,10 +25,12 @@ namespace fs = boost::filesystem;
namespace Slic3r {
namespace GUI {
+static const char *CONFIG_KEY_PATH = "printhost_path";
+static const char *CONFIG_KEY_PRINT = "printhost_print";
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path)
: MsgDialog(nullptr, _(L("Send G-Code to printer host")), _(L("Upload to Printer Host with the following filename:")), wxID_NONE)
- , txt_filename(new wxTextCtrl(this, wxID_ANY, path.filename().wstring()))
+ , txt_filename(new wxTextCtrl(this, wxID_ANY))
, box_print(new wxCheckBox(this, wxID_ANY, _(L("Start printing after upload"))))
{
#ifdef __APPLE__
@@ -44,11 +47,30 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path)
btn_sizer->Add(CreateStdDialogButtonSizer(wxOK | wxCANCEL));
- txt_filename->SetFocus();
+ const AppConfig *app_config = wxGetApp().app_config;
+ box_print->SetValue(app_config->get("recent", CONFIG_KEY_PRINT) == "1");
+
+ wxString recent_path = from_u8(app_config->get("recent", CONFIG_KEY_PATH));
+ if (recent_path.Length() > 0 && recent_path[recent_path.Length() - 1] != '/') {
+ recent_path += '/';
+ }
+ const auto recent_path_len = recent_path.Length();
+ recent_path += path.filename().wstring();
wxString stem(path.stem().wstring());
- txt_filename->SetSelection(0, stem.Length());
+ const auto stem_len = stem.Length();
+
+ txt_filename->SetValue(recent_path);
+ txt_filename->SetFocus();
Fit();
+
+ Bind(wxEVT_SHOW, [=](const wxShowEvent &) {
+ // Another similar case where the function only works with EVT_SHOW + CallAfter,
+ // this time on Mac.
+ CallAfter([=]() {
+ txt_filename->SetSelection(recent_path_len, recent_path_len + stem_len);
+ });
+ });
}
fs::path PrintHostSendDialog::filename() const
@@ -61,6 +83,24 @@ bool PrintHostSendDialog::start_print() const
return box_print->GetValue();
}
+void PrintHostSendDialog::EndModal(int ret)
+{
+ if (ret == wxID_OK) {
+ // Persist path and print settings
+ wxString path = txt_filename->GetValue();
+ int last_slash = path.Find('/', true);
+ if (last_slash != wxNOT_FOUND) {
+ path = path.SubString(0, last_slash);
+ wxGetApp().app_config->set("recent", CONFIG_KEY_PATH, into_u8(path));
+ }
+
+ bool print = box_print->GetValue();
+ GUI::get_app_config()->set("recent", CONFIG_KEY_PRINT, print ? "1" : "0");
+ }
+
+ MsgDialog::EndModal(ret);
+}
+
wxDEFINE_EVENT(EVT_PRINTHOST_PROGRESS, PrintHostQueueDialog::Event);