mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Ref T28, settings for updater
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f12b69bb87
commit
f4af5e6cc1
@@ -10,6 +10,12 @@
|
||||
#include "settingsmodelcomponent.h"
|
||||
#include "ui_settingsmodelcomponent.h"
|
||||
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QValidator>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -19,9 +25,43 @@ namespace BlackGui
|
||||
ui(new Ui::CSettingsModelComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->le_ConsolidateSecs->setValidator(new QIntValidator(0, TBackgroundConsolidation::maxSecs(), ui->le_ConsolidateSecs));
|
||||
|
||||
this->cacheChanged();
|
||||
connect(ui->le_ConsolidateSecs, &QLineEdit::returnPressed, this, &CSettingsModelComponent::consolidationEntered);
|
||||
static QString lbl("Consolidate (%1-%2s):");
|
||||
ui->lbl_Consolidate->setText(lbl.arg(TBackgroundConsolidation::minSecs()).arg(TBackgroundConsolidation::maxSecs()));
|
||||
}
|
||||
|
||||
CSettingsModelComponent::~CSettingsModelComponent()
|
||||
{ }
|
||||
|
||||
int CSettingsModelComponent::getBackgroundUpdaterIntervallSecs() const
|
||||
{
|
||||
const QString v = ui->le_ConsolidateSecs->text().trimmed();
|
||||
if (v.isEmpty()) { return -1; }
|
||||
bool ok = false;
|
||||
const int secs = v.toInt(&ok);
|
||||
return ok ? secs : -1;
|
||||
}
|
||||
|
||||
void CSettingsModelComponent::consolidationEntered()
|
||||
{
|
||||
int v = this->getBackgroundUpdaterIntervallSecs();
|
||||
if (v < TBackgroundConsolidation::minSecs()) v = -1;
|
||||
|
||||
const CStatusMessage m = m_consolidationSetting.setAndSave(v);
|
||||
CLogMessage::preformatted(m);
|
||||
this->cacheChanged();
|
||||
}
|
||||
|
||||
void CSettingsModelComponent::cacheChanged()
|
||||
{
|
||||
const int v = m_consolidationSetting.get();
|
||||
const bool on = v > 0;
|
||||
const QString s = on ? QString::number(v) : "";
|
||||
ui->le_ConsolidateSecs->setText(s);
|
||||
ui->comp_Led->setOn(on);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user