mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-23 18:50:52 +01:00
Merge pull request #378 from elevatormind/no-kwidgetsaddons
No kwidgetsaddons
This commit is contained in:
@@ -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
|
||||||
|
|||||||
2
elements
2
elements
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);
|
||||||
|
|||||||
90
sources/colorbutton.cpp
Normal file
90
sources/colorbutton.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
53
sources/colorbutton.h
Normal file
53
sources/colorbutton.h
Normal file
@@ -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
|
||||||
98
sources/colorcombobox.cpp
Normal file
98
sources/colorcombobox.cpp
Normal file
@@ -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>());
|
||||||
|
}
|
||||||
49
sources/colorcombobox.h
Normal file
49
sources/colorcombobox.h
Normal file
@@ -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
|
||||||
62
sources/colorcomboboxdelegate.cpp
Normal file
62
sources/colorcomboboxdelegate.cpp
Normal file
@@ -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();
|
||||||
|
}
|
||||||
35
sources/colorcomboboxdelegate.h
Normal file
35
sources/colorcomboboxdelegate.h
Normal file
@@ -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
|
||||||
@@ -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.
|
||||||
|
|||||||
@@ -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::on_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()
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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