mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 23:54:13 +02:00
Add adjustable background frame to the element editor
Adds a toggleable, visual-only background frame to help proportion an element's drawing against a representative folio surface, instead of guessing against a bare grid. Follows the exact precedent of the existing hotspot indicator (ElementScene::drawForeground()): drawn by ElementView::drawBackground(), centered on the same origin, and never written to the saved .elmt file. - "Afficher le cadre de fond" toggles the frame on/off. - "Taille du cadre de fond..." opens a small width/height dialog to resize it, defaulting to a representative folio's drawable area derived from BorderProperties::defaultProperties() (columns_count * columns_width by rows_count * rows_height). - Both the visibility and the last-used size persist via QSettings, the same way the existing grid-dot rendering prefs (elementeditor/grid_pointsize_min/max) already do. Implements the scope proposed in discussion #604.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#include "elementscene.h"
|
||||
|
||||
#include "../borderproperties.h"
|
||||
#include "../NameList/ui/namelistdialog.h"
|
||||
#include "../NameList/ui/namelistwidget.h"
|
||||
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
@@ -73,6 +74,49 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
this, SLOT(managePrimitivesGroups()));
|
||||
connect(this, SIGNAL(selectionChanged()),
|
||||
this, SLOT(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