WIP: put the editor options into a separate dockable widget

This commit is contained in:
Matthias Koefferlein 2020-08-08 21:10:01 +02:00
parent 2714b34104
commit cdce2cb151
17 changed files with 318 additions and 368 deletions

View File

@ -1,139 +0,0 @@
<ui version="4.0" >
<class>EditorOptionsDialog</class>
<widget class="QDialog" name="EditorOptionsDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>642</width>
<height>572</height>
</rect>
</property>
<property name="windowTitle" >
<string>Object Editor Options</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QTabWidget" name="pages" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tab_2" >
<attribute name="title" >
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="frame" >
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ok_pb" >
<property name="text" >
<string>Ok</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="apply_pb" >
<property name="text" >
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancel_pb" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cancel_pb</sender>
<signal>clicked()</signal>
<receiver>EditorOptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>506</x>
<y>388</y>
</hint>
<hint type="destinationlabel" >
<x>276</x>
<y>205</y>
</hint>
</hints>
</connection>
<connection>
<sender>ok_pb</sender>
<signal>clicked()</signal>
<receiver>EditorOptionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>344</x>
<y>388</y>
</hint>
<hint type="destinationlabel" >
<x>276</x>
<y>205</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,7 +1,8 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditorOptionsPath</class>
<widget class="QWidget" name="EditorOptionsPath" >
<property name="geometry" >
<widget class="QWidget" name="EditorOptionsPath">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,44 +10,60 @@
<height>289</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QFrame" name="frame_2" >
<property name="frameShape" >
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<widget class="QLabel" name="label_2">
<property name="text">
<string> Width </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="width_le" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<widget class="QLineEdit" name="width_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -54,18 +71,18 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>micron</string>
<widget class="QLabel" name="label_3">
<property name="text">
<string>µm</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
@ -77,31 +94,38 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<property name="title">
<string>Extensions</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="spacing" >
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item rowspan="3" row="0" column="4" >
<item row="0" column="4" rowspan="3">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>81</height>
@ -109,100 +133,94 @@
</property>
</spacer>
</item>
<item row="2" column="3" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>micron</string>
<item row="2" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>µm</string>
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>micron</string>
<item row="1" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>µm</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QLineEdit" name="end_ext_le" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<item row="2" column="2">
<widget class="QLineEdit" name="end_ext_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<item row="2" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string> end =</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>start =</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="start_ext_le" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<item row="1" column="2">
<widget class="QLineEdit" name="start_ext_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Variable </string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="type_cb" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="type_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text" >
<property name="text">
<string>Flush</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Square</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Variable</string>
</property>
</item>
<item>
<property name="text" >
<property name="text">
<string>Round</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Type</string>
</property>
</widget>
@ -212,10 +230,10 @@
</item>
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>271</width>
<height>63</height>

View File

@ -30,7 +30,6 @@ FORMS = \
CopyModeDialog.ui \
ChangeLayerOptionsDialog.ui \
EditablePathPropertiesPage.ui \
EditorOptionsDialog.ui \
EditorOptionsGeneric.ui \
EditorOptionsInst.ui \
EditorOptionsPath.ui \

View File

@ -25,10 +25,10 @@
#include "dbLibrary.h"
#include "dbLibraryManager.h"
#include "dbPCellHeader.h"
#include "edtEditorOptionsPages.h"
#include "edtPCellParametersPage.h"
#include "edtConfig.h"
#include "edtService.h"
#include "edtEditorOptionsPages.h"
#include "tlExceptions.h"
#include "layPlugin.h"
#include "layLayoutView.h"
@ -39,6 +39,11 @@
#include "ui_EditorOptionsText.h"
#include "ui_EditorOptionsInst.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QTabWidget>
#include <QToolButton>
namespace edt
{
@ -87,13 +92,27 @@ struct EOPCompareOp
}
};
EditorOptionsPages::EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root)
: mp_root (root)
EditorOptionsPages::EditorOptionsPages (QWidget *parent, const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root)
: QFrame (parent), mp_root (root)
{
mp_ui = new Ui::EditorOptionsDialog ();
mp_ui->setupUi (this);
QVBoxLayout *ly1 = new QVBoxLayout (this);
ly1->setMargin (0);
connect (mp_ui->apply_pb, SIGNAL (clicked ()), this, SLOT (apply ()));
mp_pages = new QTabWidget (this);
ly1->addWidget (mp_pages);
QFrame *f = new QFrame (this);
ly1->addWidget (f);
QToolButton *apply_pb = new QToolButton (f);
apply_pb->setText (tr ("Apply"));
QHBoxLayout *ly2 = new QHBoxLayout (f);
ly2->setMargin (0);
ly2->addStretch (1);
ly2->addWidget (apply_pb);
connect (apply_pb, SIGNAL (clicked ()), this, SLOT (apply ()));
m_pages = pages;
for (std::vector <edt::EditorOptionsPage *>::const_iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
@ -107,11 +126,8 @@ EditorOptionsPages::EditorOptionsPages (const std::vector<edt::EditorOptionsPage
EditorOptionsPages::~EditorOptionsPages ()
{
while (m_pages.size () > 0) {
delete m_pages [0];
delete m_pages.front ();
}
delete mp_ui;
mp_ui = 0;
}
void
@ -131,16 +147,14 @@ void
EditorOptionsPages::activate_page (edt::EditorOptionsPage *page)
{
try {
page->setup (mp_root);
if (page->active ()) {
page->setup (mp_root);
}
} catch (...) {
// catch any errors related to configuration file errors etc.
}
update (page);
if (isVisible ()) {
activateWindow ();
raise ();
}
update (page);
}
void
@ -148,13 +162,13 @@ EditorOptionsPages::update (edt::EditorOptionsPage *page)
{
std::sort (m_pages.begin (), m_pages.end (), EOPCompareOp ());
while (mp_ui->pages->count () > 0) {
mp_ui->pages->removeTab (0);
while (mp_pages->count () > 0) {
mp_pages->removeTab (0);
}
int index = -1;
for (std::vector <edt::EditorOptionsPage *>::iterator p = m_pages.begin (); p != m_pages.end (); ++p) {
if ((*p)->active ()) {
mp_ui->pages->addTab ((*p)->q_frame (), tl::to_qstring ((*p)->title ()));
mp_pages->addTab ((*p)->q_frame (), tl::to_qstring ((*p)->title ()));
if ((*p) == page) {
index = int (std::distance (m_pages.begin (), p));
}
@ -163,12 +177,12 @@ EditorOptionsPages::update (edt::EditorOptionsPage *page)
}
}
if (index < 0) {
index = mp_ui->pages->currentIndex ();
index = mp_pages->currentIndex ();
}
if (index >= int (mp_ui->pages->count ())) {
index = mp_ui->pages->count () - 1;
if (index >= int (mp_pages->count ())) {
index = mp_pages->count () - 1;
}
mp_ui->pages->setCurrentIndex (index);
mp_pages->setCurrentIndex (index);
}
void
@ -209,15 +223,6 @@ BEGIN_PROTECTED
END_PROTECTED_W (this)
}
void
EditorOptionsPages::accept ()
{
BEGIN_PROTECTED
do_apply ();
QDialog::accept ();
END_PROTECTED_W (this)
}
// ------------------------------------------------------------------
// EditorOptionsGeneric implementation

View File

@ -26,10 +26,12 @@
#include <tlVariant.h>
#include <QDialog>
#include <QFrame>
#include <vector>
#include <string>
class QTabWidget;
namespace Ui
{
class EditorOptionsDialog;
@ -87,26 +89,30 @@ private:
* @brief The object properties dialog
*/
class EditorOptionsPages
: public QDialog
: public QFrame
{
Q_OBJECT
public:
EditorOptionsPages (const std::vector<edt::EditorOptionsPage *> &pages, lay::Dispatcher *root);
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);
const std::vector <edt::EditorOptionsPage *> &pages () const
{
return m_pages;
}
public slots:
void apply ();
void setup ();
void accept ();
private:
std::vector <edt::EditorOptionsPage *> m_pages;
Ui::EditorOptionsDialog *mp_ui;
lay::Dispatcher *mp_root;
QTabWidget *mp_pages;
void update (edt::EditorOptionsPage *page);
void do_apply ();

View File

@ -150,8 +150,6 @@ MainService::menu_activated (const std::string &symbol)
cm_descend ();
} else if (symbol == "edt::ascend") {
cm_ascend ();
} else if (symbol == "edt::edit_options") {
cm_edit_options ();
} else if (symbol == "edt::sel_align") {
cm_align ();
} else if (symbol == "edt::sel_distribute") {
@ -2272,9 +2270,9 @@ MainService::cm_change_layer ()
}
void
MainService::cm_edit_options ()
MainService::show_editor_options ()
{
show_editor_options_dialog ();
show_editor_options_page (view ());
}
void

View File

@ -94,11 +94,6 @@ public:
*/
void cm_ascend ();
/**
* @brief Edit object options
*/
void cm_edit_options ();
/**
* @brief Change the layer of the shapes in the selection
*/
@ -194,6 +189,11 @@ public:
*/
void cm_tap ();
/**
* @brief Shows the editor options
*/
void show_editor_options ();
/**
* @brief "paste" operation
*/

View File

@ -31,6 +31,7 @@
#include "edtEditorOptionsPages.h"
#include <QApplication>
#include <QLayout>
namespace edt
{
@ -189,7 +190,7 @@ class MainPluginDeclaration
{
public:
MainPluginDeclaration (const std::string &title)
: mp_root (0), m_title (title), mp_obj_prop_dialog (0)
: mp_root (0), m_title (title)
{
// .. nothing yet ..
}
@ -218,8 +219,6 @@ public:
menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)"));
menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)"));
menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)"));
menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array"))));
menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end"));
menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer"))));
@ -279,24 +278,6 @@ public:
mp_root = root;
// create the editor options dialog
m_prop_dialog_pages.push_back (new edt::EditorOptionsGeneric ());
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
const PluginDeclarationBase *pd_base = dynamic_cast<const PluginDeclarationBase *> (&*cls);
if (pd_base) {
pd_base->get_editor_options_pages (m_prop_dialog_pages, root);
}
}
mp_obj_prop_dialog = new edt::EditorOptionsPages (m_prop_dialog_pages, root);
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = m_prop_dialog_pages.begin (); op != m_prop_dialog_pages.end (); ++op) {
if ((*op)->plugin_declaration () != 0) {
(*op)->activate (false);
}
}
// add entries to the combine mode dialog
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add)));
mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge)));
@ -334,42 +315,6 @@ public:
}
}
virtual void uninitialize (lay::Dispatcher *)
{
if (mp_obj_prop_dialog) {
delete mp_obj_prop_dialog;
mp_obj_prop_dialog = 0;
}
}
virtual void config_finalize ()
{
if (mp_obj_prop_dialog && mp_obj_prop_dialog->isVisible ()) {
mp_obj_prop_dialog->setup ();
}
}
void show_dialog () const
{
if (mp_obj_prop_dialog) {
if (! mp_obj_prop_dialog->isVisible ()) {
mp_obj_prop_dialog->setup ();
mp_obj_prop_dialog->show ();
}
mp_obj_prop_dialog->activateWindow ();
mp_obj_prop_dialog->raise ();
}
}
void activate (const lay::PluginDeclaration *pd, bool active) const
{
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = m_prop_dialog_pages.begin (); op != m_prop_dialog_pages.end (); ++op) {
if ((*op)->plugin_declaration () == pd) {
(*op)->activate (active);
}
}
}
void initialized (lay::Dispatcher *root)
{
lay::Dispatcher *mp = lay::Dispatcher::instance ();
@ -398,38 +343,63 @@ public:
private:
lay::Dispatcher *mp_root;
std::string m_title;
edt::EditorOptionsPages *mp_obj_prop_dialog;
std::vector<edt::EditorOptionsPage *> m_prop_dialog_pages;
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService");
void
show_editor_options_dialog ()
show_editor_options_page (lay::LayoutView *view)
{
// look for the plugin declaration and show the dialog
if (! view->editor_options_frame ()) {
return;
}
std::vector<edt::EditorOptionsPage *> prop_dialog_pages;
EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric ();
generic_opt->setup (view->dispatcher ());
prop_dialog_pages.push_back (generic_opt);
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
const MainPluginDeclaration *main_pd = dynamic_cast<const MainPluginDeclaration *> (&*cls);
if (main_pd) {
main_pd->show_dialog ();
break;
const PluginDeclarationBase *pd_base = dynamic_cast<const PluginDeclarationBase *> (&*cls);
if (pd_base) {
pd_base->get_editor_options_pages (prop_dialog_pages, view->dispatcher ());
}
}
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = prop_dialog_pages.begin (); op != prop_dialog_pages.end (); ++op) {
(*op)->activate (false);
}
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->dispatcher ());
view->editor_options_frame ()->layout ()->addWidget (pages);
}
void
activate_service (const lay::PluginDeclaration *pd, bool active)
activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active)
{
// look for the plugin declaration and show the dialog
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
const MainPluginDeclaration *main_pd = dynamic_cast<const MainPluginDeclaration *> (&*cls);
if (main_pd) {
main_pd->activate (pd, active);
break;
}
// TODO: is there a better way to find the editor options pages?
edt::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);
}
if (!eo_pages) {
return;
}
for (std::vector<edt::EditorOptionsPage *>::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) {
(*op)->activate (((*op)->plugin_declaration () == pd || ! (*op)->plugin_declaration ()) && active);
}
}
static tl::RegisteredClass<lay::PluginDeclaration> config_decl20 (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService");
class PartialPluginDeclaration
: public lay::PluginDeclaration
{

View File

@ -52,14 +52,14 @@ namespace edt
*
* This dialog is a global resource which is managed by the main plugin declaration
*/
void show_editor_options_dialog ();
void show_editor_options_page (lay::LayoutView *view);
/**
* @brief Activate or deactivate a certain service
*
* This will show or hide the editor properties pages for the respective service.
*/
void activate_service (const lay::PluginDeclaration *pd, bool active);
void activate_service (lay::LayoutView *view, const lay::PluginDeclaration *pd, bool active);
}
#endif

View File

@ -795,22 +795,22 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio
void
Service::activated ()
{
// make all editor option pages visible
activate_service (plugin_declaration (), true);
if (view ()->is_editable ()) {
view ()->cancel (); // cancel any pending edit operations and clear the selection
set_edit_marker (0);
m_immediate = do_activated ();
m_editing = false;
}
// make all editor option pages visible
activate_service (view (), plugin_declaration (), true);
}
void
Service::deactivated ()
{
// make all editor option pages visible
activate_service (plugin_declaration (), false);
activate_service (view (), plugin_declaration (), false);
edit_cancel ();

View File

@ -752,7 +752,7 @@ TextService::do_activated ()
// Show editor options dialog to allow entering of width
std::vector<edt::MainService *> edt_main_services = view ()->get_plugins <edt::MainService> ();
if (edt_main_services.size () > 0) {
edt_main_services [0]->cm_edit_options ();
edt_main_services [0]->show_editor_options ();
}
return true; // start editing immediately
@ -918,7 +918,7 @@ PathService::do_activated ()
// Show editor options dialog to allow entering of width
std::vector<edt::MainService *> edt_main_services = view ()->get_plugins <edt::MainService> ();
if (edt_main_services.size () > 0) {
edt_main_services [0]->cm_edit_options ();
edt_main_services [0]->show_editor_options ();
}
return false; // don't start editing immediately
@ -1123,7 +1123,7 @@ InstService::do_activated ()
// Show editor options dialog to allow entering of parameters
std::vector<edt::MainService *> edt_main_services = view ()->get_plugins <edt::MainService> ();
if (edt_main_services.size () > 0) {
edt_main_services [0]->cm_edit_options ();
edt_main_services [0]->show_editor_options ();
}
m_cv_index = view ()->active_cellview_index ();

View File

@ -500,6 +500,14 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
connect (mp_libs_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
m_libs_visible = true;
mp_eo_dock_widget = new QDockWidget (QObject::tr ("Editor Options"), this);
mp_eo_dock_widget->hide ();
mp_eo_dock_widget->setObjectName (QString::fromUtf8 ("eo_dock_widget"));
mp_eo_stack = new ControlWidgetStack (mp_eo_dock_widget, "eo_stack");
mp_eo_dock_widget->setWidget (mp_eo_stack);
connect (mp_eo_dock_widget, SIGNAL (visibilityChanged (bool)), this, SLOT (dock_widget_visibility_changed (bool)));
m_eo_visible = false;
mp_bm_dock_widget = new QDockWidget (QObject::tr ("Bookmarks"), this);
mp_bm_dock_widget->setObjectName (QString::fromUtf8 ("bookmarks_dock_widget"));
mp_bm_stack = new ControlWidgetStack (mp_bm_dock_widget, "bookmarks_stack");
@ -539,6 +547,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha
addDockWidget(Qt::LeftDockWidgetArea, mp_navigator_dock_widget);
addDockWidget(Qt::LeftDockWidgetArea, mp_hp_dock_widget);
addDockWidget(Qt::LeftDockWidgetArea, mp_libs_dock_widget);
addDockWidget(Qt::LeftDockWidgetArea, mp_eo_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_bm_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_lp_dock_widget);
addDockWidget(Qt::RightDockWidgetArea, mp_layer_toolbox_dock_widget);
@ -925,6 +934,7 @@ MainWindow::close_all ()
mp_lp_stack->removeWidget (mp_views.size ());
mp_hp_stack->removeWidget (mp_views.size ());
mp_libs_stack->removeWidget (mp_views.size ());
mp_eo_stack->removeWidget (mp_views.size ());
mp_bm_stack->removeWidget (mp_views.size ());
mp_view_stack->removeWidget (mp_views.size ());
@ -1518,6 +1528,12 @@ MainWindow::update_dock_widget_state ()
mp_libs_dock_widget->hide ();
}
if (m_eo_visible) {
mp_eo_dock_widget->show ();
} else {
mp_eo_dock_widget->hide ();
}
if (m_bm_visible) {
mp_bm_dock_widget->show ();
} else {
@ -1856,6 +1872,30 @@ MainWindow::select_mode (int m)
}
}
// if the current mode supports editing, show the editor options panel
const lay::PluginDeclaration *pd_sel = 0;
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
const lay::PluginDeclaration *pd = cls.operator-> ();
if (pd->id () == m_mode) {
pd_sel = pd;
}
}
bool editable = false;
if (pd_sel) {
editable = pd_sel->editable_enabled ();
}
if (editable != m_eo_visible) {
m_eo_visible = editable;
if (m_eo_visible) {
mp_eo_dock_widget->show ();
} else {
mp_eo_dock_widget->hide ();
}
}
}
}
@ -2526,6 +2566,7 @@ MainWindow::select_view (int index)
mp_hp_stack->raiseWidget (index);
mp_lp_stack->raiseWidget (index);
mp_libs_stack->raiseWidget (index);
mp_eo_stack->raiseWidget (index);
mp_bm_stack->raiseWidget (index);
mp_setup_form->setup ();
@ -2717,6 +2758,7 @@ MainWindow::clone_current_view ()
mp_lp_stack->addWidget (view->layer_control_frame ());
mp_hp_stack->addWidget (view->hierarchy_control_frame ());
mp_libs_stack->addWidget (view->libraries_frame ());
mp_eo_stack->addWidget (view->editor_options_frame ());
mp_bm_stack->addWidget (view->bookmarks_frame ());
bool f = m_disable_tab_selected;
@ -2965,6 +3007,7 @@ MainWindow::close_view (int index)
mp_lp_stack->removeWidget (index);
mp_hp_stack->removeWidget (index);
mp_libs_stack->removeWidget (index);
mp_eo_stack->removeWidget (index);
mp_bm_stack->removeWidget (index);
view_closed_event (int (index));
@ -3286,6 +3329,7 @@ MainWindow::create_view ()
mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ());
mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ());
mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ());
mp_eo_stack->addWidget (mp_views.back ()->editor_options_frame ());
mp_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ());
bool f = m_disable_tab_selected;
@ -3349,6 +3393,7 @@ MainWindow::create_or_load_layout (const std::string *filename, const db::LoadLa
mp_lp_stack->addWidget (mp_views.back ()->layer_control_frame ());
mp_hp_stack->addWidget (mp_views.back ()->hierarchy_control_frame ());
mp_libs_stack->addWidget (mp_views.back ()->libraries_frame ());
mp_eo_stack->addWidget (mp_views.back ()->editor_options_frame ());
mp_bm_stack->addWidget (mp_views.back ()->bookmarks_frame ());
bool f = m_disable_tab_selected;
@ -3824,6 +3869,13 @@ MainWindow::menu_activated (const std::string &symbol)
cm_help_about ();
} else if (symbol == "cm_help_about_qt") {
cm_help_about_qt ();
} else if (symbol == "cm_edit_options") {
if (!m_eo_visible) {
mp_eo_dock_widget->show ();
m_eo_visible = true;
}
} else {
// Try the plugin declarations
@ -4189,6 +4241,10 @@ public:
menu_entries.push_back (lay::submenu ("@secrets", at, tl::to_string (QObject::tr ("Secret Features"))));
menu_entries.push_back (lay::submenu ("@toolbar", at, std::string ()));
at = "edit_menu.end";
menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end"));
menu_entries.push_back (lay::menu_item ("cm_edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)"));
at = "file_menu.end";
menu_entries.push_back (lay::menu_item ("cm_new_layout", "new_layout:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layout"))));
menu_entries.push_back (lay::menu_item ("cm_new_panel", "new_panel:edit:edit_mode", at, tl::to_string (QObject::tr ("New Panel"))));

View File

@ -680,9 +680,9 @@ private:
QToolBar *mp_tool_bar;
QDockWidget *mp_navigator_dock_widget;
lay::Navigator *mp_navigator;
QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget, *mp_libs_dock_widget, *mp_bm_dock_widget;
ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack, *mp_bm_stack;
bool m_hp_visible, m_lp_visible, m_libs_visible, m_bm_visible, m_navigator_visible, m_layer_toolbox_visible;
QDockWidget *mp_hp_dock_widget, *mp_lp_dock_widget, *mp_libs_dock_widget, *mp_eo_dock_widget, *mp_bm_dock_widget;
ControlWidgetStack *mp_hp_stack, *mp_lp_stack, *mp_libs_stack, *mp_eo_stack, *mp_bm_stack;
bool m_hp_visible, m_lp_visible, m_libs_visible, m_eo_visible, m_bm_visible, m_navigator_visible, m_layer_toolbox_visible;
QDockWidget *mp_layer_toolbox_dock_widget;
lay::LayerToolbox *mp_layer_toolbox;
ViewWidgetStack *mp_view_stack;

View File

@ -467,6 +467,12 @@ Class<lay::LayoutView> decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutView::LV_NoEditorOptionsPanel,
"@brief With this option, no editor options panel will be provided (see \\editor_options_frame)\n"
"Use this value with the constructor's 'options' argument.\n"
"\n"
"This constant has been introduced in version 0.27.\n"
) +
gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView,
"@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n"
"Use this value with the constructor's 'options' argument.\n"

View File

@ -390,6 +390,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
mp_libraries_view = 0;
mp_bookmarks_view = 0;
mp_libraries_frame = 0;
mp_editor_options_frame = 0;
mp_bookmarks_frame = 0;
mp_min_hier_spbx = 0;
mp_max_hier_spbx = 0;
@ -557,6 +558,20 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/)
}
if (is_editable () && (m_options & LV_NoEditorOptionsPanel) == 0 && (m_options & LV_Naked) == 0) {
QFrame *editor_options_frame = new QFrame (0);
editor_options_frame->setObjectName (QString::fromUtf8 ("editor_options_frame"));
mp_editor_options_frame = editor_options_frame;
QVBoxLayout *left_frame_ly = new QVBoxLayout (editor_options_frame);
left_frame_ly->setMargin (0);
left_frame_ly->setSpacing (0);
connect (mp_editor_options_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ()));
}
// occupy services and editables:
// these services get deleted by the canvas destructor automatically:
if ((m_options & LV_NoTracker) == 0) {
@ -686,6 +701,11 @@ LayoutView::~LayoutView ()
mp_libraries_frame = 0;
mp_libraries_view = 0;
if (mp_editor_options_frame) {
delete mp_editor_options_frame;
}
mp_editor_options_frame = 0;
if (mp_bookmarks_frame) {
delete mp_bookmarks_frame;
}
@ -709,6 +729,8 @@ void LayoutView::side_panel_destroyed ()
} else if (sender () == mp_libraries_frame) {
mp_libraries_frame = 0;
mp_libraries_view = 0;
} else if (sender () == mp_editor_options_frame) {
mp_editor_options_frame = 0;
} else if (sender () == mp_bookmarks_frame) {
mp_bookmarks_frame = 0;
mp_bookmarks_view = 0;

View File

@ -175,14 +175,15 @@ public:
LV_NoLayers = 1,
LV_NoHierarchyPanel = 2,
LV_NoLibrariesView = 4,
LV_NoBookmarksView = 8,
LV_Naked = 16,
LV_NoZoom = 32,
LV_NoGrid = 64,
LV_NoMove = 128,
LV_NoTracker = 256,
LV_NoSelection = 512,
LV_NoPlugins = 1024,
LV_NoEditorOptionsPanel = 8,
LV_NoBookmarksView = 16,
LV_Naked = 32,
LV_NoZoom = 64,
LV_NoGrid = 128,
LV_NoMove = 256,
LV_NoTracker = 512,
LV_NoSelection = 1024,
LV_NoPlugins = 2048,
LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins
};
@ -268,6 +269,14 @@ public:
return mp_libraries_frame;
}
/**
* @brief Gets the container with the editor options
*/
QWidget *editor_options_frame ()
{
return mp_editor_options_frame;
}
/**
* @brief Gets the container with the bookmarks view
*/
@ -2708,7 +2717,7 @@ private:
lay::HierarchyControlPanel *mp_hierarchy_panel;
lay::LibrariesView *mp_libraries_view;
lay::BookmarksView *mp_bookmarks_view;
QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_bookmarks_frame;
QWidget *mp_control_frame, *mp_hierarchy_frame, *mp_libraries_frame, *mp_editor_options_frame, *mp_bookmarks_frame;
QSpinBox *mp_min_hier_spbx;
QSpinBox *mp_max_hier_spbx;
std::list <CellView> m_cellviews;

View File

@ -2065,7 +2065,7 @@ public:
menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (QObject::tr ("Select Next Item(Space)"))));
menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (QObject::tr ("Select Next Item too(Shift+Space)"))));
at = "edit_menu.end";
at = "edit_menu.edit_options_group";
menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)"))));
menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)"))));