mirror of https://github.com/KLayout/klayout.git
Ruler setup enhanced
- Issue: on an entirely fresh installation the "Ruler" entry was not visible. Now, a new standard template called "Ruler" is present. - Ruler templates with categories cannot be deleted any more and are shown with italic font. If they were deleted, they would show up again after restart.
This commit is contained in:
parent
daf4ee092e
commit
059c7ee37a
|
|
@ -29,6 +29,7 @@
|
|||
#include "antConfig.h"
|
||||
#include "layConverters.h"
|
||||
#include "layQtTools.h"
|
||||
#include "tlExceptions.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
|
||||
|
|
@ -254,6 +255,7 @@ ConfigPage4::add_clicked ()
|
|||
} else {
|
||||
new_one = m_ruler_templates [m_current_template];
|
||||
}
|
||||
new_one.category (std::string ());
|
||||
m_ruler_templates.insert (m_ruler_templates.begin () + m_current_template, new_one);
|
||||
m_ruler_templates [m_current_template].title (tl::to_string (QObject::tr ("New Ruler")));
|
||||
update_list ();
|
||||
|
|
@ -264,7 +266,12 @@ ConfigPage4::add_clicked ()
|
|||
void
|
||||
ConfigPage4::del_clicked ()
|
||||
{
|
||||
BEGIN_PROTECTED
|
||||
|
||||
if (m_current_template >= 0 && m_current_template < int (m_ruler_templates.size ())) {
|
||||
if (! m_ruler_templates [m_current_template].category ().empty ()) {
|
||||
throw tl::Exception (tl::to_string (tr ("This ruler is a built-in template and cannot be deleted")));
|
||||
}
|
||||
m_ruler_templates.erase (m_ruler_templates.begin () + m_current_template);
|
||||
if (m_current_template > 0) {
|
||||
--m_current_template;
|
||||
|
|
@ -276,6 +283,8 @@ ConfigPage4::del_clicked ()
|
|||
update_list ();
|
||||
show ();
|
||||
}
|
||||
|
||||
END_PROTECTED
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -309,6 +318,12 @@ ConfigPage4::update_list ()
|
|||
mp_ui->template_list->clear ();
|
||||
for (std::vector <ant::Template>::const_iterator t = m_ruler_templates.begin (); t != m_ruler_templates.end (); ++t) {
|
||||
mp_ui->template_list->addItem (tl::to_qstring (t->title ()));
|
||||
if (! t->category ().empty ()) {
|
||||
QListWidgetItem *item = mp_ui->template_list->item (int (t - m_ruler_templates.begin ()));
|
||||
QFont font = item->font ();
|
||||
font.setItalic (true);
|
||||
item->setFont (font);
|
||||
}
|
||||
}
|
||||
mp_ui->template_list->setCurrentRow (m_current_template);
|
||||
m_current_changed_enabled = true;
|
||||
|
|
|
|||
|
|
@ -171,6 +171,9 @@ PluginDeclaration::config_finalize ()
|
|||
void
|
||||
PluginDeclaration::initialized (lay::PluginRoot *)
|
||||
{
|
||||
ant::Template ruler_template (tl::to_string (QObject::tr ("Ruler")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_ruler");
|
||||
register_annotation_template (ruler_template);
|
||||
|
||||
ant::Template pos_template (tl::to_string (QObject::tr ("Cross")), "", "", "$U,$V", ant::Object::STY_cross_both, ant::Object::OL_diag, true, lay::AC_Global, "_cross");
|
||||
pos_template.set_mode (ant::Template::RulerSingleClick);
|
||||
register_annotation_template (pos_template);
|
||||
|
|
@ -178,6 +181,8 @@ PluginDeclaration::initialized (lay::PluginRoot *)
|
|||
ant::Template auto_template (tl::to_string (QObject::tr ("Measure")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_measure");
|
||||
auto_template.set_mode (ant::Template::RulerAutoMetric);
|
||||
register_annotation_template (auto_template);
|
||||
|
||||
update_menu ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -217,18 +222,16 @@ PluginDeclaration::update_menu ()
|
|||
{
|
||||
lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance ();
|
||||
|
||||
if (m_templates.empty ()) {
|
||||
m_templates.push_back (Template ());
|
||||
}
|
||||
|
||||
if (m_current_template < 0 || m_current_template >= int (m_templates.size ())) {
|
||||
m_current_template = 0;
|
||||
}
|
||||
|
||||
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
|
||||
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
|
||||
lay::Action action = mp->menu ()->action (*m);
|
||||
action.set_title (m_templates [m_current_template].title ());
|
||||
if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) {
|
||||
std::vector<std::string> menu_entries = mp->menu ()->group ("ruler_mode_group");
|
||||
for (std::vector<std::string>::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) {
|
||||
lay::Action action = mp->menu ()->action (*m);
|
||||
action.set_title (m_templates [m_current_template].title ());
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> tmpl_group = mp->menu ()->group ("ruler_templates_group");
|
||||
|
|
|
|||
Loading…
Reference in New Issue