mirror of https://github.com/KLayout/klayout.git
Allow to configure auto-sync of library folders. Default is off.
This commit is contained in:
parent
9b2d1fe0be
commit
21ecd80253
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>611</width>
|
<width>619</width>
|
||||||
<height>271</height>
|
<height>475</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -154,6 +154,32 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_4">
|
||||||
|
<property name="title">
|
||||||
|
<string>Synchronize Library Files</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>If this option is enabled, library files will be reloaded automatically. If disabled, you can reload the files using "File/Refresh Libraries" manually.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="auto_sync_libraries">
|
||||||
|
<property name="text">
|
||||||
|
<string>Synchronize library files automatically</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ static const std::string cfg_micron_digits ("digits-micron");
|
||||||
static const std::string cfg_dbu_digits ("digits-dbu");
|
static const std::string cfg_dbu_digits ("digits-dbu");
|
||||||
static const std::string cfg_assistant_bookmarks ("assistant-bookmarks");
|
static const std::string cfg_assistant_bookmarks ("assistant-bookmarks");
|
||||||
static const std::string cfg_always_exit_without_saving ("always-exit-without-saving");
|
static const std::string cfg_always_exit_without_saving ("always-exit-without-saving");
|
||||||
|
static const std::string cfg_auto_sync_libraries ("auto-sync-libraries");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "layApplication.h"
|
#include "layApplication.h"
|
||||||
#include "laySaltController.h"
|
#include "laySaltController.h"
|
||||||
#include "layConfig.h"
|
#include "layConfig.h"
|
||||||
#include "layMainWindow.h"
|
|
||||||
#include "layQtTools.h"
|
#include "layQtTools.h"
|
||||||
#include "dbLibraryManager.h"
|
#include "dbLibraryManager.h"
|
||||||
#include "dbLibrary.h"
|
#include "dbLibrary.h"
|
||||||
|
|
@ -44,7 +43,8 @@ namespace lay
|
||||||
|
|
||||||
LibraryController::LibraryController ()
|
LibraryController::LibraryController ()
|
||||||
: m_file_watcher (0),
|
: m_file_watcher (0),
|
||||||
dm_sync_files (this, &LibraryController::sync_files)
|
dm_sync_files (this, &LibraryController::sync_files_maybe),
|
||||||
|
m_sync (false), m_sync_once (false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ LibraryController::initialize (lay::Dispatcher * /*root*/)
|
||||||
{
|
{
|
||||||
// NOTE: we initialize the libraries in the stage once to have them available for the autorun
|
// NOTE: we initialize the libraries in the stage once to have them available for the autorun
|
||||||
// macros. We'll do that later again in order to pull in the libraries from the packages.
|
// macros. We'll do that later again in order to pull in the libraries from the packages.
|
||||||
sync_files ();
|
sync_files (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -69,7 +69,7 @@ LibraryController::initialized (lay::Dispatcher * /*root*/)
|
||||||
connect (m_file_watcher, SIGNAL (fileRemoved (const QString &)), this, SLOT (file_watcher_triggered ()));
|
connect (m_file_watcher, SIGNAL (fileRemoved (const QString &)), this, SLOT (file_watcher_triggered ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_files ();
|
sync_files (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -88,9 +88,9 @@ LibraryController::uninitialize (lay::Dispatcher * /*root*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LibraryController::get_options (std::vector < std::pair<std::string, std::string> > & /*options*/) const
|
LibraryController::get_options (std::vector < std::pair<std::string, std::string> > &options) const
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
options.push_back (std::pair<std::string, std::string> (cfg_auto_sync_libraries, "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -100,8 +100,21 @@ LibraryController::get_menu_entries (std::vector<lay::MenuEntry> & /*menu_entrie
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LibraryController::configure (const std::string & /*name*/, const std::string & /*value*/)
|
LibraryController::configure (const std::string &name, const std::string &value)
|
||||||
{
|
{
|
||||||
|
if (name == cfg_auto_sync_libraries) {
|
||||||
|
|
||||||
|
bool sync = false;
|
||||||
|
tl::from_string (value, sync);
|
||||||
|
|
||||||
|
m_sync = sync;
|
||||||
|
if (sync) {
|
||||||
|
dm_sync_files ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't consume
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,8 +132,24 @@ LibraryController::can_exit (lay::Dispatcher * /*root*/) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LibraryController::sync_files ()
|
LibraryController::sync_files_maybe ()
|
||||||
{
|
{
|
||||||
|
sync_files (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LibraryController::sync_files (bool always)
|
||||||
|
{
|
||||||
|
if (tl::verbosity () >= 20) {
|
||||||
|
if (always) {
|
||||||
|
tl::info << tl::to_string (tr ("Synchronize library files unconditionally"));
|
||||||
|
} else {
|
||||||
|
tl::info << tl::to_string (tr ("Synchronize library files"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sync_once = false;
|
||||||
|
|
||||||
if (m_file_watcher) {
|
if (m_file_watcher) {
|
||||||
m_file_watcher->clear ();
|
m_file_watcher->clear ();
|
||||||
m_file_watcher->enable (false);
|
m_file_watcher->enable (false);
|
||||||
|
|
@ -179,7 +208,7 @@ LibraryController::sync_files ()
|
||||||
std::vector<LibFileInfo> libs;
|
std::vector<LibFileInfo> libs;
|
||||||
read_lib_file (lf->first, lf->second, libs);
|
read_lib_file (lf->first, lf->second, libs);
|
||||||
|
|
||||||
read_libs (libs, new_lib_files);
|
read_libs (libs, new_lib_files, always);
|
||||||
|
|
||||||
if (m_file_watcher) {
|
if (m_file_watcher) {
|
||||||
m_file_watcher->add_file (tl::absolute_file_path (lf->first));
|
m_file_watcher->add_file (tl::absolute_file_path (lf->first));
|
||||||
|
|
@ -222,7 +251,7 @@ LibraryController::sync_files ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read_libs (libs, new_lib_files);
|
read_libs (libs, new_lib_files, always);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -424,9 +453,9 @@ LibraryController::read_lib_file (const std::string &lib_file, const std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LibraryController::read_libs (const std::vector<LibraryController::LibFileInfo> &libs, std::map<std::string, LibraryController::LibInfo> &new_lib_files)
|
LibraryController::read_libs (const std::vector<LibraryController::LibFileInfo> &libs, std::map<std::string, LibraryController::LibInfo> &new_lib_files, bool always)
|
||||||
{
|
{
|
||||||
bool needs_load = false;
|
bool needs_load = always;
|
||||||
|
|
||||||
for (auto im = libs.begin (); im != libs.end () && ! needs_load; ++im) {
|
for (auto im = libs.begin (); im != libs.end () && ! needs_load; ++im) {
|
||||||
|
|
||||||
|
|
@ -532,14 +561,17 @@ void
|
||||||
LibraryController::sync_with_external_sources ()
|
LibraryController::sync_with_external_sources ()
|
||||||
{
|
{
|
||||||
tl::log << tl::to_string (tr ("Package updates - updating libraries"));
|
tl::log << tl::to_string (tr ("Package updates - updating libraries"));
|
||||||
|
m_sync_once = true;
|
||||||
dm_sync_files ();
|
dm_sync_files ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LibraryController::file_watcher_triggered ()
|
LibraryController::file_watcher_triggered ()
|
||||||
{
|
{
|
||||||
tl::log << tl::to_string (tr ("Detected file system change in libraries - updating"));
|
if (m_sync) {
|
||||||
dm_sync_files ();
|
tl::log << tl::to_string (tr ("Detected file system change in libraries - updating"));
|
||||||
|
dm_sync_files ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LibraryController *
|
LibraryController *
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,13 @@ public:
|
||||||
*/
|
*/
|
||||||
bool can_exit (lay::Dispatcher *root) const;
|
bool can_exit (lay::Dispatcher *root) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Synchronize files
|
||||||
|
*
|
||||||
|
* If "always" is set, all files are synchronized unconditionally.
|
||||||
|
*/
|
||||||
|
void sync_files (bool always);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the singleton instance for this object
|
* @brief Gets the singleton instance for this object
|
||||||
*/
|
*/
|
||||||
|
|
@ -147,9 +154,11 @@ private:
|
||||||
tl::FileSystemWatcher *m_file_watcher;
|
tl::FileSystemWatcher *m_file_watcher;
|
||||||
tl::DeferredMethod<LibraryController> dm_sync_files;
|
tl::DeferredMethod<LibraryController> dm_sync_files;
|
||||||
std::map<std::string, LibInfo> m_lib_files;
|
std::map<std::string, LibInfo> m_lib_files;
|
||||||
|
bool m_sync;
|
||||||
|
bool m_sync_once;
|
||||||
|
|
||||||
void sync_files ();
|
void sync_files_maybe ();
|
||||||
void read_libs (const std::vector<LibFileInfo> &file_info, std::map<std::string, LibInfo> &new_lib_files);
|
void read_libs (const std::vector<LibFileInfo> &file_info, std::map<std::string, LibInfo> &new_lib_files, bool always);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,10 @@ MainConfigPage7::setup (lay::Dispatcher *root)
|
||||||
root->config_get (cfg_layout_file_watcher_enabled, en);
|
root->config_get (cfg_layout_file_watcher_enabled, en);
|
||||||
mp_ui->check_for_updates->setChecked (en);
|
mp_ui->check_for_updates->setChecked (en);
|
||||||
|
|
||||||
|
bool asl = false;
|
||||||
|
root->config_get (cfg_auto_sync_libraries, asl);
|
||||||
|
mp_ui->auto_sync_libraries->setChecked (asl);
|
||||||
|
|
||||||
int kb = 0;
|
int kb = 0;
|
||||||
root->config_get (cfg_keep_backups, kb);
|
root->config_get (cfg_keep_backups, kb);
|
||||||
mp_ui->keep_backups->setValue (kb);
|
mp_ui->keep_backups->setValue (kb);
|
||||||
|
|
@ -211,6 +215,7 @@ MainConfigPage7::commit (lay::Dispatcher *root)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
root->config_set (cfg_layout_file_watcher_enabled, mp_ui->check_for_updates->isChecked ());
|
root->config_set (cfg_layout_file_watcher_enabled, mp_ui->check_for_updates->isChecked ());
|
||||||
|
root->config_set (cfg_auto_sync_libraries, mp_ui->auto_sync_libraries->isChecked ());
|
||||||
root->config_set (cfg_keep_backups, mp_ui->keep_backups->value ());
|
root->config_set (cfg_keep_backups, mp_ui->keep_backups->value ());
|
||||||
root->config_set (cfg_always_exit_without_saving, mp_ui->always_exit_without_saving->isChecked ());
|
root->config_set (cfg_always_exit_without_saving, mp_ui->always_exit_without_saving->isChecked ());
|
||||||
} catch (...) { }
|
} catch (...) { }
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@
|
||||||
#include "laySettingsForm.h"
|
#include "laySettingsForm.h"
|
||||||
#include "laySelectCellViewForm.h"
|
#include "laySelectCellViewForm.h"
|
||||||
#include "layTechnologyController.h"
|
#include "layTechnologyController.h"
|
||||||
|
#include "layLibraryController.h"
|
||||||
#include "laySaltController.h"
|
#include "laySaltController.h"
|
||||||
#include "layTipDialog.h"
|
#include "layTipDialog.h"
|
||||||
#include "layMacroController.h"
|
#include "layMacroController.h"
|
||||||
|
|
@ -2612,6 +2613,10 @@ MainWindow::cm_writer_options ()
|
||||||
void
|
void
|
||||||
MainWindow::cm_refresh ()
|
MainWindow::cm_refresh ()
|
||||||
{
|
{
|
||||||
|
if (lay::LibraryController::instance ()) {
|
||||||
|
lay::LibraryController::instance ()->sync_files (false);
|
||||||
|
}
|
||||||
|
|
||||||
db::LibraryManager::instance ().refresh_all ();
|
db::LibraryManager::instance ().refresh_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue