mirror of https://github.com/KLayout/klayout.git
WIP: refactoring editor options - moved some classes from edt to lay namespace
This commit is contained in:
parent
fb90144176
commit
46b5b87eaf
|
|
@ -28,27 +28,6 @@
|
|||
namespace ant
|
||||
{
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
indicate_error (QWidget *le, const tl::Exception *ex)
|
||||
{
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
QPalette pl = le->palette ();
|
||||
if (ex) {
|
||||
pl.setColor (QPalette::Active, QPalette::Text, Qt::red);
|
||||
pl.setColor (QPalette::Active, QPalette::Base, QColor (Qt::red).lighter (180));
|
||||
le->setToolTip (tl::to_qstring (ex->msg ()));
|
||||
} else {
|
||||
QWidget *pw = dynamic_cast<QWidget *> (le->parent ());
|
||||
tl_assert (pw != 0);
|
||||
pl.setColor (QPalette::Active, QPalette::Text, pw->palette ().color (QPalette::Text));
|
||||
pl.setColor (QPalette::Active, QPalette::Base, pw->palette ().color (QPalette::Base));
|
||||
le->setToolTip (QString ());
|
||||
}
|
||||
le->setPalette (pl);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// PropertiesPage implementation
|
||||
|
||||
|
|
@ -155,33 +134,33 @@ PropertiesPage::get_points (db::DPoint &p1, db::DPoint &p2)
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x1->text ()), dx1);
|
||||
indicate_error (x1, 0);
|
||||
lay::indicate_error (x1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x1, &ex);
|
||||
lay::indicate_error (x1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x2->text ()), dx2);
|
||||
indicate_error (x2, 0);
|
||||
lay::indicate_error (x2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x2, &ex);
|
||||
lay::indicate_error (x2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y1->text ()), dy1);
|
||||
indicate_error (y1, 0);
|
||||
lay::indicate_error (y1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y1, &ex);
|
||||
lay::indicate_error (y1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y2->text ()), dy2);
|
||||
indicate_error (y2, 0);
|
||||
lay::indicate_error (y2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y2, &ex);
|
||||
lay::indicate_error (y2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ HEADERS = \
|
|||
edtUtils.h \
|
||||
edtCommon.h \
|
||||
edtDistribute.h \
|
||||
edtRecentConfigurationPage.h \
|
||||
edtEditorOptionsPage.h
|
||||
edtRecentConfigurationPage.h
|
||||
|
||||
FORMS = \
|
||||
AlignOptionsDialog.ui \
|
||||
|
|
@ -62,8 +61,7 @@ SOURCES = \
|
|||
edtUtils.cc \
|
||||
gsiDeclEdt.cc \
|
||||
edtDistribute.cc \
|
||||
edtRecentConfigurationPage.cc \
|
||||
edtEditorOptionsPage.cc
|
||||
edtRecentConfigurationPage.cc
|
||||
|
||||
INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC
|
||||
DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "layPlugin.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layCellSelectionForm.h"
|
||||
#include "layQtTools.h"
|
||||
#include "ui_EditorOptionsDialog.h"
|
||||
#include "ui_EditorOptionsGeneric.h"
|
||||
#include "ui_EditorOptionsPath.h"
|
||||
|
|
@ -51,153 +52,7 @@ namespace edt
|
|||
{
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// EditorOptionsPages implementation
|
||||
|
||||
struct EOPCompareOp
|
||||
{
|
||||
bool operator() (edt::EditorOptionsPage *a, edt::EditorOptionsPage *b) const
|
||||
{
|
||||
return a->order () < b->order ();
|
||||
}
|
||||
};
|
||||
|
||||
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *dispatcher)
|
||||
: QFrame (parent), mp_dispatcher (dispatcher)
|
||||
{
|
||||
QVBoxLayout *ly1 = new QVBoxLayout (this);
|
||||
ly1->setMargin (0);
|
||||
|
||||
mp_pages = new QTabWidget (this);
|
||||
ly1->addWidget (mp_pages);
|
||||
|
||||
m_pages = pages;
|
||||
for (std::vector <edt::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
(*p)->set_owner (this);
|
||||
}
|
||||
|
||||
update (0);
|
||||
setup ();
|
||||
}
|
||||
|
||||
EditorOptionsPages::~EditorOptionsPages ()
|
||||
{
|
||||
while (m_pages.size () > 0) {
|
||||
delete m_pages.front ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::focusInEvent (QFocusEvent * /*event*/)
|
||||
{
|
||||
// Sends the focus to the current page's last focus owner
|
||||
if (mp_pages->currentWidget () && mp_pages->currentWidget ()->focusWidget ()) {
|
||||
mp_pages->currentWidget ()->focusWidget ()->setFocus ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::unregister_page (edt::EditorOptionsPage *page)
|
||||
{
|
||||
std::vector <edt::EditorOptionsPage *> pages;
|
||||
for (std::vector <edt::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if (*p != page) {
|
||||
pages.push_back (*p);
|
||||
}
|
||||
}
|
||||
m_pages = pages;
|
||||
update (0);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::activate_page (edt::EditorOptionsPage *page)
|
||||
{
|
||||
try {
|
||||
if (page->active ()) {
|
||||
page->setup (mp_dispatcher);
|
||||
}
|
||||
} catch (...) {
|
||||
// catch any errors related to configuration file errors etc.
|
||||
}
|
||||
|
||||
update (page);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::update (edt::EditorOptionsPage *page)
|
||||
{
|
||||
std::vector <edt::EditorOptionsPage *> sorted_pages = m_pages;
|
||||
std::sort (sorted_pages.begin (), sorted_pages.end (), EOPCompareOp ());
|
||||
|
||||
if (! page && m_pages.size () > 0) {
|
||||
page = m_pages.back ();
|
||||
}
|
||||
|
||||
while (mp_pages->count () > 0) {
|
||||
mp_pages->removeTab (0);
|
||||
}
|
||||
int index = -1;
|
||||
for (std::vector <edt::EditorOptionsPage *>::iterator p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
if ((*p) == page) {
|
||||
index = mp_pages->count ();
|
||||
}
|
||||
mp_pages->addTab (*p, tl::to_qstring ((*p)->title ()));
|
||||
} else {
|
||||
(*p)->setParent (0);
|
||||
}
|
||||
}
|
||||
if (index < 0) {
|
||||
index = mp_pages->currentIndex ();
|
||||
}
|
||||
if (index >= int (mp_pages->count ())) {
|
||||
index = mp_pages->count () - 1;
|
||||
}
|
||||
mp_pages->setCurrentIndex (index);
|
||||
|
||||
setVisible (mp_pages->count () > 0);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::setup ()
|
||||
{
|
||||
try {
|
||||
|
||||
for (std::vector <edt::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
(*p)->setup (mp_dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
// make the display consistent with the status (this is important for
|
||||
// PCell parameters where the PCell may be asked to modify the parameters)
|
||||
do_apply ();
|
||||
|
||||
} catch (...) {
|
||||
// catch any errors related to configuration file errors etc.
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::do_apply ()
|
||||
{
|
||||
for (std::vector <edt::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
// NOTE: we apply to the root dispatcher, so other dispatchers (views) get informed too.
|
||||
(*p)->apply (mp_dispatcher->dispatcher ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::apply ()
|
||||
{
|
||||
BEGIN_PROTECTED
|
||||
do_apply ();
|
||||
END_PROTECTED_W (this)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Indicates an error on a line edit
|
||||
// Configures a value from a line edit
|
||||
|
||||
template <class Value>
|
||||
static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le, const std::string &cfg_name)
|
||||
|
|
@ -206,9 +61,9 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le
|
|||
Value value = Value (0);
|
||||
tl::from_string (tl::to_string (le->text ()), value);
|
||||
dispatcher->config_set (cfg_name, tl::to_string (value));
|
||||
indicate_error (le, 0);
|
||||
lay::indicate_error (le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (le, &ex);
|
||||
lay::indicate_error (le, &ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -240,17 +95,17 @@ EditorOptionsGeneric::~EditorOptionsGeneric ()
|
|||
mp_ui = 0;
|
||||
}
|
||||
|
||||
std::string
|
||||
std::string
|
||||
EditorOptionsGeneric::title () const
|
||||
{
|
||||
return tl::to_string (QObject::tr ("Basic Editing"));
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EditorOptionsGeneric::apply (lay::Dispatcher *root)
|
||||
{
|
||||
// Edit grid
|
||||
|
||||
|
||||
EditGridConverter egc;
|
||||
if (mp_ui->grid_cb->currentIndex () == 0) {
|
||||
root->config_set (cfg_edit_grid, egc.to_string (db::DVector (-1.0, -1.0)));
|
||||
|
|
@ -260,10 +115,10 @@ EditorOptionsGeneric::apply (lay::Dispatcher *root)
|
|||
try {
|
||||
db::DVector eg;
|
||||
egc.from_string_picky (tl::to_string (mp_ui->edit_grid_le->text ()), eg);
|
||||
indicate_error (mp_ui->edit_grid_le, 0);
|
||||
lay::indicate_error (mp_ui->edit_grid_le, 0);
|
||||
root->config_set (cfg_edit_grid, egc.to_string (eg));
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (mp_ui->edit_grid_le, &ex);
|
||||
lay::indicate_error (mp_ui->edit_grid_le, &ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +149,7 @@ EditorOptionsGeneric::show_shapes_changed ()
|
|||
mp_ui->max_shapes_le->setEnabled (mp_ui->show_shapes_cbx->isChecked ());
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
EditorOptionsGeneric::setup (lay::Dispatcher *root)
|
||||
{
|
||||
// Edit grid
|
||||
|
|
@ -312,13 +167,13 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
|
|||
mp_ui->edit_grid_le->setText (tl::to_qstring (egc.to_string (eg)));
|
||||
}
|
||||
grid_changed (mp_ui->grid_cb->currentIndex ());
|
||||
indicate_error (mp_ui->edit_grid_le, 0);
|
||||
lay::indicate_error (mp_ui->edit_grid_le, 0);
|
||||
|
||||
// edit & move angle
|
||||
|
||||
ACConverter acc;
|
||||
lay::angle_constraint_type ac;
|
||||
|
||||
|
||||
ac = lay::AC_Any;
|
||||
root->config_get (cfg_edit_move_angle_mode, ac, acc);
|
||||
mp_ui->move_angle_cb->setCurrentIndex (int (ac));
|
||||
|
|
@ -342,7 +197,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
|
|||
unsigned int max_shapes = 1000;
|
||||
root->config_get (cfg_edit_max_shapes_of_instances, max_shapes);
|
||||
mp_ui->max_shapes_le->setText (tl::to_qstring (tl::to_string (max_shapes)));
|
||||
indicate_error (mp_ui->max_shapes_le, 0);
|
||||
lay::indicate_error (mp_ui->max_shapes_le, 0);
|
||||
|
||||
bool show_shapes = true;
|
||||
root->config_get (cfg_edit_show_shapes_of_instances, show_shapes);
|
||||
|
|
@ -353,7 +208,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsText implementation
|
||||
|
||||
EditorOptionsText::EditorOptionsText (lay::Dispatcher *dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
: lay::EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsText ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -431,7 +286,7 @@ EditorOptionsText::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsPath implementation
|
||||
|
||||
EditorOptionsPath::EditorOptionsPath (lay::Dispatcher *dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
: lay::EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsPath ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -502,7 +357,7 @@ EditorOptionsPath::setup (lay::Dispatcher *root)
|
|||
double w = 0.0;
|
||||
root->config_get (cfg_edit_path_width, w);
|
||||
mp_ui->width_le->setText (tl::to_qstring (tl::to_string (w)));
|
||||
indicate_error (mp_ui->width_le, 0);
|
||||
lay::indicate_error (mp_ui->width_le, 0);
|
||||
|
||||
// path type and extensions
|
||||
|
||||
|
|
@ -523,16 +378,16 @@ EditorOptionsPath::setup (lay::Dispatcher *root)
|
|||
root->config_get (cfg_edit_path_ext_var_begin, bgnext);
|
||||
root->config_get (cfg_edit_path_ext_var_end, endext);
|
||||
mp_ui->start_ext_le->setText (tl::to_qstring (tl::to_string (bgnext)));
|
||||
indicate_error (mp_ui->start_ext_le, 0);
|
||||
lay::indicate_error (mp_ui->start_ext_le, 0);
|
||||
mp_ui->end_ext_le->setText (tl::to_qstring (tl::to_string (endext)));
|
||||
indicate_error (mp_ui->end_ext_le, 0);
|
||||
lay::indicate_error (mp_ui->end_ext_le, 0);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// EditorOptionsInst implementation
|
||||
|
||||
EditorOptionsInst::EditorOptionsInst (lay::Dispatcher *dispatcher)
|
||||
: EditorOptionsPage (dispatcher)
|
||||
: lay::EditorOptionsPage (dispatcher)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsInst ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
@ -623,7 +478,7 @@ EditorOptionsInst::update_cell_edits ()
|
|||
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
tl::Exception ex ("No cell or PCell with this name");
|
||||
indicate_error (mp_ui->cell_le, (! pc.first && ! cc.first) ? &ex : 0);
|
||||
lay::indicate_error (mp_ui->cell_le, (! pc.first && ! cc.first) ? &ex : 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -766,7 +621,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
|
|||
double angle = 0.0;
|
||||
root->config_get (cfg_edit_inst_angle, angle);
|
||||
mp_ui->angle_le->setText (tl::to_qstring (tl::to_string (angle)));
|
||||
indicate_error (mp_ui->angle_le, 0);
|
||||
lay::indicate_error (mp_ui->angle_le, 0);
|
||||
|
||||
bool mirror = false;
|
||||
root->config_get (cfg_edit_inst_mirror, mirror);
|
||||
|
|
@ -775,7 +630,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
|
|||
double scale = 1.0;
|
||||
root->config_get (cfg_edit_inst_scale, scale);
|
||||
mp_ui->scale_le->setText (tl::to_qstring (tl::to_string (scale)));
|
||||
indicate_error (mp_ui->scale_le, 0);
|
||||
lay::indicate_error (mp_ui->scale_le, 0);
|
||||
|
||||
// array
|
||||
bool array = false;
|
||||
|
|
@ -792,17 +647,17 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
|
|||
root->config_get (cfg_edit_inst_column_y, column_y);
|
||||
|
||||
mp_ui->rows_le->setText (tl::to_qstring (tl::to_string (rows)));
|
||||
indicate_error (mp_ui->rows_le, 0);
|
||||
lay::indicate_error (mp_ui->rows_le, 0);
|
||||
mp_ui->row_x_le->setText (tl::to_qstring (tl::to_string (row_x)));
|
||||
indicate_error (mp_ui->row_x_le, 0);
|
||||
lay::indicate_error (mp_ui->row_x_le, 0);
|
||||
mp_ui->row_y_le->setText (tl::to_qstring (tl::to_string (row_y)));
|
||||
indicate_error (mp_ui->row_y_le, 0);
|
||||
lay::indicate_error (mp_ui->row_y_le, 0);
|
||||
mp_ui->columns_le->setText (tl::to_qstring (tl::to_string (columns)));
|
||||
indicate_error (mp_ui->columns_le, 0);
|
||||
lay::indicate_error (mp_ui->columns_le, 0);
|
||||
mp_ui->column_x_le->setText (tl::to_qstring (tl::to_string (column_x)));
|
||||
indicate_error (mp_ui->column_x_le, 0);
|
||||
lay::indicate_error (mp_ui->column_x_le, 0);
|
||||
mp_ui->column_y_le->setText (tl::to_qstring (tl::to_string (column_y)));
|
||||
indicate_error (mp_ui->column_y_le, 0);
|
||||
lay::indicate_error (mp_ui->column_y_le, 0);
|
||||
|
||||
// place origin of cell flag
|
||||
bool place_origin = false;
|
||||
|
|
@ -814,7 +669,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
|
|||
// EditorOptionsInstPCellParam implementation
|
||||
|
||||
EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::Dispatcher *dispatcher)
|
||||
: EditorOptionsPage (dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
|
||||
: lay::EditorOptionsPage (dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
|
||||
{
|
||||
mp_ui = new Ui::EditorOptionsInstPCellParam ();
|
||||
mp_ui->setupUi (this);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef HDR_edtEditorOptionsPages
|
||||
#define HDR_edtEditorOptionsPages
|
||||
|
||||
#include "edtEditorOptionsPage.h"
|
||||
#include "layEditorOptionsPage.h"
|
||||
|
||||
#include <tlVariant.h>
|
||||
|
||||
|
|
@ -59,45 +59,11 @@ namespace edt
|
|||
|
||||
class PCellParametersPage;
|
||||
|
||||
/**
|
||||
* @brief The object properties dialog
|
||||
*/
|
||||
class EditorOptionsPages
|
||||
: public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EditorOptionsPages (QWidget *parent, const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root);
|
||||
~EditorOptionsPages ();
|
||||
|
||||
void unregister_page (edt::EditorOptionsPage *page);
|
||||
void activate_page (edt::EditorOptionsPage *page);
|
||||
void focusInEvent (QFocusEvent *event);
|
||||
|
||||
const std::vector <edt::EditorOptionsPage *> &pages () const
|
||||
{
|
||||
return m_pages;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void apply ();
|
||||
void setup ();
|
||||
|
||||
private:
|
||||
std::vector <edt::EditorOptionsPage *> m_pages;
|
||||
lay::Dispatcher *mp_dispatcher;
|
||||
QTabWidget *mp_pages;
|
||||
|
||||
void update (edt::EditorOptionsPage *page);
|
||||
void do_apply ();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The generic properties page
|
||||
*/
|
||||
class EditorOptionsGeneric
|
||||
: public EditorOptionsPage
|
||||
: public lay::EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -122,7 +88,7 @@ private:
|
|||
* @brief The text properties page
|
||||
*/
|
||||
class EditorOptionsText
|
||||
: public EditorOptionsPage
|
||||
: public lay::EditorOptionsPage
|
||||
{
|
||||
public:
|
||||
EditorOptionsText (lay::Dispatcher *dispatcher);
|
||||
|
|
@ -141,7 +107,7 @@ private:
|
|||
* @brief The path properties page
|
||||
*/
|
||||
class EditorOptionsPath
|
||||
: public EditorOptionsPage
|
||||
: public lay::EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -165,7 +131,7 @@ private:
|
|||
* @brief The instance properties page
|
||||
*/
|
||||
class EditorOptionsInst
|
||||
: public EditorOptionsPage
|
||||
: public lay::EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -194,7 +160,7 @@ private:
|
|||
* @brief The instance properties page (PCell parameters)
|
||||
*/
|
||||
class EditorOptionsInstPCellParam
|
||||
: public EditorOptionsPage
|
||||
: public lay::EditorOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "layObjectInstPath.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layCellSelectionForm.h"
|
||||
#include "layQtTools.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "tlString.h"
|
||||
|
||||
|
|
@ -404,10 +405,10 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance &
|
|||
throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cell or PCell name: %s")).c_str (), tl::to_string (cell_name_le->text ()).c_str ());
|
||||
}
|
||||
|
||||
indicate_error (cell_name_le, 0);
|
||||
lay::indicate_error (cell_name_le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (cell_name_le, &ex);
|
||||
lay::indicate_error (cell_name_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -446,17 +447,17 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance &
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (pos_x_le->text ()), x);
|
||||
indicate_error (pos_x_le, 0);
|
||||
lay::indicate_error (pos_x_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (pos_x_le, &ex);
|
||||
lay::indicate_error (pos_x_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (pos_y_le->text ()), y);
|
||||
indicate_error (pos_y_le, 0);
|
||||
lay::indicate_error (pos_y_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (pos_y_le, &ex);
|
||||
lay::indicate_error (pos_y_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -471,18 +472,18 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance &
|
|||
double angle = 0.0;
|
||||
try {
|
||||
tl::from_string (tl::to_string (angle_le->text ()), angle);
|
||||
indicate_error (angle_le, 0);
|
||||
lay::indicate_error (angle_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (angle_le, &ex);
|
||||
lay::indicate_error (angle_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
double mag = 0.0;
|
||||
try {
|
||||
tl::from_string (tl::to_string (mag_le->text ()), mag);
|
||||
indicate_error (mag_le, 0);
|
||||
lay::indicate_error (mag_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (mag_le, &ex);
|
||||
lay::indicate_error (mag_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -509,49 +510,49 @@ InstPropertiesPage::create_applicator (db::Cell & /*cell*/, const db::Instance &
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (column_x_le->text ()), cx);
|
||||
indicate_error (column_x_le, 0);
|
||||
lay::indicate_error (column_x_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (column_x_le, &ex);
|
||||
lay::indicate_error (column_x_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (column_y_le->text ()), cy);
|
||||
indicate_error (column_y_le, 0);
|
||||
lay::indicate_error (column_y_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (column_y_le, &ex);
|
||||
lay::indicate_error (column_y_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (row_x_le->text ()), rx);
|
||||
indicate_error (row_x_le, 0);
|
||||
lay::indicate_error (row_x_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (row_x_le, &ex);
|
||||
lay::indicate_error (row_x_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (row_y_le->text ()), ry);
|
||||
indicate_error (row_y_le, 0);
|
||||
lay::indicate_error (row_y_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (row_y_le, &ex);
|
||||
lay::indicate_error (row_y_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (rows_le->text ()), rows);
|
||||
indicate_error (rows_le, 0);
|
||||
lay::indicate_error (rows_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (rows_le, &ex);
|
||||
lay::indicate_error (rows_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (columns_le->text ()), cols);
|
||||
indicate_error (columns_le, 0);
|
||||
lay::indicate_error (columns_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (columns_le, &ex);
|
||||
lay::indicate_error (columns_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -763,9 +764,9 @@ InstPropertiesPage::update_pcell_parameters ()
|
|||
// indicate an invalid cell name
|
||||
if (! pc.first && ! cc.first) {
|
||||
tl::Exception ex (tl::to_string (QObject::tr ("Not a valid cell or PCell name: %s")).c_str (), tl::to_string (cell_name_le->text ()).c_str ());
|
||||
indicate_error (cell_name_le, &ex);
|
||||
lay::indicate_error (cell_name_le, &ex);
|
||||
} else {
|
||||
indicate_error (cell_name_le, 0);
|
||||
lay::indicate_error (cell_name_le, 0);
|
||||
}
|
||||
|
||||
if (pc.first && layout->pcell_declaration (pc.second)) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "edtPCellParametersPage.h"
|
||||
#include "edtPropertiesPageUtils.h"
|
||||
#include "layWidgets.h"
|
||||
#include "layQtTools.h"
|
||||
#include "tlScriptError.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
|
@ -489,11 +490,11 @@ PCellParametersPage::get_parameters (bool *ok)
|
|||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
|
||||
parameters.back () = tl::Variant (v);
|
||||
indicate_error (le, 0);
|
||||
lay::indicate_error (le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
||||
indicate_error (le, &ex);
|
||||
lay::indicate_error (le, &ex);
|
||||
edit_error = false;
|
||||
|
||||
}
|
||||
|
|
@ -513,11 +514,11 @@ PCellParametersPage::get_parameters (bool *ok)
|
|||
tl::from_string (tl::to_string (le->text ()), v);
|
||||
|
||||
parameters.back () = tl::Variant (v);
|
||||
indicate_error (le, 0);
|
||||
lay::indicate_error (le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
|
||||
indicate_error (le, &ex);
|
||||
lay::indicate_error (le, &ex);
|
||||
edit_error = false;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "layTipDialog.h"
|
||||
#include "layEditorOptionsPages.h"
|
||||
#include "edtPlugin.h"
|
||||
#include "edtConfig.h"
|
||||
#include "edtService.h"
|
||||
|
|
@ -43,7 +44,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] =
|
|||
};
|
||||
|
||||
static
|
||||
void get_shape_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
void get_shape_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
{
|
||||
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param",
|
||||
&shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])]));
|
||||
|
|
@ -68,7 +69,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor text_cfg_descriptors[] =
|
|||
};
|
||||
|
||||
static
|
||||
void get_text_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
void get_text_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
{
|
||||
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-text-param",
|
||||
&text_cfg_descriptors[0], &text_cfg_descriptors[sizeof (text_cfg_descriptors) / sizeof (text_cfg_descriptors[0])]));
|
||||
|
|
@ -94,7 +95,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor path_cfg_descriptors[] =
|
|||
};
|
||||
|
||||
static
|
||||
void get_path_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
void get_path_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
{
|
||||
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-path-param",
|
||||
&path_cfg_descriptors[0], &path_cfg_descriptors[sizeof (path_cfg_descriptors) / sizeof (path_cfg_descriptors[0])]));
|
||||
|
|
@ -138,7 +139,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor inst_cfg_descriptors[] =
|
|||
};
|
||||
|
||||
static
|
||||
void get_inst_editor_options_pages (std::vector<edt::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
void get_inst_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher)
|
||||
{
|
||||
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-inst-param",
|
||||
&inst_cfg_descriptors[0], &inst_cfg_descriptors[sizeof (inst_cfg_descriptors) / sizeof (inst_cfg_descriptors[0])]));
|
||||
|
|
@ -153,7 +154,7 @@ class PluginDeclaration
|
|||
public:
|
||||
PluginDeclaration (const std::string &title, const std::string &mouse_mode,
|
||||
void (*option_get_f) (std::vector < std::pair<std::string, std::string> > &) = 0,
|
||||
void (*pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) = 0)
|
||||
void (*pages_f) (std::vector <lay::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) = 0)
|
||||
: m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
|
|
@ -176,7 +177,7 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &pages, lay::LayoutView *view, lay::Dispatcher *root) const
|
||||
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutView *view, lay::Dispatcher *root) const
|
||||
{
|
||||
if (mp_pages_f != 0) {
|
||||
size_t nstart = pages.size ();
|
||||
|
|
@ -211,7 +212,7 @@ private:
|
|||
std::string m_mouse_mode;
|
||||
|
||||
void (*mp_option_get_f) (std::vector < std::pair<std::string, std::string> > &options);
|
||||
void (*mp_pages_f) (std::vector <edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *);
|
||||
void (*mp_pages_f) (std::vector <lay::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *);
|
||||
};
|
||||
|
||||
static tl::RegisteredClass<lay::PluginDeclaration> config_decl1 (
|
||||
|
|
@ -409,7 +410,7 @@ show_editor_options_page (lay::LayoutView *view)
|
|||
return;
|
||||
}
|
||||
|
||||
std::vector<edt::EditorOptionsPage *> prop_dialog_pages;
|
||||
std::vector<lay::EditorOptionsPage *> prop_dialog_pages;
|
||||
EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view->dispatcher ());
|
||||
prop_dialog_pages.push_back (generic_opt);
|
||||
|
||||
|
|
@ -420,13 +421,13 @@ show_editor_options_page (lay::LayoutView *view)
|
|||
}
|
||||
}
|
||||
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = prop_dialog_pages.begin (); op != prop_dialog_pages.end (); ++op) {
|
||||
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = prop_dialog_pages.begin (); op != prop_dialog_pages.end (); ++op) {
|
||||
(*op)->activate (false);
|
||||
}
|
||||
|
||||
remove_editor_options_page (view);
|
||||
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
lay::EditorOptionsPages *pages = new lay::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
view->editor_options_frame ()->layout ()->addWidget (pages);
|
||||
view->editor_options_frame ()->setFocusProxy (pages);
|
||||
}
|
||||
|
|
@ -447,13 +448,13 @@ remove_editor_options_page (lay::LayoutView *view)
|
|||
}
|
||||
|
||||
static
|
||||
edt::EditorOptionsPages *get_pages_widget (lay::LayoutView *view)
|
||||
lay::EditorOptionsPages *get_pages_widget (lay::LayoutView *view)
|
||||
{
|
||||
// TODO: is there a better way to find the editor options pages?
|
||||
edt::EditorOptionsPages *eo_pages = 0;
|
||||
lay::EditorOptionsPages *eo_pages = 0;
|
||||
QObjectList children = view->editor_options_frame ()->children ();
|
||||
for (QObjectList::iterator c = children.begin (); c != children.end () && !eo_pages; ++c) {
|
||||
eo_pages = dynamic_cast<edt::EditorOptionsPages *> (*c);
|
||||
eo_pages = dynamic_cast<lay::EditorOptionsPages *> (*c);
|
||||
}
|
||||
|
||||
return eo_pages;
|
||||
|
|
@ -462,13 +463,13 @@ edt::EditorOptionsPages *get_pages_widget (lay::LayoutView *view)
|
|||
void
|
||||
activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active)
|
||||
{
|
||||
edt::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
lay::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
if (!eo_pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: this is very inefficient as each "activate" will regenerate the tabs
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
(*op)->activate (((*op)->plugin_declaration () == pd || ! (*op)->plugin_declaration ()) && active);
|
||||
}
|
||||
}
|
||||
|
|
@ -476,12 +477,12 @@ activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool
|
|||
void
|
||||
setup_pages (lay::LayoutView *view)
|
||||
{
|
||||
edt::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
lay::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
if (!eo_pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
(*op)->setup (view);
|
||||
}
|
||||
}
|
||||
|
|
@ -489,12 +490,12 @@ setup_pages (lay::LayoutView *view)
|
|||
void
|
||||
commit_recent (lay::LayoutView *view)
|
||||
{
|
||||
edt::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
lay::EditorOptionsPages *eo_pages = get_pages_widget (view);
|
||||
if (!eo_pages) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
|
||||
if ((*op)->active ()) {
|
||||
(*op)->commit_recent (view);
|
||||
}
|
||||
|
|
@ -516,7 +517,7 @@ public:
|
|||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const
|
||||
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const
|
||||
{
|
||||
// .. no specific ones ..
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,12 +31,11 @@
|
|||
namespace lay
|
||||
{
|
||||
class Dispatcher;
|
||||
class EditorOptionsPage;
|
||||
}
|
||||
|
||||
namespace edt
|
||||
{
|
||||
class EditorOptionsPage;
|
||||
|
||||
/**
|
||||
* @brief A helper class for plugin declarations for editor services
|
||||
*/
|
||||
|
|
@ -44,7 +43,7 @@ namespace edt
|
|||
: public lay::PluginDeclaration
|
||||
{
|
||||
public:
|
||||
virtual void get_editor_options_pages (std::vector<edt::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) const = 0;
|
||||
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &, lay::LayoutView *, lay::Dispatcher *) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -786,24 +786,5 @@ coords_to_string (const db::DPoint &dp, double dbu, bool du, const char *sep)
|
|||
return coord_to_string (dp.x (), dbu, du) + sep + coord_to_string (dp.y (), dbu, du);
|
||||
}
|
||||
|
||||
void
|
||||
indicate_error (QWidget *le, const tl::Exception *ex)
|
||||
{
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
QPalette pl = le->palette ();
|
||||
if (ex) {
|
||||
pl.setColor (QPalette::Active, QPalette::Text, Qt::red);
|
||||
pl.setColor (QPalette::Active, QPalette::Base, QColor (Qt::red).lighter (180));
|
||||
le->setToolTip (tl::to_qstring (ex->msg ()));
|
||||
} else {
|
||||
QWidget *pw = dynamic_cast<QWidget *> (le->parent ());
|
||||
tl_assert (pw != 0);
|
||||
pl.setColor (QPalette::Active, QPalette::Text, pw->palette ().color (QPalette::Text));
|
||||
pl.setColor (QPalette::Active, QPalette::Base, pw->palette ().color (QPalette::Base));
|
||||
le->setToolTip (QString ());
|
||||
}
|
||||
le->setPalette (pl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -480,11 +480,6 @@ db::Point point_from_dpoint (const db::DPoint &dp, double dbu, bool du, const db
|
|||
*/
|
||||
db::Coord coord_from_string (const char *txt, double dbu, bool du, const db::VCplxTrans &t);
|
||||
|
||||
/**
|
||||
* @brief Configures a QLineEdit to indicate a format error
|
||||
*/
|
||||
void indicate_error (QWidget *le, const tl::Exception *ex);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "layDialogs.h"
|
||||
#include "layObjectInstPath.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layQtTools.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "tlString.h"
|
||||
|
||||
|
|
@ -508,10 +509,10 @@ PolygonPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Sha
|
|||
|
||||
}
|
||||
|
||||
indicate_error (pointListEdit, 0);
|
||||
lay::indicate_error (pointListEdit, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (pointListEdit, &ex);
|
||||
lay::indicate_error (pointListEdit, &ex);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
@ -608,33 +609,33 @@ BoxPropertiesPage::get_box (int mode) const
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x1_le_1->text ()), x1);
|
||||
indicate_error (x1_le_1, 0);
|
||||
lay::indicate_error (x1_le_1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x1_le_1, &ex);
|
||||
lay::indicate_error (x1_le_1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y1_le_1->text ()), y1);
|
||||
indicate_error (y1_le_1, 0);
|
||||
lay::indicate_error (y1_le_1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y1_le_1, &ex);
|
||||
lay::indicate_error (y1_le_1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x2_le_1->text ()), x2);
|
||||
indicate_error (x2_le_1, 0);
|
||||
lay::indicate_error (x2_le_1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x2_le_1, &ex);
|
||||
lay::indicate_error (x2_le_1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y2_le_1->text ()), y2);
|
||||
indicate_error (y2_le_1, 0);
|
||||
lay::indicate_error (y2_le_1, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y2_le_1, &ex);
|
||||
lay::indicate_error (y2_le_1, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -668,33 +669,33 @@ BoxPropertiesPage::get_box (int mode) const
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (cx_le_2->text ()), cx);
|
||||
indicate_error (cx_le_2, 0);
|
||||
lay::indicate_error (cx_le_2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (cx_le_2, &ex);
|
||||
lay::indicate_error (cx_le_2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (cy_le_2->text ()), cy);
|
||||
indicate_error (cy_le_2, 0);
|
||||
lay::indicate_error (cy_le_2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (cy_le_2, &ex);
|
||||
lay::indicate_error (cy_le_2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (w_le_2->text ()), w);
|
||||
indicate_error (w_le_2, 0);
|
||||
lay::indicate_error (w_le_2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (w_le_2, &ex);
|
||||
lay::indicate_error (w_le_2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (h_le_2->text ()), h);
|
||||
indicate_error (h_le_2, 0);
|
||||
lay::indicate_error (h_le_2, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (h_le_2, &ex);
|
||||
lay::indicate_error (h_le_2, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -833,17 +834,17 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x_le->text ()), x);
|
||||
indicate_error (x_le, 0);
|
||||
lay::indicate_error (x_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x_le, &ex);
|
||||
lay::indicate_error (x_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y_le->text ()), y);
|
||||
indicate_error (y_le, 0);
|
||||
lay::indicate_error (y_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y_le, &ex);
|
||||
lay::indicate_error (y_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -874,9 +875,9 @@ TextPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db::Shape
|
|||
if (! size_le->text ().isEmpty ()) {
|
||||
try {
|
||||
size = coord_from_string (tl::to_string (size_le->text ()).c_str (), dbu, du, t);
|
||||
indicate_error (size_le, 0);
|
||||
lay::indicate_error (size_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (size_le, &ex);
|
||||
lay::indicate_error (size_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1083,19 +1084,19 @@ EditablePathPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db
|
|||
throw tl::Exception (tl::to_string (QObject::tr ("The path must have at least one point")));
|
||||
}
|
||||
|
||||
indicate_error (ptlist_le, 0);
|
||||
lay::indicate_error (ptlist_le, 0);
|
||||
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (ptlist_le, &ex);
|
||||
lay::indicate_error (ptlist_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
db::Coord w = 0;
|
||||
try {
|
||||
w = coord_from_string (tl::to_string (width_le->text ()).c_str (), dbu, du, t);
|
||||
indicate_error (width_le, 0);
|
||||
lay::indicate_error (width_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (width_le, &ex);
|
||||
lay::indicate_error (width_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -1110,16 +1111,16 @@ EditablePathPropertiesPage::create_applicator (db::Shapes & /*shapes*/, const db
|
|||
case 2: // variable
|
||||
try {
|
||||
se = coord_from_string (tl::to_string (start_ext_le->text ()).c_str (), dbu, du, t);
|
||||
indicate_error (start_ext_le, 0);
|
||||
lay::indicate_error (start_ext_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (start_ext_le, &ex);
|
||||
lay::indicate_error (start_ext_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
try {
|
||||
ee = coord_from_string (tl::to_string (end_ext_le->text ()).c_str (), dbu, du, t);
|
||||
indicate_error (end_ext_le, 0);
|
||||
lay::indicate_error (end_ext_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (end_ext_le, &ex);
|
||||
lay::indicate_error (end_ext_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef HDR_edtRecentConfigurationPage
|
||||
#define HDR_edtRecentConfigurationPage
|
||||
|
||||
#include "edtEditorOptionsPage.h"
|
||||
#include "layEditorOptionsPage.h"
|
||||
#include "tlObject.h"
|
||||
|
||||
#include <list>
|
||||
|
|
@ -46,7 +46,8 @@ class EditorOptionsPages;
|
|||
* @brief The base class for a object properties page
|
||||
*/
|
||||
class RecentConfigurationPage
|
||||
: public EditorOptionsPage, public tl::Object
|
||||
: public lay::EditorOptionsPage,
|
||||
public tl::Object
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ namespace edt {
|
|||
|
||||
class Service;
|
||||
class PluginDeclarationBase;
|
||||
class EditorOptionsPages;
|
||||
class EditorOptionsPage;
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "imgStream.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layFileDialog.h"
|
||||
#include "layQtTools.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
|
|
@ -35,27 +36,6 @@ namespace img
|
|||
const double min_gamma = 0.3;
|
||||
const double max_gamma = 3.0;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
indicate_error (QWidget *le, const tl::Exception *ex)
|
||||
{
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
QPalette pl = le->palette ();
|
||||
if (ex) {
|
||||
pl.setColor (QPalette::Active, QPalette::Text, Qt::red);
|
||||
pl.setColor (QPalette::Active, QPalette::Base, QColor (Qt::red).lighter (180));
|
||||
le->setToolTip (tl::to_qstring (ex->msg ()));
|
||||
} else {
|
||||
QWidget *pw = dynamic_cast<QWidget *> (le->parent ());
|
||||
tl_assert (pw != 0);
|
||||
pl.setColor (QPalette::Active, QPalette::Text, pw->palette ().color (QPalette::Text));
|
||||
pl.setColor (QPalette::Active, QPalette::Base, pw->palette ().color (QPalette::Base));
|
||||
le->setToolTip (QString ());
|
||||
}
|
||||
le->setPalette (pl);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// PropertiesPage implementation
|
||||
|
||||
|
|
@ -239,24 +219,24 @@ PropertiesPage::get_xmin_xmax (double &xmin, double &xmax, bool &has_error_out)
|
|||
|
||||
try {
|
||||
tl::from_string (tl::to_string (from_le->text ()), xmin);
|
||||
indicate_error (from_le, 0);
|
||||
lay::indicate_error (from_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (from_le, &ex);
|
||||
lay::indicate_error (from_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (to_le->text ()), xmax);
|
||||
indicate_error (to_le, 0);
|
||||
lay::indicate_error (to_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (to_le, &ex);
|
||||
lay::indicate_error (to_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
if (! has_error && xmin >= xmax) {
|
||||
tl::Exception ex (tl::to_string (QObject::tr ("Invalid data value range (min. value must be less than max. value)")));
|
||||
indicate_error (from_le, &ex);
|
||||
indicate_error (to_le, &ex);
|
||||
lay::indicate_error (from_le, &ex);
|
||||
lay::indicate_error (to_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -356,16 +336,16 @@ PropertiesPage::value_changed ()
|
|||
double x = 0.0;
|
||||
try {
|
||||
tl::from_string (tl::to_string (value_le->text ()), x);
|
||||
indicate_error (value_le, 0);
|
||||
lay::indicate_error (value_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (value_le, &ex);
|
||||
lay::indicate_error (value_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
xx = (x - xmin) / (xmax - xmin);
|
||||
if (! has_error && (xx < 0 || xx > 1.0)) {
|
||||
tl::Exception ex (tl::to_string (QObject::tr ("The position entered (%g) must be between the minimum (%g) and maximum (%g) value")), x, xmin, xmax);
|
||||
indicate_error (value_le, &ex);
|
||||
lay::indicate_error (value_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -825,41 +805,41 @@ PropertiesPage::apply ()
|
|||
if (w <= 0.0 || h <= 0.0) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Pixel width or height must be positive, non-null values")));
|
||||
}
|
||||
indicate_error (width_le, 0);
|
||||
lay::indicate_error (width_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (width_le, &ex);
|
||||
lay::indicate_error (width_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (height_le->text ()), h);
|
||||
indicate_error (height_le, 0);
|
||||
lay::indicate_error (height_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (height_le, &ex);
|
||||
lay::indicate_error (height_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (x_offset_le->text ()), x);
|
||||
indicate_error (x_offset_le, 0);
|
||||
lay::indicate_error (x_offset_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (x_offset_le, &ex);
|
||||
lay::indicate_error (x_offset_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (y_offset_le->text ()), y);
|
||||
indicate_error (y_offset_le, 0);
|
||||
lay::indicate_error (y_offset_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (y_offset_le, &ex);
|
||||
lay::indicate_error (y_offset_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
tl::from_string (tl::to_string (angle_le->text ()), a);
|
||||
indicate_error (angle_le, 0);
|
||||
lay::indicate_error (angle_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (angle_le, &ex);
|
||||
lay::indicate_error (angle_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -868,9 +848,9 @@ PropertiesPage::apply ()
|
|||
if (sa <= -45 || sa >= 45) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("The shear angle must be larger than -45 and less than 45 degree")));
|
||||
}
|
||||
indicate_error (shear_le, 0);
|
||||
lay::indicate_error (shear_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (shear_le, &ex);
|
||||
lay::indicate_error (shear_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -879,9 +859,9 @@ PropertiesPage::apply ()
|
|||
if (tx <= -90 || tx >= 90) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("The perspective tilt angles must be larger than -90 and less than 90 degree")));
|
||||
}
|
||||
indicate_error (persp_tx_le, 0);
|
||||
lay::indicate_error (persp_tx_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (persp_tx_le, &ex);
|
||||
lay::indicate_error (persp_tx_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
@ -890,9 +870,9 @@ PropertiesPage::apply ()
|
|||
if (ty <= -90 || ty >= 90) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("The perspective tilt angles must be larger than -90 and less than 90 degree")));
|
||||
}
|
||||
indicate_error (persp_ty_le, 0);
|
||||
lay::indicate_error (persp_ty_le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
indicate_error (persp_ty_le, &ex);
|
||||
lay::indicate_error (persp_ty_le, &ex);
|
||||
has_error = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
|
||||
#include "tlInternational.h"
|
||||
#include "edtEditorOptionsPage.h"
|
||||
#include "edtEditorOptionsPages.h"
|
||||
#include "layEditorOptionsPage.h"
|
||||
#include "layEditorOptionsPages.h"
|
||||
|
||||
namespace edt
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
@ -20,21 +20,17 @@
|
|||
|
||||
*/
|
||||
|
||||
#ifndef HDR_edtEditorOptionsPage
|
||||
#define HDR_edtEditorOptionsPage
|
||||
#ifndef HDR_layEditorOptionsPage
|
||||
#define HDR_layEditorOptionsPage
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
class PluginDeclaration;
|
||||
class Dispatcher;
|
||||
class Plugin;
|
||||
}
|
||||
|
||||
namespace edt
|
||||
{
|
||||
|
||||
class PluginDeclaration;
|
||||
class Dispatcher;
|
||||
class Plugin;
|
||||
class EditorOptionsPages;
|
||||
|
||||
/**
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2020 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "tlInternational.h"
|
||||
#include "layEditorOptionsPages.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "layPlugin.h"
|
||||
#include "layLayoutView.h"
|
||||
#include "layQtTools.h"
|
||||
#include "ui_EditorOptionsGeneric.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTabWidget>
|
||||
#include <QToolButton>
|
||||
#include <QCompleter>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// EditorOptionsPages implementation
|
||||
|
||||
struct EOPCompareOp
|
||||
{
|
||||
bool operator() (lay::EditorOptionsPage *a, lay::EditorOptionsPage *b) const
|
||||
{
|
||||
return a->order () < b->order ();
|
||||
}
|
||||
};
|
||||
|
||||
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<lay::EditorOptionsPage *> &pages, lay::Dispatcher *dispatcher)
|
||||
: QFrame (parent), mp_dispatcher (dispatcher)
|
||||
{
|
||||
QVBoxLayout *ly1 = new QVBoxLayout (this);
|
||||
ly1->setMargin (0);
|
||||
|
||||
mp_pages = new QTabWidget (this);
|
||||
ly1->addWidget (mp_pages);
|
||||
|
||||
m_pages = pages;
|
||||
for (std::vector <lay::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
(*p)->set_owner (this);
|
||||
}
|
||||
|
||||
update (0);
|
||||
setup ();
|
||||
}
|
||||
|
||||
EditorOptionsPages::~EditorOptionsPages ()
|
||||
{
|
||||
while (m_pages.size () > 0) {
|
||||
delete m_pages.front ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::focusInEvent (QFocusEvent * /*event*/)
|
||||
{
|
||||
// Sends the focus to the current page's last focus owner
|
||||
if (mp_pages->currentWidget () && mp_pages->currentWidget ()->focusWidget ()) {
|
||||
mp_pages->currentWidget ()->focusWidget ()->setFocus ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::unregister_page (lay::EditorOptionsPage *page)
|
||||
{
|
||||
std::vector <lay::EditorOptionsPage *> pages;
|
||||
for (std::vector <lay::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if (*p != page) {
|
||||
pages.push_back (*p);
|
||||
}
|
||||
}
|
||||
m_pages = pages;
|
||||
update (0);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::activate_page (lay::EditorOptionsPage *page)
|
||||
{
|
||||
try {
|
||||
if (page->active ()) {
|
||||
page->setup (mp_dispatcher);
|
||||
}
|
||||
} catch (...) {
|
||||
// catch any errors related to configuration file errors etc.
|
||||
}
|
||||
|
||||
update (page);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::update (lay::EditorOptionsPage *page)
|
||||
{
|
||||
std::vector <lay::EditorOptionsPage *> sorted_pages = m_pages;
|
||||
std::sort (sorted_pages.begin (), sorted_pages.end (), EOPCompareOp ());
|
||||
|
||||
if (! page && m_pages.size () > 0) {
|
||||
page = m_pages.back ();
|
||||
}
|
||||
|
||||
while (mp_pages->count () > 0) {
|
||||
mp_pages->removeTab (0);
|
||||
}
|
||||
int index = -1;
|
||||
for (std::vector <lay::EditorOptionsPage *>::iterator p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
if ((*p) == page) {
|
||||
index = mp_pages->count ();
|
||||
}
|
||||
mp_pages->addTab (*p, tl::to_qstring ((*p)->title ()));
|
||||
} else {
|
||||
(*p)->setParent (0);
|
||||
}
|
||||
}
|
||||
if (index < 0) {
|
||||
index = mp_pages->currentIndex ();
|
||||
}
|
||||
if (index >= int (mp_pages->count ())) {
|
||||
index = mp_pages->count () - 1;
|
||||
}
|
||||
mp_pages->setCurrentIndex (index);
|
||||
|
||||
setVisible (mp_pages->count () > 0);
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::setup ()
|
||||
{
|
||||
try {
|
||||
|
||||
for (std::vector <lay::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
(*p)->setup (mp_dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
// make the display consistent with the status (this is important for
|
||||
// PCell parameters where the PCell may be asked to modify the parameters)
|
||||
do_apply ();
|
||||
|
||||
} catch (...) {
|
||||
// catch any errors related to configuration file errors etc.
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::do_apply ()
|
||||
{
|
||||
for (std::vector <lay::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
|
||||
if ((*p)->active ()) {
|
||||
// NOTE: we apply to the root dispatcher, so other dispatchers (views) get informed too.
|
||||
(*p)->apply (mp_dispatcher->dispatcher ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EditorOptionsPages::apply ()
|
||||
{
|
||||
BEGIN_PROTECTED
|
||||
do_apply ();
|
||||
END_PROTECTED_W (this)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Indicates an error on a line edit
|
||||
|
||||
template <class Value>
|
||||
static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le, const std::string &cfg_name)
|
||||
{
|
||||
try {
|
||||
Value value = Value (0);
|
||||
tl::from_string (tl::to_string (le->text ()), value);
|
||||
dispatcher->config_set (cfg_name, tl::to_string (value));
|
||||
lay::indicate_error (le, 0);
|
||||
} catch (tl::Exception &ex) {
|
||||
lay::indicate_error (le, &ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2020 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HDR_layEditorOptionsPages
|
||||
#define HDR_layEditorOptionsPages
|
||||
|
||||
#include "layEditorOptionsPage.h"
|
||||
|
||||
#include <tlVariant.h>
|
||||
|
||||
#include <QFrame>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class QTabWidget;
|
||||
class QLabel;
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
class PluginDeclaration;
|
||||
class Dispatcher;
|
||||
class Plugin;
|
||||
|
||||
/**
|
||||
* @brief The object properties dialog
|
||||
*/
|
||||
class EditorOptionsPages
|
||||
: public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EditorOptionsPages (QWidget *parent, const std::vector<lay::EditorOptionsPage *> &pages, lay::Dispatcher *root);
|
||||
~EditorOptionsPages ();
|
||||
|
||||
void unregister_page (lay::EditorOptionsPage *page);
|
||||
void activate_page (lay::EditorOptionsPage *page);
|
||||
void focusInEvent (QFocusEvent *event);
|
||||
|
||||
const std::vector <lay::EditorOptionsPage *> &pages () const
|
||||
{
|
||||
return m_pages;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void apply ();
|
||||
void setup ();
|
||||
|
||||
private:
|
||||
std::vector <lay::EditorOptionsPage *> m_pages;
|
||||
lay::Dispatcher *mp_dispatcher;
|
||||
QTabWidget *mp_pages;
|
||||
|
||||
void update (lay::EditorOptionsPage *page);
|
||||
void do_apply ();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
#include <QSplitter>
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPalette>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -159,5 +160,24 @@ restore_dialog_state (QWidget *dialog, const std::string &s, bool with_section_s
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
indicate_error (QWidget *le, const tl::Exception *ex)
|
||||
{
|
||||
// by the way, update the foreground color of the cell edit box as well (red, if not valid)
|
||||
QPalette pl = le->palette ();
|
||||
if (ex) {
|
||||
pl.setColor (QPalette::Active, QPalette::Text, Qt::red);
|
||||
pl.setColor (QPalette::Active, QPalette::Base, QColor (Qt::red).lighter (180));
|
||||
le->setToolTip (tl::to_qstring (ex->msg ()));
|
||||
} else {
|
||||
QWidget *pw = dynamic_cast<QWidget *> (le->parent ());
|
||||
tl_assert (pw != 0);
|
||||
pl.setColor (QPalette::Active, QPalette::Text, pw->palette ().color (QPalette::Text));
|
||||
pl.setColor (QPalette::Active, QPalette::Base, pw->palette ().color (QPalette::Base));
|
||||
le->setToolTip (QString ());
|
||||
}
|
||||
le->setPalette (pl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ class QLabel;
|
|||
class QWidget;
|
||||
class QObject;
|
||||
|
||||
namespace tl
|
||||
{
|
||||
class Exception;
|
||||
}
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
|
|
@ -62,6 +67,14 @@ LAYBASIC_PUBLIC void activate_modal_help_links (QLabel *label);
|
|||
*/
|
||||
LAYBASIC_PUBLIC void register_help_handler (QObject *object, const char *slot, const char *modal_slot);
|
||||
|
||||
/**
|
||||
* @brief Configures a QLineEdit or other widget to indicate an error
|
||||
*
|
||||
* When a non-null ex pointer is passed, the background will be turned red
|
||||
* and the exception's text will be used as tooltip. Use this function with
|
||||
* a null ex pointer to clear the error condition.
|
||||
*/
|
||||
void indicate_error (QWidget *le, const tl::Exception *ex);
|
||||
|
||||
} // namespace lay
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ SOURCES = \
|
|||
layEditable.cc \
|
||||
layEditStipplesForm.cc \
|
||||
layEditStippleWidget.cc \
|
||||
layEditorOptionsPage.cc \
|
||||
layEditorOptionsPages.cc \
|
||||
layFileDialog.cc \
|
||||
layFinder.cc \
|
||||
layFixedFont.cc \
|
||||
|
|
@ -216,6 +218,8 @@ HEADERS = \
|
|||
layEditable.h \
|
||||
layEditStipplesForm.h \
|
||||
layEditStippleWidget.h \
|
||||
layEditorOptionsPage.h \
|
||||
layEditorOptionsPages.h \
|
||||
layFileDialog.h \
|
||||
layFinder.h \
|
||||
layFixedFont.h \
|
||||
|
|
|
|||
Loading…
Reference in New Issue