Add suspend if no recent input to computing preferences.

This commit is contained in:
Vulpine05 2021-12-28 13:50:48 -06:00
parent 8b7078ce74
commit cace209c23
3 changed files with 37 additions and 0 deletions

View File

@ -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)) {

View File

@ -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"));

View File

@ -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;