From 8dd002bd0f06c05a3229ced136710943609863bd Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Sep 2022 22:53:01 +0200 Subject: [PATCH] More enhancements to support LayoutView as widget --- src/lay/lay/layControlWidgetStack.cc | 31 ++++--- src/lay/lay/layControlWidgetStack.h | 2 + .../laybasic/gsiDeclLayLayoutViewBase.cc | 6 ++ src/laybasic/laybasic/layEditable.cc | 37 +-------- src/laybasic/laybasic/layEditable.h | 8 +- src/laybasic/laybasic/layLayoutViewBase.h | 1 + src/laybasic/laybasic/laySelector.cc | 5 +- src/laybasic/laybasic/laybasic.pro | 3 - .../layui}/PropertiesDialog.ui | 0 src/layui/layui/layLayoutViewFunctions.cc | 52 +++++------- .../layui}/layPropertiesDialog.cc | 82 ++++++++++--------- .../layui}/layPropertiesDialog.h | 16 +++- src/layui/layui/layui.pro | 3 + .../layview/gsiDeclLayLayoutView_qt.cc | 4 +- src/layview/layview/layLayoutView_qt.cc | 38 +++++++++ src/layview/layview/layLayoutView_qt.h | 9 +- .../lay_plugin/layBooleanOperationsPlugin.cc | 2 +- 17 files changed, 157 insertions(+), 142 deletions(-) rename src/{laybasic/laybasic => layui/layui}/PropertiesDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/layPropertiesDialog.cc (75%) rename src/{laybasic/laybasic => layui/layui}/layPropertiesDialog.h (92%) diff --git a/src/lay/lay/layControlWidgetStack.cc b/src/lay/lay/layControlWidgetStack.cc index 671a338a7..b60e7f9c7 100644 --- a/src/lay/lay/layControlWidgetStack.cc +++ b/src/lay/lay/layControlWidgetStack.cc @@ -68,20 +68,29 @@ void ControlWidgetStack::add_widget(QWidget *w) resize (minimumWidth (), height ()); } + update_geometry (); +} + +void ControlWidgetStack::update_geometry () +{ if (m_size_follows_content) { - updateGeometry (); + + int h = sizeHint ().height (); + if (h > 0) { + setMinimumHeight (h); + setMaximumHeight (h); + } else { + setMinimumHeight (0); + setMaximumHeight (QWIDGETSIZE_MAX); + } + } } bool ControlWidgetStack::event(QEvent *e) { if (e->type () == QEvent::LayoutRequest) { - if (m_size_follows_content) { - int h = sizeHint ().height (); - setMinimumHeight (h); - setMaximumHeight (h); - updateGeometry (); - } + update_geometry (); } return QWidget::event (e); } @@ -115,9 +124,7 @@ void ControlWidgetStack::remove_widget(size_t index) mp_bglabel->show (); } - if (m_size_follows_content) { - updateGeometry (); - } + update_geometry (); } void ControlWidgetStack::raise_widget(size_t index) @@ -142,9 +149,7 @@ void ControlWidgetStack::raise_widget(size_t index) mp_bglabel->hide (); } - if (m_size_follows_content) { - updateGeometry (); - } + update_geometry (); } QWidget *ControlWidgetStack::widget(size_t index) diff --git a/src/lay/lay/layControlWidgetStack.h b/src/lay/lay/layControlWidgetStack.h index 3d2fbcb5f..077aa2519 100644 --- a/src/lay/lay/layControlWidgetStack.h +++ b/src/lay/lay/layControlWidgetStack.h @@ -66,9 +66,11 @@ protected: } void resize_children (); + void update_geometry (); bool event (QEvent *e); + std::vector m_widgets; QWidget *mp_current_widget; QLabel *mp_bglabel; diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 742c1f635..b932c43e6 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -534,6 +534,12 @@ LAYBASIC_PUBLIC Class decl_LayoutViewBase ("lay", "LayoutVi "\n" "This constant has been introduced in version 0.27.\n" ) + + gsi::constant ("LV_NoPropertiesPopup", (unsigned int) lay::LayoutViewBase::LV_NoPropertiesPopup, + "@brief This option disables the properties popup on double click\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.28.\n" + ) + gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutViewBase::LV_NoServices, "@brief This option disables all services except the ones for pure viewing\n" "Use this value with the constructor's 'options' argument.\n" diff --git a/src/laybasic/laybasic/layEditable.cc b/src/laybasic/laybasic/layEditable.cc index 4adbed801..732e63cd4 100644 --- a/src/laybasic/laybasic/layEditable.cc +++ b/src/laybasic/laybasic/layEditable.cc @@ -25,10 +25,6 @@ #include "dbClipboard.h" #include "tlAssert.h" -#if defined(HAVE_QT) -# include "layPropertiesDialog.h" -#endif - #include #include @@ -76,21 +72,11 @@ Editable::~Editable () Editables::Editables (db::Manager *manager) : db::Object (manager), m_move_selection (false), m_any_move_operation (false) { -#if defined(HAVE_QT) - mp_properties_dialog = 0; -#endif } Editables::~Editables () { cancel_edits (); - -#if defined(HAVE_QT) - if (mp_properties_dialog) { - delete mp_properties_dialog; - mp_properties_dialog = 0; - } -#endif } void @@ -674,36 +660,17 @@ Editables::edit_cancel () void Editables::cancel_edits () { -#if defined(HAVE_QT) - // close the property dialog - if (mp_properties_dialog) { - mp_properties_dialog->hide (); - } -#endif - // cancel any edit operations for (iterator e = begin (); e != end (); ++e) { e->edit_cancel (); } } -#if defined(HAVE_QT) void -Editables::show_properties (QWidget *parent) +Editables::show_properties () { - if (! has_selection ()) { - // try to use the transient selection for the real one - transient_to_selection (); - } - - // re-create a new properties dialog - if (mp_properties_dialog) { - delete mp_properties_dialog; - } - mp_properties_dialog = new lay::PropertiesDialog (parent, manager (), this); - mp_properties_dialog->show (); + // The default implementation does nothing } -#endif } diff --git a/src/laybasic/laybasic/layEditable.h b/src/laybasic/laybasic/layEditable.h index 40721d5a0..64b117efb 100644 --- a/src/laybasic/laybasic/layEditable.h +++ b/src/laybasic/laybasic/layEditable.h @@ -47,7 +47,6 @@ namespace lay class Editables; #if defined(HAVE_QT) class PropertiesPage; -class PropertiesDialog; #endif /** @@ -590,12 +589,10 @@ public: return m_editables.end (); } -#if defined(HAVE_QT) /** * @brief The "show properties" operation */ - void show_properties (QWidget *parent); -#endif + virtual void show_properties (); /** * @brief An event triggered if the selection changed @@ -651,9 +648,6 @@ private: tl::shared_collection m_editables; std::set m_enabled; -#if defined(HAVE_QT) - lay::PropertiesDialog *mp_properties_dialog; -#endif bool m_move_selection; bool m_any_move_operation; db::DBox m_last_selected_point; diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index b50a8d412..df8612f84 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -179,6 +179,7 @@ public: LV_NoTracker = 512, LV_NoSelection = 1024, LV_NoPlugins = 2048, + LV_NoPropertiesPopup = 4096, LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins }; diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 3b1769f56..8967fc88c 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -30,7 +30,6 @@ #if defined(HAVE_QT) # include -# include #endif namespace lay @@ -185,12 +184,10 @@ SelectionService::mouse_double_click_event (const db::DPoint & /*p*/, unsigned i reset_box (); } -#if defined(HAVE_QT) if (prio && (buttons & lay::LeftButton) != 0) { - mp_view->show_properties (QApplication::activeWindow ()); + mp_view->show_properties (); return true; } -#endif return false; } diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index fdd56f679..037825ce8 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -9,12 +9,10 @@ DEFINES += MAKE_LAYBASIC_LIBRARY !equals(HAVE_QT, 0) { FORMS = \ - PropertiesDialog.ui \ SOURCES = \ gtf.cc \ layPluginConfigPage.cc \ - layPropertiesDialog.cc \ layProperties.cc \ layDragDropData.cc \ layCursor.cc \ @@ -22,7 +20,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY HEADERS = \ gtf.h \ layPluginConfigPage.h \ - layPropertiesDialog.h \ layProperties.h \ layDragDropData.h \ layCursor.h \ diff --git a/src/laybasic/laybasic/PropertiesDialog.ui b/src/layui/layui/PropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/PropertiesDialog.ui rename to src/layui/layui/PropertiesDialog.ui diff --git a/src/layui/layui/layLayoutViewFunctions.cc b/src/layui/layui/layLayoutViewFunctions.cc index a493670e4..a321eb15a 100644 --- a/src/layui/layui/layLayoutViewFunctions.cc +++ b/src/layui/layui/layLayoutViewFunctions.cc @@ -50,19 +50,9 @@ namespace lay /** * @brief Gets a suitable parent widget for the modal dialogs used in this module */ -static QWidget *parent () +static QWidget *parent_widget () { - QWidgetList tl_widgets; - if (qApp) { - tl_widgets = qApp->topLevelWidgets (); - } - for (auto i = tl_widgets.begin (); i != tl_widgets.end (); ++i) { - QMainWindow *mw = dynamic_cast (*i); - if (mw) { - return mw; - } - } - return 0; + return QApplication::activeWindow (); } static void @@ -133,7 +123,7 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) if (symbol == "cm_show_properties") { - view ()->show_properties (parent ()); + view ()->show_properties (); } else if (symbol == "cm_delete") { @@ -326,10 +316,10 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) cm_new_layer (); } } else if (symbol == "cm_layout_props") { - lay::LayoutPropertiesForm lp_form (parent (), view (), "layout_props_form"); + lay::LayoutPropertiesForm lp_form (parent_widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_layout_stats") { - lay::LayoutStatisticsForm lp_form (parent (), view (), "layout_props_form"); + lay::LayoutStatisticsForm lp_form (parent_widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_reload") { cm_reload (); @@ -449,7 +439,7 @@ LayoutViewFunctions::cm_cell_user_properties () db::Cell &cell = layout.cell (path.back ()); db::properties_id_type prop_id = cell.prop_id (); - lay::UserPropertiesForm props_form (parent ()); + lay::UserPropertiesForm props_form (parent_widget ()); if (props_form.show (view (), cv_index, prop_id)) { view ()->transaction (tl::to_string (tr ("Edit cell's user properties"))); @@ -484,7 +474,7 @@ LayoutViewFunctions::cm_cell_replace () } - lay::ReplaceCellOptionsDialog mode_dialog (parent ()); + lay::ReplaceCellOptionsDialog mode_dialog (parent_widget ()); db::cell_index_type with_cell = paths.front ().back (); int mode = needs_to_ask ? m_del_cell_mode : 0; @@ -672,7 +662,7 @@ LayoutViewFunctions::cm_cell_delete () mode = 0; } - lay::DeleteCellModeDialog mode_dialog (parent ()); + lay::DeleteCellModeDialog mode_dialog (parent_widget ()); if (! needs_to_ask || mode_dialog.exec_dialog (mode)) { if (needs_to_ask) { @@ -795,7 +785,7 @@ LayoutViewFunctions::cm_cell_flatten () } } - FlattenInstOptionsDialog options_dialog (parent ()); + FlattenInstOptionsDialog options_dialog (parent_widget ()); int flatten_insts_levels = -1; bool prune = true; @@ -877,7 +867,7 @@ LayoutViewFunctions::cm_cell_rename () if (cv_index >= 0 && path.size () > 0) { - lay::RenameCellDialog name_dialog (parent ()); + lay::RenameCellDialog name_dialog (parent_widget ()); db::Layout &layout = view ()->cellview (cv_index)->layout (); std::string name (layout.cell_name (path.back ())); @@ -1227,7 +1217,7 @@ LayoutViewFunctions::cm_new_cell () static double s_new_cell_window_size = 2.0; static std::string s_new_cell_cell_name; - NewCellPropertiesDialog cell_prop_dia (parent ()); + NewCellPropertiesDialog cell_prop_dia (parent_widget ()); if (cell_prop_dia.exec_dialog (& cv->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { db::cell_index_type new_ci = view ()->new_cell (view ()->active_cellview_index (), s_new_cell_cell_name.c_str ()); @@ -1290,7 +1280,7 @@ LayoutViewFunctions::cm_reload () bool can_reload = true; if (dirty_layouts != 0) { - QMessageBox mbox (parent ()); + QMessageBox mbox (parent_widget ()); mbox.setText (tl::to_qstring (tl::to_string (tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); mbox.setWindowTitle (tr ("Save Needed")); mbox.setIcon (QMessageBox::Warning); @@ -1343,7 +1333,7 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) } if (has_proxy && - QMessageBox::question (parent (), + QMessageBox::question (parent_widget (), tr ("Transforming PCells Or Library Cells"), tr ("The layout contains PCells or library cells or both.\n" "Any changes to such cells may be lost when their layout is refreshed later.\n" @@ -1430,7 +1420,7 @@ LayoutViewFunctions::cm_lay_scale () void LayoutViewFunctions::cm_lay_move () { - lay::MoveOptionsDialog options (parent ()); + lay::MoveOptionsDialog options (parent_widget ()); if (options.exec_dialog (m_move_dist)) { transform_layout (db::DCplxTrans (m_move_dist)); } @@ -1550,7 +1540,7 @@ LayoutViewFunctions::cm_sel_move_to () double y = sel_bbox.bottom () + (sel_bbox.height () * (1 + m_move_to_origin_mode_y) * 0.5); db::DPoint move_target (x, y); - lay::MoveToOptionsDialog options (parent ()); + lay::MoveToOptionsDialog options (parent_widget ()); if (options.exec_dialog (m_move_to_origin_mode_x, m_move_to_origin_mode_y, move_target)) { x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5); @@ -1564,7 +1554,7 @@ LayoutViewFunctions::cm_sel_move_to () void LayoutViewFunctions::cm_sel_move () { - lay::MoveOptionsDialog options (parent ()); + lay::MoveOptionsDialog options (parent_widget ()); if (options.exec_dialog (m_move_dist)) { do_transform (db::DCplxTrans (m_move_dist)); } @@ -1598,7 +1588,7 @@ LayoutViewFunctions::cm_copy_layer () } - lay::DuplicateLayerDialog dialog (parent ()); + lay::DuplicateLayerDialog dialog (parent_widget ()); if (dialog.exec_dialog (view (), m_copy_cva, m_copy_layera, m_copy_cvr, m_copy_layerr, m_duplicate_hier_mode, m_clear_before)) { bool supports_undo = true; @@ -1758,7 +1748,7 @@ LayoutViewFunctions::cm_new_layer () const lay::CellView &cv = view ()->cellview (index); - lay::NewLayerPropertiesDialog prop_dia (parent ()); + lay::NewLayerPropertiesDialog prop_dia (parent_widget ()); if (prop_dia.exec_dialog (cv, m_new_layer_props)) { for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { @@ -1796,7 +1786,7 @@ LayoutViewFunctions::cm_align_cell_origin () throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } - lay::AlignCellOptionsDialog dialog (parent ()); + lay::AlignCellOptionsDialog dialog (parent_widget ()); if (dialog.exec_dialog (m_align_cell_options)) { view ()->clear_selection (); @@ -1897,7 +1887,7 @@ LayoutViewFunctions::cm_edit_layer () db::LayerProperties layer_props = layout.get_properties ((unsigned int) sel->layer_index ()); db::LayerProperties old_props = layer_props; - lay::NewLayerPropertiesDialog prop_dia (parent ()); + lay::NewLayerPropertiesDialog prop_dia (parent_widget ()); if (prop_dia.exec_dialog (cv, layer_props)) { for (unsigned int l = 0; l < layout.layers (); ++l) { @@ -2040,7 +2030,7 @@ LayoutViewFunctions::cm_clear_layer () throw tl::Exception (tl::to_string (tr ("No layer selected for clearing"))); } - lay::ClearLayerModeDialog mode_dialog (parent ()); + lay::ClearLayerModeDialog mode_dialog (parent_widget ()); if (mode_dialog.exec_dialog (m_layer_hier_mode)) { view ()->cancel_edits (); diff --git a/src/laybasic/laybasic/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc similarity index 75% rename from src/laybasic/laybasic/layPropertiesDialog.cc rename to src/layui/layui/layPropertiesDialog.cc index 09d8a697b..37e00cda9 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.cc +++ b/src/layui/layui/layPropertiesDialog.cc @@ -29,6 +29,8 @@ #include "layProperties.h" #include "tlExceptions.h" +#include "ui_PropertiesDialog.h" + #include namespace lay @@ -38,16 +40,17 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, : QDialog (0 /*parent*/), mp_manager (manager), mp_editables (editables), m_index (-1), m_auto_applied (false), m_transaction_id (0) { - mp_editables->enable_edits (false); + mp_ui = new Ui::PropertiesDialog (); setObjectName (QString::fromUtf8 ("properties_dialog")); + mp_ui->setupUi (this); - Ui::PropertiesDialog::setupUi (this); + mp_editables->enable_edits (false); mp_stack = new QStackedLayout; for (lay::Editables::iterator e = mp_editables->begin (); e != mp_editables->end (); ++e) { - mp_properties_pages.push_back (e->properties_page (mp_manager, content_frame)); + mp_properties_pages.push_back (e->properties_page (mp_manager, mp_ui->content_frame)); if (mp_properties_pages.back ()) { mp_stack->addWidget (mp_properties_pages.back ()); connect (mp_properties_pages.back (), SIGNAL (edited ()), this, SLOT (apply ())); @@ -58,19 +61,19 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, std::reverse (mp_properties_pages.begin (), mp_properties_pages.end ()); // Add a label as a dummy - QLabel *dummy = new QLabel (QObject::tr ("No object with properties to display"), content_frame); + QLabel *dummy = new QLabel (QObject::tr ("No object with properties to display"), mp_ui->content_frame); dummy->setAlignment (Qt::AlignHCenter | Qt::AlignVCenter); mp_stack->addWidget (dummy); - content_frame->setLayout (mp_stack); + mp_ui->content_frame->setLayout (mp_stack); // disable the apply button for first .. - apply_to_all_cbx->setEnabled (false); - relative_cbx->setEnabled (false); - ok_button->setEnabled (false); + mp_ui->apply_to_all_cbx->setEnabled (false); + mp_ui->relative_cbx->setEnabled (false); + mp_ui->ok_button->setEnabled (false); // as a proposal, the start button can be enabled in most cases - prev_button->setEnabled (true); + mp_ui->prev_button->setEnabled (true); // count the total number of objects m_objects = mp_editables->selection_size (); @@ -84,40 +87,43 @@ PropertiesDialog::PropertiesDialog (QWidget * /*parent*/, db::Manager *manager, ++m_index; } - prev_button->setEnabled (false); + mp_ui->prev_button->setEnabled (false); // if at end disable the "Next" button and return (this may only happen at the first call) if (m_index >= int (mp_properties_pages.size ())) { - next_button->setEnabled (false); + mp_ui->next_button->setEnabled (false); mp_stack->setCurrentWidget (dummy); - apply_to_all_cbx->setEnabled (false); - apply_to_all_cbx->setChecked (false); - relative_cbx->setEnabled (false); - relative_cbx->setChecked (false); - ok_button->setEnabled (false); + mp_ui->apply_to_all_cbx->setEnabled (false); + mp_ui->apply_to_all_cbx->setChecked (false); + mp_ui->relative_cbx->setEnabled (false); + mp_ui->relative_cbx->setChecked (false); + mp_ui->ok_button->setEnabled (false); } else { - next_button->setEnabled (any_next ()); + mp_ui->next_button->setEnabled (any_next ()); mp_properties_pages [m_index]->update (); mp_stack->setCurrentWidget (mp_properties_pages [m_index]); - apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); - apply_to_all_cbx->setChecked (false); - relative_cbx->setEnabled (apply_to_all_cbx->isEnabled () && apply_to_all_cbx->isChecked ()); - relative_cbx->setChecked (true); - ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); + mp_ui->apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); + mp_ui->apply_to_all_cbx->setChecked (false); + mp_ui->relative_cbx->setEnabled (mp_ui->apply_to_all_cbx->isEnabled () && mp_ui->apply_to_all_cbx->isChecked ()); + mp_ui->relative_cbx->setChecked (true); + mp_ui->ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); } - connect (ok_button, SIGNAL (clicked ()), this, SLOT (ok_pressed ())); - connect (cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ())); - connect (prev_button, SIGNAL (clicked ()), this, SLOT (prev_pressed ())); - connect (next_button, SIGNAL (clicked ()), this, SLOT (next_pressed ())); + connect (mp_ui->ok_button, SIGNAL (clicked ()), this, SLOT (ok_pressed ())); + connect (mp_ui->cancel_button, SIGNAL (clicked ()), this, SLOT (cancel_pressed ())); + connect (mp_ui->prev_button, SIGNAL (clicked ()), this, SLOT (prev_pressed ())); + connect (mp_ui->next_button, SIGNAL (clicked ()), this, SLOT (next_pressed ())); } PropertiesDialog::~PropertiesDialog () { + delete mp_ui; + mp_ui = 0; + disconnect (); } @@ -166,11 +172,11 @@ BEGIN_PROTECTED ++m_current_object; update_title (); - prev_button->setEnabled (true); - next_button->setEnabled (any_next ()); - apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); - relative_cbx->setEnabled (apply_to_all_cbx->isEnabled () && apply_to_all_cbx->isChecked ()); - ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); + mp_ui->prev_button->setEnabled (true); + mp_ui->next_button->setEnabled (any_next ()); + mp_ui->apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); + mp_ui->relative_cbx->setEnabled (mp_ui->apply_to_all_cbx->isEnabled () && mp_ui->apply_to_all_cbx->isChecked ()); + mp_ui->ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); mp_properties_pages [m_index]->update (); END_PROTECTED @@ -212,11 +218,11 @@ BEGIN_PROTECTED --m_current_object; update_title (); - next_button->setEnabled (true); - prev_button->setEnabled (any_prev ()); - apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); - relative_cbx->setEnabled (apply_to_all_cbx->isEnabled () && apply_to_all_cbx->isChecked ()); - ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); + mp_ui->next_button->setEnabled (true); + mp_ui->prev_button->setEnabled (any_prev ()); + mp_ui->apply_to_all_cbx->setEnabled (! mp_properties_pages [m_index]->readonly () && mp_properties_pages [m_index]->can_apply_to_all ()); + mp_ui->relative_cbx->setEnabled (mp_ui->apply_to_all_cbx->isEnabled () && mp_ui->apply_to_all_cbx->isChecked ()); + mp_ui->ok_button->setEnabled (! mp_properties_pages [m_index]->readonly ()); mp_properties_pages [m_index]->update (); END_PROTECTED @@ -274,8 +280,8 @@ BEGIN_PROTECTED try { - if (apply_to_all_cbx->isChecked () && mp_properties_pages [m_index]->can_apply_to_all ()) { - mp_properties_pages [m_index]->apply_to_all (relative_cbx->isChecked ()); + if (mp_ui->apply_to_all_cbx->isChecked () && mp_properties_pages [m_index]->can_apply_to_all ()) { + mp_properties_pages [m_index]->apply_to_all (mp_ui->relative_cbx->isChecked ()); } else { mp_properties_pages [m_index]->apply (); } diff --git a/src/laybasic/laybasic/layPropertiesDialog.h b/src/layui/layui/layPropertiesDialog.h similarity index 92% rename from src/laybasic/laybasic/layPropertiesDialog.h rename to src/layui/layui/layPropertiesDialog.h index 85faaf991..94fab9db2 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.h +++ b/src/layui/layui/layPropertiesDialog.h @@ -25,6 +25,8 @@ #ifndef HDR_layPropertiesDialog #define HDR_layPropertiesDialog +#include "layuiCommon.h" + #include #include @@ -35,12 +37,15 @@ #include -#include "ui_PropertiesDialog.h" - #include class QStackedLayout; +namespace Ui +{ + class PropertiesDialog; +} + namespace lay { @@ -57,8 +62,8 @@ class MainWindow; * objects from a set of editables. */ -class PropertiesDialog - : public QDialog, private Ui::PropertiesDialog +class LAYUI_PUBLIC PropertiesDialog + : public QDialog { Q_OBJECT @@ -98,6 +103,9 @@ public slots: protected: void reject (); + +private: + Ui::PropertiesDialog *mp_ui; }; } diff --git a/src/layui/layui/layui.pro b/src/layui/layui/layui.pro index 3c4fc15ee..00099e914 100644 --- a/src/layui/layui/layui.pro +++ b/src/layui/layui/layui.pro @@ -53,6 +53,7 @@ FORMS = \ NewLayerPropertiesDialog.ui \ NewLayoutPropertiesDialog.ui \ OpenLayoutModeDialog.ui \ + PropertiesDialog.ui \ RenameCellDialog.ui \ ReplaceCellOptionsDialog.ui \ SaveLayoutOptionsDialog.ui \ @@ -127,6 +128,7 @@ SOURCES = \ layNetlistBrowserTreeModel.cc \ layNetlistCrossReferenceModel.cc \ layNetlistLogModel.cc \ + layPropertiesDialog.cc \ layQtTools.cc \ laySaveLayoutOptionsDialog.cc \ laySelectCellViewForm.cc \ @@ -186,6 +188,7 @@ HEADERS = \ layNetlistBrowserTreeModel.h \ layNetlistCrossReferenceModel.h \ layNetlistLogModel.h \ + layPropertiesDialog.h \ layQtTools.h \ laySaveLayoutOptionsDialog.h \ laySelectCellViewForm.h \ diff --git a/src/layview/layview/gsiDeclLayLayoutView_qt.cc b/src/layview/layview/gsiDeclLayLayoutView_qt.cc index a46586861..651092250 100644 --- a/src/layview/layview/gsiDeclLayLayoutView_qt.cc +++ b/src/layview/layview/gsiDeclLayLayoutView_qt.cc @@ -92,7 +92,7 @@ Class decl_LayoutViewWidget (QT_EXTERNAL_BASE (QFrame) "l "@param parent The parent widget in which to embed the view\n" "@param editable True to make the view editable\n" "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants from \\LayoutView\n" + "@param options A combination of the values in the LV_... constants from \\LayoutViewBase\n" "\n" "This constructor has been introduced in version 0.25.\n" "It has been enhanced with the arguments in version 0.27.\n" @@ -161,7 +161,7 @@ Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView" "\n" "@param editable True to make the view editable\n" "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants\n" + "@param options A combination of the values in the LV_... constants from \\LayoutViewBase\n" "\n" "This constructor has been introduced in version 0.25.\n" "It has been enhanced with the arguments in version 0.27.\n" diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index c8e9e9218..e166737c9 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -75,6 +75,7 @@ #include "layEditorOptionsFrame.h" #include "layEditorOptionsPages.h" #include "layUtils.h" +#include "layPropertiesDialog.h" #include "dbClipboard.h" #include "dbLayout.h" #include "dbLayoutUtils.h" @@ -568,6 +569,32 @@ LayoutView::finish () } } +void +LayoutView::show_properties () +{ + if ((options () & lay::LayoutViewBase::LV_NoPropertiesPopup) != 0) { + return; + } + + if (! has_selection ()) { + // try to use the transient selection for the real one + transient_to_selection (); + } + + // re-create a new properties dialog + if (mp_properties_dialog) { + delete mp_properties_dialog.data (); + } + mp_properties_dialog = new lay::PropertiesDialog (widget (), manager (), this); + + // if launched from a dialog, do not use "show" as this blocks user interaction + if (QApplication::activeModalWidget ()) { + mp_properties_dialog->exec (); + } else { + mp_properties_dialog->show (); + } +} + void LayoutView::do_change_active_cellview () { @@ -1243,6 +1270,17 @@ LayoutView::set_current_cell_path (int cv_index, const cell_path_type &path) } } +void +LayoutView::cancel_edits () +{ + // close the property dialog + if (mp_properties_dialog) { + mp_properties_dialog->hide (); + } + + LayoutViewBase::cancel_edits (); +} + void LayoutView::activate () { diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h index 061c7551f..6a9a2f588 100644 --- a/src/layview/layview/layLayoutView_qt.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -56,6 +56,7 @@ #include #include +#include class QSpinBox; @@ -87,6 +88,7 @@ class Browser; class ColorButton; class ConfigureAction; class EditorOptionsPages; +class PropertiesDialog; /** * @brief An object connecting child widget signals with methods from LayoutView @@ -454,10 +456,7 @@ public: /** * @brief Cancels all edit operations but maintains selection */ - void cancel_edits () - { - LayoutViewBase::cancel_edits (); - } + void cancel_edits (); /** * @brief Select all levels of hierarchy available @@ -611,6 +610,7 @@ private: lay::EditorOptionsFrame *mp_editor_options_frame; QSpinBox *mp_min_hier_spbx; QSpinBox *mp_max_hier_spbx; + QPointer mp_properties_dialog; bool m_always_show_source; bool m_always_show_ld; bool m_always_show_layout_index; @@ -669,6 +669,7 @@ protected: virtual void do_change_active_cellview (); virtual bool is_activated () const; virtual void bookmarks_changed (); + virtual void show_properties (); // overrides Editables method to display a message void signal_selection_changed (); diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index e1a76a4eb..34cd5565e 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -38,7 +38,7 @@ namespace lay static QWidget *parent_widget () { - return lay::MainWindow::instance (); + return QApplication::activeWindow (); } class BooleanOperationsPlugin