This commit is contained in:
Matthias Koefferlein
2026-01-12 15:45:17 +01:00
parent 160cceb7b5
commit c738cf7255
24 changed files with 405 additions and 241 deletions
@@ -25,7 +25,6 @@
#include "gsiDecl.h"
#include "gsiDeclBasic.h"
#include "gsiEnums.h"
#include "layEditorOptionsPages.h"
#include "layCursor.h"
#include "layEditorUtils.h"
#include "layConverters.h"
@@ -28,8 +28,6 @@
#include "gsiDeclLayConfigPage.h"
#include "gsiDeclLayPlugin.h"
#include "layEditorOptionsPages.h"
namespace gsi
{
+78 -58
View File
@@ -20,11 +20,8 @@
*/
#if defined(HAVE_QT)
#include "tlInternational.h"
#include "layEditorOptionsPage.h"
#include "layEditorOptionsPages.h"
#include "layLayoutViewBase.h"
#include "tlExceptions.h"
@@ -38,13 +35,13 @@ namespace lay
// EditorOptionsPage implementation
EditorOptionsPage::EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: QWidget (0), mp_owner (0), m_active (true), m_focus_page (false), m_modal_page (false), mp_plugin_declaration (0), mp_dispatcher (dispatcher), mp_view (view)
: mp_owner (0), m_active (true), m_focus_page (false), m_modal_page (false), m_toolbox_widget (false), mp_plugin_declaration (0), mp_dispatcher (0), mp_view (0)
{
attach_events ();
init (view, dispatcher);
}
EditorOptionsPage::EditorOptionsPage ()
: QWidget (0), mp_owner (0), m_active (true), m_focus_page (false), m_modal_page (false), mp_plugin_declaration (0), mp_dispatcher (0), mp_view (0)
: mp_owner (0), m_active (true), m_focus_page (false), m_modal_page (false), m_toolbox_widget (false), mp_plugin_declaration (0), mp_dispatcher (0), mp_view (0)
{
// .. nothing yet ..
}
@@ -62,57 +59,6 @@ EditorOptionsPage::init (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
attach_events ();
}
void
EditorOptionsPage::edited ()
{
apply (dispatcher ());
}
static bool is_parent_widget (QWidget *w, QWidget *parent)
{
while (w && w != parent) {
w = dynamic_cast<QWidget *> (w->parent ());
}
return w == parent;
}
bool
EditorOptionsPage::focusNextPrevChild (bool next)
{
bool res = QWidget::focusNextPrevChild (next);
// Stop making the focus leave the page - this way we can jump back to the
// view on "enter"
if (res && ! is_modal_page () && ! is_parent_widget (QApplication::focusWidget (), this) && focusWidget ()) {
focusWidget ()->setFocus ();
}
return res;
}
void
EditorOptionsPage::keyPressEvent (QKeyEvent *event)
{
BEGIN_PROTECTED
if (! is_modal_page () && event->modifiers () == Qt::NoModifier && event->key () == Qt::Key_Return) {
// The Return key on a non-modal page commits the values and gives back the focus
// to the view
apply (dispatcher ());
view ()->set_focus ();
event->accept ();
} else {
QWidget::keyPressEvent (event);
}
END_PROTECTED
}
void
EditorOptionsPage::set_focus ()
{
setFocus (Qt::TabFocusReason);
QWidget::focusNextPrevChild (true);
}
int
EditorOptionsPage::show ()
{
@@ -153,7 +99,7 @@ EditorOptionsPage::on_technology_changed ()
}
void
EditorOptionsPage::set_owner (EditorOptionsPages *owner)
EditorOptionsPage::set_owner (EditorOptionsPageCollection *owner)
{
if (mp_owner) {
mp_owner->unregister_page (this);
@@ -172,6 +118,80 @@ EditorOptionsPage::activate (bool active)
}
}
#if defined(HAVE_QT)
// ------------------------------------------------------------------
// EditorOptionsPage implementation
EditorOptionsPageWidget::EditorOptionsPageWidget (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: QWidget (0), EditorOptionsPage (view, dispatcher)
{
init (view, dispatcher);
}
EditorOptionsPageWidget::EditorOptionsPageWidget ()
: QWidget (0), EditorOptionsPage ()
{
// .. nothing yet ..
}
EditorOptionsPageWidget::~EditorOptionsPageWidget ()
{
set_owner (0);
}
void
EditorOptionsPageWidget::edited ()
{
apply (dispatcher ());
}
static bool is_parent_widget (QWidget *w, QWidget *parent)
{
while (w && w != parent) {
w = dynamic_cast<QWidget *> (w->parent ());
}
return w == parent;
}
bool
EditorOptionsPageWidget::focusNextPrevChild (bool next)
{
bool res = QWidget::focusNextPrevChild (next);
// Stop making the focus leave the page - this way we can jump back to the
// view on "enter"
if (res && ! is_modal_page () && ! is_parent_widget (QApplication::focusWidget (), this) && focusWidget ()) {
focusWidget ()->setFocus ();
}
return res;
}
void
EditorOptionsPageWidget::keyPressEvent (QKeyEvent *event)
{
BEGIN_PROTECTED
if (! is_modal_page () && event->modifiers () == Qt::NoModifier && event->key () == Qt::Key_Return) {
// The Return key on a non-modal page commits the values and gives back the focus
// to the view
apply (dispatcher ());
view ()->set_focus ();
event->accept ();
} else {
QWidget::keyPressEvent (event);
}
END_PROTECTED
}
void
EditorOptionsPageWidget::set_focus ()
{
setFocus (Qt::TabFocusReason);
QWidget::focusNextPrevChild (true);
}
#endif
}
+59 -18
View File
@@ -20,8 +20,6 @@
*/
#if defined(HAVE_QT)
#ifndef HDR_layEditorOptionsPage
#define HDR_layEditorOptionsPage
@@ -29,7 +27,9 @@
#include "tlObject.h"
#include <QWidget>
#if defined(HAVE_QT)
# include <QWidget>
#endif
namespace db
{
@@ -44,16 +44,34 @@ class Dispatcher;
class LayoutViewBase;
class Plugin;
class CellView;
class EditorOptionsPages;
class EditorOptionsPage;
class EditorOptionsPageWidget;
/**
* @brief An interface managing a collection of EditorOptionPage objects
*/
class LAYBASIC_PUBLIC EditorOptionsPageCollection
{
public:
virtual ~EditorOptionsPageCollection () { }
virtual void unregister_page (EditorOptionsPage *page) = 0;
virtual bool has_content () const = 0;
virtual bool has_modal_content () const = 0;
virtual void make_page_current (EditorOptionsPage *page) = 0;
virtual void activate_page (EditorOptionsPage *page) = 0;
virtual void activate (const lay::Plugin *plugin) = 0;
virtual bool exec_modal (EditorOptionsPage *page) = 0;
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages (const lay::PluginDeclaration *plugin) = 0;
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages () = 0;
};
/**
* @brief The base class for a object properties page
*/
class LAYBASIC_PUBLIC EditorOptionsPage
: public QWidget, public tl::Object
: public tl::Object
{
Q_OBJECT
public:
EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
EditorOptionsPage ();
@@ -65,17 +83,21 @@ public:
virtual void setup (lay::Dispatcher * /*root*/) { }
virtual void commit_recent (lay::Dispatcher * /*root*/) { }
virtual void config_recent_for_layer (lay::Dispatcher * /*root*/, const db::LayerProperties & /*lp*/, int /*cv_index*/) { }
virtual void set_focus () { }
virtual EditorOptionsPageWidget *widget () { return 0; }
bool is_focus_page () const { return m_focus_page; }
void set_focus_page (bool f) { m_focus_page = f; }
void set_focus ();
bool is_modal_page () const { return m_modal_page; }
void set_modal_page (bool f) { m_modal_page = f; }
bool is_toolbox_widget () const { return m_toolbox_widget; }
void set_toolbox_widget (bool f) { m_toolbox_widget = f; }
bool active () const { return m_active; }
void activate (bool active);
void set_owner (EditorOptionsPages *owner);
void set_owner (EditorOptionsPageCollection *owner);
/**
* @brief Shows the editor page
@@ -98,21 +120,15 @@ public:
return mp_view;
}
protected slots:
void edited ();
protected:
virtual void active_cellview_changed () { }
virtual void technology_changed (const std::string & /*tech*/) { }
virtual bool focusNextPrevChild (bool next);
virtual void keyPressEvent (QKeyEvent *event);
private:
EditorOptionsPages *mp_owner;
EditorOptionsPageCollection *mp_owner;
bool m_active;
bool m_focus_page;
bool m_modal_page;
bool m_modal_page, m_toolbox_widget;
const lay::PluginDeclaration *mp_plugin_declaration;
lay::Dispatcher *mp_dispatcher;
lay::LayoutViewBase *mp_view;
@@ -122,8 +138,33 @@ private:
void attach_events ();
};
#if defined(HAVE_QT)
/**
* @brief The base class for a object properties page
*/
class LAYBASIC_PUBLIC EditorOptionsPageWidget
: public QWidget, public EditorOptionsPage
{
Q_OBJECT
public:
EditorOptionsPageWidget (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
EditorOptionsPageWidget ();
virtual ~EditorOptionsPageWidget ();
virtual void set_focus ();
virtual EditorOptionsPageWidget *widget () { return this; }
protected slots:
void edited ();
protected:
virtual bool focusNextPrevChild (bool next);
virtual void keyPressEvent (QKeyEvent *event);
};
#endif // defined(HAVE_QT)
}
#endif
#endif // defined(HAVE_QT)
@@ -1,449 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 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
*/
#if defined(HAVE_QT)
#include "tlInternational.h"
#include "layEditorOptionsPages.h"
#include "tlExceptions.h"
#include "layPlugin.h"
#include "layLayoutViewBase.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QTabWidget>
#include <QToolButton>
#include <QCompleter>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QPushButton>
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)
{
mp_modal_pages = new EditorOptionsModalPages (this);
QVBoxLayout *ly1 = new QVBoxLayout (this);
ly1->setContentsMargins (0, 0, 0, 0);
mp_pages = new QTabWidget (this);
mp_pages->setSizePolicy (QSizePolicy (QSizePolicy::Ignored, QSizePolicy::Ignored));
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 ();
}
delete mp_modal_pages;
mp_modal_pages = 0;
}
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 ();
}
}
bool
EditorOptionsPages::has_content () const
{
for (std::vector <lay::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
if ((*p)->active () && ! (*p)->is_modal_page ()) {
return true;
}
}
return false;
}
bool
EditorOptionsPages::has_modal_content () const
{
for (std::vector <lay::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
if ((*p)->active () && (*p)->is_modal_page ()) {
return true;
}
}
return false;
}
bool
EditorOptionsPages::exec_modal (EditorOptionsPage *page)
{
for (int i = 0; i < mp_modal_pages->count (); ++i) {
if (mp_modal_pages->widget (i) == page) {
// found the page - make it current and show the dialog
mp_modal_pages->set_current_index (i);
page->setup (mp_dispatcher);
page->set_focus ();
return mp_modal_pages->exec () != 0;
}
}
return false;
}
void
EditorOptionsPages::activate (const lay::Plugin *plugin)
{
for (auto op = m_pages.begin (); op != m_pages.end (); ++op) {
bool is_active = false;
if ((*op)->plugin_declaration () == 0) {
is_active = (plugin && plugin->plugin_declaration ()->enable_catchall_editor_options_pages ());
} else if (plugin && plugin->plugin_declaration () == (*op)->plugin_declaration ()) {
is_active = true;
}
(*op)->activate (is_active);
}
}
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::make_page_current (lay::EditorOptionsPage *page)
{
for (int i = 0; i < mp_pages->count (); ++i) {
if (mp_pages->widget (i) == page) {
mp_pages->setCurrentIndex (i);
page->setup (mp_dispatcher);
page->set_focus ();
break;
}
}
}
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);
}
while (mp_modal_pages->count () > 0) {
mp_modal_pages->remove_page (0);
}
int index = -1;
int modal_index = -1;
for (std::vector <lay::EditorOptionsPage *>::iterator p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
if ((*p)->active ()) {
if (! (*p)->is_modal_page ()) {
if ((*p) == page) {
index = mp_pages->count ();
}
mp_pages->addTab (*p, tl::to_qstring ((*p)->title ()));
} else {
if ((*p) == page) {
modal_index = mp_modal_pages->count ();
}
mp_modal_pages->add_page (*p);
}
} 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);
if (modal_index < 0) {
modal_index = mp_modal_pages->current_index ();
}
if (modal_index >= int (mp_modal_pages->count ())) {
modal_index = mp_modal_pages->count () - 1;
}
mp_modal_pages->set_current_index (modal_index);
setVisible (mp_pages->count () > 0);
}
void
EditorOptionsPages::setup ()
{
BEGIN_PROTECTED
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 (false);
do_apply (true);
END_PROTECTED_W (this)
}
void
EditorOptionsPages::do_apply (bool modal)
{
for (std::vector <lay::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
if ((*p)->active () && modal == (*p)->is_modal_page ()) {
// 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 (false);
END_PROTECTED_W (this)
}
// ------------------------------------------------------------------
// EditorOptionsModalPages implementation
EditorOptionsModalPages::EditorOptionsModalPages (EditorOptionsPages *parent)
: QDialog (parent), mp_parent (parent), mp_single_page (0)
{
QVBoxLayout *ly = new QVBoxLayout (this);
ly->setContentsMargins (0, 0, 0, 0);
QVBoxLayout *ly4 = new QVBoxLayout (0);
ly4->setContentsMargins (6, 6, 6, 0);
ly->addLayout (ly4);
mp_pages = new QTabWidget (this);
ly4->addWidget (mp_pages, 1);
#if QT_VERSION >= 0x50400
mp_pages->setTabBarAutoHide (true);
#endif
mp_pages->hide ();
mp_single_page_frame = new QFrame (this);
QVBoxLayout *ly2 = new QVBoxLayout (mp_single_page_frame);
ly2->setContentsMargins (0, 0, 0, 0);
ly->addWidget (mp_single_page_frame, 1);
mp_single_page_frame->hide ();
QVBoxLayout *ly3 = new QVBoxLayout (0);
ly3->setContentsMargins (6, 6, 6, 6);
ly->addLayout (ly3);
mp_button_box = new QDialogButtonBox (this);
ly3->addWidget (mp_button_box);
mp_button_box->setOrientation (Qt::Horizontal);
mp_button_box->setStandardButtons (QDialogButtonBox::Cancel | QDialogButtonBox::Apply | QDialogButtonBox::Ok);
connect (mp_button_box, SIGNAL (clicked(QAbstractButton *)), this, SLOT (clicked(QAbstractButton *)));
connect (mp_button_box, SIGNAL (accepted()), this, SLOT (accept()));
connect (mp_button_box, SIGNAL (rejected()), this, SLOT (reject()));
update_title ();
}
EditorOptionsModalPages::~EditorOptionsModalPages ()
{
// .. nothing yet ..
}
int
EditorOptionsModalPages::count ()
{
return mp_single_page ? 1 : mp_pages->count ();
}
int
EditorOptionsModalPages::current_index ()
{
return mp_single_page ? 0 : mp_pages->currentIndex ();
}
void
EditorOptionsModalPages::set_current_index (int index)
{
if (! mp_single_page) {
mp_pages->setCurrentIndex (index);
}
}
void
EditorOptionsModalPages::add_page (EditorOptionsPage *page)
{
if (! mp_single_page) {
if (mp_pages->count () == 0) {
mp_single_page = page;
mp_single_page->setParent (mp_single_page_frame);
mp_single_page_frame->layout ()->addWidget (mp_single_page);
mp_single_page_frame->show ();
mp_pages->hide ();
} else {
mp_pages->addTab (page, tl::to_qstring (page->title ()));
}
} else {
mp_pages->clear ();
mp_single_page_frame->layout ()->removeWidget (mp_single_page);
mp_single_page_frame->hide ();
mp_pages->addTab (mp_single_page, tl::to_qstring (mp_single_page->title ()));
mp_single_page = 0;
mp_pages->addTab (page, tl::to_qstring (page->title ()));
mp_pages->show ();
}
update_title ();
}
void
EditorOptionsModalPages::remove_page (int index)
{
if (mp_single_page) {
if (index == 0) {
mp_single_page->setParent (0);
mp_single_page = 0;
mp_single_page_frame->hide ();
mp_single_page_frame->layout ()->removeWidget (mp_single_page);
}
} else {
mp_pages->removeTab (index);
if (mp_pages->count () == 1) {
mp_pages->hide ();
mp_single_page = dynamic_cast<EditorOptionsPage *> (mp_pages->widget (0));
mp_pages->removeTab (0);
mp_single_page->setParent (mp_single_page_frame);
mp_single_page_frame->layout ()->addWidget (mp_single_page);
mp_single_page_frame->show ();
}
}
update_title ();
}
void
EditorOptionsModalPages::update_title ()
{
if (mp_single_page) {
setWindowTitle (tl::to_qstring (mp_single_page->title ()));
} else {
setWindowTitle (tr ("Editor Options"));
}
}
EditorOptionsPage *
EditorOptionsModalPages::widget (int index)
{
if (mp_single_page) {
return index == 0 ? mp_single_page : 0;
} else {
return dynamic_cast<EditorOptionsPage *> (mp_pages->widget (index));
}
}
void
EditorOptionsModalPages::accept ()
{
BEGIN_PROTECTED
mp_parent->do_apply (true);
QDialog::accept ();
END_PROTECTED
}
void
EditorOptionsModalPages::reject ()
{
QDialog::reject ();
}
void
EditorOptionsModalPages::clicked (QAbstractButton *button)
{
BEGIN_PROTECTED
if (button == mp_button_box->button (QDialogButtonBox::Apply)) {
mp_parent->do_apply (true);
}
END_PROTECTED
}
}
#endif
@@ -1,129 +0,0 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 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
*/
#if defined(HAVE_QT)
#ifndef HDR_layEditorOptionsPages
#define HDR_layEditorOptionsPages
#include "laybasicCommon.h"
#include "layEditorOptionsPage.h"
#include <QFrame>
#include <QDialog>
#include <vector>
#include <string>
class QTabWidget;
class QLabel;
class QDialogButtonBox;
class QAbstractButton;
namespace lay
{
class PluginDeclaration;
class Dispatcher;
class Plugin;
class EditorOptionsModalPages;
/**
* @brief The object properties tab widget
*/
class LAYBASIC_PUBLIC 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 activate (const lay::Plugin *plugin);
void focusInEvent (QFocusEvent *event);
void make_page_current (lay::EditorOptionsPage *page);
bool exec_modal (lay::EditorOptionsPage *page);
const std::vector <lay::EditorOptionsPage *> &pages () const
{
return m_pages;
}
bool has_content () const;
bool has_modal_content () const;
void do_apply (bool modal);
public slots:
void apply ();
void setup ();
private:
std::vector <lay::EditorOptionsPage *> m_pages;
lay::Dispatcher *mp_dispatcher;
QTabWidget *mp_pages;
EditorOptionsModalPages *mp_modal_pages;
void update (lay::EditorOptionsPage *page);
};
/**
* @brief The object properties modal page dialog
*/
class LAYBASIC_PUBLIC EditorOptionsModalPages
: public QDialog
{
Q_OBJECT
public:
EditorOptionsModalPages (EditorOptionsPages *parent);
~EditorOptionsModalPages ();
int count ();
int current_index ();
void set_current_index (int index);
void add_page (EditorOptionsPage *page);
void remove_page (int index);
EditorOptionsPage *widget (int index);
private slots:
void accept ();
void reject ();
void clicked (QAbstractButton *button);
private:
EditorOptionsPages *mp_parent;
QTabWidget *mp_pages;
QFrame *mp_single_page_frame;
EditorOptionsPage *mp_single_page;
QDialogButtonBox *mp_button_box;
void update_title ();
};
}
#endif
#endif // defined(HAVE_QT)
+2 -33
View File
@@ -22,7 +22,6 @@
#include "layEditorServiceBase.h"
#include "layEditorOptionsPage.h"
#include "layEditorOptionsPages.h"
#include "layViewport.h"
#include "layLayoutViewBase.h"
#include "laybasicConfig.h"
@@ -345,22 +344,14 @@ EditorServiceBase::activated ()
m_active = true;
}
#if defined(HAVE_QT)
std::vector<lay::EditorOptionsPage *>
EditorServiceBase::editor_options_pages ()
{
lay::EditorOptionsPages *eo_pages = mp_view->editor_options_pages ();
lay::EditorOptionsPageCollection *eo_pages = mp_view->editor_options_pages ();
if (!eo_pages) {
return std::vector<lay::EditorOptionsPage *> ();
} else {
std::vector<lay::EditorOptionsPage *> pages;
for (auto p = eo_pages->pages ().begin (); p != eo_pages->pages ().end (); ++p) {
if ((*p)->plugin_declaration () == plugin_declaration ()) {
pages.push_back (*p);
}
}
return pages;
return eo_pages->editor_options_pages (plugin_declaration ());
}
}
@@ -402,26 +393,4 @@ EditorServiceBase::show_error (tl::Exception &ex)
QMessageBox::critical (ui ()->widget (), tr ("Error"), tl::to_qstring (ex.msg ()));
}
#else
bool
EditorServiceBase::key_event (unsigned int key, unsigned int buttons)
{
return false;
}
void
EditorServiceBase::show_error (tl::Exception &ex)
{
tl::error << ex.msg ();
}
int
EditorServiceBase::focus_page_open ()
{
return 0;
}
#endif
}
@@ -272,7 +272,6 @@ public:
*/
virtual int focus_page_open ();
#if defined(HAVE_QT)
/**
* @brief Gets the editor options pages associated with this plugin
*/
@@ -282,7 +281,6 @@ public:
* @brief Gets the focus page or 0 if there is none
*/
lay::EditorOptionsPage *focus_page ();
#endif
private:
// The marker representing the mouse cursor
+31 -3
View File
@@ -77,11 +77,12 @@ class MouseTracker;
class ZoomService;
class SelectionService;
class MoveService;
class EditorOptionsPage;
class EditorOptionsPageCollection;
#if defined(HAVE_QT)
class LayerControlPanel;
class HierarchyControlPanel;
class EditorOptionsPages;
#endif
/**
@@ -351,6 +352,33 @@ public:
// the base implementation does nothing
}
/**
* @brief Removes a notification
*/
virtual void remove_notification (const LayoutViewNotification & /*notification*/)
{
// the base implementation does nothing
}
/**
* @brief Shows or hides a toolbox widget with the given name
*
* Initially toolbox widgets are invisible. They are made visible
* by using this method.
*/
virtual void show_toolbox_widget (const std::string & /*name*/, bool /*visible*/)
{
// the base implementation does nothing
}
/**
* @brief Adds an editor options page as a toolbox widget
*/
virtual void add_toolbox_widget (lay::EditorOptionsPage * /*toolbox_widget*/)
{
// the base implementation does nothing
}
/**
* @brief Gets the explicit title string of the view
*
@@ -1899,15 +1927,15 @@ public:
{
return 0;
}
#endif
/**
* @brief Gets the editor options page
*/
virtual lay::EditorOptionsPages *editor_options_pages ()
virtual lay::EditorOptionsPageCollection *editor_options_pages ()
{
return 0;
}
#endif
/**
* @brief Get the current viewport
+55
View File
@@ -27,6 +27,13 @@
#include "laySelector.h"
#include "laybasicConfig.h"
#if defined(HAVE_QT)
# include "layEditorOptionsPage.h"
# include <QWidget>
# include <QHBoxLayout>
# include <QLineEdit>
#endif
namespace lay
{
@@ -369,6 +376,47 @@ MoveService::finish ()
// ----------------------------------------------------------------------------
#if defined(HAVE_QT)
namespace {
class MoveToolboxPage
: public lay::EditorOptionsPageWidget
{
public:
MoveToolboxPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: lay::EditorOptionsPageWidget (view, dispatcher)
{
mp_layout = new QHBoxLayout (this);
mp_x_le = new QLineEdit (this);
mp_layout->addWidget (mp_x_le);
mp_y_le = new QLineEdit (this);
mp_layout->addWidget (mp_y_le);
mp_layout->addStretch (1);
// @@@
set_toolbox_widget (true);
}
virtual std::string title () const
{
return "Move Options";
}
virtual int order () const
{
return 0;
}
private:
QHBoxLayout *mp_layout;
QLineEdit *mp_x_le, *mp_y_le;
};
}
#endif
class MoveServiceDeclaration
: public lay::PluginDeclaration
{
@@ -383,6 +431,13 @@ public:
{
return new MoveService (view);
}
#if defined(HAVE_QT)
virtual void get_editor_options_pages (std::vector<lay::EditorOptionsPage *> &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const
{
pages.push_back (new MoveToolboxPage (view, dispatcher));
}
#endif
};
static tl::RegisteredClass<lay::PluginDeclaration> move_service_decl (new MoveServiceDeclaration (), -970, "laybasic::MoveServicePlugin");
-2
View File
@@ -42,7 +42,6 @@ SOURCES += \
gsiDeclLayPluginFactory.cc \
layAbstractMenu.cc \
layEditorOptionsPage.cc \
layEditorOptionsPages.cc \
layEditorUtils.cc \
layLayoutViewConfig.cc \
layMargin.cc \
@@ -100,7 +99,6 @@ HEADERS += \
gsiDeclLayEditorOptionsPage.h \
gsiDeclLayPlugin.h \
layEditorOptionsPage.h \
layEditorOptionsPages.h \
layEditorUtils.h \
layMargin.h \
laybasicConfig.h \