mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-08 19:23:13 +02:00
Compare commits
33 Commits
d7a15d6cb6
...
qt6-cmake
| Author | SHA1 | Date | |
|---|---|---|---|
| 411fb3c4dc | |||
| 07a07a5719 | |||
| 3913836137 | |||
| 242a601984 | |||
| 635bb15faf | |||
| 2deb37d351 | |||
| 1124a567aa | |||
| 8e7120e923 | |||
| 0a9f62126b | |||
| c0864eced3 | |||
| e01e3d7838 | |||
| 0e85314a84 | |||
| 80e404048c | |||
| 0e5f37503c | |||
| f14f6c6a8d | |||
| b815244494 | |||
| 01d018f8cf | |||
| d4972dc588 | |||
| e66061fdca | |||
| e2e84a56f7 | |||
| 565374f174 | |||
| 7bdca47d8e | |||
| f0c954329f | |||
| e99ad6b424 | |||
| 74460a6645 | |||
| 231a1c919a | |||
| 19c9d614e8 | |||
| 43386aa14f | |||
| 181680e6f1 | |||
| 667d25899f | |||
| c9b9165911 | |||
| 78ee65a21b | |||
| 68a2ddde18 |
@@ -64,7 +64,8 @@ message("GIT_COMMIT_SHA :" ${GIT_COMMIT_SHA})
|
|||||||
|
|
||||||
if(BUILD_WITH_KF6 AND BUILD_KF6)
|
if(BUILD_WITH_KF6 AND BUILD_KF6)
|
||||||
message("KF6_GIT_TAG :" ${KF6_GIT_TAG})
|
message("KF6_GIT_TAG :" ${KF6_GIT_TAG})
|
||||||
else()
|
endif()
|
||||||
|
if(NOT BUILD_WITH_KF6)
|
||||||
add_definitions(-DBUILD_WITHOUT_KF6)
|
add_definitions(-DBUILD_WITHOUT_KF6)
|
||||||
endif()
|
endif()
|
||||||
message("QET_COMPONENTS :" ${QET_COMPONENTS})
|
message("QET_COMPONENTS :" ${QET_COMPONENTS})
|
||||||
|
|||||||
@@ -42,31 +42,19 @@ if(BUILD_WITH_KF6)
|
|||||||
FetchContent_MakeAvailable(kcoreaddons)
|
FetchContent_MakeAvailable(kcoreaddons)
|
||||||
get_target_property(kca_version KF6::CoreAddons VERSION)
|
get_target_property(kca_version KF6::CoreAddons VERSION)
|
||||||
|
|
||||||
FetchContent_Declare(
|
|
||||||
kwidgetsaddons
|
|
||||||
GIT_REPOSITORY https://invent.kde.org/frameworks/kwidgetsaddons.git
|
|
||||||
GIT_TAG ${KF6_GIT_TAG})
|
|
||||||
FetchContent_MakeAvailable(kwidgetsaddons)
|
|
||||||
get_target_property(kwa_version KF6::WidgetsAddons VERSION)
|
|
||||||
else()
|
else()
|
||||||
find_package(KF6CoreAddons REQUIRED)
|
find_package(KF6CoreAddons REQUIRED)
|
||||||
set(kca_version ${KF6CoreAddons_VERSION})
|
set(kca_version ${KF6CoreAddons_VERSION})
|
||||||
find_package(KF6WidgetsAddons REQUIRED)
|
|
||||||
set(kwa_version ${KF6WidgetsAddons_VERSION})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
get_target_property(kca_type KF6::WidgetsAddons TYPE)
|
|
||||||
get_target_property(kwa_type KF6::CoreAddons TYPE)
|
get_target_property(kwa_type KF6::CoreAddons TYPE)
|
||||||
|
|
||||||
message(NOTICE "ecm version : " ${ECM_VERSION})
|
message(NOTICE "ecm version : " ${ECM_VERSION})
|
||||||
message(NOTICE "kcoreaddons library : " ${kca_type})
|
message(NOTICE "kcoreaddons library : " ${kca_type})
|
||||||
message(NOTICE "kcoreaddons version : " ${kca_version})
|
message(NOTICE "kcoreaddons version : " ${kca_version})
|
||||||
message(NOTICE "kwidgetsaddons library : " ${kwa_type})
|
|
||||||
message(NOTICE "kwidgetsaddons version : " ${kwa_version})
|
|
||||||
endblock()
|
endblock()
|
||||||
|
|
||||||
set(KF6_PRIVATE_LIBRARIES
|
set(KF6_PRIVATE_LIBRARIES
|
||||||
KF6::WidgetsAddons
|
|
||||||
KF6::CoreAddons
|
KF6::CoreAddons
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ set(QET_SRC_FILES
|
|||||||
${QET_DIR}/sources/borderproperties.h
|
${QET_DIR}/sources/borderproperties.h
|
||||||
${QET_DIR}/sources/bordertitleblock.cpp
|
${QET_DIR}/sources/bordertitleblock.cpp
|
||||||
${QET_DIR}/sources/bordertitleblock.h
|
${QET_DIR}/sources/bordertitleblock.h
|
||||||
|
${QET_DIR}/sources/colorbutton.cpp
|
||||||
|
${QET_DIR}/sources/colorbutton.h
|
||||||
|
${QET_DIR}/sources/colorcombobox.cpp
|
||||||
|
${QET_DIR}/sources/colorcombobox.h
|
||||||
|
${QET_DIR}/sources/colorcomboboxdelegate.cpp
|
||||||
|
${QET_DIR}/sources/colorcomboboxdelegate.h
|
||||||
${QET_DIR}/sources/conductorautonumerotation.cpp
|
${QET_DIR}/sources/conductorautonumerotation.cpp
|
||||||
${QET_DIR}/sources/conductorautonumerotation.h
|
${QET_DIR}/sources/conductorautonumerotation.h
|
||||||
${QET_DIR}/sources/conductornumexport.cpp
|
${QET_DIR}/sources/conductornumexport.cpp
|
||||||
|
|||||||
+1
-1
Submodule elements updated: bfb09dd021...48eb7dcedf
@@ -26,6 +26,7 @@ Comment[nl]=Bewerken bedradingsdiagrammen.
|
|||||||
Comment[be]=Bewerken elektrisch schema.
|
Comment[be]=Bewerken elektrisch schema.
|
||||||
Comment[da]=Rediger elektriske diagrammer.
|
Comment[da]=Rediger elektriske diagrammer.
|
||||||
Comment[ja]=電気回路図の編集。
|
Comment[ja]=電気回路図の編集。
|
||||||
|
Comment[sk]=Úprava elektrických schém.
|
||||||
GenericName=Electrical diagram editor
|
GenericName=Electrical diagram editor
|
||||||
GenericName[de]=Schaltplaneditor
|
GenericName[de]=Schaltplaneditor
|
||||||
GenericName[fr]=Éditeur de schémas électriques
|
GenericName[fr]=Éditeur de schémas électriques
|
||||||
@@ -42,3 +43,4 @@ GenericName[nl]=Elektrische schema editor
|
|||||||
GenericName[be]=Elektrische schema editor
|
GenericName[be]=Elektrische schema editor
|
||||||
GenericName[da]=Elektrisk diagram redigering
|
GenericName[da]=Elektrisk diagram redigering
|
||||||
GenericName[ja]=電気回路図エディタ
|
GenericName[ja]=電気回路図エディタ
|
||||||
|
GenericName[sk]=Editor elektrických schém
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1" colspan="2">
|
<item row="12" column="1" colspan="2">
|
||||||
<widget class="KColorCombo" name="m_bridge_color_cb"/>
|
<widget class="ColorComboBox" name="m_bridge_color_cb"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
@@ -323,9 +323,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KColorCombo</class>
|
<class>ColorComboBox</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header>kcolorcombo.h</header>
|
<header>../../colorcombobox.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "../diagram.h"
|
#include "../diagram.h"
|
||||||
#include "../diagramposition.h"
|
#include "../diagramposition.h"
|
||||||
#include "../qetapp.h"
|
#include "../qetapp.h"
|
||||||
|
#include "../qetgraphicsitem/conductor.h"
|
||||||
#include "../qetgraphicsitem/element.h"
|
#include "../qetgraphicsitem/element.h"
|
||||||
#include "../qetxml.h"
|
#include "../qetxml.h"
|
||||||
|
|
||||||
@@ -189,12 +190,14 @@ namespace autonum
|
|||||||
QString AssignVariables::formulaToLabel(QString formula,
|
QString AssignVariables::formulaToLabel(QString formula,
|
||||||
sequentialNumbers &seqStruct,
|
sequentialNumbers &seqStruct,
|
||||||
Diagram *diagram,
|
Diagram *diagram,
|
||||||
const Element *elmt)
|
const Element *elmt,
|
||||||
|
const Conductor *cndr)
|
||||||
{
|
{
|
||||||
AssignVariables av(std::move(formula),
|
AssignVariables av(std::move(formula),
|
||||||
seqStruct,
|
seqStruct,
|
||||||
diagram,
|
diagram,
|
||||||
elmt);
|
elmt,
|
||||||
|
cndr);
|
||||||
seqStruct = av.m_seq_struct;
|
seqStruct = av.m_seq_struct;
|
||||||
return av.m_assigned_label;
|
return av.m_assigned_label;
|
||||||
}
|
}
|
||||||
@@ -301,13 +304,14 @@ namespace autonum
|
|||||||
AssignVariables::AssignVariables(const QString& formula,
|
AssignVariables::AssignVariables(const QString& formula,
|
||||||
const sequentialNumbers& seqStruct,
|
const sequentialNumbers& seqStruct,
|
||||||
Diagram *diagram,
|
Diagram *diagram,
|
||||||
const Element *elmt):
|
const Element *elmt,
|
||||||
|
const Conductor *cndr):
|
||||||
m_diagram(diagram),
|
m_diagram(diagram),
|
||||||
m_arg_formula(formula),
|
m_arg_formula(formula),
|
||||||
m_assigned_label(formula),
|
m_assigned_label(formula),
|
||||||
m_seq_struct(seqStruct),
|
m_seq_struct(seqStruct),
|
||||||
m_element(elmt)
|
m_element(elmt),
|
||||||
|
m_conductor(cndr)
|
||||||
{
|
{
|
||||||
if (m_diagram)
|
if (m_diagram)
|
||||||
{
|
{
|
||||||
@@ -349,6 +353,14 @@ namespace autonum
|
|||||||
m_assigned_label.replace("%prefix", m_element->getPrefix());
|
m_assigned_label.replace("%prefix", m_element->getPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_conductor)
|
||||||
|
{
|
||||||
|
m_assigned_label.replace("%wf", cndr->properties().m_function);
|
||||||
|
m_assigned_label.replace("%wv", cndr->properties().m_tension_protocol);
|
||||||
|
m_assigned_label.replace("%wc", cndr->properties().m_wire_color);
|
||||||
|
m_assigned_label.replace("%ws", cndr->properties().m_wire_section);
|
||||||
|
}
|
||||||
|
|
||||||
assignTitleBlockVar();
|
assignTitleBlockVar();
|
||||||
assignProjectVar();
|
assignProjectVar();
|
||||||
assignSequence();
|
assignSequence();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
class Conductor;
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class Element;
|
class Element;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
@@ -61,12 +62,12 @@ namespace autonum
|
|||||||
class AssignVariables
|
class AssignVariables
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr);
|
static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr, const Conductor *cndr = nullptr);
|
||||||
static QString replaceVariable (const QString &formula, const DiagramContext &dc);
|
static QString replaceVariable (const QString &formula, const DiagramContext &dc);
|
||||||
static QString genericXref (const Element *element);
|
static QString genericXref (const Element *element);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt = nullptr);
|
AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt = nullptr, const Conductor *cndr = nullptr);
|
||||||
void assignTitleBlockVar();
|
void assignTitleBlockVar();
|
||||||
void assignProjectVar();
|
void assignProjectVar();
|
||||||
void assignSequence();
|
void assignSequence();
|
||||||
@@ -76,6 +77,7 @@ namespace autonum
|
|||||||
QString m_assigned_label;
|
QString m_assigned_label;
|
||||||
sequentialNumbers m_seq_struct;
|
sequentialNumbers m_seq_struct;
|
||||||
const Element *m_element = nullptr;
|
const Element *m_element = nullptr;
|
||||||
|
const Conductor *m_conductor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setSequentialToList(QStringList &list, NumerotationContext &nc, const QString& type);
|
void setSequentialToList(QStringList &list, NumerotationContext &nc, const QString& type);
|
||||||
|
|||||||
@@ -55,11 +55,8 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
|||||||
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
|
||||||
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
|
||||||
|
|
||||||
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
|
// disable the QPicture-based cache to avoid rendering errors and crashes
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
|
|
||||||
#else
|
|
||||||
m_titleblock_template_renderer -> setUseCache(false);
|
m_titleblock_template_renderer -> setUseCache(false);
|
||||||
#endif
|
|
||||||
|
|
||||||
// dimensions par defaut du schema
|
// dimensions par defaut du schema
|
||||||
importBorder(BorderProperties());
|
importBorder(BorderProperties());
|
||||||
@@ -239,7 +236,8 @@ void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
|||||||
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
||||||
|
|
||||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||||
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
// attribute from version 0.1 - leave for backwards-compatibility
|
||||||
|
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -946,10 +944,10 @@ QString BorderTitleBlock::incrementLetters(const QString &string) {
|
|||||||
if (last_digit != 'Z') {
|
if (last_digit != 'Z') {
|
||||||
// increments the last digit
|
// increments the last digit
|
||||||
// incremente le dernier digit
|
// incremente le dernier digit
|
||||||
last_digit = (char)(string[string.length()-1].unicode()) + 1;
|
last_digit = (char)(string[string.length()-1].unicode()) + 1;
|
||||||
return(first_digits + QString(last_digit));
|
return(first_digits + QString(last_digit));
|
||||||
} else {
|
} else {
|
||||||
return(incrementLetters(first_digits) + "A");
|
return(incrementLetters(first_digits) % "A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "colorbutton.h"
|
||||||
|
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorButton::ColorButton
|
||||||
|
Simple constructor
|
||||||
|
@param parent QObject parent of the ColorButton
|
||||||
|
*/
|
||||||
|
ColorButton::ColorButton(QWidget *parent) : QPushButton(parent)
|
||||||
|
{
|
||||||
|
connect(this, &QPushButton::clicked, this, &ColorButton::clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Getter for current color
|
||||||
|
@return The current selected color
|
||||||
|
*/
|
||||||
|
const QColor ColorButton::color()
|
||||||
|
{
|
||||||
|
return m_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Setter for current color
|
||||||
|
*/
|
||||||
|
void ColorButton::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
m_color = color;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorButton::clicked
|
||||||
|
Opens a color selection dialog and lets the user select a color.
|
||||||
|
@param checked Not used
|
||||||
|
*/
|
||||||
|
void ColorButton::clicked(bool checked)
|
||||||
|
{
|
||||||
|
// Open color selection dialog
|
||||||
|
auto new_color = QColorDialog::getColor(m_color, this, tr("Select color"), QColorDialog::DontUseNativeDialog);
|
||||||
|
|
||||||
|
// Validate user input
|
||||||
|
if (new_color.isValid()) {
|
||||||
|
m_color = new_color;
|
||||||
|
emit changed(new_color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorButton::paintEvent
|
||||||
|
Paints a filled rectangle with the current selected color on the button surface.
|
||||||
|
@param e Paint event context
|
||||||
|
*/
|
||||||
|
void ColorButton::paintEvent(QPaintEvent *e) {
|
||||||
|
QPushButton::paintEvent(e);
|
||||||
|
|
||||||
|
// Padding for the color indicator
|
||||||
|
const int padding_x = 5;
|
||||||
|
const int padding_y = 5;
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
// Get dimensions of the button paint surface
|
||||||
|
auto r_width = painter.device()->width();
|
||||||
|
auto r_height = painter.device()->height();
|
||||||
|
|
||||||
|
// Paint a rectangle with a margin of 5
|
||||||
|
auto color_indicator = QRect(padding_x, padding_y, r_width - padding_x * 2, r_height - padding_y * 2);
|
||||||
|
painter.fillRect(color_indicator, m_color);
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef COLORBUTTON_H
|
||||||
|
#define COLORBUTTON_H
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <Qt>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The ColorButton class
|
||||||
|
*/
|
||||||
|
class ColorButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorButton(QWidget * = nullptr);
|
||||||
|
|
||||||
|
const QColor color();
|
||||||
|
void setColor(const QColor &);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void clicked(bool = false);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void changed(const QColor &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @brief Current selected color
|
||||||
|
QColor m_color = Qt::black;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "colorcombobox.h"
|
||||||
|
|
||||||
|
#include "colorcomboboxdelegate.h"
|
||||||
|
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStylePainter>
|
||||||
|
#include <Qt>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorComboBox::ColorComboBox
|
||||||
|
Simple constructor
|
||||||
|
@param parent QObject parent of the ColorComboBox
|
||||||
|
*/
|
||||||
|
ColorComboBox::ColorComboBox(QWidget *parent) : QComboBox(parent)
|
||||||
|
{
|
||||||
|
connect(this, &QComboBox::activated, this, &ColorComboBox::colorSelected);
|
||||||
|
setItemDelegate(new ColorComboBoxDelegate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorComboBox::setColors
|
||||||
|
Sets the colors of the combo box. An item at the top will be added to allow selection
|
||||||
|
of a custom color.
|
||||||
|
@param colors Vector of colors to add to the combo box
|
||||||
|
*/
|
||||||
|
void ColorComboBox::setColors(const QVector<QColor> &colors)
|
||||||
|
{
|
||||||
|
addItem(tr("[Custom color...]"), QColor(Qt::black));
|
||||||
|
for(auto &color : colors) {
|
||||||
|
addItem(color.name(), color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorComboBox::colorSelected
|
||||||
|
Opens a color selection dialog and lets the user select a color.
|
||||||
|
@param checked Not used
|
||||||
|
*/
|
||||||
|
void ColorComboBox::colorSelected(int index)
|
||||||
|
{
|
||||||
|
if (index == 0) {
|
||||||
|
// Open color selection dialog if custom color is selected
|
||||||
|
auto new_color = QColorDialog::getColor(itemData(index).value<QColor>(), this, tr("Select color"), QColorDialog::DontUseNativeDialog);
|
||||||
|
|
||||||
|
// Validate and emit user input color
|
||||||
|
if (new_color.isValid()) {
|
||||||
|
setItemData(index, new_color);
|
||||||
|
emit activated(new_color);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Emit color from selected combo box row
|
||||||
|
emit activated(itemData(index).value<QColor>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorComboBox::paintEvent
|
||||||
|
Paints a filled rectangle with the current selected color on the combo box surface.
|
||||||
|
@param e Paint event context
|
||||||
|
*/
|
||||||
|
void ColorComboBox::paintEvent(QPaintEvent *e) {
|
||||||
|
// Padding for the color indicator
|
||||||
|
const int padding_x = 5;
|
||||||
|
const int padding_y = 5;
|
||||||
|
|
||||||
|
// Create painter and draw a vanilla combobox
|
||||||
|
QStylePainter painter(this);
|
||||||
|
QStyleOptionComboBox opt;
|
||||||
|
initStyleOption(&opt);
|
||||||
|
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
|
||||||
|
|
||||||
|
// Get dimensions of the combo box paint surface
|
||||||
|
auto r_width = painter.device()->width();
|
||||||
|
auto r_height = painter.device()->height();
|
||||||
|
|
||||||
|
// Paint a rectangle with a margin
|
||||||
|
auto color_indicator = QRect(padding_x, padding_y, r_width - padding_x * 2, r_height - padding_y * 2);
|
||||||
|
painter.fillRect(color_indicator, itemData(currentIndex()).value<QColor>());
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef COLORCOMBOBOX_H
|
||||||
|
#define COLORCOMBOBOX_H
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QVector>
|
||||||
|
#include <Qt>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The ColorComboBox class
|
||||||
|
*/
|
||||||
|
class ColorComboBox : public QComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ColorComboBox(QWidget * = nullptr);
|
||||||
|
|
||||||
|
void setColors(const QVector<QColor> &);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void colorSelected(int);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void activated(const QColor &);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "colorcomboboxdelegate.h"
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief ColorComboBoxDelegate::paint
|
||||||
|
Paints a filled rectangle on the drop down item with the items color.
|
||||||
|
@param painter Painter context
|
||||||
|
@param option Style options
|
||||||
|
@param index Index of the item to paint
|
||||||
|
|
||||||
|
*/
|
||||||
|
void ColorComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
// Padding for the color indicator
|
||||||
|
const int padding_x = 5;
|
||||||
|
const int padding_y = 2;
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
if (index.row() > 0)
|
||||||
|
{
|
||||||
|
auto rect = option.rect;
|
||||||
|
|
||||||
|
// Draw mouseover background
|
||||||
|
if (option.state & QStyle::State_MouseOver)
|
||||||
|
{
|
||||||
|
auto pal = option.widget->palette();
|
||||||
|
painter->fillRect(rect, pal.color(QPalette::Highlight));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw color indicator rectangle
|
||||||
|
auto color = qvariant_cast<QColor>(index.data());
|
||||||
|
rect.adjust(padding_x, padding_y, -padding_x, -padding_y);
|
||||||
|
painter->fillRect(rect, color);
|
||||||
|
} else {
|
||||||
|
// Draw a normal drop down item for custom color
|
||||||
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2025 The QElectroTech Team
|
||||||
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef COLORCOMBOBOXDELEGATE_H
|
||||||
|
#define COLORCOMBOBOXDELEGATE_H
|
||||||
|
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The ColorComboBoxDelegate class
|
||||||
|
Handles drawing of items in the drop down list of ColorComboBox.
|
||||||
|
*/
|
||||||
|
class ColorComboBoxDelegate : public QStyledItemDelegate
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -72,14 +72,7 @@ bool ConductorNumExport::toCsv()
|
|||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
|
|
||||||
stream << wiresNum() << endl;
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 5.15 or later")
|
|
||||||
#endif
|
|
||||||
stream << wiresNum() << &Qt::endl(stream);
|
stream << wiresNum() << &Qt::endl(stream);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -376,31 +376,31 @@ void ConductorProperties::fromXml(QDomElement &e)
|
|||||||
*/
|
*/
|
||||||
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const
|
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "color", color.name());
|
settings.setValue(prefix % "color", color.name());
|
||||||
settings.setValue(prefix + "bicolor", m_bicolor);
|
settings.setValue(prefix % "bicolor", m_bicolor);
|
||||||
settings.setValue(prefix + "color2", m_color_2.name());
|
settings.setValue(prefix % "color2", m_color_2.name());
|
||||||
settings.setValue(prefix + "dash-size", m_dash_size);
|
settings.setValue(prefix % "dash-size", m_dash_size);
|
||||||
settings.setValue(prefix + "style", writeStyle());
|
settings.setValue(prefix % "style", writeStyle());
|
||||||
settings.setValue(prefix + "type", typeToString(type));
|
settings.setValue(prefix % "type", typeToString(type));
|
||||||
settings.setValue(prefix + "text", text);
|
settings.setValue(prefix % "text", text);
|
||||||
settings.setValue(prefix + "text_color", text_color.name());
|
settings.setValue(prefix % "text_color", text_color.name());
|
||||||
settings.setValue(prefix + "formula", m_formula);
|
settings.setValue(prefix % "formula", m_formula);
|
||||||
settings.setValue(prefix + "cable", m_cable);
|
settings.setValue(prefix % "cable", m_cable);
|
||||||
settings.setValue(prefix + "bus", m_bus);
|
settings.setValue(prefix % "bus", m_bus);
|
||||||
settings.setValue(prefix + "function", m_function);
|
settings.setValue(prefix % "function", m_function);
|
||||||
settings.setValue(prefix + "tension_protocol", m_tension_protocol);
|
settings.setValue(prefix % "tension_protocol", m_tension_protocol);
|
||||||
settings.setValue(prefix + "conductor_color", m_wire_color);
|
settings.setValue(prefix % "conductor_color", m_wire_color);
|
||||||
settings.setValue(prefix + "conductor_section", m_wire_section);
|
settings.setValue(prefix % "conductor_section", m_wire_section);
|
||||||
settings.setValue(prefix + "textsize", QString::number(text_size));
|
settings.setValue(prefix % "textsize", QString::number(text_size));
|
||||||
settings.setValue(prefix + "size", QString::number(cond_size));
|
settings.setValue(prefix % "size", QString::number(cond_size));
|
||||||
settings.setValue(prefix + "displaytext", m_show_text);
|
settings.setValue(prefix % "displaytext", m_show_text);
|
||||||
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
settings.setValue(prefix % "onetextperfolio", m_one_text_per_folio);
|
||||||
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
settings.setValue(prefix % "vertirotatetext", QString::number(verti_rotate_text));
|
||||||
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
settings.setValue(prefix % "horizrotatetext", QString::number(horiz_rotate_text));
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
settings.setValue(prefix % "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||||
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
settings.setValue(prefix % "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||||
|
|
||||||
singleLineProperties.toSettings(settings, prefix);
|
singleLineProperties.toSettings(settings, prefix);
|
||||||
}
|
}
|
||||||
@@ -417,36 +417,36 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
||||||
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
||||||
|
|
||||||
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
|
m_bicolor = settings.value(prefix % "bicolor", false).toBool();
|
||||||
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
|
m_dash_size = settings.value(prefix % "dash-size", 1).toInt();
|
||||||
|
|
||||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
QString setting_type = settings.value(prefix % "type", typeToString(Multi)).toString();
|
||||||
type = (setting_type == typeToString(Single)? Single : Multi);
|
type = (setting_type == typeToString(Single)? Single : Multi);
|
||||||
|
|
||||||
singleLineProperties.fromSettings(settings, prefix);
|
singleLineProperties.fromSettings(settings, prefix);
|
||||||
|
|
||||||
text = settings.value(prefix + "text", "_").toString();
|
text = settings.value(prefix % "text", "_").toString();
|
||||||
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
QColor settings_text_color = QColor(settings.value(prefix % "text_color").toString());
|
||||||
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
||||||
m_formula = settings.value(prefix + "formula", "").toString();
|
m_formula = settings.value(prefix % "formula", "").toString();
|
||||||
m_cable = settings.value(prefix + "cable", "").toString();
|
m_cable = settings.value(prefix % "cable", "").toString();
|
||||||
m_bus = settings.value(prefix + "bus", "").toString();
|
m_bus = settings.value(prefix % "bus", "").toString();
|
||||||
m_function = settings.value(prefix + "function", "").toString();
|
m_function = settings.value(prefix % "function", "").toString();
|
||||||
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
m_tension_protocol = settings.value(prefix % "tension_protocol", "").toString();
|
||||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
m_wire_color = settings.value(prefix % "conductor_color", "").toString();
|
||||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
m_wire_section = settings.value(prefix % "conductor_section", "").toString();
|
||||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
text_size = settings.value(prefix % "textsize", "7").toInt();
|
||||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
cond_size = settings.value(prefix % "size", "1").toInt();
|
||||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
m_show_text = settings.value(prefix % "displaytext", true).toBool();
|
||||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
m_one_text_per_folio = settings.value(prefix % "onetextperfolio", false).toBool();
|
||||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
verti_rotate_text = settings.value((prefix % "vertirotatetext"), "270").toDouble();
|
||||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
horiz_rotate_text = settings.value((prefix % "horizrotatetext"), "0").toDouble();
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix % "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix % "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
||||||
|
|
||||||
readStyle(settings.value(prefix + "style").toString());
|
readStyle(settings.value(prefix % "style").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -811,14 +811,7 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
|||||||
if (style_string.isEmpty()) return;
|
if (style_string.isEmpty()) return;
|
||||||
|
|
||||||
// recupere la liste des couples style / valeur
|
// recupere la liste des couples style / valeur
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
|
||||||
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
|
|
||||||
#endif
|
|
||||||
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
|
||||||
|
|
||||||
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
|
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
|
||||||
if (!Rx.isValid())
|
if (!Rx.isValid())
|
||||||
@@ -896,10 +889,10 @@ int SingleLineProperties::operator!=(const SingleLineProperties &other) const
|
|||||||
void SingleLineProperties::toSettings(QSettings &settings,
|
void SingleLineProperties::toSettings(QSettings &settings,
|
||||||
const QString &prefix) const
|
const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "hasGround", hasGround);
|
settings.setValue(prefix % "hasGround", hasGround);
|
||||||
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
settings.setValue(prefix % "hasNeutral", hasNeutral);
|
||||||
settings.setValue(prefix + "phases", phases);
|
settings.setValue(prefix % "phases", phases);
|
||||||
settings.setValue(prefix + "pen", is_pen);
|
settings.setValue(prefix % "pen", is_pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -908,8 +901,8 @@ void SingleLineProperties::toSettings(QSettings &settings,
|
|||||||
*/
|
*/
|
||||||
void SingleLineProperties::fromSettings(QSettings &settings,
|
void SingleLineProperties::fromSettings(QSettings &settings,
|
||||||
const QString &prefix) {
|
const QString &prefix) {
|
||||||
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
hasGround = settings.value(prefix % "hasGround", true).toBool();
|
||||||
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
hasNeutral = settings.value(prefix % "hasNeutral", true).toBool();
|
||||||
phases = settings.value(prefix + "phases", 1).toInt();
|
phases = settings.value(prefix % "phases", 1).toInt();
|
||||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
is_pen = settings.value(prefix % "pen", false).toBool();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-17
@@ -213,8 +213,8 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
.insideBorderRect()
|
.insideBorderRect()
|
||||||
.intersected(r);
|
.intersected(r);
|
||||||
|
|
||||||
qreal limite_x = rect.x() + rect.width();
|
qreal limit_x = rect.x() + rect.width();
|
||||||
qreal limite_y = rect.y() + rect.height();
|
qreal limit_y = rect.y() + rect.height();
|
||||||
|
|
||||||
int g_x = (int)ceil(rect.x());
|
int g_x = (int)ceil(rect.x());
|
||||||
while (g_x % xGrid) ++ g_x;
|
while (g_x % xGrid) ++ g_x;
|
||||||
@@ -222,8 +222,8 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
while (g_y % yGrid) ++ g_y;
|
while (g_y % yGrid) ++ g_y;
|
||||||
|
|
||||||
QPolygon points;
|
QPolygon points;
|
||||||
for (int gx = g_x ; gx < limite_x ; gx += xGrid) {
|
for (int gx = g_x ; gx < limit_x ; gx += xGrid) {
|
||||||
for (int gy = g_y ; gy < limite_y ; gy += yGrid) {
|
for (int gy = g_y ; gy < limit_y ; gy += yGrid) {
|
||||||
points << QPoint(gx, gy);
|
points << QPoint(gx, gy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1139,8 +1139,8 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
assert(conductor_index == 1 || conductor_index == 2);
|
assert(conductor_index == 1 || conductor_index == 2);
|
||||||
|
|
||||||
auto str_index = QString::number(conductor_index);
|
auto str_index = QString::number(conductor_index);
|
||||||
QString element_index = QStringLiteral("element") + str_index;
|
QString element_index = QStringLiteral("element") % str_index;
|
||||||
QString terminal_index = QStringLiteral("terminal") + str_index;
|
QString terminal_index = QStringLiteral("terminal") % str_index;
|
||||||
|
|
||||||
if (f.hasAttribute(element_index)) {
|
if (f.hasAttribute(element_index)) {
|
||||||
QUuid element_uuid = QUuid(f.attribute(element_index));
|
QUuid element_uuid = QUuid(f.attribute(element_index));
|
||||||
@@ -1483,14 +1483,6 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
if (content_ptr) {
|
if (content_ptr) {
|
||||||
content_ptr -> m_elements = added_elements;
|
content_ptr -> m_elements = added_elements;
|
||||||
content_ptr -> m_conductors_to_move = added_conductors;
|
content_ptr -> m_conductors_to_move = added_conductors;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
|
||||||
content_ptr -> m_text_fields = added_texts.toSet();
|
|
||||||
content_ptr -> m_images = added_images.toSet();
|
|
||||||
content_ptr -> m_shapes = added_shapes.toSet();
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
|
||||||
#endif
|
|
||||||
content_ptr -> m_text_fields = QSet<IndependentTextItem *>(
|
content_ptr -> m_text_fields = QSet<IndependentTextItem *>(
|
||||||
added_texts.begin(),
|
added_texts.begin(),
|
||||||
added_texts.end());
|
added_texts.end());
|
||||||
@@ -1501,7 +1493,6 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
added_shapes.begin(),
|
added_shapes.begin(),
|
||||||
added_shapes.end());
|
added_shapes.end());
|
||||||
content_ptr->m_terminal_strip.swap(added_strips);
|
content_ptr->m_terminal_strip.swap(added_strips);
|
||||||
#endif
|
|
||||||
content_ptr->m_tables.swap(added_tables);
|
content_ptr->m_tables.swap(added_tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1536,9 +1527,9 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
|||||||
QStringList list;
|
QStringList list;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (folioseq.hasAttribute(seq
|
while (folioseq.hasAttribute(seq
|
||||||
+ QString::number(i))) {
|
% QString::number(i))) {
|
||||||
list << folioseq.attribute(
|
list << folioseq.attribute(
|
||||||
seq + QString::number(i));
|
seq % QString::number(i));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
hash->insert(title,list);
|
hash->insert(title,list);
|
||||||
|
|||||||
@@ -248,9 +248,9 @@ void DiagramEventAddElement::addElement()
|
|||||||
QUndoCommand *undo_object = new QUndoCommand(tr("Ajouter %1").arg(element->name()));
|
QUndoCommand *undo_object = new QUndoCommand(tr("Ajouter %1").arg(element->name()));
|
||||||
new AddGraphicsObjectCommand(element, m_diagram, m_element -> pos(), undo_object);
|
new AddGraphicsObjectCommand(element, m_diagram, m_element -> pos(), undo_object);
|
||||||
|
|
||||||
//When we search for free aligned terminal we
|
//When we search for free aligned terminal we temporally remove m_element to
|
||||||
//temporally remove m_element to avoid any interaction with the function Element::AlignedFreeTerminals
|
//avoid any interaction with the function Element::AlignedFreeTerminals
|
||||||
//this is useful when an element who have two (or more) terminals opposite,
|
//This is useful when an element has two (or more) terminals on opposite sides,
|
||||||
//because m_element is exactly at the same pos of the new element
|
//because m_element is exactly at the same pos of the new element
|
||||||
//added to the scene so new conductor are created between terminal of the new element
|
//added to the scene so new conductor are created between terminal of the new element
|
||||||
//and the opposite terminal of m_element.
|
//and the opposite terminal of m_element.
|
||||||
|
|||||||
+4
-48
@@ -93,7 +93,10 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
|||||||
|
|
||||||
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
||||||
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
|
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
// TODO: review the following line. Old line commented out, been broken since commit
|
||||||
|
// "27dcd5ef007a282d1a5a7f2f3dcaefc62669d668".
|
||||||
|
// connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||||
|
connect(&(m_diagram->border_and_titleblock), &BorderTitleBlock::informationChanged, this, &DiagramView::updateWindowTitle);
|
||||||
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
||||||
|
|
||||||
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
QShortcut *edit_conductor_color_shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);
|
||||||
@@ -203,18 +206,9 @@ void DiagramView::handleElementDrop(QDropEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
diagram()->setEventInterface(
|
|
||||||
new DiagramEventAddElement(
|
|
||||||
location, diagram(), mapToScene(event->pos())));
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
diagram()->setEventInterface(
|
diagram()->setEventInterface(
|
||||||
new DiagramEventAddElement(
|
new DiagramEventAddElement(
|
||||||
location, diagram(), event->position()));
|
location, diagram(), event->position()));
|
||||||
#endif
|
|
||||||
|
|
||||||
//Set focus to the view to get event
|
//Set focus to the view to get event
|
||||||
this->setFocus();
|
this->setFocus();
|
||||||
@@ -283,17 +277,8 @@ void DiagramView::handleTextDrop(QDropEvent *e) {
|
|||||||
iti -> setHtml (e -> mimeData() -> text());
|
iti -> setHtml (e -> mimeData() -> text());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
|
|
||||||
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
|
|
||||||
iti, m_diagram, mapToScene(e->pos())));
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
|
m_diagram->undoStack().push(new AddGraphicsObjectCommand(
|
||||||
iti, m_diagram, e->position()));
|
iti, m_diagram, e->position()));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,15 +432,7 @@ void DiagramView::mousePressEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
if (m_event_interface && m_event_interface->mousePressEvent(e)) return;
|
if (m_event_interface && m_event_interface->mousePressEvent(e)) return;
|
||||||
|
|
||||||
//Start drag view when hold the middle button
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
if (e->button() == Qt::MidButton)
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
if (e->button() == Qt::MiddleButton)
|
if (e->button() == Qt::MiddleButton)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
m_drag_last_pos = e->pos();
|
m_drag_last_pos = e->pos();
|
||||||
viewport()->setCursor(Qt::ClosedHandCursor);
|
viewport()->setCursor(Qt::ClosedHandCursor);
|
||||||
@@ -505,14 +482,7 @@ void DiagramView::mouseMoveEvent(QMouseEvent *e)
|
|||||||
if (m_event_interface && m_event_interface->mouseMoveEvent(e)) return;
|
if (m_event_interface && m_event_interface->mouseMoveEvent(e)) return;
|
||||||
|
|
||||||
// Drag the view
|
// Drag the view
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
if (e->buttons() == Qt::MidButton)
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
if (e->buttons() == Qt::MiddleButton)
|
if (e->buttons() == Qt::MiddleButton)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
QScrollBar *h = horizontalScrollBar();
|
QScrollBar *h = horizontalScrollBar();
|
||||||
QScrollBar *v = verticalScrollBar();
|
QScrollBar *v = verticalScrollBar();
|
||||||
@@ -573,14 +543,7 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
if (m_event_interface && m_event_interface->mouseReleaseEvent(e)) return;
|
if (m_event_interface && m_event_interface->mouseReleaseEvent(e)) return;
|
||||||
|
|
||||||
// Stop drag view
|
// Stop drag view
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
if (e->button() == Qt::MidButton)
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
if (e->button() == Qt::MiddleButton)
|
if (e->button() == Qt::MiddleButton)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
viewport()->setCursor(Qt::ArrowCursor);
|
viewport()->setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
@@ -614,14 +577,7 @@ void DiagramView::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
QMenu *menu = new QMenu(this);
|
QMenu *menu = new QMenu(this);
|
||||||
menu->addAction(act);
|
menu->addAction(act);
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
menu->popup(e->globalPos());
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
menu->popup(e->pos());
|
menu->popup(e->pos());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_free_rubberbanding = false;
|
m_free_rubberbanding = false;
|
||||||
|
|||||||
@@ -541,19 +541,19 @@ void RotateElementsCommand::undo()
|
|||||||
}
|
}
|
||||||
else if (item->type() == PartLine::Type) {
|
else if (item->type() == PartLine::Type) {
|
||||||
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
||||||
line->setRotation(-90);
|
line->setRotation(line->rotation()-90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartPolygon::Type) {
|
else if (item->type() == PartPolygon::Type) {
|
||||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||||
poly->setRotation(-90);
|
poly->setRotation(poly->rotation()-90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartText::Type) {
|
else if (item->type() == PartText::Type) {
|
||||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||||
text->setRotation(-90);
|
text->setRotation(text->rotation()-90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartDynamicTextField::Type) {
|
else if (item->type() == PartDynamicTextField::Type) {
|
||||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
||||||
dyntext->setRotation(-90);
|
dyntext->setRotation(dyntext->rotation()-90);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
item->setRotation(item->rotation()-90);
|
item->setRotation(item->rotation()-90);
|
||||||
@@ -586,19 +586,19 @@ void RotateElementsCommand::redo()
|
|||||||
}
|
}
|
||||||
else if (item->type() == PartLine::Type) {
|
else if (item->type() == PartLine::Type) {
|
||||||
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
||||||
line->setRotation(+90);
|
line->setRotation(line->rotation()+90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartPolygon::Type) {
|
else if (item->type() == PartPolygon::Type) {
|
||||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||||
poly->setRotation(+90);
|
poly->setRotation(poly->rotation()+90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartText::Type) {
|
else if (item->type() == PartText::Type) {
|
||||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||||
text->setRotation(+90);
|
text->setRotation(text->rotation()+90);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartDynamicTextField::Type) {
|
else if (item->type() == PartDynamicTextField::Type) {
|
||||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
||||||
dyntext->setRotation(+90);
|
dyntext->setRotation(dyntext->rotation()+90);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
item->setRotation(item->rotation()+90);
|
item->setRotation(item->rotation()+90);
|
||||||
@@ -622,22 +622,22 @@ void RotateFineElementsCommand::undo()
|
|||||||
{
|
{
|
||||||
if (item->type() == PartLine::Type) {
|
if (item->type() == PartLine::Type) {
|
||||||
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
||||||
line->setRotation(-5);
|
line->setRotation(line->rotation()-5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartPolygon::Type) {
|
else if (item->type() == PartPolygon::Type) {
|
||||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||||
poly->setRotation(-5);
|
poly->setRotation(poly->rotation()-5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartText::Type) {
|
else if (item->type() == PartText::Type) {
|
||||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||||
text->setRotation(-5);
|
text->setRotation(text->rotation()-5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartDynamicTextField::Type) {
|
else if (item->type() == PartDynamicTextField::Type) {
|
||||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
||||||
dyntext->setRotation(-5);
|
dyntext->setRotation(dyntext->rotation()-5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//item->setRotation(-5);
|
//item->setRotation(item->rotation()-5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,22 +651,22 @@ void RotateFineElementsCommand::redo()
|
|||||||
{
|
{
|
||||||
if (item->type() == PartLine::Type) {
|
if (item->type() == PartLine::Type) {
|
||||||
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
|
||||||
line->setRotation(+5);
|
line->setRotation(line->rotation()+5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartPolygon::Type) {
|
else if (item->type() == PartPolygon::Type) {
|
||||||
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
|
||||||
poly->setRotation(+5);
|
poly->setRotation(poly->rotation()+5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartText::Type) {
|
else if (item->type() == PartText::Type) {
|
||||||
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
PartText* text = qgraphicsitem_cast<PartText*>(item);
|
||||||
text->setRotation(+5);
|
text->setRotation(text->rotation()+5);
|
||||||
}
|
}
|
||||||
else if (item->type() == PartDynamicTextField::Type) {
|
else if (item->type() == PartDynamicTextField::Type) {
|
||||||
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
|
||||||
dyntext->setRotation(+5);
|
dyntext->setRotation(dyntext->rotation()+5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//item->setRotation(+5);
|
//item->setRotation(item->rotation()+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,8 +172,10 @@ QPainterPath PartArc::shadowShape() const
|
|||||||
|
|
||||||
|
|
||||||
void PartArc::setRotation(qreal angle) {
|
void PartArc::setRotation(qreal angle) {
|
||||||
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
|
m_rot = QET::correctAngle(angle, true);
|
||||||
// idea taken from QET_ElementScaler:
|
// idea taken from QET_ElementScaler:
|
||||||
if (angle > 0) {
|
if (diffAngle > 0) {
|
||||||
m_start_angle += 270.0 * 16;
|
m_start_angle += 270.0 * 16;
|
||||||
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
while (m_start_angle < 0) { m_start_angle += (360*16); }
|
||||||
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
while (m_start_angle >= (360*16)) { m_start_angle -= (360*16); }
|
||||||
|
|||||||
@@ -67,8 +67,9 @@ QString PartDynamicTextField::xmlName() const
|
|||||||
@param angle
|
@param angle
|
||||||
*/
|
*/
|
||||||
void PartDynamicTextField::setRotation(qreal angle) {
|
void PartDynamicTextField::setRotation(qreal angle) {
|
||||||
QGraphicsObject::setRotation(QET::correctAngle(rotation()+angle, true));
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
setPos(QTransform().rotate(angle).map(pos()));
|
QGraphicsObject::setRotation(QET::correctAngle(angle, true));
|
||||||
|
setPos(QTransform().rotate(diffAngle).map(pos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartDynamicTextField::mirror() {
|
void PartDynamicTextField::mirror() {
|
||||||
|
|||||||
@@ -238,8 +238,10 @@ bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
|||||||
|
|
||||||
|
|
||||||
void PartEllipse::setRotation(qreal angle) {
|
void PartEllipse::setRotation(qreal angle) {
|
||||||
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
|
m_rot = QET::correctAngle(angle, true);
|
||||||
// idea taken from QET_ElementScaler:
|
// idea taken from QET_ElementScaler:
|
||||||
if (angle > 0) {
|
if (diffAngle > 0) {
|
||||||
qreal width = m_rect.height();
|
qreal width = m_rect.height();
|
||||||
qreal height = m_rect.width();
|
qreal height = m_rect.width();
|
||||||
qreal x = (m_rect.y() + m_rect.height()) * (-1);
|
qreal x = (m_rect.y() + m_rect.height()) * (-1);
|
||||||
|
|||||||
@@ -579,9 +579,10 @@ void PartLine::setSecondEndLength(const qreal &l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PartLine::setRotation(qreal angle) {
|
void PartLine::setRotation(qreal angle) {
|
||||||
m_rot += angle;
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
m_line.setP1(QTransform().rotate(angle).map(m_line.p1()));
|
m_rot = QET::correctAngle(angle, true);
|
||||||
m_line.setP2(QTransform().rotate(angle).map(m_line.p2()));
|
m_line.setP1(QTransform().rotate(diffAngle).map(m_line.p1()));
|
||||||
|
m_line.setP2(QTransform().rotate(diffAngle).map(m_line.p2()));
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
setLine(m_line);
|
setLine(m_line);
|
||||||
adjustHandlerPos();
|
adjustHandlerPos();
|
||||||
|
|||||||
@@ -297,8 +297,9 @@ void PartPolygon::resetAllHandlerColor()
|
|||||||
|
|
||||||
|
|
||||||
void PartPolygon::setRotation(qreal angle) {
|
void PartPolygon::setRotation(qreal angle) {
|
||||||
QTransform rotation = QTransform().rotate(angle);
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
m_rot += angle;
|
m_rot = QET::correctAngle(angle, true);
|
||||||
|
QTransform rotation = QTransform().rotate(diffAngle);
|
||||||
setPolygon(rotation.map(m_polygon));
|
setPolygon(rotation.map(m_polygon));
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
adjustHandlerPos();
|
adjustHandlerPos();
|
||||||
|
|||||||
@@ -168,12 +168,14 @@ void PartRectangle::setYRadius(qreal Y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PartRectangle::setRotation(qreal angle) {
|
void PartRectangle::setRotation(qreal angle) {
|
||||||
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
|
m_rot = QET::correctAngle(angle, true);
|
||||||
// for whatever reason: with "rect" we need to use scene-positions...
|
// for whatever reason: with "rect" we need to use scene-positions...
|
||||||
auto pos = mapToScene(m_rect.x(),m_rect.y());
|
auto pos = mapToScene(m_rect.x(),m_rect.y());
|
||||||
qreal width = m_rect.height();
|
qreal width = m_rect.height();
|
||||||
qreal height = m_rect.width();
|
qreal height = m_rect.width();
|
||||||
qreal x; qreal y;
|
qreal x; qreal y;
|
||||||
if (angle > 0) {
|
if (diffAngle > 0) {
|
||||||
x = (pos.y() + m_rect.height()) * (-1);
|
x = (pos.y() + m_rect.height()) * (-1);
|
||||||
y = pos.x();
|
y = pos.x();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ PartTerminal::~PartTerminal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Import terminal properties from an XML element
|
||||||
Importe les proprietes d'une borne depuis un element XML
|
Importe les proprietes d'une borne depuis un element XML
|
||||||
@param xml_elmt Element XML a lire
|
@param xml_elmt Element XML a lire / XML element to read
|
||||||
*/
|
*/
|
||||||
void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||||
d -> fromXml(xml_elmt);
|
d -> fromXml(xml_elmt);
|
||||||
@@ -166,8 +167,9 @@ void PartTerminal::setRotation(qreal angle) {
|
|||||||
else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South;
|
else if (180 <= angle_mod && angle_mod < 270) new_ori = Qet::South;
|
||||||
else new_ori = Qet::West;
|
else new_ori = Qet::West;
|
||||||
|
|
||||||
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
double tmp, y, x;
|
double tmp, y, x;
|
||||||
if (angle > 0) {
|
if (diffAngle > 0) {
|
||||||
tmp = d->m_pos.y();
|
tmp = d->m_pos.y();
|
||||||
y = d->m_pos.x();
|
y = d->m_pos.x();
|
||||||
x = (-1) * tmp;
|
x = (-1) * tmp;
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ PartText::~PartText()
|
|||||||
@param angle
|
@param angle
|
||||||
*/
|
*/
|
||||||
void PartText::setRotation(qreal angle) {
|
void PartText::setRotation(qreal angle) {
|
||||||
QGraphicsObject::setRotation(QET::correctAngle(rotation()+angle, true));
|
qreal diffAngle = qRound((angle - rotation()) * 100.0) / 100.0;
|
||||||
setPos(QTransform().rotate(angle).map(pos()));
|
QGraphicsObject::setRotation(QET::correctAngle(angle, true));
|
||||||
|
setPos(QTransform().rotate(diffAngle).map(pos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::mirror() {
|
void PartText::mirror() {
|
||||||
|
|||||||
@@ -140,10 +140,7 @@ void DynamicTextFieldEditor::updateForm()
|
|||||||
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
|
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
|
||||||
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
|
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
|
||||||
ui->m_keep_visual_rotation_cb->setChecked(m_text_field.data()->keepVisualRotation());
|
ui->m_keep_visual_rotation_cb->setChecked(m_text_field.data()->keepVisualRotation());
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
|
||||||
#else
|
|
||||||
m_color_kpb -> setColor(m_text_field.data() -> color());
|
m_color_kpb -> setColor(m_text_field.data() -> color());
|
||||||
#endif
|
|
||||||
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
|
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
|
||||||
ui -> m_font_pb -> setText(m_text_field -> font().family());
|
ui -> m_font_pb -> setText(m_text_field -> font().family());
|
||||||
|
|
||||||
@@ -169,16 +166,13 @@ void DynamicTextFieldEditor::updateForm()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::setupWidget()
|
void DynamicTextFieldEditor::setupWidget()
|
||||||
{
|
{
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
m_color_kpb = new ColorButton(this);
|
||||||
#else
|
|
||||||
m_color_kpb = new KColorButton(this);
|
|
||||||
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
|
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
|
||||||
|
|
||||||
connect(m_color_kpb, &KColorButton::changed,
|
connect(m_color_kpb, &ColorButton::changed,
|
||||||
this, &DynamicTextFieldEditor::on_m_color_kpb_changed);
|
this, &DynamicTextFieldEditor::m_color_kpb_changed);
|
||||||
|
|
||||||
ui->m_main_grid_layout->addWidget(m_color_kpb, 6, 1, 1, 2);
|
ui->m_main_grid_layout->addWidget(m_color_kpb, 6, 1, 1, 2);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections()
|
void DynamicTextFieldEditor::setUpConnections()
|
||||||
@@ -312,8 +306,8 @@ void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1) {
|
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(int index) {
|
||||||
Q_UNUSED(arg1)
|
Q_UNUSED(index)
|
||||||
|
|
||||||
QString info = ui -> m_elmt_info_cb -> currentData().toString();
|
QString info = ui -> m_elmt_info_cb -> currentData().toString();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
@@ -414,7 +408,7 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor) {
|
void DynamicTextFieldEditor::m_color_kpb_changed(QColor newColor) {
|
||||||
if (!newColor.isValid()) {
|
if (!newColor.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
#include "../elementitemeditor.h"
|
#include "../elementitemeditor.h"
|
||||||
#include "../graphicspart/partdynamictextfield.h"
|
#include "../graphicspart/partdynamictextfield.h"
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
#include "../../colorbutton.h"
|
||||||
#else
|
|
||||||
# include <KColorButton>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DynamicTextFieldEditor;
|
class DynamicTextFieldEditor;
|
||||||
@@ -61,13 +58,13 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
|||||||
void on_m_size_sb_editingFinished();
|
void on_m_size_sb_editingFinished();
|
||||||
void on_m_frame_cb_clicked();
|
void on_m_frame_cb_clicked();
|
||||||
void on_m_width_sb_editingFinished();
|
void on_m_width_sb_editingFinished();
|
||||||
void on_m_elmt_info_cb_activated(const QString &arg1);
|
void on_m_elmt_info_cb_activated(int index);
|
||||||
void on_m_text_from_cb_activated(int index);
|
void on_m_text_from_cb_activated(int index);
|
||||||
void on_m_composite_text_pb_clicked();
|
void on_m_composite_text_pb_clicked();
|
||||||
void on_m_alignment_pb_clicked();
|
void on_m_alignment_pb_clicked();
|
||||||
void on_m_font_pb_clicked();
|
void on_m_font_pb_clicked();
|
||||||
|
|
||||||
void on_m_color_kpb_changed(const QColor &newColor);
|
void m_color_kpb_changed(QColor newColor);
|
||||||
|
|
||||||
void on_m_keep_visual_rotation_cb_clicked();
|
void on_m_keep_visual_rotation_cb_clicked();
|
||||||
|
|
||||||
@@ -77,10 +74,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
|||||||
QList<PartDynamicTextField*> m_parts;
|
QList<PartDynamicTextField*> m_parts;
|
||||||
QList<QMetaObject::Connection> m_connection_list;
|
QList<QMetaObject::Connection> m_connection_list;
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
ColorButton* m_color_kpb = nullptr;
|
||||||
#else
|
|
||||||
KColorButton* m_color_kpb = nullptr;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DYNAMICTEXTFIELDEDITOR_H
|
#endif // DYNAMICTEXTFIELDEDITOR_H
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ void QETElementEditor::fillPartsList()
|
|||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
v.setValue(qgi);
|
||||||
#endif
|
#endif
|
||||||
qlwi -> setData(42, v);
|
qlwi -> setData(42, v);
|
||||||
m_parts_list -> addItem(qlwi);
|
m_parts_list -> addItem(qlwi);
|
||||||
|
|||||||
@@ -62,10 +62,7 @@ void TextEditor::updateForm()
|
|||||||
m_rotation_sb -> setValue(m_text -> rotation());
|
m_rotation_sb -> setValue(m_text -> rotation());
|
||||||
m_size_sb -> setValue(m_text -> font().pointSize());
|
m_size_sb -> setValue(m_text -> font().pointSize());
|
||||||
m_font_pb -> setText(m_text -> font().family());
|
m_font_pb -> setText(m_text -> font().family());
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
|
||||||
#else
|
|
||||||
m_color_pb -> setColor(m_text -> defaultTextColor());
|
m_color_pb -> setColor(m_text -> defaultTextColor());
|
||||||
#endif
|
|
||||||
|
|
||||||
setUpEditConnection();
|
setUpEditConnection();
|
||||||
}
|
}
|
||||||
@@ -344,19 +341,16 @@ void TextEditor::setUpWidget(QWidget *parent)
|
|||||||
m_line_edit->setPlaceholderText(tr("Entrer votre texte ici"));
|
m_line_edit->setPlaceholderText(tr("Entrer votre texte ici"));
|
||||||
|
|
||||||
gridLayout->addWidget(m_line_edit, 0, 0, 1, 6);
|
gridLayout->addWidget(m_line_edit, 0, 0, 1, 6);
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
m_color_pb = new ColorButton(parent);
|
||||||
#else
|
|
||||||
m_color_pb = new KColorButton(parent);
|
|
||||||
m_color_pb->setObjectName(QString::fromUtf8("m_color_pb"));
|
m_color_pb->setObjectName(QString::fromUtf8("m_color_pb"));
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
m_color_pb,
|
m_color_pb,
|
||||||
&KColorButton::changed,
|
&ColorButton::changed,
|
||||||
this,
|
this,
|
||||||
&TextEditor::on_m_color_pb_changed);
|
&TextEditor::on_m_color_pb_changed);
|
||||||
|
|
||||||
gridLayout->addWidget(m_color_pb, 2, 5, 1, 1);
|
gridLayout->addWidget(m_color_pb, 2, 5, 1, 1);
|
||||||
#endif
|
|
||||||
QLabel *label_5 = new QLabel(parent);
|
QLabel *label_5 = new QLabel(parent);
|
||||||
label_5->setObjectName(QString::fromUtf8("label_5"));
|
label_5->setObjectName(QString::fromUtf8("label_5"));
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,7 @@
|
|||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
#include "../../colorbutton.h"
|
||||||
#else
|
|
||||||
#include <KColorButton>
|
|
||||||
#endif
|
|
||||||
class PartText;
|
class PartText;
|
||||||
|
|
||||||
class TextEditor : public ElementItemEditor {
|
class TextEditor : public ElementItemEditor {
|
||||||
@@ -65,10 +62,7 @@ class TextEditor : public ElementItemEditor {
|
|||||||
QSpinBox *m_size_sb;
|
QSpinBox *m_size_sb;
|
||||||
QLineEdit *m_line_edit;
|
QLineEdit *m_line_edit;
|
||||||
QPushButton *m_font_pb;
|
QPushButton *m_font_pb;
|
||||||
#ifdef BUILD_WITHOUT_KF6
|
ColorButton *m_color_pb;
|
||||||
#else
|
|
||||||
KColorButton *m_color_pb;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEXTEDITOR_H
|
#endif // TEXTEDITOR_H
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ void ElementsPanelWidget::reloadAndFilter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emit the requestForProject signal with te selected project
|
* Emit the requestForProject signal with the selected project
|
||||||
*/
|
*/
|
||||||
void ElementsPanelWidget::activateProject()
|
void ElementsPanelWidget::activateProject()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Check if a conf with the same name already exist
|
//Check if a conf with the same name already exist
|
||||||
if (QFileInfo::exists(dir.absoluteFilePath(m_name + ".xml")))
|
if (QFileInfo::exists(dir.absoluteFilePath(m_name % ".xml")))
|
||||||
{
|
{
|
||||||
bool r = QMessageBox::question(parentWidget(),
|
bool r = QMessageBox::question(parentWidget(),
|
||||||
QObject::tr("Configuration de textes"),
|
QObject::tr("Configuration de textes"),
|
||||||
@@ -71,7 +71,7 @@ ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument doc = xmlConf();
|
QDomDocument doc = xmlConf();
|
||||||
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name + ".xml"));
|
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name % ".xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,7 +202,7 @@ void ImportElementTextPattern::apply(QString name, bool erase) const
|
|||||||
if(!name.endsWith(".xml"))
|
if(!name.endsWith(".xml"))
|
||||||
name.append(".xml");
|
name.append(".xml");
|
||||||
|
|
||||||
QFile conf_file(QETApp::configDir() + "/element_texts_pattern/" + name);
|
QFile conf_file(QETApp::configDir() % "/element_texts_pattern/" % name);
|
||||||
if(!conf_file.open(QIODevice::ReadOnly | QIODevice::Text))
|
if(!conf_file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
+34
-14
@@ -128,7 +128,9 @@ int ExportDialog::diagramsToExportCount() const
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Met en place la liste des schemas
|
Met en place la liste des schemas
|
||||||
|
Set up the schematics list
|
||||||
@return Le widget representant la liste des schemas
|
@return Le widget representant la liste des schemas
|
||||||
|
The widget representing the list of schematics
|
||||||
*/
|
*/
|
||||||
QWidget *ExportDialog::initDiagramsListPart()
|
QWidget *ExportDialog::initDiagramsListPart()
|
||||||
{
|
{
|
||||||
@@ -139,17 +141,17 @@ QWidget *ExportDialog::initDiagramsListPart()
|
|||||||
reset_mapper_ = new QSignalMapper(this);
|
reset_mapper_ = new QSignalMapper(this);
|
||||||
clipboard_mapper_ = new QSignalMapper(this);
|
clipboard_mapper_ = new QSignalMapper(this);
|
||||||
|
|
||||||
connect(preview_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_previewDiagram(int)));
|
connect(preview_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_previewDiagram(int)));
|
||||||
connect(width_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctHeight(int)));
|
connect(width_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_correctHeight(int)));
|
||||||
connect(height_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctWidth(int)));
|
connect(height_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_correctWidth(int)));
|
||||||
connect(ratio_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_keepRatioChanged(int)));
|
connect(ratio_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_keepRatioChanged(int)));
|
||||||
connect(reset_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_resetSize(int)));
|
connect(reset_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_resetSize(int)));
|
||||||
connect(clipboard_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_exportToClipBoard(int)));
|
connect(clipboard_mapper_, SIGNAL(mappedInt(int)), this, SLOT(slot_exportToClipBoard(int)));
|
||||||
|
|
||||||
diagrams_list_layout_ = new QGridLayout();
|
diagrams_list_layout_ = new QGridLayout();
|
||||||
|
|
||||||
int line_count = 0;
|
int line_count = 0;
|
||||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Titre du folio")), line_count, 1, Qt::AlignHCenter | Qt::AlignVCenter);
|
diagrams_list_layout_ -> addWidget(new QLabel(tr("Titre du folio")), line_count, 1, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Nom de fichier")), line_count, 2, Qt::AlignHCenter | Qt::AlignVCenter);
|
diagrams_list_layout_ -> addWidget(new QLabel(tr("Nom de fichier")), line_count, 2, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
diagrams_list_layout_ -> addWidget(new QLabel(tr("Dimensions")), line_count, 3, Qt::AlignHCenter | Qt::AlignVCenter);
|
diagrams_list_layout_ -> addWidget(new QLabel(tr("Dimensions")), line_count, 3, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
@@ -245,21 +247,28 @@ QSize ExportDialog::diagramSize(Diagram *diagram)
|
|||||||
Cette methode ajuste la largeur d'un des schemas a exporter en fonction de
|
Cette methode ajuste la largeur d'un des schemas a exporter en fonction de
|
||||||
sa hauteur si et seulement si l'option "Conserver les proportions" est
|
sa hauteur si et seulement si l'option "Conserver les proportions" est
|
||||||
activee pour ce schema.
|
activee pour ce schema.
|
||||||
@param diagram_id numero du schema concerne
|
This method adjusts the width of one of the layouts to be exported
|
||||||
|
according to its height if, and only if, the ‘Keep proportions’ option
|
||||||
|
is enabled for this layout.
|
||||||
|
@param diagram_id numero du schema concerne / number of drawing concerned
|
||||||
*/
|
*/
|
||||||
void ExportDialog::slot_correctWidth(int diagram_id)
|
void ExportDialog::slot_correctWidth(int diagram_id)
|
||||||
{
|
{
|
||||||
// recupere l'ExportDiagramLine concernee
|
// recupere l'ExportDiagramLine concernee
|
||||||
|
// retrieve the ExportDiagramLine concerned
|
||||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||||
if (!current_diagram) return;
|
if (!current_diagram) return;
|
||||||
|
|
||||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||||
|
// do nothing if the ‘Keep proportions’ option is not active
|
||||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||||
|
|
||||||
// recupere les proportions du schema
|
// recupere les proportions du schema
|
||||||
|
// retrieve the proportions of the diagram
|
||||||
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
||||||
|
|
||||||
// ajuste la largeur
|
// ajuste la largeur
|
||||||
|
// adjust the width
|
||||||
current_diagram -> width -> blockSignals(true);
|
current_diagram -> width -> blockSignals(true);
|
||||||
current_diagram -> width -> setValue(qRound(current_diagram -> height -> value() * diagram_ratio));
|
current_diagram -> width -> setValue(qRound(current_diagram -> height -> value() * diagram_ratio));
|
||||||
current_diagram -> width -> blockSignals(false);
|
current_diagram -> width -> blockSignals(false);
|
||||||
@@ -269,21 +278,28 @@ void ExportDialog::slot_correctWidth(int diagram_id)
|
|||||||
Cette methode ajuste la hauteur d'un des schemas a exporter en fonction de
|
Cette methode ajuste la hauteur d'un des schemas a exporter en fonction de
|
||||||
sa largeur si et seulement si l'option "Conserver les proportions" est
|
sa largeur si et seulement si l'option "Conserver les proportions" est
|
||||||
activee pour ce schema.
|
activee pour ce schema.
|
||||||
@param diagram_id numero du schema concerne
|
This method adjusts the height of one of the layouts to be exported
|
||||||
|
according to its width if, and only if, the ‘Keep proportions’ option
|
||||||
|
is enabled for this layout.
|
||||||
|
@param diagram_id numero du schema concerne / number of drawing concerned
|
||||||
*/
|
*/
|
||||||
void ExportDialog::slot_correctHeight(int diagram_id)
|
void ExportDialog::slot_correctHeight(int diagram_id)
|
||||||
{
|
{
|
||||||
// recupere l'ExportDiagramLine concernee
|
// recupere l'ExportDiagramLine concernee
|
||||||
|
// retrieve the ExportDiagramLine concerned
|
||||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||||
if (!current_diagram) return;
|
if (!current_diagram) return;
|
||||||
|
|
||||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||||
|
// do nothing if the ‘Keep proportions’ option is not active
|
||||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||||
|
|
||||||
// recupere les proportions du schema
|
// recupere les proportions du schema
|
||||||
|
// retrieve the proportions of the diagram
|
||||||
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
qreal diagram_ratio = diagramRatio(current_diagram -> diagram);
|
||||||
|
|
||||||
// ajuste la hauteur
|
// ajuste la hauteur
|
||||||
|
// adjust the height
|
||||||
current_diagram -> height -> blockSignals(true);
|
current_diagram -> height -> blockSignals(true);
|
||||||
current_diagram -> height -> setValue(qRound(current_diagram -> width -> value() / diagram_ratio));
|
current_diagram -> height -> setValue(qRound(current_diagram -> width -> value() / diagram_ratio));
|
||||||
current_diagram -> height -> blockSignals(false);
|
current_diagram -> height -> blockSignals(false);
|
||||||
@@ -297,10 +313,12 @@ void ExportDialog::slot_correctHeight(int diagram_id)
|
|||||||
void ExportDialog::slot_keepRatioChanged(int diagram_id)
|
void ExportDialog::slot_keepRatioChanged(int diagram_id)
|
||||||
{
|
{
|
||||||
// recupere l'ExportDiagramLine concernee
|
// recupere l'ExportDiagramLine concernee
|
||||||
|
// retrieve the ExportDiagramLine concerned
|
||||||
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
ExportDialog::ExportDiagramLine *current_diagram = diagram_lines_[diagram_id];
|
||||||
if (!current_diagram) return;
|
if (!current_diagram) return;
|
||||||
|
|
||||||
// gere l'icone du bouton "Conserver les proportions"
|
// gere l'icone du bouton "Conserver les proportions"
|
||||||
|
// manages the ‘Keep proportions’ button icon
|
||||||
if (current_diagram -> keep_ratio -> isChecked()) {
|
if (current_diagram -> keep_ratio -> isChecked()) {
|
||||||
current_diagram -> keep_ratio -> setIcon(QET::Icons::ObjectLocked);
|
current_diagram -> keep_ratio -> setIcon(QET::Icons::ObjectLocked);
|
||||||
} else {
|
} else {
|
||||||
@@ -308,9 +326,11 @@ void ExportDialog::slot_keepRatioChanged(int diagram_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
// ne fait rien si l'option "Conserver les proportions" n'est pas activee
|
||||||
|
// do nothing if the ‘Keep proportions’ option is not active
|
||||||
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
if (!(current_diagram -> keep_ratio -> isChecked())) return;
|
||||||
|
|
||||||
// au contraire, si elle est activee, ajuste la hauteur en fonction de la largeur
|
// au contraire, si elle est activee, ajuste la hauteur en fonction de la largeur
|
||||||
|
// on the other hand, if it is active, adjusts the height according to the width
|
||||||
slot_correctHeight(diagram_id);
|
slot_correctHeight(diagram_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,7 +790,7 @@ void ExportDialog::exportDiagram(ExportDiagramLine *diagram_line) {
|
|||||||
|
|
||||||
// recupere le format a utiliser (acronyme et extension)
|
// recupere le format a utiliser (acronyme et extension)
|
||||||
QString format_acronym = export_properties.format;
|
QString format_acronym = export_properties.format;
|
||||||
QString format_extension = "." + format_acronym.toLower();
|
QString format_extension = "." % format_acronym.toLower();
|
||||||
|
|
||||||
// determine le nom de fichier a utiliser
|
// determine le nom de fichier a utiliser
|
||||||
QString diagram_path = diagram_line -> file_name -> text();
|
QString diagram_path = diagram_line -> file_name -> text();
|
||||||
@@ -867,7 +887,7 @@ void ExportDialog::slot_checkDiagramsCount()
|
|||||||
void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
||||||
// recupere le format a utiliser (acronyme et extension)
|
// recupere le format a utiliser (acronyme et extension)
|
||||||
QString format_acronym = epw -> exportProperties().format;
|
QString format_acronym = epw -> exportProperties().format;
|
||||||
QString format_extension = "." + format_acronym.toLower();
|
QString format_extension = "." % format_acronym.toLower();
|
||||||
|
|
||||||
// set maximum width / height according limitations in QPainter
|
// set maximum width / height according limitations in QPainter
|
||||||
if ((format_extension == ".bmp") ||
|
if ((format_extension == ".bmp") ||
|
||||||
@@ -897,11 +917,11 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
|||||||
// cas 2 : l'extension est absente
|
// cas 2 : l'extension est absente
|
||||||
if (diagram_filename_info.suffix().isEmpty()) {
|
if (diagram_filename_info.suffix().isEmpty()) {
|
||||||
if (force_extension) {
|
if (force_extension) {
|
||||||
diagram_filename = diagram_filename_info.completeBaseName() + format_extension;
|
diagram_filename = diagram_filename_info.completeBaseName() % format_extension;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// cas 3 : l'extension est presente mais erronee
|
// cas 3 : l'extension est presente mais erronee
|
||||||
diagram_filename = diagram_filename_info.completeBaseName() + format_extension;
|
diagram_filename = diagram_filename_info.completeBaseName() % format_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
diagram_line -> file_name -> setText(diagram_filename);
|
diagram_line -> file_name -> setText(diagram_filename);
|
||||||
@@ -1014,7 +1034,7 @@ ExportDialog::ExportDiagramLine::ExportDiagramLine(Diagram *dia, QSize diagram_s
|
|||||||
if (diagram_title.isEmpty()) diagram_title = QObject::tr("Folio sans titre");
|
if (diagram_title.isEmpty()) diagram_title = QObject::tr("Folio sans titre");
|
||||||
QString diagram_filename = diagram -> title();
|
QString diagram_filename = diagram -> title();
|
||||||
if (diagram_filename.isEmpty()) diagram_filename = QObject::tr("schema");
|
if (diagram_filename.isEmpty()) diagram_filename = QObject::tr("schema");
|
||||||
diagram_filename = QET::stringToFileName(diagram_index + "_" + diagram_filename);
|
diagram_filename = QET::stringToFileName(diagram_index % "_" % diagram_filename);
|
||||||
|
|
||||||
title_label = new QLabel(diagram_title);
|
title_label = new QLabel(diagram_title);
|
||||||
|
|
||||||
|
|||||||
@@ -54,24 +54,24 @@ ExportProperties::~ExportProperties()
|
|||||||
void ExportProperties::toSettings(QSettings &settings,
|
void ExportProperties::toSettings(QSettings &settings,
|
||||||
const QString &prefix) const
|
const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "path",
|
settings.setValue(prefix % "path",
|
||||||
QDir::toNativeSeparators(
|
QDir::toNativeSeparators(
|
||||||
destination_directory.absolutePath()));
|
destination_directory.absolutePath()));
|
||||||
settings.setValue(prefix + "format",
|
settings.setValue(prefix % "format",
|
||||||
format);
|
format);
|
||||||
settings.setValue(prefix + "drawgrid",
|
settings.setValue(prefix % "drawgrid",
|
||||||
draw_grid);
|
draw_grid);
|
||||||
settings.setValue(prefix + "drawborder",
|
settings.setValue(prefix % "drawborder",
|
||||||
draw_border);
|
draw_border);
|
||||||
settings.setValue(prefix + "drawtitleblock",
|
settings.setValue(prefix % "drawtitleblock",
|
||||||
draw_titleblock);
|
draw_titleblock);
|
||||||
settings.setValue(prefix + "drawterminals",
|
settings.setValue(prefix % "drawterminals",
|
||||||
draw_terminals);
|
draw_terminals);
|
||||||
settings.setValue(prefix + "drawbgtransparent",
|
settings.setValue(prefix % "drawbgtransparent",
|
||||||
draw_bg_transparent);
|
draw_bg_transparent);
|
||||||
settings.setValue(prefix + "drawcoloredconductors",
|
settings.setValue(prefix % "drawcoloredconductors",
|
||||||
draw_colored_conductors);
|
draw_colored_conductors);
|
||||||
settings.setValue(prefix + "area",
|
settings.setValue(prefix % "area",
|
||||||
QET::diagramAreaToString(exported_area));
|
QET::diagramAreaToString(exported_area));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,30 +85,30 @@ void ExportProperties::fromSettings(QSettings &settings,
|
|||||||
QString export_path = QETApp::documentDir();
|
QString export_path = QETApp::documentDir();
|
||||||
destination_directory.setPath(
|
destination_directory.setPath(
|
||||||
settings.value(
|
settings.value(
|
||||||
prefix + "path",
|
prefix % "path",
|
||||||
export_path).toString());
|
export_path).toString());
|
||||||
if (!destination_directory.exists())
|
if (!destination_directory.exists())
|
||||||
destination_directory.setPath(export_path);
|
destination_directory.setPath(export_path);
|
||||||
|
|
||||||
format = settings.value(prefix + "format").toString();
|
format = settings.value(prefix % "format").toString();
|
||||||
|
|
||||||
draw_grid = settings.value(prefix + "drawgrid",
|
draw_grid = settings.value(prefix % "drawgrid",
|
||||||
false).toBool();
|
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",
|
||||||
true ).toBool();
|
true ).toBool();
|
||||||
draw_terminals = settings.value(prefix + "drawterminals",
|
draw_terminals = settings.value(prefix % "drawterminals",
|
||||||
false).toBool();
|
false).toBool();
|
||||||
draw_bg_transparent = settings.value(prefix + "drawbgtransparent",
|
draw_bg_transparent = settings.value(prefix % "drawbgtransparent",
|
||||||
false).toBool();
|
false).toBool();
|
||||||
draw_colored_conductors = settings.value(
|
draw_colored_conductors = settings.value(
|
||||||
prefix + "drawcoloredconductors",
|
prefix % "drawcoloredconductors",
|
||||||
true ).toBool();
|
true ).toBool();
|
||||||
|
|
||||||
exported_area = QET::diagramAreaFromString(
|
exported_area = QET::diagramAreaFromString(
|
||||||
settings.value(
|
settings.value(
|
||||||
prefix + "area",
|
prefix % "area",
|
||||||
"border").toString());
|
"border").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+35
-73
@@ -55,43 +55,6 @@ void MachineInfo::send_info_to_debug()
|
|||||||
<< QLibraryInfo::isDebugBuild();
|
<< QLibraryInfo::isDebugBuild();
|
||||||
qInfo()<< "Qt library version:"
|
qInfo()<< "Qt library version:"
|
||||||
<< QLibraryInfo::version();
|
<< QLibraryInfo::version();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
qInfo()<< "Qt library location default prefix:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::PrefixPath);
|
|
||||||
qInfo()<< "Qt library location documentation:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::DocumentationPath);
|
|
||||||
qInfo()<< "Qt library location headers:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::HeadersPath);
|
|
||||||
qInfo()<< "Qt library location libraries:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::LibrariesPath);
|
|
||||||
qInfo()<< "Qt library location executables:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath);
|
|
||||||
qInfo()<< "Qt library location Qt binaries:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::BinariesPath);
|
|
||||||
qInfo()<< "Qt library location Qt plugins:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::PluginsPath);
|
|
||||||
qInfo()<< "Qt library location installed QML extensions:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::ImportsPath);
|
|
||||||
qInfo()<< "Qt library location installed QML extensions:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
|
|
||||||
qInfo()<< "Qt library location dependent Qt data:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::ArchDataPath);
|
|
||||||
qInfo()<< "Qt library location independent Qt data:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::DataPath);
|
|
||||||
qInfo()<< "Qt library location translation:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
||||||
qInfo()<< "Qt library location examples:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::ExamplesPath);
|
|
||||||
qInfo()<< "Qt library location Qt testcases:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::TestsPath);
|
|
||||||
#ifndef Q_OS_WIN
|
|
||||||
qInfo()<< "Qt library location Qt settings:"
|
|
||||||
<< QLibraryInfo::location(QLibraryInfo::SettingsPath);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
qInfo()<< "Qt library path default prefix:"
|
qInfo()<< "Qt library path default prefix:"
|
||||||
<< QLibraryInfo::path(QLibraryInfo::PrefixPath);
|
<< QLibraryInfo::path(QLibraryInfo::PrefixPath);
|
||||||
qInfo()<< "Qt library path documentation:"
|
qInfo()<< "Qt library path documentation:"
|
||||||
@@ -123,30 +86,29 @@ void MachineInfo::send_info_to_debug()
|
|||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
qInfo()<< "Qt library path Qt settings:"
|
qInfo()<< "Qt library path Qt settings:"
|
||||||
<< QLibraryInfo::path(QLibraryInfo::SettingsPath);
|
<< QLibraryInfo::path(QLibraryInfo::SettingsPath);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
if (strlen(GIT_COMMIT_SHA)) {
|
if (strlen(GIT_COMMIT_SHA)) {
|
||||||
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
|
qInfo() << "GitRevision " % QString(GIT_COMMIT_SHA);
|
||||||
}
|
}
|
||||||
qInfo()<< "QElectroTech V " + QetVersion::displayedVersion();
|
qInfo()<< "QElectroTech V " % QetVersion::displayedVersion();
|
||||||
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
|
qInfo()<< QObject::tr("Compilation : ") % pc.built.version;
|
||||||
qInfo()<< "Built with Qt " + pc.built.QT
|
qInfo()<< "Built with Qt " % pc.built.QT
|
||||||
+ " - " + pc.built.arch
|
% " - " % pc.built.arch
|
||||||
+ " - Date : " + pc.built.date
|
% " - Date : " % pc.built.date
|
||||||
+ " : " + pc.built.time;
|
% " : " % pc.built.time;
|
||||||
qInfo()<< "Run with Qt "+ QString(qVersion())
|
qInfo()<< "Run with Qt " % QString(qVersion())
|
||||||
+ " using"
|
% " using"
|
||||||
+ QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
% QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
||||||
qInfo()<< "CPU : " + pc.cpu.info;
|
qInfo()<< "CPU : " % pc.cpu.info;
|
||||||
qInfo()<< pc.ram.Total;
|
qInfo()<< pc.ram.Total;
|
||||||
qInfo()<< pc.ram.Available;
|
qInfo()<< pc.ram.Available;
|
||||||
qInfo()<< "GPU : " + pc.gpu.info;
|
qInfo()<< "GPU : " % pc.gpu.info;
|
||||||
qInfo()<< "GPU RAM : " + pc.gpu.RAM;
|
qInfo()<< "GPU RAM : " % pc.gpu.RAM;
|
||||||
|
|
||||||
qInfo()<< "OS : " + pc.os.type
|
qInfo()<< "OS : " % pc.os.type
|
||||||
+ " - " + pc.cpu.Architecture
|
% " - " % pc.cpu.Architecture
|
||||||
+ " - Version : "+pc.os.name
|
% " - Version : " % pc.os.name
|
||||||
+ " - Kernel : "+pc.os.kernel;
|
% " - Kernel : " % pc.os.kernel;
|
||||||
qInfo()<< "";
|
qInfo()<< "";
|
||||||
|
|
||||||
qInfo()<< " OS System language:"<< QLocale::system().name();
|
qInfo()<< " OS System language:"<< QLocale::system().name();
|
||||||
@@ -171,8 +133,8 @@ void MachineInfo::send_info_to_debug()
|
|||||||
qInfo()<< " App Config Location:"<< QETApp::configDir();
|
qInfo()<< " App Config Location:"<< QETApp::configDir();
|
||||||
qInfo()<< " For data-files (user-/company-collections, titleblocks, etc.):";
|
qInfo()<< " For data-files (user-/company-collections, titleblocks, etc.):";
|
||||||
qInfo()<< " App Data Location:"<< QETApp::dataDir();
|
qInfo()<< " App Data Location:"<< QETApp::dataDir();
|
||||||
qInfo()<< " Directory for project stalefiles:";
|
qInfo()<< " Directory for project's autosave files (stalefiles):";
|
||||||
qInfo()<< " Generic Data Location:"<< QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/stalefiles/QElectroTech/";
|
qInfo()<< " Autosave:"<< QETApp::autosaveDir() % "/autosave";
|
||||||
// qInfo()<< " App Local DataLocation:"<< QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
|
// qInfo()<< " App Local DataLocation:"<< QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
|
||||||
// qInfo()<< " Home Location:"<< QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
// qInfo()<< " Home Location:"<< QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
|
||||||
// qInfo()<< " Runtime Location:"<< QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
// qInfo()<< " Runtime Location:"<< QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||||
@@ -452,29 +414,29 @@ int32_t MachineInfo::i_max_screen_height() {
|
|||||||
*/
|
*/
|
||||||
QString MachineInfo::compilation_info()
|
QString MachineInfo::compilation_info()
|
||||||
{
|
{
|
||||||
QString compilation_info = "<br />" + QObject::tr("Compilation : ");
|
QString compilation_info = "<br />" % QObject::tr("Compilation : ");
|
||||||
compilation_info +=pc.built.version;
|
compilation_info +=pc.built.version;
|
||||||
|
|
||||||
compilation_info += "<br>Built with Qt " + pc.built.QT;
|
compilation_info += "<br>Built with Qt " % pc.built.QT;
|
||||||
compilation_info += " - " + pc.built.arch;
|
compilation_info += " - " % pc.built.arch;
|
||||||
compilation_info += " - Date : " + pc.built.date;
|
compilation_info += " - Date : " % pc.built.date;
|
||||||
compilation_info += " : " + pc.built.time;
|
compilation_info += " : " % pc.built.time;
|
||||||
if (strlen(GIT_COMMIT_SHA)) {
|
if (strlen(GIT_COMMIT_SHA)) {
|
||||||
compilation_info += "<br> Git Revision : " + QString(GIT_COMMIT_SHA);
|
compilation_info += "<br> Git Revision : " % QString(GIT_COMMIT_SHA);
|
||||||
}
|
}
|
||||||
compilation_info += " <br>Run with Qt " + QString(qVersion());
|
compilation_info += " <br>Run with Qt " % QString(qVersion());
|
||||||
compilation_info += " using"
|
compilation_info += " using"
|
||||||
+ QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
+ QString(" %1 thread(s)").arg(pc.cpu.ThreadCount);
|
||||||
compilation_info += "<br> CPU : " + pc.cpu.info;
|
compilation_info += "<br> CPU : " % pc.cpu.info;
|
||||||
compilation_info += "<br>" + pc.ram.Total;
|
compilation_info += "<br>" % pc.ram.Total;
|
||||||
compilation_info += "<br>" + pc.ram.Available;
|
compilation_info += "<br>" % pc.ram.Available;
|
||||||
compilation_info += "<br>GPU : " + pc.gpu.info;
|
compilation_info += "<br>GPU : " % pc.gpu.info;
|
||||||
compilation_info += "<br>GPU RAM : " + pc.gpu.RAM;
|
compilation_info += "<br>GPU RAM : " % pc.gpu.RAM;
|
||||||
|
|
||||||
compilation_info += "<br> OS : " + pc.os.type;
|
compilation_info += "<br> OS : " % pc.os.type;
|
||||||
compilation_info += " - " + pc.cpu.Architecture;
|
compilation_info += " - " % pc.cpu.Architecture;
|
||||||
compilation_info += " - Version : "+pc.os.name;
|
compilation_info += " - Version : " % pc.os.name;
|
||||||
compilation_info += "</br> - Kernel : "+pc.os.kernel;
|
compilation_info += "</br> - Kernel : " % pc.os.kernel;
|
||||||
compilation_info += "<br> *** Qt screens *** </br>";
|
compilation_info += "<br> *** Qt screens *** </br>";
|
||||||
|
|
||||||
for (int ii = 0; ii < pc.screen.count; ++ii) {
|
for (int ii = 0; ii < pc.screen.count; ++ii) {
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ class MachineInfo
|
|||||||
QString version=
|
QString version=
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#ifdef __APPLE_CC__
|
#ifdef __APPLE_CC__
|
||||||
"CLANG " + QString(__clang_version__);
|
"CLANG " % QString(__clang_version__);
|
||||||
#else
|
#else
|
||||||
"GCC " + QString(__VERSION__);
|
"GCC " % QString(__VERSION__);
|
||||||
#endif
|
#endif
|
||||||
#elif defined(Q_CC_MSVC)
|
#elif defined(Q_CC_MSVC)
|
||||||
"MSVC " + QString(QT_STRINGIFY(_MSC_FULL_VER));
|
"MSVC " % QString(QT_STRINGIFY(_MSC_FULL_VER));
|
||||||
#endif
|
#endif
|
||||||
QString QT=QString(QT_VERSION_STR);
|
QString QT=QString(QT_VERSION_STR);
|
||||||
QString date=QString(__DATE__);
|
QString date=QString(__DATE__);
|
||||||
|
|||||||
@@ -24,13 +24,6 @@
|
|||||||
|
|
||||||
#include "ui_projectprintwindow.h"
|
#include "ui_projectprintwindow.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
# include <QDesktopWidget>
|
|
||||||
#else
|
|
||||||
# if TODO_LIST
|
|
||||||
# pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#include <QMarginsF>
|
#include <QMarginsF>
|
||||||
#include <QPageSetupDialog>
|
#include <QPageSetupDialog>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -50,14 +43,7 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
|||||||
auto printer_ = new QPrinter();
|
auto printer_ = new QPrinter();
|
||||||
QPrinter printer(QPrinter::HighResolution);
|
QPrinter printer(QPrinter::HighResolution);
|
||||||
printer_->setDocName(ProjectPrintWindow::docName(project));
|
printer_->setDocName(ProjectPrintWindow::docName(project));
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
printer_->setOrientation(QPrinter::Landscape);
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
printer_->setPageOrientation(QPageLayout::Landscape);
|
printer_->setPageOrientation(QPageLayout::Landscape);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (format == QPrinter::NativeFormat) //To physical printer
|
if (format == QPrinter::NativeFormat) //To physical printer
|
||||||
{
|
{
|
||||||
@@ -66,15 +52,7 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
|||||||
print_dialog.setWindowFlags(Qt::Sheet);
|
print_dialog.setWindowFlags(Qt::Sheet);
|
||||||
#endif
|
#endif
|
||||||
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
|
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
||||||
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintShowPageSize);
|
|
||||||
#else
|
|
||||||
print_dialog.setOptions(QAbstractPrintDialog::PrintShowPageSize);
|
print_dialog.setOptions(QAbstractPrintDialog::PrintShowPageSize);
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
|
||||||
#endif
|
|
||||||
if (print_dialog.exec() == QDialog::Rejected) {
|
if (print_dialog.exec() == QDialog::Rejected) {
|
||||||
delete printer_;
|
delete printer_;
|
||||||
return;
|
return;
|
||||||
@@ -83,7 +61,7 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
|||||||
else //To pdf file
|
else //To pdf file
|
||||||
{
|
{
|
||||||
auto dir_path = project->currentDir();
|
auto dir_path = project->currentDir();
|
||||||
QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path + "/" + printer_->docName()));
|
QString file_name = QDir::toNativeSeparators(QDir::cleanPath(dir_path % "/" % printer_->docName()));
|
||||||
if (!file_name.endsWith(".pdf")) {
|
if (!file_name.endsWith(".pdf")) {
|
||||||
file_name.append(".pdf");
|
file_name.append(".pdf");
|
||||||
}
|
}
|
||||||
@@ -191,23 +169,21 @@ ProjectPrintWindow::~ProjectPrintWindow()
|
|||||||
*/
|
*/
|
||||||
void ProjectPrintWindow::requestPaint()
|
void ProjectPrintWindow::requestPaint()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
#ifdef Q_OS_WIN
|
||||||
#ifdef Q_OS_WIN
|
#ifdef QT_DEBUG
|
||||||
#ifdef QT_DEBUG
|
qDebug() << "--";
|
||||||
qDebug() << "--";
|
qDebug() << "DiagramPrintDialog::print printer_->resolution() before " << m_printer->resolution();
|
||||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() before " << m_printer->resolution();
|
qDebug() << "DiagramPrintDialog::print screennumber " << QApplication::desktop()->screenNumber();
|
||||||
qDebug() << "DiagramPrintDialog::print screennumber " << QApplication::desktop()->screenNumber();
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
QScreen *srn = QApplication::screens().at(QApplication::desktop()->screenNumber());
|
QScreen *srn = QApplication::screens().at(QApplication::desktop()->screenNumber());
|
||||||
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
|
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
|
||||||
m_printer->setResolution(dotsPerInch);
|
m_printer->setResolution(dotsPerInch);
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
qDebug() << "DiagramPrintDialog::print dotsPerInch " << dotsPerInch;
|
qDebug() << "DiagramPrintDialog::print dotsPerInch " << dotsPerInch;
|
||||||
qDebug() << "DiagramPrintDialog::print printer_->resolution() after" << m_printer->resolution();
|
qDebug() << "DiagramPrintDialog::print printer_->resolution() after" << m_printer->resolution();
|
||||||
qDebug() << "--";
|
qDebug() << "--";
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -260,15 +236,8 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
|||||||
diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio);
|
diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio);
|
||||||
} else {
|
} else {
|
||||||
// Print on one or several pages
|
// Print on one or several pages
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter)
|
||||||
auto printed_rect = full_page ? printer->paperRect() : printer->pageRect();
|
: printer->pageRect(QPrinter::Millimeter);
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
|
||||||
auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : printer->pageRect(QPrinter::Millimeter);
|
|
||||||
#endif
|
|
||||||
auto used_width = printed_rect.width();
|
auto used_width = printed_rect.width();
|
||||||
auto used_height = printed_rect.height();
|
auto used_height = printed_rect.height();
|
||||||
auto h_pages_count = horizontalPagesCount(diagram, option, full_page);
|
auto h_pages_count = horizontalPagesCount(diagram, option, full_page);
|
||||||
@@ -277,24 +246,17 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
|||||||
QVector<QVector<QRect>> page_grid;
|
QVector<QVector<QRect>> page_grid;
|
||||||
//The diagram is printed on a matrix of sheet
|
//The diagram is printed on a matrix of sheet
|
||||||
//scrolls through the rows of the matrix
|
//scrolls through the rows of the matrix
|
||||||
auto y_offset = 0;
|
qreal y_offset = 0;
|
||||||
for (auto i=0 ; i<v_pages_count ; ++i)
|
for (auto i=0 ; i<v_pages_count ; ++i)
|
||||||
{
|
{
|
||||||
page_grid << QVector<QRect>();
|
page_grid << QVector<QRect>();
|
||||||
//scrolls through the lines of sheet
|
//scrolls through the lines of sheet
|
||||||
auto x_offset = 0;
|
qreal x_offset = 0;
|
||||||
for (auto j=0 ; j<h_pages_count ; ++j)
|
for (auto j=0 ; j<h_pages_count ; ++j)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
page_grid.last() << QRect(QPoint(x_offset, y_offset),
|
page_grid.last() << QRect(QPoint(x_offset, y_offset),
|
||||||
QSize(qMin(used_width, diagram_rect.width() - x_offset),
|
QSize(qMin(used_width, diagram_rect.width() - x_offset),
|
||||||
qMin(used_height, diagram_rect.height() - y_offset)));
|
qMin(used_height, diagram_rect.height() - y_offset)));
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
|
||||||
#endif
|
|
||||||
x_offset += used_width;
|
x_offset += used_width;
|
||||||
}
|
}
|
||||||
y_offset += used_height;
|
y_offset += used_height;
|
||||||
@@ -359,17 +321,10 @@ int ProjectPrintWindow::horizontalPagesCount(
|
|||||||
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
||||||
{
|
{
|
||||||
QRect printable_area;
|
QRect printable_area;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
printable_area = full_page ? m_printer->paperRect() : m_printer->pageRect();
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
printable_area =
|
printable_area =
|
||||||
full_page ?
|
full_page ?
|
||||||
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
||||||
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
||||||
#endif
|
|
||||||
QRect diagram_rect = diagramRect(diagram, option);
|
QRect diagram_rect = diagramRect(diagram, option);
|
||||||
|
|
||||||
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||||
@@ -388,17 +343,10 @@ int ProjectPrintWindow::verticalPagesCount(
|
|||||||
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
Diagram *diagram, const ExportProperties &option, bool full_page) const
|
||||||
{
|
{
|
||||||
QRect printable_area;
|
QRect printable_area;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
printable_area = full_page ? m_printer->paperRect() : m_printer->pageRect();
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
printable_area =
|
printable_area =
|
||||||
full_page ?
|
full_page ?
|
||||||
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
m_printer->pageLayout().fullRectPixels(m_printer->resolution()) :
|
||||||
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
m_printer->pageLayout().paintRectPixels(m_printer->resolution());
|
||||||
#endif
|
|
||||||
QRect diagram_rect = diagramRect(diagram, option);
|
QRect diagram_rect = diagramRect(diagram, option);
|
||||||
|
|
||||||
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||||
@@ -469,43 +417,6 @@ void ProjectPrintWindow::loadPageSetupForCurrentPrinter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
if (settings.contains("orientation")) {
|
|
||||||
QString value = settings.value("orientation", "landscape").toString();
|
|
||||||
m_printer -> setOrientation(value == "landscape" ? QPrinter::Landscape : QPrinter::Portrait);
|
|
||||||
}
|
|
||||||
if (settings.contains("papersize")) {
|
|
||||||
int value = settings.value("papersize", QPrinter::A4).toInt();
|
|
||||||
if (value == QPrinter::Custom) {
|
|
||||||
bool w_ok, h_ok;
|
|
||||||
int w = settings.value("customwidthmm", -1).toInt(&w_ok);
|
|
||||||
int h = settings.value("customheightmm", -1).toInt(&h_ok);
|
|
||||||
if (w_ok && h_ok && w != -1 && h != -1) {
|
|
||||||
m_printer -> setPaperSize(QSizeF(w, h), QPrinter::Millimeter);
|
|
||||||
}
|
|
||||||
} else if (value < QPrinter::Custom) {
|
|
||||||
m_printer -> setPaperSize(static_cast<QPrinter::PaperSize>(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal margins[4];
|
|
||||||
m_printer -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
|
|
||||||
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
|
|
||||||
for (int i = 0 ; i < 4 ; ++ i) {
|
|
||||||
bool conv_ok;
|
|
||||||
qreal value = settings.value("margin" + margins_names.at(i), -1.0).toReal(&conv_ok);
|
|
||||||
if (conv_ok && value != -1.0) margins[i] = value;
|
|
||||||
}
|
|
||||||
m_printer->setPageMargins(
|
|
||||||
margins[0],
|
|
||||||
margins[1],
|
|
||||||
margins[2],
|
|
||||||
margins[3],
|
|
||||||
QPrinter::Millimeter);
|
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
if (settings.contains("orientation"))
|
if (settings.contains("orientation"))
|
||||||
{
|
{
|
||||||
QString value = settings.value("orientation", "landscape").toString();
|
QString value = settings.value("orientation", "landscape").toString();
|
||||||
@@ -551,14 +462,13 @@ void ProjectPrintWindow::loadPageSetupForCurrentPrinter()
|
|||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
qreal value = settings.value("margin" + margins_names.at(i), -1.0)
|
qreal value = settings.value("margin" % margins_names.at(i), -1.0)
|
||||||
.toReal(&conv_ok);
|
.toReal(&conv_ok);
|
||||||
if (conv_ok && value != -1.0) margins[i] = value;
|
if (conv_ok && value != -1.0) margins[i] = value;
|
||||||
}
|
}
|
||||||
m_printer->setPageMargins(
|
m_printer->setPageMargins(
|
||||||
QMarginsF(margins[0], margins[1], margins[2], margins[3]),
|
QMarginsF(margins[0], margins[1], margins[2], margins[3]),
|
||||||
QPageLayout::Millimeter);
|
QPageLayout::Millimeter);
|
||||||
#endif
|
|
||||||
m_printer->setFullPage(
|
m_printer->setFullPage(
|
||||||
settings.value("fullpage", "false").toString() == "true");
|
settings.value("fullpage", "false").toString() == "true");
|
||||||
|
|
||||||
@@ -575,35 +485,6 @@ void ProjectPrintWindow::savePageSetupForCurrentPrinter()
|
|||||||
settings.beginGroup("printers");
|
settings.beginGroup("printers");
|
||||||
settings.beginGroup(printer_section);
|
settings.beginGroup(printer_section);
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
|
||||||
settings.setValue("orientation", m_printer -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
|
|
||||||
settings.setValue("papersize", int(m_printer -> paperSize()));
|
|
||||||
if (m_printer -> paperSize() == QPrinter::Custom) {
|
|
||||||
QSizeF size = m_printer -> paperSize(QPrinter::Millimeter);
|
|
||||||
settings.setValue("customwidthmm", size.width());
|
|
||||||
settings.setValue("customheightmm", size.height());
|
|
||||||
} else {
|
|
||||||
settings.remove("customwidthmm");
|
|
||||||
settings.remove("customheightmm");
|
|
||||||
}
|
|
||||||
qreal left, top, right, bottom;
|
|
||||||
m_printer
|
|
||||||
->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
|
||||||
settings.setValue("marginleft", left);
|
|
||||||
settings.setValue("margintop", top);
|
|
||||||
settings.setValue("marginright", right);
|
|
||||||
settings.setValue("marginbottom", bottom);
|
|
||||||
settings.setValue("fullpage", m_printer->fullPage() ? "true" : "false");
|
|
||||||
settings.endGroup();
|
|
||||||
settings.endGroup();
|
|
||||||
settings.sync();
|
|
||||||
|
|
||||||
#else
|
|
||||||
# if TODO_LIST
|
|
||||||
# pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
# endif
|
|
||||||
qDebug() << "Help code for QT 6 or later";
|
|
||||||
|
|
||||||
settings.setValue(
|
settings.setValue(
|
||||||
"orientation",
|
"orientation",
|
||||||
m_printer->pageLayout().orientation() == QPageLayout::Portrait ?
|
m_printer->pageLayout().orientation() == QPageLayout::Portrait ?
|
||||||
@@ -634,7 +515,6 @@ void ProjectPrintWindow::savePageSetupForCurrentPrinter()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.sync();
|
settings.sync();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1505,7 +1505,7 @@ void Conductor::refreshText()
|
|||||||
{
|
{
|
||||||
if (diagram())
|
if (diagram())
|
||||||
{
|
{
|
||||||
QString text = autonum::AssignVariables::formulaToLabel(m_properties.m_formula, m_autoNum_seq, diagram());
|
QString text = autonum::AssignVariables::formulaToLabel(m_properties.m_formula, m_autoNum_seq, diagram(), nullptr, this);
|
||||||
m_properties.text = text;
|
m_properties.text = text;
|
||||||
m_text_item->setPlainText(text);
|
m_text_item->setPlainText(text);
|
||||||
}
|
}
|
||||||
@@ -1590,7 +1590,7 @@ void Conductor::setProperties(const ConductorProperties &property)
|
|||||||
{
|
{
|
||||||
if (diagram())
|
if (diagram())
|
||||||
{
|
{
|
||||||
QString text = autonum::AssignVariables::formulaToLabel(m_properties.m_formula, m_autoNum_seq, diagram());
|
QString text = autonum::AssignVariables::formulaToLabel(m_properties.m_formula, m_autoNum_seq, diagram(), nullptr, this);
|
||||||
m_properties.text = text;
|
m_properties.text = text;
|
||||||
}
|
}
|
||||||
else if (m_properties.text.isEmpty())
|
else if (m_properties.text.isEmpty())
|
||||||
|
|||||||
@@ -545,8 +545,16 @@ void DynamicElementTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
if(m_slave_Xref_item)
|
if(m_slave_Xref_item)
|
||||||
m_slave_Xref_item->setDefaultTextColor(Qt::black);
|
m_slave_Xref_item->setDefaultTextColor(Qt::black);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramTextItem::mousePressEvent(event);
|
// Shift or no parent initiates movement of dynamic text, otherwise movement of parent element
|
||||||
|
if((event->modifiers() & Qt::ShiftModifier) || !m_parent_element)
|
||||||
|
{
|
||||||
|
m_move_parent = false;
|
||||||
|
DiagramTextItem::mousePressEvent(event);
|
||||||
|
} else {
|
||||||
|
m_move_parent = true;
|
||||||
|
parentElement()->mousePressEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,26 +565,33 @@ void DynamicElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable))
|
if((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable))
|
||||||
{
|
{
|
||||||
if(diagram() && m_first_move)
|
if(m_move_parent)
|
||||||
diagram()->elementTextsMover().beginMovement(diagram(), this);
|
|
||||||
|
|
||||||
if(m_first_move)
|
|
||||||
{
|
{
|
||||||
m_initial_position = pos();
|
parentElement()->mouseMoveEvent(event);
|
||||||
if(parentElement())
|
} else {
|
||||||
parentElement()->setHighlighted(true);
|
if(diagram() && m_first_move)
|
||||||
|
diagram()->elementTextsMover().beginMovement(diagram(), this);
|
||||||
|
|
||||||
|
if(m_first_move)
|
||||||
|
{
|
||||||
|
m_initial_position = pos();
|
||||||
|
if(parentElement())
|
||||||
|
parentElement()->setHighlighted(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF current_parent_pos;
|
||||||
|
QPointF button_down_parent_pos;
|
||||||
|
current_parent_pos = mapToParent(mapFromScene(event->scenePos()));
|
||||||
|
button_down_parent_pos = mapToParent(mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
|
||||||
|
|
||||||
|
int diffx = qRound(current_parent_pos.x() - button_down_parent_pos.x());
|
||||||
|
int diffy = qRound(current_parent_pos.y() - button_down_parent_pos.y());
|
||||||
|
QPointF new_pos = m_initial_position + QPointF(diffx, diffy);
|
||||||
|
setPos(new_pos);
|
||||||
|
|
||||||
|
if(diagram())
|
||||||
|
diagram()->elementTextsMover().continueMovement(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF current_parent_pos;
|
|
||||||
QPointF button_down_parent_pos;
|
|
||||||
current_parent_pos = mapToParent(mapFromScene(event->scenePos()));
|
|
||||||
button_down_parent_pos = mapToParent(mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
|
|
||||||
|
|
||||||
QPointF new_pos = m_initial_position + current_parent_pos - button_down_parent_pos;
|
|
||||||
event->modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
|
|
||||||
|
|
||||||
if(diagram())
|
|
||||||
diagram()->elementTextsMover().continueMovement(event);
|
|
||||||
} else {
|
} else {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
@@ -591,14 +606,19 @@ void DynamicElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
void DynamicElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void DynamicElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_parent_element)
|
if(m_move_parent)
|
||||||
m_parent_element->setHighlighted(false);
|
{
|
||||||
|
parentElement()->mouseReleaseEvent(event);
|
||||||
|
} else {
|
||||||
|
if (m_parent_element)
|
||||||
|
m_parent_element->setHighlighted(false);
|
||||||
|
|
||||||
if(m_parent_element && m_parent_element->diagram())
|
if(m_parent_element && m_parent_element->diagram())
|
||||||
m_parent_element.data()->diagram()->elementTextsMover().endMovement();
|
m_parent_element.data()->diagram()->elementTextsMover().endMovement();
|
||||||
|
|
||||||
if(!(event->modifiers() & Qt::ControlModifier))
|
if(!(event->modifiers() & Qt::ControlModifier))
|
||||||
QGraphicsTextItem::mouseReleaseEvent(event);
|
QGraphicsTextItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
QPointF m_initial_position;
|
QPointF m_initial_position;
|
||||||
bool m_keep_visual_rotation = true;
|
bool m_keep_visual_rotation = true;
|
||||||
qreal m_visual_rotation_ref = 0;
|
qreal m_visual_rotation_ref = 0;
|
||||||
|
bool m_move_parent = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DYNAMICELEMENTTEXTITEM_H
|
#endif // DYNAMICELEMENTTEXTITEM_H
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class ElementTextItemGroup;
|
|||||||
class Element : public QetGraphicsItem
|
class Element : public QetGraphicsItem
|
||||||
{
|
{
|
||||||
friend class DiagramEventAddElement;
|
friend class DiagramEventAddElement;
|
||||||
|
friend class DynamicElementTextItem;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -695,11 +695,15 @@ bool Terminal::valideXml(QDomElement &terminal)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Terminal::fromXml
|
@brief Terminal::fromXml
|
||||||
|
Enables you to find out whether an XML element represents this terminal.
|
||||||
|
Warning, the XML element is not checked
|
||||||
Permet de savoir si un element XML represente cette borne. Attention,
|
Permet de savoir si un element XML represente cette borne. Attention,
|
||||||
l'element XML n'est pas verifie
|
l'element XML n'est pas verifie
|
||||||
@param terminal Le QDomElement a analyser
|
@param terminal Le QDomElement a analyser / QDomElement to check
|
||||||
@return true si la borne "se reconnait"
|
@return true si la borne "se reconnait"
|
||||||
(memes coordonnes, meme orientation), false sinon
|
(memes coordonnes, meme orientation), false sinon
|
||||||
|
true, if the terminal ‘recognises’ itself (same coordinates,
|
||||||
|
same orientation), false otherwise
|
||||||
*/
|
*/
|
||||||
bool Terminal::fromXml(QDomElement &terminal)
|
bool Terminal::fromXml(QDomElement &terminal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ QString TitleBlockTemplateLogoManager::confirmLogoName(const QString &initial_na
|
|||||||
connect(replace_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
connect(replace_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||||
connect(rename_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
connect(rename_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||||
connect(cancel_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
connect(cancel_button, SIGNAL(clicked()), signal_mapper, SLOT(map()));
|
||||||
connect(signal_mapper, SIGNAL(mapped(int)), rename_dialog, SLOT(done(int)));
|
connect(signal_mapper, SIGNAL(mappedInt(int)), rename_dialog, SLOT(done(int)));
|
||||||
}
|
}
|
||||||
rd_label -> setText(
|
rd_label -> setText(
|
||||||
QString(tr(
|
QString(tr(
|
||||||
@@ -312,7 +312,7 @@ void TitleBlockTemplateLogoManager::exportLogo()
|
|||||||
QString filepath = QFileDialog::getSaveFileName(
|
QString filepath = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
tr("Choisir un fichier pour exporter ce logo"),
|
tr("Choisir un fichier pour exporter ce logo"),
|
||||||
open_dialog_dir_.absolutePath() + "/" + current_logo,
|
open_dialog_dir_.absolutePath() % "/" + current_logo,
|
||||||
tr("Tous les fichiers (*);;Images vectorielles (*.svg);;Images bitmap (*.png *.jpg *.jpeg *.gif *.bmp *.xpm)")
|
tr("Tous les fichiers (*);;Images vectorielles (*.svg);;Images bitmap (*.png *.jpg *.jpeg *.gif *.bmp *.xpm)")
|
||||||
);
|
);
|
||||||
if (filepath.isEmpty()) return;
|
if (filepath.isEmpty()) return;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="KColorButton" name="m_text_color_kpb"/>
|
<widget class="ColorButton" name="m_text_color_kpb"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QSpinBox" name="m_text_size_sb">
|
<widget class="QSpinBox" name="m_text_size_sb">
|
||||||
@@ -458,7 +458,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="KColorButton" name="m_color_kpb"/>
|
<widget class="ColorButton" name="m_color_kpb"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_10">
|
<widget class="QLabel" name="label_10">
|
||||||
@@ -530,7 +530,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="KColorButton" name="m_color_2_kpb"/>
|
<widget class="ColorButton" name="m_color_2_kpb"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -576,9 +576,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KColorButton</class>
|
<class>ColorButton</class>
|
||||||
<extends>QPushButton</extends>
|
<extends>QPushButton</extends>
|
||||||
<header>kcolorbutton.h</header>
|
<header>../colorbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|||||||
@@ -478,13 +478,13 @@ void ShapeGraphicsItemPropertiesWidget::setUpEditConnection()
|
|||||||
m_edit_connection << connect (ui->m_size_dsb, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
m_edit_connection << connect (ui->m_size_dsb, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
m_edit_connection << connect (ui->m_color_kpb, &KColorButton::changed,
|
m_edit_connection << connect (ui->m_color_kpb, &ColorButton::changed,
|
||||||
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
m_edit_connection << connect (ui->m_brush_style_cb, QOverload<int>::of(&QComboBox::activated),
|
m_edit_connection << connect (ui->m_brush_style_cb, QOverload<int>::of(&QComboBox::activated),
|
||||||
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
m_edit_connection << connect (ui->m_brush_color_kpb, &KColorButton::changed,
|
m_edit_connection << connect (ui->m_brush_color_kpb, &ColorButton::changed,
|
||||||
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
this, &ShapeGraphicsItemPropertiesWidget::apply);
|
||||||
|
|
||||||
m_edit_connection << connect (ui->m_close_polygon, &QCheckBox::clicked,
|
m_edit_connection << connect (ui->m_close_polygon, &QCheckBox::clicked,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="KColorButton" name="m_color_kpb"/>
|
<widget class="ColorButton" name="m_color_kpb"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="m_size_dsb">
|
<widget class="QDoubleSpinBox" name="m_size_dsb">
|
||||||
@@ -215,7 +215,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="KColorButton" name="m_brush_color_kpb"/>
|
<widget class="ColorButton" name="m_brush_color_kpb"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -251,9 +251,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KColorButton</class>
|
<class>ColorButton</class>
|
||||||
<extends>QPushButton</extends>
|
<extends>QPushButton</extends>
|
||||||
<header>kcolorbutton.h</header>
|
<header>../colorbutton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|||||||
Reference in New Issue
Block a user