Automatically start background updater

Ref T28
This commit is contained in:
Klaus Basan
2017-07-03 14:08:31 +02:00
committed by Mathew Sutcliffe
parent c790e344ac
commit e2c43a688b
4 changed files with 11 additions and 4 deletions

View File

@@ -89,6 +89,7 @@ namespace BlackCore
{ {
if (!CThreadUtils::isCurrentThreadObjectThread(this)) if (!CThreadUtils::isCurrentThreadObjectThread(this))
{ {
// shift in correct thread
QTimer::singleShot(0, this, [this, updateTimeSecs] { this->startUpdating(updateTimeSecs); }); QTimer::singleShot(0, this, [this, updateTimeSecs] { this->startUpdating(updateTimeSecs); });
return; return;
} }

View File

@@ -30,8 +30,11 @@ namespace BlackGui
this->cacheChanged(); this->cacheChanged();
connect(ui->le_ConsolidateSecs, &QLineEdit::returnPressed, this, &CSettingsModelComponent::consolidationEntered); connect(ui->le_ConsolidateSecs, &QLineEdit::returnPressed, this, &CSettingsModelComponent::consolidationEntered);
static QString lbl("Consolidate (%1-%2s):"); const QString lbl("Consolidate (%1-%2s):");
ui->lbl_Consolidate->setText(lbl.arg(TBackgroundConsolidation::minSecs()).arg(TBackgroundConsolidation::maxSecs())); ui->lbl_Consolidate->setText(lbl.arg(TBackgroundConsolidation::minSecs()).arg(TBackgroundConsolidation::maxSecs()));
// start updater if not yet done
QTimer::singleShot(2000, this, &CSettingsModelComponent::consolidationEntered);
} }
CSettingsModelComponent::~CSettingsModelComponent() CSettingsModelComponent::~CSettingsModelComponent()
@@ -54,7 +57,7 @@ namespace BlackGui
void CSettingsModelComponent::consolidationEntered() void CSettingsModelComponent::consolidationEntered()
{ {
int v = this->getBackgroundUpdaterIntervallSecs(); int v = this->getBackgroundUpdaterIntervallSecs();
if (v < TBackgroundConsolidation::minSecs()) v = -1; if (v < TBackgroundConsolidation::minSecs()) { v = -1; }
const CStatusMessage m = m_consolidationSetting.setAndSave(v); const CStatusMessage m = m_consolidationSetting.setAndSave(v);
CLogMessage::preformatted(m); CLogMessage::preformatted(m);

View File

@@ -44,7 +44,7 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CSettingsModelComponent> ui; QScopedPointer<Ui::CSettingsModelComponent> ui;
BlackMisc::CSetting<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time BlackMisc::CSetting<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time
BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr; BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr; //!< externally (i.e. other component) provided existing updater
//! Consolidation time entered //! Consolidation time entered
void consolidationEntered(); void consolidationEntered();

View File

@@ -150,7 +150,10 @@ void CSwiftData::initMenu()
void CSwiftData::performGracefulShutdown() void CSwiftData::performGracefulShutdown()
{ {
// void if (this->m_updater)
{
this->m_updater->gracefulShutdown();
}
} }
void CSwiftData::consolidationSettingChanged() void CSwiftData::consolidationSettingChanged()