Merge pull request #509 from Kellermorph/master

Add Custom Guides
This commit is contained in:
Laurent Trinques
2026-07-07 16:34:56 +02:00
committed by GitHub
41 changed files with 507 additions and 110 deletions
+2
View File
@@ -685,6 +685,8 @@ set(QET_SRC_FILES
${QET_DIR}/sources/ui/configpage/generalconfigurationpage.h ${QET_DIR}/sources/ui/configpage/generalconfigurationpage.h
${QET_DIR}/sources/ui/configpage/projectconfigpages.cpp ${QET_DIR}/sources/ui/configpage/projectconfigpages.cpp
${QET_DIR}/sources/ui/configpage/projectconfigpages.h ${QET_DIR}/sources/ui/configpage/projectconfigpages.h
${QET_DIR}/sources/ui/configpage/guidespropertieswidget.cpp
${QET_DIR}/sources/ui/configpage/guidespropertieswidget.h
${QET_DIR}/sources/undocommand/addelementtextcommand.cpp ${QET_DIR}/sources/undocommand/addelementtextcommand.cpp
${QET_DIR}/sources/undocommand/addelementtextcommand.h ${QET_DIR}/sources/undocommand/addelementtextcommand.h
Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

+1
View File
@@ -222,6 +222,7 @@
<file>ico/24x16/dk.png</file> <file>ico/24x16/dk.png</file>
<file>ico/24x16/br.png</file> <file>ico/24x16/br.png</file>
<file>ico/22x22/grid.png</file> <file>ico/22x22/grid.png</file>
<file>ico/22x22/guides.png</file>
<file>ico/22x22/terminalstrip.png</file> <file>ico/22x22/terminalstrip.png</file>
<file>ico/16x16/diagram.png</file> <file>ico/16x16/diagram.png</file>
<file>ico/16x16/edit-clear-locationbar-rtl.png</file> <file>ico/16x16/edit-clear-locationbar-rtl.png</file>
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "searchandreplaceworker.h" #include "searchandreplaceworker.h"
#include "../qetproject.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h" #include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h" #include "../diagram.h"
#include "../diagramcommands.h" #include "../diagramcommands.h"
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstripitem.h" #include "terminalstripitem.h"
#include "../../qetproject.h"
#include "../diagram.h" #include "../diagram.h"
#include "../../project/projectpropertieshandler.h" #include "../../project/projectpropertieshandler.h"
@@ -17,7 +17,7 @@
*/ */
#include "addterminalstripitemdialog.h" #include "addterminalstripitemdialog.h"
#include "ui_addterminalstripitemdialog.h" #include "ui_addterminalstripitemdialog.h"
#include "../../qetproject.h"
#include "../../undocommand/addgraphicsobjectcommand.h" #include "../../undocommand/addgraphicsobjectcommand.h"
#include "../terminalstrip.h" #include "../terminalstrip.h"
#include "../GraphicsItem/terminalstripitem.h" #include "../GraphicsItem/terminalstripitem.h"
+1 -1
View File
@@ -23,7 +23,7 @@
#include "../qetgraphicsitem/conductor.h" #include "../qetgraphicsitem/conductor.h"
#include "../qetgraphicsitem/element.h" #include "../qetgraphicsitem/element.h"
#include "../qetxml.h" #include "../qetxml.h"
#include "../qetproject.h"
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <utility> #include <utility>
+3
View File
@@ -116,9 +116,12 @@ void renderDiagram(Diagram *diagram, QPainter &painter, const QRectF &target)
// draw_grid_ is set (default true), so toggle it off around the render // draw_grid_ is set (default true), so toggle it off around the render
// and restore it afterwards. // and restore it afterwards.
const bool was_drawing_grid = diagram->displayGrid(); const bool was_drawing_grid = diagram->displayGrid();
const bool was_drawing_guides = diagram->displayGuides();
diagram->setDisplayGrid(false); diagram->setDisplayGrid(false);
diagram->setDisplayGuides(false);
diagram->render(&painter, target, source, Qt::KeepAspectRatio); diagram->render(&painter, target, source, Qt::KeepAspectRatio);
diagram->setDisplayGrid(was_drawing_grid); diagram->setDisplayGrid(was_drawing_grid);
diagram->setDisplayGuides(was_drawing_guides);
} }
int exportPdf(QETProject &project, const QString &output) int exportPdf(QETProject &project, const QString &output)
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "conductorautonumerotation.h" #include "conductorautonumerotation.h"
#include "qetproject.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "autoNum/assignvariables.h" #include "autoNum/assignvariables.h"
#include "autoNum/numerotationcontextcommands.h" #include "autoNum/numerotationcontextcommands.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "conductornumexport.h" #include "conductornumexport.h"
#include "qetproject.h"
#include "qetapp.h" #include "qetapp.h"
#include "diagram.h" #include "diagram.h"
#include "diagramcontent.h" #include "diagramcontent.h"
+77 -13
View File
@@ -39,7 +39,7 @@
#include "qetxml.h" #include "qetxml.h"
#include "undocommand/addelementtextcommand.h" #include "undocommand/addelementtextcommand.h"
#include "qetinformation.h" #include "qetinformation.h"
#include "qetproject.h"
#include <cassert> #include <cassert>
#include <math.h> #include <math.h>
@@ -65,7 +65,6 @@ QColor Diagram::background_color = Qt::white;
Diagram::Diagram(QETProject *project) : Diagram::Diagram(QETProject *project) :
QGraphicsScene (project), QGraphicsScene (project),
m_project (project), m_project (project),
draw_grid_ (true),
use_border_ (true), use_border_ (true),
draw_terminals_ (true), draw_terminals_ (true),
draw_colored_conductors_ (true), draw_colored_conductors_ (true),
@@ -73,6 +72,11 @@ Diagram::Diagram(QETProject *project) :
m_freeze_new_elements (false), m_freeze_new_elements (false),
m_freeze_new_conductors_ (false) m_freeze_new_conductors_ (false)
{ {
QSettings settings;
draw_grid_ = settings.value(QStringLiteral("diagrameditor/grid_display_startup"), true).toBool();
draw_guides_ = settings.value(QStringLiteral("diagrameditor/guides_display_startup"), false).toBool();
setItemIndexMethod(QGraphicsScene::NoIndex); setItemIndexMethod(QGraphicsScene::NoIndex);
/* Set to no index, /* Set to no index,
* because they can be the source of the crash with conductor and shape ghost. * because they can be the source of the crash with conductor and shape ghost.
@@ -121,8 +125,30 @@ Diagram::Diagram(QETProject *project) :
connect(this, &Diagram::diagramActivated, connect(this, &Diagram::diagramActivated,
this, &Diagram::loadCndFolioSeq); this, &Diagram::loadCndFolioSeq);
adjustSceneRect(); adjustSceneRect();
}
m_guides_list.clear();
if (m_project) {
for (const auto &pg : m_project->defaultGuides()) {
Diagram::Guide g;
g.orientation = static_cast<Diagram::Guide::Orientation>(pg.orientation);
g.position = pg.position;
g.color = pg.color;
m_guides_list.append(g);
}
} else {
QSettings settings;
int size = settings.beginReadArray(QStringLiteral("diagrameditor/defaultguides"));
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
Diagram::Guide g;
g.orientation = static_cast<Diagram::Guide::Orientation>(settings.value(QStringLiteral("orientation"), 0).toInt());
g.position = settings.value(QStringLiteral("position"), 0.0).toReal();
g.color = QColor(settings.value(QStringLiteral("color"), QStringLiteral("#ff0000")).toString());
m_guides_list.append(g);
}
settings.endArray();
}
}
/** /**
@brief Diagram::~Diagram @brief Diagram::~Diagram
Destructor Destructor
@@ -186,6 +212,14 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> setBrush(Diagram::background_color); p -> setBrush(Diagram::background_color);
p -> drawRect(r); p -> drawRect(r);
QSettings settings;
QRectF rect = settings.value(
QStringLiteral("diagrameditor/zoom-out-beyond-of-folio"),
false).toBool() ? r
: border_and_titleblock
.insideBorderRect()
.intersected(r);
if (draw_grid_) { if (draw_grid_) {
/* Draw the points of the grid /* Draw the points of the grid
* if background color is black, * if background color is black,
@@ -200,19 +234,10 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> setBrush(Qt::NoBrush); p -> setBrush(Qt::NoBrush);
// If user allow zoom out beyond of folio,
// we draw grid outside of border.
QSettings settings;
int xGrid = settings.value(QStringLiteral("diagrameditor/Xgrid"), int xGrid = settings.value(QStringLiteral("diagrameditor/Xgrid"),
Diagram::xGrid).toInt(); Diagram::xGrid).toInt();
int yGrid = settings.value(QStringLiteral("diagrameditor/Ygrid"), int yGrid = settings.value(QStringLiteral("diagrameditor/Ygrid"),
Diagram::yGrid).toInt(); Diagram::yGrid).toInt();
QRectF rect = settings.value(
QStringLiteral("diagrameditor/zoom-out-beyond-of-folio"),
false).toBool() ? r
: border_and_titleblock
.insideBorderRect()
.intersected(r);
qreal limit_x = rect.x() + rect.width(); qreal limit_x = rect.x() + rect.width();
qreal limit_y = rect.y() + rect.height(); qreal limit_y = rect.y() + rect.height();
@@ -252,7 +277,23 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
p -> drawPoints(points); p -> drawPoints(points);
} }
if (use_border_) border_and_titleblock.draw(p); if (draw_guides_) {
for (const Diagram::Guide &guide : m_guides_list) {
QPen guidePen(guide.color, 1, Qt::DashLine);
guidePen.setCosmetic(true);
p->setPen(guidePen);
if (guide.orientation == Diagram::Guide::Vertical) {
p->drawLine(guide.position, rect.top(), guide.position, rect.bottom());
} else {
p->drawLine(rect.left(), guide.position, rect.right(), guide.position);
}
}
}
if (use_border_) {
border_and_titleblock.draw(p);
}
p -> restore(); p -> restore();
} }
@@ -2274,6 +2315,7 @@ ExportProperties Diagram::applyProperties(
// exporte les options de rendu en cours // exporte les options de rendu en cours
ExportProperties old_properties; ExportProperties old_properties;
old_properties.draw_grid = displayGrid(); old_properties.draw_grid = displayGrid();
old_properties.draw_guides = displayGuides();
old_properties.draw_border = border_and_titleblock.borderIsDisplayed(); old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed(); old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
old_properties.draw_terminals = drawTerminals(); old_properties.draw_terminals = drawTerminals();
@@ -2287,6 +2329,7 @@ ExportProperties Diagram::applyProperties(
setDrawTerminals (new_properties.draw_terminals); setDrawTerminals (new_properties.draw_terminals);
setDrawColoredConductors (new_properties.draw_colored_conductors); setDrawColoredConductors (new_properties.draw_colored_conductors);
setDisplayGrid (new_properties.draw_grid); setDisplayGrid (new_properties.draw_grid);
setDisplayGuides (new_properties.draw_guides);
border_and_titleblock.displayBorder(new_properties.draw_border); border_and_titleblock.displayBorder(new_properties.draw_border);
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock); border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
@@ -2635,3 +2678,24 @@ void Diagram::restoreText(Element* elmt)
} }
} }
} }
QUndoStack &Diagram::undoStack() {
return *(project()->undoStack());
}
/**
* @brief Diagram::updateProjectGuides
* Aktualisiert die internen Hilfslinien dieses Schaltplans
* basierend auf den Projekt-Einstellungen und erzwingt ein Neuzeichnen.
*/
void Diagram::updateProjectGuides(const QList<GuideProperties> &guides) {
m_guides_list.clear();
for (const GuideProperties &pg : guides) {
Diagram::Guide g;
g.orientation = static_cast<Diagram::Guide::Orientation>(pg.orientation);
g.position = pg.position;
g.color = pg.color;
m_guides_list.append(g);
}
update();
}
+23 -11
View File
@@ -24,7 +24,6 @@
#include "elementtextsmover.h" #include "elementtextsmover.h"
#include "exportproperties.h" #include "exportproperties.h"
#include "properties/xrefproperties.h" #include "properties/xrefproperties.h"
#include "qetproject.h"
#include "qgimanager.h" #include "qgimanager.h"
#include <QHash> #include <QHash>
@@ -39,12 +38,11 @@ class DiagramPosition;
class DiagramTextItem; class DiagramTextItem;
class Element; class Element;
class ElementsLocation; class ElementsLocation;
class QETProject;
class Terminal;
class DiagramImageItem; class DiagramImageItem;
class DiagramEventInterface; class DiagramEventInterface;
class DiagramFolioList; class DiagramFolioList;
class QETProject; class QETProject;
struct GuideProperties;
/** /**
@brief The Diagram class @brief The Diagram class
@@ -67,6 +65,13 @@ class Diagram : public QGraphicsScene
// ATTRIBUTES // ATTRIBUTES
public: public:
struct Guide {
enum Orientation { Horizontal, Vertical };
Orientation orientation;
qreal position;
QColor color;
};
/** /**
@brief The BorderOptions enum @brief The BorderOptions enum
Represents available options when rendering a particular diagram: Represents available options when rendering a particular diagram:
@@ -119,6 +124,8 @@ class Diagram : public QGraphicsScene
bool draw_grid_; bool draw_grid_;
bool use_border_; bool use_border_;
bool draw_guides_;
QList<Diagram::Guide> m_guides_list;
bool draw_terminals_; bool draw_terminals_;
bool draw_colored_conductors_; bool draw_colored_conductors_;
@@ -207,6 +214,9 @@ class Diagram : public QGraphicsScene
ExportProperties applyProperties(const ExportProperties &); ExportProperties applyProperties(const ExportProperties &);
void setDisplayGrid(bool); void setDisplayGrid(bool);
bool displayGrid(); bool displayGrid();
void setDisplayGuides(bool);
bool displayGuides();
void updateProjectGuides(const QList<GuideProperties> &guides);
void setUseBorder(bool); void setUseBorder(bool);
bool useBorder(); bool useBorder();
void setBorderOptions(BorderOptions); void setBorderOptions(BorderOptions);
@@ -341,6 +351,16 @@ inline bool Diagram::displayGrid() {
return(draw_grid_); return(draw_grid_);
} }
inline void Diagram::setDisplayGuides(bool dg) {
if (draw_guides_ != dg) {
draw_guides_ = dg;
update();
}
}
inline bool Diagram::displayGuides() {
return(draw_guides_);
}
/** /**
@brief Diagram::setUseBorder @brief Diagram::setUseBorder
Set whether the diagram border (including rows/columns headers and the title Set whether the diagram border (including rows/columns headers and the title
@@ -389,14 +409,6 @@ inline Diagram::BorderOptions Diagram::borderOptions() {
return(options); return(options);
} }
/**
@brief Diagram::undoStack
@return the diagram undo stack
*/
inline QUndoStack &Diagram::undoStack() {
return *(project()->undoStack());
}
/** /**
@brief Diagram::qgiManager @brief Diagram::qgiManager
@return the diagram graphics item manager @return the diagram graphics item manager
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "diagrameventaddelement.h" #include "diagrameventaddelement.h"
#include "../qetproject.h"
#include "../conductorautonumerotation.h" #include "../conductorautonumerotation.h"
#include "../diagram.h" #include "../diagram.h"
#include "../undocommand/addgraphicsobjectcommand.h" #include "../undocommand/addgraphicsobjectcommand.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "diagramview.h" #include "diagramview.h"
#include "qetproject.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "diagramcommands.h" #include "diagramcommands.h"
#include "diagramevent/diagrameventaddelement.h" #include "diagramevent/diagrameventaddelement.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "elementsmover.h" #include "elementsmover.h"
#include "qetproject.h"
#include "conductorautonumerotation.h" #include "conductorautonumerotation.h"
#include "diagram.h" #include "diagram.h"
#include "qetgraphicsitem/conductor.h" #include "qetgraphicsitem/conductor.h"
+5
View File
@@ -30,6 +30,7 @@ ExportProperties::ExportProperties() :
destination_directory(QETApp::documentDir()), destination_directory(QETApp::documentDir()),
format("PNG"), format("PNG"),
draw_grid(false), draw_grid(false),
draw_guides(false),
draw_border(true), draw_border(true),
draw_titleblock(true), draw_titleblock(true),
draw_terminals(false), draw_terminals(false),
@@ -61,6 +62,8 @@ void ExportProperties::toSettings(QSettings &settings,
format); format);
settings.setValue(prefix % "drawgrid", settings.setValue(prefix % "drawgrid",
draw_grid); draw_grid);
settings.setValue(prefix % "drawguides",
draw_guides);
settings.setValue(prefix % "drawborder", settings.setValue(prefix % "drawborder",
draw_border); draw_border);
settings.setValue(prefix % "drawtitleblock", settings.setValue(prefix % "drawtitleblock",
@@ -94,6 +97,8 @@ void ExportProperties::fromSettings(QSettings &settings,
draw_grid = settings.value(prefix % "drawgrid", draw_grid = settings.value(prefix % "drawgrid",
false).toBool(); false).toBool();
draw_guides = settings.value(prefix % "drawguides",
false).toBool();
draw_border = settings.value(prefix % "drawborder", draw_border = settings.value(prefix % "drawborder",
true ).toBool(); true ).toBool();
draw_titleblock = settings.value(prefix % "drawtitleblock", draw_titleblock = settings.value(prefix % "drawtitleblock",
+1
View File
@@ -43,6 +43,7 @@ class ExportProperties {
QDir destination_directory; ///< Target directory for generated files QDir destination_directory; ///< Target directory for generated files
QString format; ///< Image format of generated files QString format; ///< Image format of generated files
bool draw_grid; ///< Whether to render the diagram grid bool draw_grid; ///< Whether to render the diagram grid
bool draw_guides; ///< Whether to render the diagram guides
bool draw_border; ///< Whether to render the border (along with rows/columns headers) bool draw_border; ///< Whether to render the border (along with rows/columns headers)
bool draw_titleblock; ///< Whether to render the title block bool draw_titleblock; ///< Whether to render the title block
bool draw_terminals; ///< Whether to render terminals bool draw_terminals; ///< Whether to render terminals
+1 -1
View File
@@ -25,7 +25,7 @@
#include "../qetgraphicsitem/ViewItem/qetgraphicstableitem.h" #include "../qetgraphicsitem/ViewItem/qetgraphicstableitem.h"
#include "../utils/qetutils.h" #include "../utils/qetutils.h"
#include "ui/addtabledialog.h" #include "ui/addtabledialog.h"
#include "../qetproject.h"
#include <QDialog> #include <QDialog>
QetGraphicsTableFactory::QetGraphicsTableFactory() QetGraphicsTableFactory::QetGraphicsTableFactory()
+1
View File
@@ -522,6 +522,7 @@ ExportProperties ProjectPrintWindow::exportProperties() const
exp.draw_terminals = ui->m_draw_terminal_cb->isChecked(); exp.draw_terminals = ui->m_draw_terminal_cb->isChecked();
exp.draw_colored_conductors = ui->m_keep_conductor_color_cb->isChecked(); exp.draw_colored_conductors = ui->m_keep_conductor_color_cb->isChecked();
exp.draw_grid = false; exp.draw_grid = false;
exp.draw_guides = false;
return exp; return exp;
} }
+16 -1
View File
@@ -373,8 +373,9 @@ void QETDiagramEditor::setUpActions()
//Draw or not the background grid //Draw or not the background grid
m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this); m_draw_grid = new QAction ( QET::Icons::Grid, tr("Afficher la grille"), this);
m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios")); m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios"));
QSettings settings;
m_draw_grid->setCheckable(true); m_draw_grid->setCheckable(true);
m_draw_grid->setChecked(true); m_draw_grid->setChecked(settings.value("diagrameditor/grid_display_startup", true).toBool());
connect(m_draw_grid, &QAction::triggered, [this](bool checked) { connect(m_draw_grid, &QAction::triggered, [this](bool checked) {
foreach (ProjectView *prjv, this->openedProjects()) foreach (ProjectView *prjv, this->openedProjects())
foreach (Diagram *d, prjv->project()->diagrams()) { foreach (Diagram *d, prjv->project()->diagrams()) {
@@ -383,6 +384,18 @@ void QETDiagramEditor::setUpActions()
} }
}); });
// Draw or not the custom guides
m_draw_guides = new QAction ( QIcon(":/ico/22x22/guides.png"), tr("Afficher les guides"), this);
m_draw_guides->setStatusTip(tr("Affiche ou masque les guides"));
m_draw_guides->setCheckable(true);
m_draw_guides->setChecked(settings.value("diagrameditor/guides_display_startup", false).toBool());
connect(m_draw_guides, &QAction::triggered, [this](bool checked) {
foreach (ProjectView *prjv, this->openedProjects())
foreach (Diagram *d, prjv->project()->diagrams()) {
d->setDisplayGuides(checked);
}
});
//Edit current diagram properties //Edit current diagram properties
m_edit_diagram_properties = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this); m_edit_diagram_properties = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this);
m_edit_diagram_properties->setShortcut(Qt::CTRL | Qt::Key_L); m_edit_diagram_properties->setShortcut(Qt::CTRL | Qt::Key_L);
@@ -765,6 +778,7 @@ void QETDiagramEditor::setUpToolBar()
view_tool_bar -> addWidget(new DiagramEditorHandlerSizeWidget(this)); view_tool_bar -> addWidget(new DiagramEditorHandlerSizeWidget(this));
view_tool_bar -> addSeparator(); view_tool_bar -> addSeparator();
view_tool_bar -> addAction(m_draw_grid); view_tool_bar -> addAction(m_draw_grid);
view_tool_bar -> addAction(m_draw_guides);
view_tool_bar -> addAction (m_grey_background); view_tool_bar -> addAction (m_grey_background);
view_tool_bar -> addSeparator(); view_tool_bar -> addSeparator();
view_tool_bar -> addActions(m_zoom_action_toolBar); view_tool_bar -> addActions(m_zoom_action_toolBar);
@@ -1577,6 +1591,7 @@ void QETDiagramEditor::slot_updateActions()
m_row_column_actions_group. setEnabled(editable_project); m_row_column_actions_group. setEnabled(editable_project);
m_grey_background-> setEnabled(opened_diagram); m_grey_background-> setEnabled(opened_diagram);
m_draw_grid-> setEnabled(opened_diagram); m_draw_grid-> setEnabled(opened_diagram);
m_draw_guides-> setEnabled(opened_diagram);
//Project menu //Project menu
m_project_edit_properties -> setEnabled(opened_project); m_project_edit_properties -> setEnabled(opened_project);
+1
View File
@@ -193,6 +193,7 @@ class QETDiagramEditor : public QETMainWindow
*conductor_default, ///< Show a dialog to edit default conductor properties *conductor_default, ///< Show a dialog to edit default conductor properties
*m_grey_background, ///< Switch the background color in white or grey *m_grey_background, ///< Switch the background color in white or grey
*m_draw_grid, ///< Switch the background grid display or not *m_draw_grid, ///< Switch the background grid display or not
*m_draw_guides = nullptr, ///< Switch the custom guides display or not
*m_project_edit_properties, ///< Edit the properties of the current project. *m_project_edit_properties, ///< Edit the properties of the current project.
*m_project_add_diagram, ///< Add a diagram to the current project. *m_project_add_diagram, ///< Add a diagram to the current project.
*m_remove_diagram_from_project, ///< Delete a diagram from the current project *m_remove_diagram_from_project, ///< Delete a diagram from the current project
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "qetgraphicstableitem.h" #include "qetgraphicstableitem.h"
#include "../../qetproject.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h" #include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../createdxf.h" #include "../../createdxf.h"
#include "../../diagram.h" #include "../../diagram.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../qetgraphicsitem/conductor.h" #include "../qetgraphicsitem/conductor.h"
#include "../qetproject.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h" #include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../autoNum/numerotationcontextcommands.h" #include "../autoNum/numerotationcontextcommands.h"
#include "../conductorautonumerotation.h" #include "../conductorautonumerotation.h"
+1 -1
View File
@@ -18,7 +18,7 @@
#include "crossrefitem.h" #include "crossrefitem.h"
#include <QTimer> #include <QTimer>
#include "../qetproject.h"
#include "../autoNum/assignvariables.h" #include "../autoNum/assignvariables.h"
#include "../diagram.h" #include "../diagram.h"
#include "../diagramposition.h" #include "../diagramposition.h"
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "dynamicelementtextitem.h" #include "dynamicelementtextitem.h"
#include "../qetproject.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h" #include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h" #include "../diagram.h"
#include "../qetapp.h" #include "../qetapp.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "element.h" #include "element.h"
#include "../qetproject.h"
#include "../PropertiesEditor/propertieseditordialog.h" #include "../PropertiesEditor/propertieseditordialog.h"
#include "../autoNum/numerotationcontextcommands.h" #include "../autoNum/numerotationcontextcommands.h"
#include "../diagram.h" #include "../diagram.h"
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "elementtextitemgroup.h" #include "elementtextitemgroup.h"
#include "../qetproject.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h" #include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h" #include "../diagram.h"
#include "../qetapp.h" #include "../qetapp.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "masterelement.h" #include "masterelement.h"
#include "../qetproject.h"
#include "../diagram.h" #include "../diagram.h"
#include "crossrefitem.h" #include "crossrefitem.h"
#include "dynamicelementtextitem.h" #include "dynamicelementtextitem.h"
+1 -1
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../qetgraphicsitem/terminal.h" #include "../qetgraphicsitem/terminal.h"
#include "../qetproject.h"
#include "../conductorautonumerotation.h" #include "../conductorautonumerotation.h"
#include "../diagram.h" #include "../diagram.h"
#include "../undocommand/addgraphicsobjectcommand.h" #include "../undocommand/addgraphicsobjectcommand.h"
+56 -1
View File
@@ -65,6 +65,18 @@ QETProject::QETProject(QObject *parent) :
m_elements_collection = new XmlElementCollection(this); m_elements_collection = new XmlElementCollection(this);
init(); init();
QSettings settings;
int size = settings.beginReadArray(QStringLiteral("diagrameditor/defaultguides"));
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
GuideProperties g;
g.orientation = settings.value(QStringLiteral("orientation"), 0).toInt();
g.position = settings.value(QStringLiteral("position"), 0.0).toReal();
g.color = QColor(settings.value(QStringLiteral("color"), QStringLiteral("#ff0000")).toString());
m_default_guides.append(g);
}
settings.endArray();
} }
ProjectPropertiesHandler &QETProject::projectPropertiesHandler() ProjectPropertiesHandler &QETProject::projectPropertiesHandler()
@@ -205,6 +217,7 @@ void QETProject::init()
}); });
m_autosave_timer.start(); m_autosave_timer.start();
} }
} }
/** /**
@@ -502,6 +515,23 @@ TitleBlockProperties QETProject::defaultTitleBlockProperties() const
return(default_titleblock_properties_); return(default_titleblock_properties_);
} }
QList<GuideProperties> QETProject::defaultGuides() const {
return m_default_guides;
}
void QETProject::setDefaultGuides(const QList<GuideProperties> &guides) {
if (m_default_guides != guides) {
m_default_guides = guides;
setModified(true);
for (Diagram *diagram : m_diagrams_list) {
if (diagram) {
diagram->updateProjectGuides(m_default_guides);
}
}
}
}
/** /**
@brief QETProject::setDefaultTitleBlockProperties @brief QETProject::setDefaultTitleBlockProperties
Specify the title block to be used at the creation of a new diagram for this project Specify the title block to be used at the creation of a new diagram for this project
@@ -1589,7 +1619,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
m_default_xref_properties = XRefProperties:: defaultProperties(); m_default_xref_properties = XRefProperties:: defaultProperties();
//Read values indicate in project //Read values indicate in project
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums; QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums, guides_elmt;
for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling()) for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling())
{ {
@@ -1612,6 +1642,8 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
folio_autonums = child_elmt; folio_autonums = child_elmt;
else if (child_elmt.tagName()== QLatin1String("element_autonums")) else if (child_elmt.tagName()== QLatin1String("element_autonums"))
element_autonums = child_elmt; element_autonums = child_elmt;
else if (child_elmt.tagName() == QLatin1String("guides"))
guides_elmt = child_elmt;
} }
// size, titleblock, conductor, report, conductor autonum, folio autonum, element autonum // size, titleblock, conductor, report, conductor autonum, folio autonum, element autonum
@@ -1659,6 +1691,18 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
m_element_autonum.insert(elmt.attribute(QStringLiteral("title")), nc); m_element_autonum.insert(elmt.attribute(QStringLiteral("title")), nc);
} }
} }
// Read guides from XML (if missing, e.g. in old projects, list stays empty)
m_default_guides.clear();
if (!guides_elmt.isNull()) {
for (auto elmt : QET::findInDomElement(guides_elmt, QStringLiteral("guide"))) {
GuideProperties g;
g.orientation = elmt.attribute(QStringLiteral("orientation"), QStringLiteral("0")).toInt();
g.position = elmt.attribute(QStringLiteral("position"), QStringLiteral("0.0")).toDouble();
g.color = QColor(elmt.attribute(QStringLiteral("color"), QStringLiteral("#ff0000")));
m_default_guides.append(g);
}
}
} }
/** /**
@@ -1769,6 +1813,17 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
} }
} }
xml_element.appendChild(element_autonums); xml_element.appendChild(element_autonums);
// Export default guides
QDomElement guides_elmt = xml_document.createElement("guides");
for (const auto &g : m_default_guides) {
QDomElement guide_elmt = xml_document.createElement("guide");
guide_elmt.setAttribute("orientation", static_cast<int>(g.orientation));
guide_elmt.setAttribute("position", g.position);
guide_elmt.setAttribute("color", g.color.name());
guides_elmt.appendChild(guide_elmt);
}
xml_element.appendChild(guides_elmt);
} }
/** /**
+23 -1
View File
@@ -28,7 +28,7 @@
#include "properties/xrefproperties.h" #include "properties/xrefproperties.h"
#include "titleblock/templatescollection.h" #include "titleblock/templatescollection.h"
#include "titleblockproperties.h" #include "titleblockproperties.h"
#include "diagram.h"
#ifdef BUILD_WITHOUT_KF5 #ifdef BUILD_WITHOUT_KF5
# include "ui/nokde/kautosavefile.h" # include "ui/nokde/kautosavefile.h"
#else #else
@@ -50,6 +50,23 @@ class QTimer;
class TerminalStrip; class TerminalStrip;
#include <QColor>
struct GuideProperties {
int orientation; // 0 = Horizontal, 1 = Vertical
qreal position;
QColor color;
bool operator==(const GuideProperties &other) const {
return orientation == other.orientation &&
position == other.position &&
color == other.color;
}
bool operator!=(const GuideProperties &other) const {
return !(*this == other);
}
};
/** /**
This class represents a QET project. Typically saved as a .qet file, it This class represents a QET project. Typically saved as a .qet file, it
consists in an XML document grouping 0 to n diagrams and embedding an elements consists in an XML document grouping 0 to n diagrams and embedding an elements
@@ -110,6 +127,9 @@ class QETProject : public QObject
BorderProperties defaultBorderProperties() const; BorderProperties defaultBorderProperties() const;
void setDefaultBorderProperties(const BorderProperties &); void setDefaultBorderProperties(const BorderProperties &);
QList<GuideProperties> defaultGuides() const;
void setDefaultGuides(const QList<GuideProperties> &guides);
TitleBlockProperties defaultTitleBlockProperties() const; TitleBlockProperties defaultTitleBlockProperties() const;
void setDefaultTitleBlockProperties(const TitleBlockProperties &); void setDefaultTitleBlockProperties(const TitleBlockProperties &);
@@ -262,6 +282,8 @@ class QETProject : public QObject
QString read_only_file_path_; QString read_only_file_path_;
/// Default dimensions and properties for new diagrams created within the project /// Default dimensions and properties for new diagrams created within the project
BorderProperties default_border_properties_ = BorderProperties::defaultProperties(); BorderProperties default_border_properties_ = BorderProperties::defaultProperties();
/// Default guides for new diagrams created within the project
QList<GuideProperties> m_default_guides;
/// Default conductor properties for new diagrams created within the project /// Default conductor properties for new diagrams created within the project
ConductorProperties default_conductor_properties_ = ConductorProperties::defaultProperties(); ConductorProperties default_conductor_properties_ = ConductorProperties::defaultProperties();
/// Default title block properties for new diagrams created within the project /// Default title block properties for new diagrams created within the project
+51 -7
View File
@@ -30,7 +30,7 @@
#include "../reportpropertiewidget.h" #include "../reportpropertiewidget.h"
#include "../titleblockpropertieswidget.h" #include "../titleblockpropertieswidget.h"
#include "../xrefpropertieswidget.h" #include "../xrefpropertieswidget.h"
#include "guidespropertieswidget.h"
#include <QFont> #include <QFont>
#include <QFontDialog> #include <QFontDialog>
#include <QSizePolicy> #include <QSizePolicy>
@@ -73,6 +73,33 @@ NewDiagramPage::NewDiagramPage(QETProject *project,
rpw = new ReportPropertieWidget(ReportProperties::defaultProperties()); rpw = new ReportPropertieWidget(ReportProperties::defaultProperties());
// default properties of xref // default properties of xref
xrefpw = new XRefPropertiesWidget(XRefProperties::defaultProperties(), this); xrefpw = new XRefPropertiesWidget(XRefProperties::defaultProperties(), this);
// default guides properties
m_gpw = new GuidesPropertiesWidget(this);
QSettings settings;
QList<Diagram::Guide> loaded_guides;
if (m_project) {
for (const auto &pg : m_project->defaultGuides()) {
Diagram::Guide g;
g.orientation = static_cast<Diagram::Guide::Orientation>(pg.orientation);
g.position = pg.position;
g.color = pg.color;
loaded_guides.append(g);
}
} else {
QSettings settings;
int size = settings.beginReadArray(QStringLiteral("diagrameditor/defaultguides"));
for (int i = 0; i < size; ++i) {
settings.setArrayIndex(i);
Diagram::Guide g;
g.orientation = static_cast<Diagram::Guide::Orientation>(settings.value(QStringLiteral("orientation"), 0).toInt());
g.position = settings.value(QStringLiteral("position"), 0.0).toReal();
g.color = QColor(settings.value(QStringLiteral("color"), QStringLiteral("#ff0000")).toString());
loaded_guides.append(g);
}
settings.endArray();
}
m_gpw->setGuides(loaded_guides);
//If there is a project, we edit his properties //If there is a project, we edit his properties
if (m_project) { if (m_project) {
@@ -98,6 +125,7 @@ NewDiagramPage::NewDiagramPage(QETProject *project,
tab_widget -> addTab (m_cpw, tr("Conducteur")); tab_widget -> addTab (m_cpw, tr("Conducteur"));
tab_widget -> addTab (rpw, tr("Reports de folio")); tab_widget -> addTab (rpw, tr("Reports de folio"));
tab_widget -> addTab (xrefpw, tr("Références croisées")); tab_widget -> addTab (xrefpw, tr("Références croisées"));
tab_widget -> addTab (m_gpw, tr("Guides"));
QVBoxLayout *vlayout1 = new QVBoxLayout(); QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1->addWidget(tab_widget); vlayout1->addWidget(tab_widget);
@@ -155,6 +183,17 @@ void NewDiagramPage::applyConf()
modified_project = true; modified_project = true;
} }
QList<GuideProperties> proj_guides;
for (const auto &g : m_gpw->guides()) {
GuideProperties pg;
pg.orientation = static_cast<int>(g.orientation);
pg.position = g.position;
pg.color = g.color;
proj_guides.append(pg);
}
m_project->setDefaultGuides(proj_guides);
modified_project = true;
if (modified_project) { if (modified_project) {
m_project -> setModified(modified_project); m_project -> setModified(modified_project);
} }
@@ -176,13 +215,18 @@ void NewDiagramPage::applyConf()
// default xref properties // default xref properties
QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties(); QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
foreach (QString key, hash_xrp.keys()) {
XRefProperties xrp = hash_xrp[key];
QString str("diagrameditor/defaultxref");
xrp.toSettings(settings, str += key);
}
}
// Global in QSettings speichern
QList<Diagram::Guide> current_guides = m_gpw->guides();
settings.beginWriteArray(QStringLiteral("diagrameditor/defaultguides"));
for (int i = 0; i < current_guides.size(); ++i) {
settings.setArrayIndex(i);
settings.setValue(QStringLiteral("orientation"), static_cast<int>(current_guides[i].orientation));
settings.setValue(QStringLiteral("position"), current_guides[i].position);
settings.setValue(QStringLiteral("color"), current_guides[i].color.name());
}
settings.endArray();
}
} }
/** /**
+2
View File
@@ -29,6 +29,7 @@ class TitleBlockPropertiesWidget;
class ExportPropertiesWidget; class ExportPropertiesWidget;
class ReportPropertieWidget; class ReportPropertieWidget;
class XRefPropertiesWidget; class XRefPropertiesWidget;
class GuidesPropertiesWidget;
class QETProject; class QETProject;
class TitleBlockProperties; class TitleBlockProperties;
@@ -69,6 +70,7 @@ public slots:
ConductorPropertiesWidget *m_cpw; ///< Widget to edit default conductor properties ConductorPropertiesWidget *m_cpw; ///< Widget to edit default conductor properties
ReportPropertieWidget *rpw; ///< Widget to edit default report label ReportPropertieWidget *rpw; ///< Widget to edit default report label
XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties XRefPropertiesWidget *xrefpw; ///< Widget to edit default xref properties
GuidesPropertiesWidget *m_gpw; ///< Widget to edit guides
TitleBlockProperties savedTbp; ///< Used to save current TBP and retrieve later TitleBlockProperties savedTbp; ///< Used to save current TBP and retrieve later
}; };
@@ -22,7 +22,6 @@
#include "ui_generalconfigurationpage.h" #include "ui_generalconfigurationpage.h"
#include "../../utils/qetsettings.h" #include "../../utils/qetsettings.h"
#include "../../qetmessagebox.h" #include "../../qetmessagebox.h"
#include <QFileDialog> #include <QFileDialog>
#include <QFontDialog> #include <QFontDialog>
#include <QSettings> #include <QSettings>
@@ -66,6 +65,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
break; break;
} }
#endif #endif
ui->grid_startup_cb->setChecked(settings.value("diagrameditor/grid_display_startup", true).toBool());
ui->guides_startup_cb->setChecked(settings.value("diagrameditor/guides_display_startup", false).toBool());
ui->DiagramEditor_xGrid_sb->setValue(settings.value("diagrameditor/Xgrid", 10).toInt()); ui->DiagramEditor_xGrid_sb->setValue(settings.value("diagrameditor/Xgrid", 10).toInt());
ui->DiagramEditor_yGrid_sb->setValue(settings.value("diagrameditor/Ygrid", 10).toInt()); ui->DiagramEditor_yGrid_sb->setValue(settings.value("diagrameditor/Ygrid", 10).toInt());
ui->DiagramEditor_xKeyGrid_sb->setValue(settings.value("diagrameditor/key_Xgrid", 10).toInt()); ui->DiagramEditor_xKeyGrid_sb->setValue(settings.value("diagrameditor/key_Xgrid", 10).toInt());
@@ -240,6 +241,9 @@ void GeneralConfigurationPage::applyConf()
settings.setValue("diagrameditor/highlight-integrated-elements", ui->m_highlight_integrated_elements->isChecked()); settings.setValue("diagrameditor/highlight-integrated-elements", ui->m_highlight_integrated_elements->isChecked());
settings.setValue("diagrameditor/zoom-out-beyond-of-folio", ui->m_zoom_out_beyond_folio->isChecked()); settings.setValue("diagrameditor/zoom-out-beyond-of-folio", ui->m_zoom_out_beyond_folio->isChecked());
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value()); settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
settings.setValue("diagrameditor/grid_display_startup", ui->grid_startup_cb->isChecked());
settings.setValue("diagrameditor/guides_display_startup", ui->guides_startup_cb->isChecked());
//Grid step and key navigation //Grid step and key navigation
settings.setValue("diagrameditor/Xgrid", ui->DiagramEditor_xGrid_sb->value()); settings.setValue("diagrameditor/Xgrid", ui->DiagramEditor_xGrid_sb->value());
settings.setValue("diagrameditor/Ygrid", ui->DiagramEditor_yGrid_sb->value()); settings.setValue("diagrameditor/Ygrid", ui->DiagramEditor_yGrid_sb->value());
@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>955</width> <width>955</width>
<height>556</height> <height>570</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
<attribute name="title"> <attribute name="title">
@@ -59,6 +59,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="grid_startup_cb">
<property name="text">
<string>Afficher la grille par défaut (appliqué au prochain lancement)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="guides_startup_cb">
<property name="text">
<string>Afficher les guides par défaut (appliqué au prochain lancement)</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="m_use_windows_mode_rb"> <widget class="QRadioButton" name="m_use_windows_mode_rb">
<property name="text"> <property name="text">
@@ -911,30 +932,10 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
<string>Affichage Grille</string> <string>Affichage Grille</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1"> <item row="0" column="2">
<spacer name="horizontalSpacer_10"> <widget class="QLabel" name="label_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>555</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_18">
<property name="text"> <property name="text">
<string>max:</string> <string>min:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="Label_Diagram_Grid_PointSize">
<property name="text">
<string>Taille des points de la grille de Diagram-Editor : 1 - 5</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -954,10 +955,39 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="1">
<widget class="QLabel" name="label_19"> <spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>555</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="ElementEditor_Grid_PointSize_min_sb">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="Label_Diagram_Grid_PointSize">
<property name="text"> <property name="text">
<string>min:</string> <string>Taille des points de la grille de Diagram-Editor : 1 - 5</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -977,13 +1007,6 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Taille des points de la grille de l'éditeur d'éléments : 1 - 5</string>
</property>
</widget>
</item>
<item row="1" column="5"> <item row="1" column="5">
<widget class="QSpinBox" name="ElementEditor_Grid_PointSize_max_sb"> <widget class="QSpinBox" name="ElementEditor_Grid_PointSize_max_sb">
<property name="minimumSize"> <property name="minimumSize">
@@ -1007,19 +1030,10 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="0" column="4">
<widget class="QSpinBox" name="ElementEditor_Grid_PointSize_min_sb"> <widget class="QLabel" name="label_18">
<property name="minimumSize"> <property name="text">
<size> <string>max:</string>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>5</number>
</property> </property>
</widget> </widget>
</item> </item>
@@ -1030,6 +1044,13 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Taille des points de la grille de l'éditeur d'éléments : 1 - 5</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -1110,7 +1131,6 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>m_use_system_color_cb</tabstop> <tabstop>m_use_system_color_cb</tabstop>
<tabstop>m_use_gesture_trackpad</tabstop> <tabstop>m_use_gesture_trackpad</tabstop>
<tabstop>m_zoom_out_beyond_folio</tabstop> <tabstop>m_zoom_out_beyond_folio</tabstop>
@@ -0,0 +1,113 @@
#include "guidespropertieswidget.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTableWidget>
#include <QHeaderView>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QColorDialog>
GuidesPropertiesWidget::GuidesPropertiesWidget(QWidget *parent)
: QWidget(parent)
{
setupUi();
}
GuidesPropertiesWidget::~GuidesPropertiesWidget() {}
void GuidesPropertiesWidget::setupUi() {
QVBoxLayout *main_layout = new QVBoxLayout(this);
m_table = new QTableWidget(0, 3, this);
m_table->setHorizontalHeaderLabels({tr("Orientation"), tr("Position"), tr("Couleur")});
m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
m_add_btn = new QPushButton(tr("Ajouter"), this);
m_remove_btn = new QPushButton(tr("Supprimer"), this);
QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->addWidget(m_add_btn);
btn_layout->addWidget(m_remove_btn);
btn_layout->addStretch();
main_layout->addWidget(m_table);
main_layout->addLayout(btn_layout);
connect(m_add_btn, &QPushButton::clicked, this, &GuidesPropertiesWidget::addGuide);
connect(m_remove_btn, &QPushButton::clicked, this, &GuidesPropertiesWidget::removeGuide);
}
QList<Diagram::Guide> GuidesPropertiesWidget::guides() const {
QList<Diagram::Guide> list;
for (int row = 0; row < m_table->rowCount(); ++row) {
QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0));
QDoubleSpinBox *spin = qobject_cast<QDoubleSpinBox*>(m_table->cellWidget(row, 1));
QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2));
if (combo && spin && colorBtn) {
Diagram::Guide g;
g.orientation = (combo->currentIndex() == 0) ? Diagram::Guide::Horizontal : Diagram::Guide::Vertical;
g.position = spin->value();
g.color = colorBtn->property("color").value<QColor>();
list.append(g);
}
}
return list;
}
void GuidesPropertiesWidget::setGuides(const QList<Diagram::Guide> &guides) {
m_table->setRowCount(0);
for (const auto &g : guides) {
addGuide();
int row = m_table->rowCount() - 1;
QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0));
QDoubleSpinBox *spin = qobject_cast<QDoubleSpinBox*>(m_table->cellWidget(row, 1));
QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2));
if (combo && spin && colorBtn) {
combo->setCurrentIndex(g.orientation == Diagram::Guide::Horizontal ? 0 : 1);
spin->setValue(g.position);
colorBtn->setProperty("color", g.color);
colorBtn->setStyleSheet(QString("background-color: %1; color: white; font-weight: bold;").arg(g.color.name()));
}
}
}
void GuidesPropertiesWidget::addGuide() {
int row = m_table->rowCount();
m_table->insertRow(row);
QComboBox *combo = new QComboBox(this);
combo->addItems({tr("Horizontal"), tr("Vertical")});
m_table->setCellWidget(row, 0, combo);
QDoubleSpinBox *spin = new QDoubleSpinBox(this);
spin->setRange(-10000.0, 10000.0);
spin->setDecimals(2);
spin->setValue(100.0);
m_table->setCellWidget(row, 1, spin);
QPushButton *colorBtn = new QPushButton(tr("Couleur"), this);
QColor defaultColor = Qt::lightGray;
colorBtn->setProperty("color", defaultColor);
colorBtn->setStyleSheet(QString("background-color: %1; color: white; font-weight: bold;").arg(defaultColor.name()));
connect(colorBtn, &QPushButton::clicked, [this, colorBtn]() {
QColor c = QColorDialog::getColor(colorBtn->property("color").value<QColor>(), this);
if (c.isValid()) {
colorBtn->setProperty("color", c);
colorBtn->setStyleSheet(QString("background-color: %1; color: white; font-weight: bold;").arg(c.name()));
}
});
m_table->setCellWidget(row, 2, colorBtn);
}
void GuidesPropertiesWidget::removeGuide() {
int row = m_table->currentRow();
if (row >= 0) {
m_table->removeRow(row);
}
}
@@ -0,0 +1,32 @@
#ifndef GUIDESPROPERTIESWIDGET_H
#define GUIDESPROPERTIESWIDGET_H
#include <QWidget>
#include <QList>
#include "../../diagram.h"
class QTableWidget;
class QPushButton;
class GuidesPropertiesWidget : public QWidget {
Q_OBJECT
public:
explicit GuidesPropertiesWidget(QWidget *parent = nullptr);
~GuidesPropertiesWidget() override;
QList<Diagram::Guide> guides() const;
void setGuides(const QList<Diagram::Guide> &guides);
private slots:
void addGuide();
void removeGuide();
private:
void setupUi();
QTableWidget *m_table;
QPushButton *m_add_btn;
QPushButton *m_remove_btn;
};
#endif // GUIDESPROPERTIESWIDGET_H
+1 -1
View File
@@ -24,7 +24,7 @@
#include "../elementprovider.h" #include "../elementprovider.h"
#include "../undocommand/linkelementcommand.h" #include "../undocommand/linkelementcommand.h"
#include "../qetinformation.h" #include "../qetinformation.h"
#include "../qetproject.h"
#include "../ui_linksingleelementwidget.h" #include "../ui_linksingleelementwidget.h"
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
+1 -1
View File
@@ -16,7 +16,7 @@
* along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. * along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "masterpropertieswidget.h" #include "masterpropertieswidget.h"
#include "../qetproject.h"
#include "../diagram.h" #include "../diagram.h"
#include "../diagramposition.h" #include "../diagramposition.h"
#include "../elementprovider.h" #include "../elementprovider.h"
+1 -1
View File
@@ -17,7 +17,7 @@
*/ */
#include "multipastedialog.h" #include "multipastedialog.h"
#include "../qetproject.h"
#include "../conductorautonumerotation.h" #include "../conductorautonumerotation.h"
#include "../diagram.h" #include "../diagram.h"
#include "../diagramcommands.h" #include "../diagramcommands.h"
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "changeelementinformationcommand.h" #include "changeelementinformationcommand.h"
#include "../qetproject.h"
#include "../diagram.h" #include "../diagram.h"
#include "../qetgraphicsitem/element.h" #include "../qetgraphicsitem/element.h"