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

View File

@ -72,7 +72,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le
// EditorOptionsGeneric implementation
EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: EditorOptionsPage (view, dispatcher)
: lay::EditorOptionsPageWidget (view, dispatcher)
{
mp_ui = new Ui::EditorOptionsGeneric ();
mp_ui->setupUi (this);
@ -215,7 +215,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
// EditorOptionsText implementation
EditorOptionsText::EditorOptionsText (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: lay::EditorOptionsPage (view, dispatcher)
: lay::EditorOptionsPageWidget (view, dispatcher)
{
mp_ui = new Ui::EditorOptionsText ();
mp_ui->setupUi (this);
@ -293,7 +293,7 @@ EditorOptionsText::setup (lay::Dispatcher *root)
// EditorOptionsPath implementation
EditorOptionsPath::EditorOptionsPath (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: lay::EditorOptionsPage (view, dispatcher)
: lay::EditorOptionsPageWidget (view, dispatcher)
{
mp_ui = new Ui::EditorOptionsPath ();
mp_ui->setupUi (this);
@ -394,7 +394,7 @@ EditorOptionsPath::setup (lay::Dispatcher *root)
// EditorOptionsInst implementation
EditorOptionsInst::EditorOptionsInst (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: lay::EditorOptionsPage (view, dispatcher)
: lay::EditorOptionsPageWidget (view, dispatcher)
{
mp_ui = new Ui::EditorOptionsInst ();
mp_ui->setupUi (this);
@ -687,7 +687,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root)
// EditorOptionsInstPCellParam implementation
EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
: lay::EditorOptionsPage (view, dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
: lay::EditorOptionsPageWidget (view, dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0)
{
mp_ui = new Ui::EditorOptionsInstPCellParam ();
mp_ui->setupUi (this);

View File

@ -65,7 +65,7 @@ class PCellParametersPage;
* @brief The generic properties page
*/
class EditorOptionsGeneric
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
Q_OBJECT
@ -90,7 +90,7 @@ private:
* @brief The text properties page
*/
class EditorOptionsText
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
public:
EditorOptionsText (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher);
@ -109,7 +109,7 @@ private:
* @brief The path properties page
*/
class EditorOptionsPath
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
Q_OBJECT
@ -133,7 +133,7 @@ private:
* @brief The instance properties page
*/
class EditorOptionsInst
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
Q_OBJECT
@ -165,7 +165,7 @@ private:
* @brief The instance properties page (PCell parameters)
*/
class EditorOptionsInstPCellParam
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
Q_OBJECT

View File

@ -21,13 +21,10 @@
*/
#if defined(HAVE_QT)
# include "layTipDialog.h"
# include "layEditorOptionsPages.h"
#endif
#include "layDispatcher.h"
#include "layLayoutViewBase.h"
#include "layEditorOptionsPage.h"
#include "layTipDialog.h"
#include "edtPlugin.h"
#include "edtConfig.h"
#include "edtService.h"
@ -40,10 +37,8 @@
#include "edtMainService.h"
#include "edtPartialService.h"
#include "edtMoveTrackerService.h"
#if defined(HAVE_QT)
# include "edtEditorOptionsPages.h"
# include "edtRecentConfigurationPage.h"
#endif
#include "edtEditorOptionsPages.h"
#include "edtRecentConfigurationPage.h"
#if defined(HAVE_QT)
# include <QApplication>
@ -65,7 +60,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] =
static
void get_shape_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher)
{
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param",
ret.push_back (new edt::RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param",
&shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])]));
}
#else
@ -94,7 +89,7 @@ void get_text_editor_options_pages (std::vector<lay::EditorOptionsPage *> &ret,
edt::RecentConfigurationPage::ConfigurationDescriptor (cfg_edit_text_valign, tl::to_string (tr ("Vert. align")), edt::RecentConfigurationPage::Text)
};
ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-text-param",
ret.push_back (new edt::RecentConfigurationPage (view, dispatcher, "edit-recent-text-param",
&text_cfg_descriptors[0], &text_cfg_descriptors[sizeof (text_cfg_descriptors) / sizeof (text_cfg_descriptors[0])]));
ret.push_back (new edt::EditorOptionsText (view, dispatcher));
}

View File

@ -48,13 +48,11 @@ namespace edt
class PCellParametersPage;
class EditorOptionsPages;
/**
* @brief The base class for a object properties page
*/
class EDT_PUBLIC RecentConfigurationPage
: public lay::EditorOptionsPage
: public lay::EditorOptionsPageWidget
{
Q_OBJECT
@ -86,7 +84,7 @@ public:
template <class Iter>
RecentConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg)
: EditorOptionsPage (view, dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg), dm_update_list (this, &RecentConfigurationPage::update_list)
: EditorOptionsPageWidget (view, dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg), dm_update_list (this, &RecentConfigurationPage::update_list)
{
init ();
}

View File

@ -2024,18 +2024,17 @@ Service::handle_guiding_shape_changes (bool commit)
void
Service::commit_recent ()
{
#if defined(HAVE_QT)
lay::EditorOptionsPages *eo_pages = view ()->editor_options_pages ();
if (!eo_pages) {
lay::EditorOptionsPageCollection *eo_pages = view ()->editor_options_pages ();
if (! eo_pages) {
return;
}
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
auto pages = eo_pages->editor_options_pages ();
for (auto op = pages.begin (); op != pages.end (); ++op) {
if ((*op)->plugin_declaration () == plugin_declaration ()) {
(*op)->commit_recent (view ());
}
}
#endif
}
// -------------------------------------------------------------

View File

@ -25,15 +25,11 @@
#include "edtPathService.h"
#include "edtPropertiesPages.h"
#include "layLayoutView.h"
#include "layEditorOptionsPage.h"
#include "layTipDialog.h"
#include "dbEdgeProcessor.h"
#include "dbPolygonTools.h"
#if defined(HAVE_QT)
# include "layTipDialog.h"
#endif
#include "layEditorOptionsPages.h"
namespace edt
{
@ -76,21 +72,19 @@ ShapeEditService::config_recent_for_layer (const db::LayerProperties &lp, int cv
return;
}
#if defined(HAVE_QT)
lay::EditorOptionsPages *eo_pages = view ()->editor_options_pages ();
if (!eo_pages) {
lay::EditorOptionsPageCollection *eo_pages = view ()->editor_options_pages ();
if (! eo_pages) {
return;
}
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
auto pages = eo_pages->editor_options_pages ();
for (auto op = pages.begin (); op != pages.end (); ++op) {
if ((*op)->plugin_declaration () == plugin_declaration ()) {
(*op)->config_recent_for_layer (dispatcher (), lp, cv_index);
}
}
#endif
}
void
ShapeEditService::get_edit_layer ()
{

View File

@ -1722,7 +1722,7 @@ MainWindow::update_editor_options_dock ()
eo_visible = pd_sel->editable_enabled ();
}
if (current_view () && eo_visible) {
lay::EditorOptionsPages *eo_pages = current_view ()->editor_options_pages ();
lay::EditorOptionsPageCollection *eo_pages = current_view ()->editor_options_pages ();
if (! eo_pages || ! eo_pages->has_content ()) {
eo_visible = false;
}

View File

@ -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"

View File

@ -28,8 +28,6 @@
#include "gsiDeclLayConfigPage.h"
#include "gsiDeclLayPlugin.h"
#include "layEditorOptionsPages.h"
namespace gsi
{

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
}

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)

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
}

View File

@ -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

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

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");

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 \

View File

@ -103,7 +103,6 @@ SOURCES = \
layEditLineStylesForm.cc \
layEditStippleWidget.cc \
layEditStipplesForm.cc \
layEditorOptionsFrame.cc \
layFileDialog.cc \
layGenericSyntaxHighlighter.cc \
layHierarchyControlPanel.cc \
@ -161,7 +160,6 @@ HEADERS = \
layEditLineStylesForm.h \
layEditStippleWidget.h \
layEditStipplesForm.h \
layEditorOptionsFrame.h \
layFileDialog.h \
layGenericSyntaxHighlighter.h \
layHierarchyControlPanel.h \

View File

@ -20,8 +20,6 @@
*/
#if defined(HAVE_QT)
#include "layEditorOptionsFrame.h"
#include "layEditorOptionsPage.h"
#include "layEditorOptionsPages.h"
@ -64,11 +62,10 @@ EditorOptionsFrame::populate (LayoutViewBase *view)
delete mp_pages;
}
mp_pages = new lay::EditorOptionsPages (this, prop_dialog_pages, view);
mp_pages = new lay::EditorOptionsPages (this, view, prop_dialog_pages);
layout ()->addWidget (mp_pages);
setFocusProxy (mp_pages);
}
}
#endif

View File

@ -20,12 +20,10 @@
*/
#if defined(HAVE_QT)
#ifndef HDR_layEditorOptionsFrame
#define HDR_layEditorOptionsFrame
#include "layuiCommon.h"
#include "layviewCommon.h"
#include <QFrame>
namespace lay
@ -34,7 +32,7 @@ namespace lay
class EditorOptionsPages;
class LayoutViewBase;
class LAYUI_PUBLIC EditorOptionsFrame
class LAYVIEW_PUBLIC EditorOptionsFrame
: public QFrame
{
public:
@ -55,5 +53,3 @@ public:
}
#endif
#endif // defined(HAVE_QT)

View File

@ -20,8 +20,6 @@
*/
#if defined(HAVE_QT)
#include "tlInternational.h"
#include "layEditorOptionsPages.h"
#include "tlExceptions.h"
@ -51,8 +49,8 @@ struct EOPCompareOp
}
};
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<lay::EditorOptionsPage *> &pages, lay::Dispatcher *dispatcher)
: QFrame (parent), mp_dispatcher (dispatcher)
EditorOptionsPages::EditorOptionsPages (QWidget *parent, lay::LayoutViewBase *view, const std::vector<lay::EditorOptionsPage *> &pages)
: QFrame (parent), mp_view (view)
{
mp_modal_pages = new EditorOptionsModalPages (this);
@ -63,9 +61,14 @@ EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<lay::
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);
for (auto p = pages.begin (); p != pages.end (); ++p) {
m_pages.push_back (*p);
}
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (! p->is_toolbox_widget ()) {
p->set_owner (this);
}
}
update (0);
@ -91,11 +94,39 @@ EditorOptionsPages::focusInEvent (QFocusEvent * /*event*/)
}
}
const tl::weak_collection <lay::EditorOptionsPage> &
EditorOptionsPages::pages () const
{
return m_pages;
}
std::vector<lay::EditorOptionsPage *>
EditorOptionsPages::editor_options_pages (const lay::PluginDeclaration *plugin_declaration)
{
std::vector<lay::EditorOptionsPage *> pages;
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->plugin_declaration () == plugin_declaration) {
pages.push_back (const_cast<lay::EditorOptionsPage *> (p.operator-> ()));
}
}
return pages;
}
std::vector<lay::EditorOptionsPage *>
EditorOptionsPages::editor_options_pages ()
{
std::vector<lay::EditorOptionsPage *> pages;
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
pages.push_back (const_cast<lay::EditorOptionsPage *> (p.operator-> ()));
}
return pages;
}
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 ()) {
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->active () && ! p->is_modal_page () && ! p->is_toolbox_widget ()) {
return true;
}
}
@ -105,8 +136,8 @@ EditorOptionsPages::has_content () const
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 ()) {
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->active () && p->is_modal_page () && ! p->is_toolbox_widget ()) {
return true;
}
}
@ -122,7 +153,7 @@ EditorOptionsPages::exec_modal (EditorOptionsPage *page)
// found the page - make it current and show the dialog
mp_modal_pages->set_current_index (i);
page->setup (mp_dispatcher);
page->setup (mp_view);
page->set_focus ();
return mp_modal_pages->exec () != 0;
@ -138,25 +169,19 @@ 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) {
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 ()) {
} else if (plugin && plugin->plugin_declaration () == op->plugin_declaration ()) {
is_active = true;
}
(*op)->activate (is_active);
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;
m_pages.erase (page);
update (0);
}
@ -164,9 +189,9 @@ void
EditorOptionsPages::make_page_current (lay::EditorOptionsPage *page)
{
for (int i = 0; i < mp_pages->count (); ++i) {
if (mp_pages->widget (i) == page) {
if (mp_pages->widget (i) == page->widget ()) {
mp_pages->setCurrentIndex (i);
page->setup (mp_dispatcher);
page->setup (mp_view);
page->set_focus ();
break;
}
@ -178,7 +203,7 @@ EditorOptionsPages::activate_page (lay::EditorOptionsPage *page)
{
try {
if (page->active ()) {
page->setup (mp_dispatcher);
page->setup (mp_view);
}
} catch (...) {
// catch any errors related to configuration file errors etc.
@ -190,7 +215,12 @@ EditorOptionsPages::activate_page (lay::EditorOptionsPage *page)
void
EditorOptionsPages::update (lay::EditorOptionsPage *page)
{
std::vector <lay::EditorOptionsPage *> sorted_pages = m_pages;
std::vector <lay::EditorOptionsPageWidget *> sorted_pages;
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->widget ()) {
sorted_pages.push_back (p->widget ());
}
}
std::sort (sorted_pages.begin (), sorted_pages.end (), EOPCompareOp ());
if (! page && m_pages.size () > 0) {
@ -208,9 +238,11 @@ EditorOptionsPages::update (lay::EditorOptionsPage *page)
int index = -1;
int modal_index = -1;
for (std::vector <lay::EditorOptionsPage *>::iterator p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
for (auto p = sorted_pages.begin (); p != sorted_pages.end (); ++p) {
if ((*p)->active ()) {
if (! (*p)->is_modal_page ()) {
if ((*p)->is_toolbox_widget ()) {
mp_view->add_toolbox_widget (*p);
} else if (! (*p)->is_modal_page ()) {
if ((*p) == page) {
index = mp_pages->count ();
}
@ -250,9 +282,9 @@ 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);
for (auto p = m_pages.begin (); p != m_pages.end (); ++p) {
if (p->active ()) {
p->setup (mp_view);
}
}
@ -267,10 +299,10 @@ 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 ()) {
for (auto 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 ());
p->apply (mp_view->dispatcher ());
}
}
}
@ -349,7 +381,7 @@ EditorOptionsModalPages::set_current_index (int index)
}
void
EditorOptionsModalPages::add_page (EditorOptionsPage *page)
EditorOptionsModalPages::add_page (EditorOptionsPageWidget *page)
{
if (! mp_single_page) {
if (mp_pages->count () == 0) {
@ -388,7 +420,7 @@ EditorOptionsModalPages::remove_page (int index)
mp_pages->removeTab (index);
if (mp_pages->count () == 1) {
mp_pages->hide ();
mp_single_page = dynamic_cast<EditorOptionsPage *> (mp_pages->widget (0));
mp_single_page = dynamic_cast<EditorOptionsPageWidget *> (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);
@ -445,5 +477,3 @@ END_PROTECTED
}
}
#endif

View File

@ -20,14 +20,14 @@
*/
#if defined(HAVE_QT)
#ifndef HDR_layEditorOptionsPages
#define HDR_layEditorOptionsPages
#include "laybasicCommon.h"
#include "layviewCommon.h"
#include "layEditorOptionsPage.h"
#include "tlObjectCollection.h"
#include <QFrame>
#include <QDialog>
@ -50,29 +50,27 @@ class EditorOptionsModalPages;
/**
* @brief The object properties tab widget
*/
class LAYBASIC_PUBLIC EditorOptionsPages
: public QFrame
class LAYVIEW_PUBLIC EditorOptionsPages
: public QFrame, public lay::EditorOptionsPageCollection
{
Q_OBJECT
public:
EditorOptionsPages (QWidget *parent, const std::vector<lay::EditorOptionsPage *> &pages, lay::Dispatcher *root);
EditorOptionsPages (QWidget *parent, lay::LayoutViewBase *view, const std::vector<lay::EditorOptionsPage *> &pages);
~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);
virtual void unregister_page (lay::EditorOptionsPage *page);
virtual bool has_content () const;
virtual bool has_modal_content () const;
virtual void activate_page (lay::EditorOptionsPage *page);
virtual void make_page_current (lay::EditorOptionsPage *page);
virtual bool exec_modal (lay::EditorOptionsPage *page);
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages (const lay::PluginDeclaration *plugin_declaration);
virtual std::vector<lay::EditorOptionsPage *> editor_options_pages ();
virtual void activate (const lay::Plugin *plugin);
const std::vector <lay::EditorOptionsPage *> &pages () const
{
return m_pages;
}
const tl::weak_collection <lay::EditorOptionsPage> &pages () const;
bool has_content () const;
bool has_modal_content () const;
void do_apply (bool modal);
public slots:
@ -80,12 +78,13 @@ public slots:
void setup ();
private:
std::vector <lay::EditorOptionsPage *> m_pages;
lay::Dispatcher *mp_dispatcher;
tl::weak_collection <lay::EditorOptionsPage> m_pages;
lay::LayoutViewBase *mp_view;
QTabWidget *mp_pages;
EditorOptionsModalPages *mp_modal_pages;
void update (lay::EditorOptionsPage *page);
void focusInEvent (QFocusEvent *event);
};
/**
@ -103,7 +102,7 @@ public:
int count ();
int current_index ();
void set_current_index (int index);
void add_page (EditorOptionsPage *page);
void add_page (EditorOptionsPageWidget *page);
void remove_page (int index);
EditorOptionsPage *widget (int index);
@ -116,7 +115,7 @@ private:
EditorOptionsPages *mp_parent;
QTabWidget *mp_pages;
QFrame *mp_single_page_frame;
EditorOptionsPage *mp_single_page;
EditorOptionsPageWidget *mp_single_page;
QDialogButtonBox *mp_button_box;
void update_title ();
@ -126,4 +125,3 @@ private:
#endif
#endif // defined(HAVE_QT)

View File

@ -190,6 +190,13 @@ LayoutViewWidget::~LayoutViewWidget ()
delete view;
}
void
LayoutViewWidget::add_toolbox_widget (lay::EditorOptionsPageWidget *toolbox_widget)
{
toolbox_widget->setParent (this);
mp_layout->insertWidget (0, toolbox_widget);
}
void
LayoutViewWidget::add_notification (const LayoutViewNotification &notificaton)
{
@ -461,6 +468,22 @@ LayoutView::add_notification (const LayoutViewNotification &notification)
}
}
void
LayoutView::remove_notification (const LayoutViewNotification &notification)
{
if (mp_widget) {
mp_widget->remove_notification (notification);
}
}
void
LayoutView::add_toolbox_widget (lay::EditorOptionsPage *toolbox_widget)
{
if (mp_widget && toolbox_widget->widget ()) {
mp_widget->add_toolbox_widget (toolbox_widget->widget ());
}
}
bool
LayoutView::event_filter (QObject *obj, QEvent *event, bool &taken)
{
@ -655,7 +678,7 @@ QWidget *LayoutView::widget ()
return mp_widget;
}
void LayoutView::close()
void LayoutView::close ()
{
close_event ();
close_event.clear ();
@ -758,7 +781,7 @@ LayoutView::do_change_active_cellview ()
dm_setup_editor_option_pages ();
}
lay::EditorOptionsPages *LayoutView::editor_options_pages ()
lay::EditorOptionsPageCollection *LayoutView::editor_options_pages ()
{
if (! mp_editor_options_frame) {
return 0;
@ -770,9 +793,10 @@ lay::EditorOptionsPages *LayoutView::editor_options_pages ()
void LayoutView::do_setup_editor_options_pages ()
{
// initialize the editor option pages
lay::EditorOptionsPages *eo_pages = editor_options_pages ();
lay::EditorOptionsPageCollection *eo_pages = editor_options_pages ();
if (eo_pages) {
for (std::vector<lay::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
auto pages = eo_pages->editor_options_pages ();
for (auto op = pages.begin (); op != pages.end (); ++op) {
(*op)->setup (this);
}
}
@ -1613,7 +1637,7 @@ LayoutView::mode (int m)
void
LayoutView::activate_editor_option_pages ()
{
lay::EditorOptionsPages *eo_pages = editor_options_pages ();
lay::EditorOptionsPageCollection *eo_pages = editor_options_pages ();
if (eo_pages) {
eo_pages->activate (active_plugin ());
}

View File

@ -89,6 +89,7 @@ class Browser;
class ColorButton;
class ConfigureAction;
class EditorOptionsPages;
class EditorOptionsPageWidget;
class PropertiesDialog;
/**
@ -154,6 +155,19 @@ public:
*/
virtual void add_notification (const LayoutViewNotification &notification);
/**
* @brief Removes a notification
*/
virtual void remove_notification (const LayoutViewNotification &notification);
/**
* @brief Adds a toolbox widget
*
* This will take ownership over the EditorOptionsPage object until
* it is re-parented.
*/
virtual void add_toolbox_widget (EditorOptionsPage *toolbox_widget);
/**
* @brief Gets the widget object that view is embedded in
*/
@ -376,7 +390,7 @@ public:
/**
* @brief Gets the editor options pages
*/
virtual lay::EditorOptionsPages *editor_options_pages ();
virtual lay::EditorOptionsPageCollection *editor_options_pages ();
/**
* @brief Gets the layer control panel
@ -750,6 +764,8 @@ public:
/**
* @brief Adds a notification
*
* Notifications are banners that pop up at the top of the view canvas.
*/
void add_notification (const LayoutViewNotification &notification);
@ -758,6 +774,15 @@ public:
*/
void remove_notification (const LayoutViewNotification &notification);
/**
* @brief Adds a tool box widget
*
* Toolbox widgets are EditorOptionsPage widgets that are placed
* at the top of the view canvas instead of being put into
* the editor options panel.
*/
void add_toolbox_widget (lay::EditorOptionsPageWidget *toolbox_widget);
/**
* @brief Gets the LayoutView embedded into this widget
*/

View File

@ -10,11 +10,15 @@ RESOURCES = \
SOURCES = \
layGridNet.cc \
layEditorOptionsFrame.cc \
layEditorOptionsPages.cc \
layviewForceLink.cc \
gsiDeclLayAdditional.cc \
HEADERS = \
layGridNet.h \
layEditorOptionsFrame.h \
layEditorOptionsPages.h \
layLayoutView.h \
layviewForceLink.h \