mirror of https://github.com/KLayout/klayout.git
Fixed #486 ('save as' feature for macros)
This commit is contained in:
parent
99f22c3221
commit
7d7c9aecc6
|
|
@ -1572,6 +1572,14 @@ p, li { white-space: pre-wrap; }
|
||||||
<string>Ctrl+F</string>
|
<string>Ctrl+F</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSaveAs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save As</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Save As</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,7 @@ MacroEditorDialog::MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection
|
||||||
macro_tree->addAction (s3);
|
macro_tree->addAction (s3);
|
||||||
macro_tree->addAction (actionSaveAll);
|
macro_tree->addAction (actionSaveAll);
|
||||||
macro_tree->addAction (actionSave);
|
macro_tree->addAction (actionSave);
|
||||||
|
macro_tree->addAction (actionSaveAs);
|
||||||
|
|
||||||
macro_tree->header ()->hide ();
|
macro_tree->header ()->hide ();
|
||||||
|
|
||||||
|
|
@ -422,6 +423,7 @@ MacroEditorDialog::MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection
|
||||||
connect (actionSaveAll, SIGNAL (triggered ()), this, SLOT (save_all_button_clicked ()));
|
connect (actionSaveAll, SIGNAL (triggered ()), this, SLOT (save_all_button_clicked ()));
|
||||||
connect (saveButton, SIGNAL (clicked ()), this, SLOT (save_button_clicked ()));
|
connect (saveButton, SIGNAL (clicked ()), this, SLOT (save_button_clicked ()));
|
||||||
connect (actionSave, SIGNAL (triggered ()), this, SLOT (save_button_clicked ()));
|
connect (actionSave, SIGNAL (triggered ()), this, SLOT (save_button_clicked ()));
|
||||||
|
connect (actionSaveAs, SIGNAL (triggered ()), this, SLOT (save_as_button_clicked ()));
|
||||||
connect (dbgOn, SIGNAL (clicked (bool)), this, SLOT (set_debugging_on (bool)));
|
connect (dbgOn, SIGNAL (clicked (bool)), this, SLOT (set_debugging_on (bool)));
|
||||||
connect (runButton, SIGNAL (clicked ()), this, SLOT (run_button_clicked ()));
|
connect (runButton, SIGNAL (clicked ()), this, SLOT (run_button_clicked ()));
|
||||||
connect (runThisButton, SIGNAL (clicked ()), this, SLOT (run_this_button_clicked ()));
|
connect (runThisButton, SIGNAL (clicked ()), this, SLOT (run_this_button_clicked ()));
|
||||||
|
|
@ -1996,7 +1998,40 @@ BEGIN_PROTECTED
|
||||||
END_PROTECTED
|
END_PROTECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
MacroEditorDialog::save_as_button_clicked ()
|
||||||
|
{
|
||||||
|
if (m_in_exec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_PROTECTED
|
||||||
|
|
||||||
|
lym::Macro *m = current_macro_tree ()->current_macro ();
|
||||||
|
if (! m) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lay::FileDialog file_dialog (lay::MainWindow::instance (), tl::to_string (QObject::tr ("Save Macro As")), tl::to_string (QObject::tr ("All files (*)")), "");
|
||||||
|
|
||||||
|
std::string fn = m->path ();
|
||||||
|
if (file_dialog.get_save (fn)) {
|
||||||
|
|
||||||
|
m->save_to (fn);
|
||||||
|
|
||||||
|
reload_macros ();
|
||||||
|
|
||||||
|
lym::Macro *lym = mp_root->find_macro (fn);
|
||||||
|
if (lym) {
|
||||||
|
open_macro (lym);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
END_PROTECTED
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
MacroEditorDialog::setup_button_clicked ()
|
MacroEditorDialog::setup_button_clicked ()
|
||||||
{
|
{
|
||||||
if (m_in_exec) {
|
if (m_in_exec) {
|
||||||
|
|
@ -2089,11 +2124,7 @@ MacroEditorDialog::new_macro()
|
||||||
// we don't want to keep the template's description
|
// we don't want to keep the template's description
|
||||||
m->set_description (std::string ());
|
m->set_description (std::string ());
|
||||||
|
|
||||||
MacroEditorPage *page = create_page (m);
|
open_macro (m);
|
||||||
int index = tabWidget->addTab (page, tl::to_qstring (m->name ()));
|
|
||||||
tabWidget->setTabToolTip (index, tl::to_qstring (m->summary ()));
|
|
||||||
tabWidget->setCurrentWidget (page);
|
|
||||||
m_tab_widgets.insert (std::make_pair (m, page));
|
|
||||||
|
|
||||||
// NOTE: we save to make the file watcher go silent and to keep the file system in sync
|
// NOTE: we save to make the file watcher go silent and to keep the file system in sync
|
||||||
m->save ();
|
m->save ();
|
||||||
|
|
@ -2710,6 +2741,16 @@ BEGIN_PROTECTED
|
||||||
END_PROTECTED
|
END_PROTECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MacroEditorDialog::open_macro (lym::Macro *m)
|
||||||
|
{
|
||||||
|
MacroEditorPage *page = create_page (m);
|
||||||
|
m_tab_widgets.insert (std::make_pair (m, page));
|
||||||
|
int index = tabWidget->addTab (page, tl::to_qstring (m->name ()));
|
||||||
|
tabWidget->setTabToolTip (index, tl::to_qstring (m->summary ()));
|
||||||
|
tabWidget->setCurrentWidget (page);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MacroEditorDialog::item_double_clicked(lym::Macro *m)
|
MacroEditorDialog::item_double_clicked(lym::Macro *m)
|
||||||
{
|
{
|
||||||
|
|
@ -2717,13 +2758,7 @@ BEGIN_PROTECTED
|
||||||
|
|
||||||
std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (m);
|
std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (m);
|
||||||
if (page == m_tab_widgets.end ()) {
|
if (page == m_tab_widgets.end ()) {
|
||||||
|
open_macro (m);
|
||||||
MacroEditorPage *page = create_page (m);
|
|
||||||
m_tab_widgets.insert (std::make_pair (m, page));
|
|
||||||
int index = tabWidget->addTab (page, tl::to_qstring (m->name ()));
|
|
||||||
tabWidget->setTabToolTip (index, tl::to_qstring (m->summary ()));
|
|
||||||
tabWidget->setCurrentWidget (page);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tabWidget->setCurrentIndex (tabWidget->indexOf (page->second));
|
tabWidget->setCurrentIndex (tabWidget->indexOf (page->second));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ private slots:
|
||||||
void new_folder_button_clicked ();
|
void new_folder_button_clicked ();
|
||||||
void save_all_button_clicked ();
|
void save_all_button_clicked ();
|
||||||
void save_button_clicked ();
|
void save_button_clicked ();
|
||||||
|
void save_as_button_clicked ();
|
||||||
void run_button_clicked ();
|
void run_button_clicked ();
|
||||||
void run_this_button_clicked ();
|
void run_this_button_clicked ();
|
||||||
void single_step_button_clicked ();
|
void single_step_button_clicked ();
|
||||||
|
|
@ -255,6 +256,7 @@ private:
|
||||||
lym::Macro *create_macro_here(const char *name = 0);
|
lym::Macro *create_macro_here(const char *name = 0);
|
||||||
void move_subfolder (lym::MacroCollection *source, lym::MacroCollection *target);
|
void move_subfolder (lym::MacroCollection *source, lym::MacroCollection *target);
|
||||||
lay::MacroEditorPage *create_page (lym::Macro *macro);
|
lay::MacroEditorPage *create_page (lym::Macro *macro);
|
||||||
|
void open_macro (lym::Macro *macro);
|
||||||
void ensure_writeable_collection_selected ();
|
void ensure_writeable_collection_selected ();
|
||||||
void update_console_text ();
|
void update_console_text ();
|
||||||
void start_exec (gsi::Interpreter *interpreter);
|
void start_exec (gsi::Interpreter *interpreter);
|
||||||
|
|
|
||||||
|
|
@ -176,10 +176,15 @@ public:
|
||||||
std::string path () const;
|
std::string path () const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Saves the macro to the specificed path
|
* @brief Saves the macro to it's path
|
||||||
*/
|
*/
|
||||||
void save ();
|
void save ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Saves the macro to the specificed path
|
||||||
|
*/
|
||||||
|
void save_to (const std::string &path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete the original file (the file behind the macro)
|
* @brief Delete the original file (the file behind the macro)
|
||||||
*
|
*
|
||||||
|
|
@ -601,7 +606,6 @@ private:
|
||||||
|
|
||||||
void on_menu_needs_update ();
|
void on_menu_needs_update ();
|
||||||
void on_changed ();
|
void on_changed ();
|
||||||
void save_to (const std::string &path);
|
|
||||||
static bool format_from_suffix_string (const std::string &suffix, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format);
|
static bool format_from_suffix_string (const std::string &suffix, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format);
|
||||||
static std::pair<bool, std::string> format_from_filename (const std::string &fn, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format);
|
static std::pair<bool, std::string> format_from_filename (const std::string &fn, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue