mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-27 20:44:13 +02:00
conductor dock: scrollable/narrowable + View-menu enable toggle (#500)
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "../ui/shapegraphicsitempropertieswidget.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QSettings>
|
||||
|
||||
/**
|
||||
@brief PropertiesEditorFactory::propertiesEditor
|
||||
@@ -104,6 +105,13 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
{
|
||||
case Conductor::Type: //1001
|
||||
{
|
||||
//Feature toggle (#500): when disabled in the View menu, selecting a
|
||||
//conductor brings up nothing in the dock. Default enabled.
|
||||
if (!QSettings().value(
|
||||
QStringLiteral("diagrameditor/conductor_properties_panel"),
|
||||
true).toBool()) {
|
||||
return nullptr;
|
||||
}
|
||||
//Prototype (#500): single-conductor editing in the dock.
|
||||
if (count_ > 1) {
|
||||
return nullptr;
|
||||
|
||||
@@ -879,6 +879,23 @@ void QETDiagramEditor::setUpMenu()
|
||||
menu_affichage -> addSeparator();
|
||||
menu_affichage -> addAction(m_draw_grid);
|
||||
menu_affichage -> addAction(m_grey_background);
|
||||
|
||||
// Toggle: show a selected conductor's properties in the selection-properties
|
||||
// dock (#500). When off, selecting a conductor brings up nothing there.
|
||||
QAction *cond_panel = menu_affichage -> addAction(tr("Propriétés du conducteur dans le panneau"));
|
||||
cond_panel -> setCheckable(true);
|
||||
cond_panel -> setStatusTip(tr("Affiche ou non les propriétés d'un conducteur sélectionné dans le panneau de sélection"));
|
||||
{
|
||||
QSettings settings;
|
||||
cond_panel -> setChecked(settings.value(QStringLiteral("diagrameditor/conductor_properties_panel"), true).toBool());
|
||||
}
|
||||
connect(cond_panel, &QAction::toggled, this, [this](bool on) {
|
||||
QSettings().setValue(QStringLiteral("diagrameditor/conductor_properties_panel"), on);
|
||||
// Apply immediately to the current selection.
|
||||
if (DiagramView *dv = currentDiagramView())
|
||||
m_selection_properties_editor -> setDiagram(dv -> diagram());
|
||||
});
|
||||
|
||||
menu_affichage -> addSeparator();
|
||||
menu_affichage -> addActions(m_zoom_actions_group.actions());
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../qetgraphicsitem/conductor.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
/**
|
||||
@@ -34,9 +35,19 @@ ConductorPropertiesEditorWidget::ConductorPropertiesEditorWidget(
|
||||
PropertiesEditorWidget(parent),
|
||||
m_cpw(new ConductorPropertiesWidget(this))
|
||||
{
|
||||
// The conductor widget is dialog-sized (min width ~600px), far too wide for
|
||||
// a dock. Host it in a scroll area with a small minimum width so the dock
|
||||
// can be dragged to any width (a scrollbar appears when narrower than the
|
||||
// content). QET already persists dock geometry across restarts via
|
||||
// QETDiagramEditor save/restoreState, so the chosen width is remembered.
|
||||
auto *scroll = new QScrollArea(this);
|
||||
scroll->setWidgetResizable(true);
|
||||
scroll->setFrameShape(QFrame::NoFrame);
|
||||
scroll->setWidget(m_cpw);
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(m_cpw);
|
||||
layout->addWidget(scroll);
|
||||
setMinimumWidth(120);
|
||||
setDisabled(true);
|
||||
setConductor(conductor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user