diff --git a/src/blackgui/components/datasettingscomponent.cpp b/src/blackgui/components/datasettingscomponent.cpp index f7d64fbed..778430431 100644 --- a/src/blackgui/components/datasettingscomponent.cpp +++ b/src/blackgui/components/datasettingscomponent.cpp @@ -11,6 +11,7 @@ #include "ui_datasettingscomponent.h" using namespace BlackGui; +using namespace BlackCore::Db; namespace BlackGui { @@ -27,5 +28,9 @@ namespace BlackGui CDataSettingsComponent::~CDataSettingsComponent() { } + void CDataSettingsComponent::setBackgroundUpdater(CBackgroundDataUpdater *updater) + { + ui->comp_ModelSettings->setBackgroundUpdater(updater); + } } // ns } // ns diff --git a/src/blackgui/components/datasettingscomponent.h b/src/blackgui/components/datasettingscomponent.h index e52b034cf..596a8447c 100644 --- a/src/blackgui/components/datasettingscomponent.h +++ b/src/blackgui/components/datasettingscomponent.h @@ -14,14 +14,13 @@ #include "blackgui/blackguiexport.h" #include "blackgui/overlaymessagesframe.h" - #include #include class QWidget; namespace Ui { class CDataSettingsComponent; } - +namespace BlackCore { namespace Db { class CBackgroundDataUpdater; }} namespace BlackGui { namespace Components @@ -38,7 +37,10 @@ namespace BlackGui explicit CDataSettingsComponent(QWidget *parent = nullptr); //! Destructor - ~CDataSettingsComponent(); + virtual ~CDataSettingsComponent(); + + //! Background updater + void setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater); private: QScopedPointer ui; diff --git a/src/blackgui/components/settingsmodelcomponent.cpp b/src/blackgui/components/settingsmodelcomponent.cpp index 1cacdd5a3..fe56fe652 100644 --- a/src/blackgui/components/settingsmodelcomponent.cpp +++ b/src/blackgui/components/settingsmodelcomponent.cpp @@ -9,7 +9,8 @@ #include "settingsmodelcomponent.h" #include "ui_settingsmodelcomponent.h" - +#include "blackgui/guiapplication.h" +#include "blackcore/db/backgrounddataupdater.h" #include "blackmisc/logmessage.h" #include @@ -45,6 +46,11 @@ namespace BlackGui return ok ? secs : -1; } + void CSettingsModelComponent::setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater) + { + m_updater = updater; + } + void CSettingsModelComponent::consolidationEntered() { int v = this->getBackgroundUpdaterIntervallSecs(); @@ -61,7 +67,12 @@ namespace BlackGui const bool on = v > 0; const QString s = on ? QString::number(v) : ""; ui->le_ConsolidateSecs->setText(s); - ui->comp_Led->setOn(on); + + const bool updater = + on && + sApp && !sApp->isShuttingDown() && + this->m_updater && this->m_updater->isEnabled(); + ui->comp_Led->setOn(updater); } } // ns } // ns diff --git a/src/blackgui/components/settingsmodelcomponent.h b/src/blackgui/components/settingsmodelcomponent.h index c0f209311..b16f1e551 100644 --- a/src/blackgui/components/settingsmodelcomponent.h +++ b/src/blackgui/components/settingsmodelcomponent.h @@ -16,6 +16,7 @@ #include namespace Ui { class CSettingsModelComponent; } +namespace BlackCore { namespace Db { class CBackgroundDataUpdater; }} namespace BlackGui { namespace Components @@ -37,9 +38,13 @@ namespace BlackGui //! Interval, -1 for disabled int getBackgroundUpdaterIntervallSecs() const; + //! Updater (the updater this setting is for) + void setBackgroundUpdater(BlackCore::Db::CBackgroundDataUpdater *updater); + private: QScopedPointer ui; BlackMisc::CSetting m_consolidationSetting { this, &CSettingsModelComponent::cacheChanged }; //!< consolidation time + BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr; //! Consolidation time entered void consolidationEntered(); diff --git a/src/swiftdata/swiftdata.cpp b/src/swiftdata/swiftdata.cpp index 43c54e8e6..42f35ac18 100644 --- a/src/swiftdata/swiftdata.cpp +++ b/src/swiftdata/swiftdata.cpp @@ -13,6 +13,7 @@ #include "blackgui/components/datamaininfoareacomponent.h" #include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/logcomponent.h" +#include "blackgui/components/datasettingscomponent.h" #include "blackgui/guiapplication.h" #include "blackgui/stylesheetutility.h" #include "blackmisc/loghandler.h" @@ -160,6 +161,7 @@ void CSwiftData::consolidationSettingChanged() { if (m_updater) { + ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(nullptr); m_updater->gracefulShutdown(); m_updater.reset(nullptr); } @@ -170,6 +172,7 @@ void CSwiftData::consolidationSettingChanged() { m_updater.reset(new CBackgroundDataUpdater(this)); m_updater->start(QThread::LowestPriority); + ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(m_updater.data()); } m_updater->startUpdating(consolidationSecs); }