ENH: auto stop liveview when print idle
Change-Id: I06dcc2a6ae469df8c39c1dc6c8626f66bc778f81 Jira: none
This commit is contained in:
parent
69ad831570
commit
06bbd235b8
|
@ -321,6 +321,10 @@ void AppConfig::set_defaults()
|
|||
set_bool("backup_switch", true);
|
||||
}
|
||||
|
||||
if (get("liveview", "auto_stop_liveview").empty()) {
|
||||
set("liveview", "auto_stop_liveview", true);
|
||||
}
|
||||
|
||||
if (get("backup_interval").empty()) {
|
||||
set("backup_interval", "10");
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
wxSize size = m_media_ctrl->GetVideoSize();
|
||||
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i", size.x, size.y));
|
||||
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i LD:%i", size.x, size.y, m_load_duration));
|
||||
#endif
|
||||
wxString str = e.GetString();
|
||||
m_stat.clear();
|
||||
|
@ -183,9 +183,20 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
|||
agent->get_camera_url(machine, [](auto) {});
|
||||
m_last_user_play = wxDateTime::Now();
|
||||
}
|
||||
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING && SecondsSinceLastInput() > 900) { // 15 minutes
|
||||
m_next_retry = wxDateTime();
|
||||
Stop(_L("Temporarily closed because there is no operating for a long time."));
|
||||
if (m_last_state == wxMediaState::wxMEDIASTATE_PLAYING) {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
if (m_play_timer <= now) {
|
||||
m_play_timer = now + 1min;
|
||||
auto obj = wxGetApp().getDeviceManager()->get_selected_machine();
|
||||
if (obj && obj->is_in_printing()) {
|
||||
m_print_idle = 0;
|
||||
} else if (++m_print_idle >= 5) {
|
||||
auto close = wxGetApp().app_config->get("liveview", "auto_stop_liveview") == "true";
|
||||
if (close) {
|
||||
Stop(_L("Temporarily closed because there is no printing for a long time."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -323,6 +334,7 @@ void MediaPlayCtrl::Play()
|
|||
|
||||
m_label_stat->SetLabel({});
|
||||
SetStatus(_L("Initializing..."));
|
||||
m_play_timer = std::chrono::system_clock::now();
|
||||
|
||||
if (agent) {
|
||||
agent->get_camera_url(m_machine,
|
||||
|
@ -627,6 +639,10 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
|||
m_last_state = state;
|
||||
m_failed_code = 0;
|
||||
SetStatus(_L("Playing..."), false);
|
||||
m_print_idle = 0;
|
||||
auto now = std::chrono::system_clock::now();
|
||||
m_load_duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_play_timer).count();
|
||||
m_play_timer = now + 1min;
|
||||
|
||||
// track event
|
||||
json j;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
|
@ -101,6 +102,9 @@ private:
|
|||
std::set<int> m_last_failed_codes;
|
||||
wxDateTime m_last_user_play;
|
||||
wxDateTime m_next_retry;
|
||||
std::chrono::system_clock::time_point m_play_timer;
|
||||
int m_print_idle = 0;
|
||||
int m_load_duration = 0;
|
||||
|
||||
::Button *m_button_play;
|
||||
::Label * m_label_stat;
|
||||
|
|
|
@ -630,8 +630,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
|||
auto checkbox = new ::CheckBox(parent);
|
||||
if (param == "privacyuse") {
|
||||
checkbox->SetValue((app_config->get("firstguide", param) == "true") ? true : false);
|
||||
}
|
||||
else {
|
||||
} else if (param == "auto_stop_liveview") {
|
||||
checkbox->SetValue((app_config->get("liveview", param) == "true") ? true : false);
|
||||
} else {
|
||||
checkbox->SetValue((app_config->get(param) == "true") ? true : false);
|
||||
}
|
||||
|
||||
|
@ -661,6 +662,9 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
|
|||
}
|
||||
app_config->save();
|
||||
}
|
||||
else if (param == "auto_stop_liveview") {
|
||||
app_config->set("liveview", param, checkbox->GetValue());
|
||||
}
|
||||
else {
|
||||
app_config->set_bool(param, checkbox->GetValue());
|
||||
app_config->save();
|
||||
|
@ -1077,8 +1081,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
auto item_backup_interval = create_item_backup_input(_L("every"), page, _L("The peroid of backup in seconds."), "backup_interval");
|
||||
|
||||
//downloads
|
||||
auto title_downloads = create_item_title(_L("Downloads"), page, _L("Downloads"));
|
||||
auto title_media = create_item_title(_L("Media"), page, _L("Media"));
|
||||
auto item_downloads = create_item_downloads(page,50,"download_path");
|
||||
auto item_auto_stop_liveview = create_item_checkbox(_L("Auto Stop Liveview"), page, _L("Automatically close the video after printing."), 50, "auto_stop_liveview");
|
||||
|
||||
//dark mode
|
||||
#ifdef _WIN32
|
||||
|
@ -1136,8 +1141,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));
|
||||
item_backup->Add(item_backup_interval, 0, wxLEFT, 0);
|
||||
|
||||
sizer_page->Add(title_downloads, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(title_media, 0, wxTOP| wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_downloads, 0, wxEXPAND, FromDIP(3));
|
||||
sizer_page->Add(item_auto_stop_liveview, 0, wxEXPAND, FromDIP(3));
|
||||
|
||||
#ifdef _WIN32
|
||||
sizer_page->Add(title_darkmode, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
|
|
Loading…
Reference in New Issue