From cace209c23b1292d3beac549bdbb5632b7c42c1f Mon Sep 17 00:00:00 2001 From: Vulpine05 Date: Tue, 28 Dec 2021 13:50:48 -0600 Subject: [PATCH] Add suspend if no recent input to computing preferences. --- clientgui/DlgAdvPreferences.cpp | 14 ++++++++++++++ clientgui/DlgAdvPreferencesBase.cpp | 21 +++++++++++++++++++++ clientgui/DlgAdvPreferencesBase.h | 2 ++ 3 files changed, 37 insertions(+) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index cfed8923f3..ef4ba887ba 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -128,6 +128,7 @@ void CDlgAdvPreferences::SetValidators() { m_txtProcUseCPUTime->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtProcIdleFor->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); + m_txtNoRecentInput->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtMaxLoad->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtNetConnectInterval->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); @@ -313,6 +314,7 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { m_txtProcIdleFor->Disable(); } + DisplayValue(prefs.suspend_if_no_recent_input, m_txtNoRecentInput); m_chkMaxLoad->SetValue(prefs.suspend_cpu_usage > 0.0); DisplayValue(prefs.suspend_cpu_usage, m_txtMaxLoad, m_chkMaxLoad); @@ -446,6 +448,12 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.idle_time_to_run=true; } + // + m_txtNoRecentInput->GetValue().ToDouble(&td); + prefs.suspend_if_no_recent_input = RoundToHundredths(td); + mask.suspend_if_no_recent_input = true; + + // if (m_chkMaxLoad->IsChecked()) { m_txtMaxLoad->GetValue().ToDouble(&td); prefs.suspend_cpu_usage=RoundToHundredths(td); @@ -686,6 +694,12 @@ bool CDlgAdvPreferences::ValidateInput() { } } + buffer = m_txtNoRecentInput->GetValue(); + if (!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { + ShowErrorMessage(invMsgLimit100, m_txtNoRecentInput); + return false; + } + if (m_chkMaxLoad->IsChecked()) { buffer = m_txtMaxLoad->GetValue(); if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index b8d2f500de..1b33b9e35e 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -335,6 +335,27 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) addNewRowToSizer(suspendComputingBoxSizer, ProcIdleForTT, staticText24, m_txtProcIdleFor, staticText25); + // suspend after max idle time + wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); + + wxStaticText* staticText27 = new wxStaticText( + suspendComputingStaticBox, ID_DEFAULT, + _("Suspend when no mouse/keyboard input in last"), + wxDefaultPosition, wxDefaultSize, 0 + ); + + wxStaticText* staticText28 = new wxStaticText( + suspendComputingStaticBox, ID_DEFAULT, + _("minutes"), + wxDefaultPosition, wxDefaultSize, 0 + ); + + m_txtNoRecentInput = new wxTextCtrl( + suspendComputingStaticBox, ID_TXTNORECENTINPUT, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT + ); + + addNewRowToSizer(suspendComputingBoxSizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); + // max CPU load wxString MaxLoadCheckBoxText = wxEmptyString; MaxLoadCheckBoxText.Printf(_("Suspend when non-BOINC CPU usage is above")); diff --git a/clientgui/DlgAdvPreferencesBase.h b/clientgui/DlgAdvPreferencesBase.h index aaaf039fd3..416bde5cd9 100644 --- a/clientgui/DlgAdvPreferencesBase.h +++ b/clientgui/DlgAdvPreferencesBase.h @@ -118,6 +118,7 @@ enum { ID_TXTPROCFRIDAYSTART, ID_TXTPROCFRIDAYSTOP, ID_TXTPROCIDLEFOR, + ID_TXTNORECENTINPUT, ID_TXTPROCMONDAYSTART, ID_TXTPROCMONDAYSTOP, ID_TXTPROCSATURDAYSTART, @@ -157,6 +158,7 @@ protected: wxCheckBox* m_chkProcInUse; wxCheckBox* m_chkGPUProcInUse; wxTextCtrl* m_txtProcIdleFor; + wxTextCtrl* m_txtNoRecentInput; wxCheckBox* m_chkMaxLoad; wxTextCtrl* m_txtMaxLoad; wxCheckBox* m_chkNetEveryDay;