mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-06 21:34:13 +02:00
Merge branch 'master' into qt6_cmake_joshua
This commit is contained in:
@@ -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
|
||||
|
||||
};
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
#include "../../qeticons.h"
|
||||
#include "ui_generalconfigurationpage.h"
|
||||
#include "../../utils/qetsettings.h"
|
||||
#include "../../utils/qetutils.h"
|
||||
#include "../../qetmessagebox.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QSettings>
|
||||
#include <sources/ui/configpage/ui_generalconfigurationpage.h>
|
||||
|
||||
/**
|
||||
@brief GeneralConfigurationPage::GeneralConfigurationPage
|
||||
@@ -62,6 +63,9 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(4);
|
||||
break;
|
||||
}
|
||||
|
||||
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());
|
||||
@@ -95,7 +99,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
if (settings.contains("diagrameditor/dynamic_text_font"))
|
||||
{
|
||||
QFont font;
|
||||
font.fromString(settings.value("diagrameditor/dynamic_text_font").toString());
|
||||
QETUtils::fontFromString(font, settings.value("diagrameditor/dynamic_text_font").toString());
|
||||
|
||||
QString fontInfos = font.family() + " " +
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
@@ -108,7 +112,7 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
if (settings.contains("diagrameditor/independent_text_font"))
|
||||
{
|
||||
QFont font;
|
||||
font.fromString(settings.value("diagrameditor/independent_text_font").toString());
|
||||
QETUtils::fontFromString(font, settings.value("diagrameditor/independent_text_font").toString());
|
||||
|
||||
QString fontInfos = font.family() + " " +
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
@@ -234,6 +238,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());
|
||||
@@ -445,11 +452,11 @@ void GeneralConfigurationPage::on_m_dyn_text_font_pb_clicked()
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont curFont;
|
||||
curFont.fromString(settings.value("diagrameditor/dynamic_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QETUtils::fontFromString(curFont, settings.value("diagrameditor/dynamic_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QFont font = QFontDialog::getFont(&ok, curFont, this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("diagrameditor/dynamic_text_font", font.toString());
|
||||
settings.setValue("diagrameditor/dynamic_text_font", QETUtils::fontToString(font));
|
||||
QString fontInfos = font.family() + " " +
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
font.styleName() + ")";
|
||||
@@ -549,11 +556,11 @@ void GeneralConfigurationPage::on_m_indi_text_font_pb_clicked()
|
||||
bool ok;
|
||||
QSettings settings;
|
||||
QFont curFont;
|
||||
curFont.fromString(settings.value("diagrameditor/independent_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QETUtils::fontFromString(curFont, settings.value("diagrameditor/independent_text_font", "Liberation Sans,9,-1,5,50,0,0,0,0,0,Regular").toString());
|
||||
QFont font = QFontDialog::getFont(&ok, curFont, this);
|
||||
if (ok)
|
||||
{
|
||||
settings.setValue("diagrameditor/independent_text_font", font.toString());
|
||||
settings.setValue("diagrameditor/independent_text_font", QETUtils::fontToString(font));
|
||||
QString fontInfos = font.family() + " " +
|
||||
QString::number(font.pointSize()) + " (" +
|
||||
font.styleName() + ")";
|
||||
|
||||
@@ -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">
|
||||
@@ -350,7 +371,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Répertoire des Macros utilisateur</string>
|
||||
</property>
|
||||
@@ -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
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../autoNum/ui/folioautonumbering.h"
|
||||
#include "../autoNum/ui/formulaautonumberingw.h"
|
||||
#include "../autoNum/ui/selectautonumw.h"
|
||||
#include "../project/projectpropertieshandler.h"
|
||||
#include "../qeticons.h"
|
||||
#include "../qetproject.h"
|
||||
#include "../borderpropertieswidget.h"
|
||||
@@ -161,6 +162,13 @@ void ProjectMainConfigPage::applyProjectConf()
|
||||
m_project -> setProjectProperties(new_properties);
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
ProjectUsageTracker &usage_tracker = m_project -> projectPropertiesHandler().usageTracker();
|
||||
if (usage_tracker.isEnabled() != usage_enabled_cb_ -> isChecked()) {
|
||||
usage_tracker.setEnabled(usage_enabled_cb_ -> isChecked());
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
if (modified_project) {
|
||||
m_project -> setModified(true);
|
||||
}
|
||||
@@ -191,6 +199,12 @@ void ProjectMainConfigPage::initWidgets()
|
||||
project_variables_label_ -> setWordWrap(true);
|
||||
project_variables_ = new DiagramContextWidget();
|
||||
project_variables_ -> setContext(DiagramContext());
|
||||
|
||||
usage_label_ = new QLabel(tr("Temps passé sur ce projet :", "label when configuring"));
|
||||
usage_value_ = new QLabel();
|
||||
usage_enabled_cb_ = new QCheckBox(tr("Suivre le temps passé sur ce projet (uniquement enregistré localement dans ce fichier)", "checkbox label"));
|
||||
usage_reset_pb_ = new QPushButton(tr("Réinitialiser", "button label"));
|
||||
connect(usage_reset_pb_, &QPushButton::clicked, this, &ProjectMainConfigPage::resetUsageTracker);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,6 +221,16 @@ void ProjectMainConfigPage::initLayout()
|
||||
main_layout0 -> addSpacing(10);
|
||||
main_layout0 -> addWidget(project_variables_label_);
|
||||
main_layout0 -> addWidget(project_variables_);
|
||||
main_layout0 -> addSpacing(10);
|
||||
|
||||
QHBoxLayout *usage_layout0 = new QHBoxLayout();
|
||||
usage_layout0 -> addWidget(usage_label_);
|
||||
usage_layout0 -> addWidget(usage_value_);
|
||||
usage_layout0 -> addStretch();
|
||||
usage_layout0 -> addWidget(usage_reset_pb_);
|
||||
main_layout0 -> addLayout(usage_layout0);
|
||||
main_layout0 -> addWidget(usage_enabled_cb_);
|
||||
|
||||
setLayout(main_layout0);
|
||||
this -> setMinimumWidth(680);
|
||||
|
||||
@@ -219,6 +243,27 @@ void ProjectMainConfigPage::readValuesFromProject()
|
||||
{
|
||||
title_value_ -> setText(m_project -> title());
|
||||
project_variables_ -> setContext(m_project -> projectProperties());
|
||||
|
||||
const ProjectUsageTracker &usage_tracker = m_project -> projectPropertiesHandler().usageTracker();
|
||||
const qint64 total_seconds = usage_tracker.secondsSpent();
|
||||
usage_value_ -> setText(tr("%1 h %2 min", "hours and minutes of time spent on a project")
|
||||
.arg(total_seconds / 3600)
|
||||
.arg((total_seconds % 3600) / 60));
|
||||
usage_enabled_cb_ -> setChecked(usage_tracker.isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ProjectMainConfigPage::resetUsageTracker
|
||||
Reset the accumulated "time spent on this project" counter to zero and
|
||||
refresh its displayed value. Applies immediately (not staged behind
|
||||
OK/Cancel like the other fields on this page), since it isn't
|
||||
destructive to any actual project content.
|
||||
*/
|
||||
void ProjectMainConfigPage::resetUsageTracker()
|
||||
{
|
||||
m_project -> projectPropertiesHandler().usageTracker().resetSecondsSpent();
|
||||
m_project -> setModified(true);
|
||||
usage_value_ -> setText(tr("%1 h %2 min", "hours and minutes of time spent on a project").arg(0).arg(0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,6 +274,8 @@ void ProjectMainConfigPage::adjustReadOnly()
|
||||
{
|
||||
bool is_read_only = m_project -> isReadOnly();
|
||||
title_value_ -> setReadOnly(is_read_only);
|
||||
usage_enabled_cb_ -> setDisabled(is_read_only);
|
||||
usage_reset_pb_ -> setDisabled(is_read_only);
|
||||
}
|
||||
|
||||
//######################################################################################//
|
||||
@@ -419,7 +466,7 @@ void ProjectAutoNumConfigPage::saveContextElement()
|
||||
m_saw_element->contextComboBox()->addItem(tr("Sans nom"));
|
||||
}
|
||||
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
|
||||
else if ( !m_project -> elementAutoNum().keys().contains( m_saw_element->contextComboBox()->currentText()))
|
||||
else if ( !m_project -> elementAutoNum().contains( m_saw_element->contextComboBox()->currentText()))
|
||||
{
|
||||
m_project->addElementAutoNum(m_saw_element->contextComboBox()->currentText(), m_saw_element->toNumContext());
|
||||
m_project->setCurrrentElementAutonum(m_saw_element->contextComboBox()->currentText());
|
||||
@@ -461,7 +508,7 @@ void ProjectAutoNumConfigPage::saveContextConductor()
|
||||
m_saw_conductor->contextComboBox()-> addItem(tr("Sans nom"));
|
||||
}
|
||||
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
|
||||
else if ( !m_project -> conductorAutoNum().keys().contains( m_saw_conductor->contextComboBox()->currentText()))
|
||||
else if ( !m_project -> conductorAutoNum().contains( m_saw_conductor->contextComboBox()->currentText()))
|
||||
{
|
||||
project()->addConductorAutoNum(m_saw_conductor->contextComboBox()->currentText(), m_saw_conductor->toNumContext());
|
||||
project()->setCurrentConductorAutoNum(m_saw_conductor->contextComboBox()->currentText());
|
||||
@@ -489,7 +536,7 @@ void ProjectAutoNumConfigPage::saveContextFolio()
|
||||
m_saw_folio->contextComboBox() -> addItem(tr("Sans nom"));
|
||||
}
|
||||
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
|
||||
else if ( !m_project -> folioAutoNum().keys().contains( m_saw_folio->contextComboBox()->currentText())) {
|
||||
else if ( !m_project -> folioAutoNum().contains( m_saw_folio->contextComboBox()->currentText())) {
|
||||
project()->addFolioAutoNum(m_saw_folio->contextComboBox()->currentText(), m_saw_folio->toNumContext());
|
||||
m_saw_folio->contextComboBox() -> addItem(m_saw_folio->contextComboBox()->currentText());
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class QETProject;
|
||||
class BorderPropertiesWidget;
|
||||
class ConductorPropertiesWidget;
|
||||
@@ -108,7 +110,10 @@ class ProjectMainConfigPage : public ProjectConfigPage {
|
||||
void initLayout() override;
|
||||
void readValuesFromProject() override;
|
||||
void adjustReadOnly() override;
|
||||
|
||||
|
||||
private slots:
|
||||
void resetUsageTracker();
|
||||
|
||||
// attributes
|
||||
protected:
|
||||
QLabel *title_label_;
|
||||
@@ -116,6 +121,10 @@ class ProjectMainConfigPage : public ProjectConfigPage {
|
||||
QLabel *title_information_;
|
||||
QLabel *project_variables_label_;
|
||||
DiagramContextWidget *project_variables_;
|
||||
QLabel *usage_label_;
|
||||
QLabel *usage_value_;
|
||||
QCheckBox *usage_enabled_cb_;
|
||||
QPushButton *usage_reset_pb_;
|
||||
};
|
||||
|
||||
class ProjectAutoNumConfigPage : public ProjectConfigPage {
|
||||
|
||||
Reference in New Issue
Block a user