mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 15:24:13 +02:00
Add an adjustable background frame to the element editor
Discussion #604. Revives #643, closed on 2026-09-10 only to clear the
review backlog, ported onto current master.
The element editor shows an infinite grid, with nothing to judge how
big a symbol will look on a real folio. Affichage > "Afficher le cadre
de fond" draws a dashed blue rectangle centred on the element's origin
(the hotspot), sized by default to the drawing area of a default folio
(BorderProperties: columns x column width by rows x row height,
1020 x 640). Affichage > "Taille du cadre de fond..." sets another
size. Both persist in QSettings (elementeditor/background_frame_*).
The frame is drawn in ElementView::drawBackground(), so it is not part
of the scene: it is never written to the .elmt file and never in the
SVG export (scene render).
Changed from #643: resolved against master's new-style connects and
the hotspot visibility switch; the toggle gets the unused
document-print-frame theme icon (light and dark), without which it
showed as a text button in the icon toolbar; the size action is
registered with ShortcutManager like the toggle.
(cherry picked from commit a245411f9f)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "elementscene.h"
|
||||
|
||||
#include "../ElementsCollection/terminaluuids.h"
|
||||
#include "../borderproperties.h"
|
||||
#include "../NameList/ui/namelistdialog.h"
|
||||
#include "../NameList/ui/namelistwidget.h"
|
||||
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
@@ -72,6 +73,49 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
m_decorator_lock = new QMutex();
|
||||
connect(&m_undo_stack, &QUndoStack::indexChanged, this, &ElementScene::managePrimitivesGroups);
|
||||
connect(this, &ElementScene::selectionChanged, this, &ElementScene::managePrimitivesGroups);
|
||||
|
||||
QSettings settings;
|
||||
m_background_frame_visible = settings.value(
|
||||
QStringLiteral("elementeditor/background_frame_visible"), false).toBool();
|
||||
BorderProperties bp = BorderProperties::defaultProperties();
|
||||
m_background_frame_size = QSizeF(
|
||||
settings.value(QStringLiteral("elementeditor/background_frame_width"),
|
||||
bp.columns_count * bp.columns_width).toReal(),
|
||||
settings.value(QStringLiteral("elementeditor/background_frame_height"),
|
||||
bp.rows_count * bp.rows_height).toReal());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::setBackgroundFrameVisible
|
||||
Toggle the visual-only background frame used to proportion this
|
||||
element's drawing against a representative folio surface. Like the
|
||||
hotspot indicator, this frame is never written to the saved .elmt file.
|
||||
@param visible
|
||||
*/
|
||||
void ElementScene::setBackgroundFrameVisible(bool visible)
|
||||
{
|
||||
if (m_background_frame_visible == visible) {
|
||||
return;
|
||||
}
|
||||
m_background_frame_visible = visible;
|
||||
QSettings().setValue(QStringLiteral("elementeditor/background_frame_visible"), visible);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementScene::setBackgroundFrameSize
|
||||
@param size the new size (in scene/grid units) of the background frame
|
||||
*/
|
||||
void ElementScene::setBackgroundFrameSize(const QSizeF &size)
|
||||
{
|
||||
if (m_background_frame_size == size) {
|
||||
return;
|
||||
}
|
||||
m_background_frame_size = size;
|
||||
QSettings settings;
|
||||
settings.setValue(QStringLiteral("elementeditor/background_frame_width"), size.width());
|
||||
settings.setValue(QStringLiteral("elementeditor/background_frame_height"), size.height());
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user