mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-07-07 20:14:12 +02:00
@@ -30,7 +30,7 @@
|
||||
#include "../reportpropertiewidget.h"
|
||||
#include "../titleblockpropertieswidget.h"
|
||||
#include "../xrefpropertieswidget.h"
|
||||
|
||||
#include "guidespropertieswidget.h"
|
||||
#include <QFont>
|
||||
#include <QFontDialog>
|
||||
#include <QSizePolicy>
|
||||
@@ -73,6 +73,33 @@ NewDiagramPage::NewDiagramPage(QETProject *project,
|
||||
rpw = new ReportPropertieWidget(ReportProperties::defaultProperties());
|
||||
// default properties of xref
|
||||
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 (m_project) {
|
||||
@@ -98,6 +125,7 @@ NewDiagramPage::NewDiagramPage(QETProject *project,
|
||||
tab_widget -> addTab (m_cpw, tr("Conducteur"));
|
||||
tab_widget -> addTab (rpw, tr("Reports de folio"));
|
||||
tab_widget -> addTab (xrefpw, tr("Références croisées"));
|
||||
tab_widget -> addTab (m_gpw, tr("Guides"));
|
||||
|
||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||
vlayout1->addWidget(tab_widget);
|
||||
@@ -155,6 +183,17 @@ void NewDiagramPage::applyConf()
|
||||
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) {
|
||||
m_project -> setModified(modified_project);
|
||||
}
|
||||
@@ -176,13 +215,18 @@ void NewDiagramPage::applyConf()
|
||||
|
||||
// default xref 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ class TitleBlockPropertiesWidget;
|
||||
class ExportPropertiesWidget;
|
||||
class ReportPropertieWidget;
|
||||
class XRefPropertiesWidget;
|
||||
class GuidesPropertiesWidget;
|
||||
class QETProject;
|
||||
class TitleBlockProperties;
|
||||
|
||||
@@ -69,6 +70,7 @@ public slots:
|
||||
ConductorPropertiesWidget *m_cpw; ///< Widget to edit default conductor properties
|
||||
ReportPropertieWidget *rpw; ///< Widget to edit default report label
|
||||
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
|
||||
|
||||
};
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ui_generalconfigurationpage.h"
|
||||
#include "../../utils/qetsettings.h"
|
||||
#include "../../qetmessagebox.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QSettings>
|
||||
@@ -66,6 +65,8 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
break;
|
||||
}
|
||||
#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_yGrid_sb->setValue(settings.value("diagrameditor/Ygrid", 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/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/grid_display_startup", ui->grid_startup_cb->isChecked());
|
||||
settings.setValue("diagrameditor/guides_display_startup", ui->guides_startup_cb->isChecked());
|
||||
//Grid step and key navigation
|
||||
settings.setValue("diagrameditor/Xgrid", ui->DiagramEditor_xGrid_sb->value());
|
||||
settings.setValue("diagrameditor/Ygrid", ui->DiagramEditor_yGrid_sb->value());
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>955</width>
|
||||
<height>556</height>
|
||||
<height>570</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -17,7 +17,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@@ -59,6 +59,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QRadioButton" name="m_use_windows_mode_rb">
|
||||
<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>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="1">
|
||||
<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="0" column="4">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>max:</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>
|
||||
<string>min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -954,10 +955,39 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<item row="0" column="1">
|
||||
<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">
|
||||
<string>min:</string>
|
||||
<string>Taille des points de la grille de Diagram-Editor : 1 - 5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -977,13 +1007,6 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QSpinBox" name="ElementEditor_Grid_PointSize_max_sb">
|
||||
<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>
|
||||
</widget>
|
||||
</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>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -1030,6 +1044,13 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -1110,7 +1131,6 @@ Vous pouvez spécifier ici la valeur par défaut de ce champ pour les éléments
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>m_use_system_color_cb</tabstop>
|
||||
<tabstop>m_use_gesture_trackpad</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
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../elementprovider.h"
|
||||
#include "../undocommand/linkelementcommand.h"
|
||||
#include "../qetinformation.h"
|
||||
|
||||
#include "../qetproject.h"
|
||||
#include "../ui_linksingleelementwidget.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "masterpropertieswidget.h"
|
||||
|
||||
#include "../qetproject.h"
|
||||
#include "../diagram.h"
|
||||
#include "../diagramposition.h"
|
||||
#include "../elementprovider.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "multipastedialog.h"
|
||||
|
||||
#include "../qetproject.h"
|
||||
#include "../conductorautonumerotation.h"
|
||||
#include "../diagram.h"
|
||||
#include "../diagramcommands.h"
|
||||
|
||||
Reference in New Issue
Block a user