mirror of https://github.com/KLayout/klayout.git
WIP: more consistent editor options
This commit is contained in:
parent
3003eb96e7
commit
994731c1f0
|
|
@ -153,6 +153,8 @@ EditorOptionsPages::update (edt::EditorOptionsPage *page)
|
|||
index = mp_pages->count () - 1;
|
||||
}
|
||||
mp_pages->setCurrentIndex (index);
|
||||
|
||||
setVisible (mp_pages->count () > 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -424,16 +424,26 @@ show_editor_options_page (lay::LayoutView *view)
|
|||
(*op)->activate (false);
|
||||
}
|
||||
|
||||
remove_editor_options_page (view);
|
||||
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
view->editor_options_frame ()->layout ()->addWidget (pages);
|
||||
view->editor_options_frame ()->setFocusProxy (pages);
|
||||
}
|
||||
|
||||
void
|
||||
remove_editor_options_page (lay::LayoutView *view)
|
||||
{
|
||||
if (! view->editor_options_frame ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QObjectList children = view->editor_options_frame ()->children ();
|
||||
for (QObjectList::iterator c = children.begin (); c != children.end (); ++c) {
|
||||
if (dynamic_cast<QWidget *> (*c)) {
|
||||
delete *c;
|
||||
}
|
||||
}
|
||||
|
||||
edt::EditorOptionsPages *pages = new edt::EditorOptionsPages (view->editor_options_frame (), prop_dialog_pages, view);
|
||||
view->editor_options_frame ()->layout ()->addWidget (pages);
|
||||
view->editor_options_frame ()->setFocusProxy (pages);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
|
|
@ -48,12 +48,15 @@ namespace edt
|
|||
};
|
||||
|
||||
/**
|
||||
* @brief Show the editor options dialog
|
||||
*
|
||||
* This dialog is a global resource which is managed by the main plugin declaration
|
||||
* @brief Creates an editor options page and installs it inside the view
|
||||
*/
|
||||
void show_editor_options_page (lay::LayoutView *view);
|
||||
|
||||
/**
|
||||
* @brief Removes the editor options page from the view
|
||||
*/
|
||||
void remove_editor_options_page (lay::LayoutView *view);
|
||||
|
||||
/**
|
||||
* @brief Activate or deactivate a certain service
|
||||
*
|
||||
|
|
|
|||
|
|
@ -818,6 +818,8 @@ Service::deactivated ()
|
|||
|
||||
edit_cancel ();
|
||||
|
||||
remove_editor_options_page (view ());
|
||||
|
||||
m_immediate = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class ControlWidgetStack
|
|||
{
|
||||
public:
|
||||
ControlWidgetStack (QWidget *parent = 0, const char *name = 0)
|
||||
: QFrame (parent)
|
||||
: QFrame (parent), mp_current_widget (0)
|
||||
{
|
||||
setObjectName (QString::fromUtf8 (name));
|
||||
|
||||
|
|
@ -217,6 +217,9 @@ public:
|
|||
void removeWidget (size_t index)
|
||||
{
|
||||
if (index < m_widgets.size ()) {
|
||||
if (mp_current_widget == m_widgets [index]) {
|
||||
mp_current_widget = 0;
|
||||
}
|
||||
m_widgets.erase (m_widgets.begin () + index);
|
||||
}
|
||||
if (m_widgets.size () == 0) {
|
||||
|
|
@ -224,13 +227,20 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
QWidget *currentWidget () const
|
||||
{
|
||||
return mp_current_widget;
|
||||
}
|
||||
|
||||
void raiseWidget (size_t index)
|
||||
{
|
||||
mp_current_widget = 0;
|
||||
bool any_visible = false;
|
||||
for (size_t i = 0; i < m_widgets.size (); ++i) {
|
||||
if (m_widgets [i]) {
|
||||
if (i == index) {
|
||||
m_widgets [i]->show ();
|
||||
mp_current_widget = m_widgets [i];
|
||||
any_visible = true;
|
||||
} else {
|
||||
m_widgets [i]->hide ();
|
||||
|
|
@ -259,6 +269,11 @@ public:
|
|||
return mp_bglabel;
|
||||
}
|
||||
|
||||
size_t count () const
|
||||
{
|
||||
return m_widgets.size ();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent (QResizeEvent *)
|
||||
{
|
||||
|
|
@ -277,6 +292,7 @@ protected:
|
|||
}
|
||||
|
||||
std::vector <QWidget *> m_widgets;
|
||||
QWidget *mp_current_widget;
|
||||
QLabel *mp_bglabel;
|
||||
};
|
||||
|
||||
|
|
@ -1990,13 +2006,17 @@ MainWindow::select_mode (int m)
|
|||
}
|
||||
}
|
||||
|
||||
bool editable = false;
|
||||
bool eo_visible = false;
|
||||
if (pd_sel) {
|
||||
editable = pd_sel->editable_enabled ();
|
||||
eo_visible = pd_sel->editable_enabled ();
|
||||
}
|
||||
if (eo_visible && (!mp_eo_stack->currentWidget () || !mp_eo_stack->currentWidget ()->findChild<QWidget *> ())) {
|
||||
//
|
||||
eo_visible = false;
|
||||
}
|
||||
|
||||
if (editable != m_eo_visible) {
|
||||
m_eo_visible = editable;
|
||||
if (eo_visible != m_eo_visible) {
|
||||
m_eo_visible = eo_visible;
|
||||
show_dock_widget (mp_eo_dock_widget, m_eo_visible);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue