From 527da0d18c5a839f77bbcf0bb6062759ecce7f78 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 24 Nov 2022 16:20:52 -0500 Subject: [PATCH] Reload color settings when changed by PCM --- kicad/pcm/dialogs/dialog_pcm.cpp | 6 ++++++ kicad/pcm/pcm_task_manager.cpp | 16 ++++++++++++++++ kicad/pcm/pcm_task_manager.h | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/kicad/pcm/dialogs/dialog_pcm.cpp b/kicad/pcm/dialogs/dialog_pcm.cpp index e1ab514c7a..6d7dbfd885 100644 --- a/kicad/pcm/dialogs/dialog_pcm.cpp +++ b/kicad/pcm/dialogs/dialog_pcm.cpp @@ -294,6 +294,9 @@ void DIALOG_PCM::OnInstallFromFileClicked( wxCommandEvent& event ) if( !m_selectedRepositoryId.IsEmpty() ) setRepositoryData( m_selectedRepositoryId ); + + if( task_manager.ColorSettingsChanged() ) + Pgm().GetSettingsManager().ReloadColorSettings(); } @@ -469,6 +472,9 @@ void DIALOG_PCM::OnApplyChangesClicked( wxCommandEvent& event ) if( !m_selectedRepositoryId.IsEmpty() ) setRepositoryData( m_selectedRepositoryId ); + + if( task_manager.ColorSettingsChanged() ) + Pgm().GetSettingsManager().ReloadColorSettings(); } diff --git a/kicad/pcm/pcm_task_manager.cpp b/kicad/pcm/pcm_task_manager.cpp index 3eed36eb35..0c99f0c2ef 100644 --- a/kicad/pcm/pcm_task_manager.cpp +++ b/kicad/pcm/pcm_task_manager.cpp @@ -221,6 +221,9 @@ void PCM_TASK_MANAGER::installDownloadedPackage( const PCM_PACKAGE& aPackage, } } + if( aPackage.type == PCM_PACKAGE_TYPE::PT_COLORTHEME ) + m_color_themes_changed.store( true ); + m_reporter->PCMReport( wxString::Format( _( "Removing downloaded archive '%s'." ), aFilePath.GetFullName() ), RPT_SEVERITY_INFO ); @@ -421,6 +424,8 @@ void PCM_TASK_MANAGER::InstallFromFile( wxWindow* aParent, const wxString& aFile m_reporter->KeepRefreshing( false ); m_reporter->Destroy(); m_reporter.reset(); + + m_color_themes_changed.store( package.type == PCM_PACKAGE_TYPE::PT_COLORTHEME ); } @@ -549,6 +554,9 @@ void PCM_TASK_MANAGER::Uninstall( const PCM_PACKAGE& aPackage ) m_pcm->MarkUninstalled( aPackage ); + if( aPackage.type == PCM_PACKAGE_TYPE::PT_COLORTHEME ) + m_color_themes_changed.store( true ); + m_reporter->PCMReport( wxString::Format( _( "Package %s uninstalled" ), aPackage.identifier ), RPT_SEVERITY_INFO ); @@ -571,6 +579,8 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent ) std::condition_variable condvar; bool download_complete = false; + m_color_themes_changed.store( false ); + std::thread download_thread( [&]() { @@ -628,3 +638,9 @@ void PCM_TASK_MANAGER::RunQueue( wxWindow* aParent ) download_thread.join(); install_thread.join(); } + + +bool PCM_TASK_MANAGER::ColorSettingsChanged() const +{ + return m_color_themes_changed.load(); +} \ No newline at end of file diff --git a/kicad/pcm/pcm_task_manager.h b/kicad/pcm/pcm_task_manager.h index e43c0a68b7..370a382ca7 100644 --- a/kicad/pcm/pcm_task_manager.h +++ b/kicad/pcm/pcm_task_manager.h @@ -104,6 +104,11 @@ public: */ void InstallFromFile( wxWindow* aParent, const wxString& aFilePath ); + /** + * @return true if color settings were installed or uninstalled by the most recent action + */ + bool ColorSettingsChanged() const; + private: /** * @brief Download URL to a file @@ -150,6 +155,7 @@ private: SYNC_QUEUE m_download_queue; SYNC_QUEUE m_install_queue; std::shared_ptr m_pcm; + std::atomic_bool m_color_themes_changed; };