Commit Graph

3648 Commits

Author SHA1 Message Date
Dieter Mayer 787335582b Element editor: optional alignment for static texts (#549)
Static texts (PartText) gain an optional alignment, exposed via the
existing AlignmentTextDialog behind a new "Alignement" button in the
static text editor:

- The horizontal part aligns the lines of a multi-line text relative
  to each other (centered block labels no longer need one hand-placed
  text per line).
- The full alignment defines the anchor: when the content or font
  changes later, the selected corner/center of the bounding rect keeps
  its place instead of always growing right/down from the top-left
  (same prepareAlignment/finishAlignment logic as DiagramTextItem).

Format: the <text> node takes the same optional Halignment/Valignment
attributes as dynamic_text, written only when they differ from the
historical top-left behaviour - existing .elmt files are untouched and
round-trip byte-identical. The saved x/y stay the baseline-left of the
text block in all cases; ElementPictureFactory only needs the line
alignment (the anchor is editor-side behaviour), so rendered elements
match the editor exactly.

German translations for the three new strings included (qet_de stays
complete, 2686/2686).

Verified headless: a project embedding a two-line text once with
Halignment=AlignHCenter and once without exports to SVG with the short
line centered under the long one (x 102.5 vs 126.5) in the aligned
block, and identical x for both lines in the legacy block. Editor-side
anchor behaviour follows the proven DiagramTextItem implementation but
was not manually exercised in the GUI yet.
2026-07-28 13:58:51 +02:00
Laurent Trinques 66129fd15c Merge pull request #560 from ispyisail/feature/project-load-timing
Log project load times, split by phase
2026-07-27 17:15:02 +02:00
ispyisail 9e070f9bce Log project load times, split by phase
Requested in #553 to compare Qt5 and Qt6 builds. QET already reports how
long the elements collection takes to load (ElementsCollectionWidget::
reload); this adds the equivalent for opening a project.

The phases are reported separately rather than as a single total. Reading
the XML and building the objects is mostly independent of the Qt version,
whereas refreshing the diagrams is graphics-scene work -- a single number
would mix the two and could suggest a Qt version makes no difference when
the part that changed is simply not where the time goes. Measured on the
example projects, XML parsing is 3-7% of the total and diagram
construction 77-83%, so the distinction matters in practice.

QETProject::openFile() reports the total with the parse/build split, and
readProjectXml() reports the build phases:

  Project content built in 1.391 seconds (elements collection 0.009,
    diagrams 1.153, terminal strips 0, refresh 0.196, database 0.033)
  Project "example.qet" (3399 KiB) opened in 1.505 seconds
    (xml parsing 0.11, content 1.395)

Logged with qInfo(), matching the existing collection timer, so it lands
in the normal log without a debug build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 17:37:49 +12:00
Laurent Trinques 0263fed6cf Merge pull request #558 from ispyisail/fix/clear-broken-stylesheet
Clear the application stylesheet when using system colors
2026-07-26 15:32:11 +02:00
Laurent Trinques 9cbd9b429c Merge pull request #559 from ispyisail/fix/554-resolve-data-paths-from-binary
Fix language (and data paths) when opening a .qet by double-click on Windows
2026-07-26 15:00:55 +02:00
ispyisail d4ec9f9c65 Resolve relative compiled-in data paths from the binary, not the CWD
commonElementsDir(), commonTitleBlockTemplatesDir() and languagesPath()
return the compile-time path verbatim when it is not marked
*_RELATIVE_TO_BINARY_PATH. On Windows those paths are relative
("./elements/", "./titleblocks/", "./lang/"), so they resolve against the
process working directory.

That only holds when QET is started from its own installation folder.
Opening a document from a file manager sets the working directory to the
document's folder, and the data is then looked for next to the user's
file. The shortcuts hide this by passing --common-elements-dir,
--common-tbt-dir and --lang-dir explicitly; anything that launches the
binary without them does not (see #554).

Add resolveConfiguredDataPath(): absolute paths are returned unchanged,
and a relative one is tried against the working directory first (so any
setup relying on the old behaviour keeps working), then next to the
executable, then in its parent -- the layout used by the Windows
packaging, where the binary sits in bin/ with the data beside it. This is
the same fallback the no-compile-option branch already performs for
issue #86, which was unreachable whenever the compile option is set.

The *_RELATIVE_TO_BINARY_PATH defines are left alone; they are only set
for macOS in qelectrotech.pro, and the CMake guard that would set them
tests a variable that is never defined.
2026-07-26 22:41:44 +12:00
ispyisail b688baf3b6 Clear the application stylesheet when using system colors
QETApp::useSystemPalette(true) installed a one-rule application stylesheet
whose only declaration was invalid CSS:

    QAbstractScrollArea#mdiarea {
        background-color -> setPalette(initial_palette_);
    }

That is not a CSS declaration but a note-to-self, committed in e6c32bc0
("Background set to use System Palette", 2014) when a hardcoded

        background-color:#D5D2D1;

was replaced with a reminder to derive the color from the palette instead.
Qt's CSS parser silently skips invalid declarations, and at the time the
same rule still carried valid background-image/-repeat/-position
properties, so the block kept working and nothing looked wrong. Those
properties were dropped later, leaving a rule with no valid declarations
at all.

The rule has therefore styled nothing for some time. It is not harmless
though: a non-empty application stylesheet wraps every widget in
QStyleSheetStyle, which overrides per-widget QWidget::setStyle(). QET
does not currently call QWidget::setStyle() anywhere, so nothing is
visibly broken today, but it blocks that API for future work — it was
found while prototyping a palette-based dark mode (see #553).

Replace it with an explicit setStyleSheet(QString()). The behavior of the
"use system colors" branch is unchanged: it already dropped whatever
style.css had loaded (by overwriting it with the inert rule), and the
qApp->setPalette(initial_palette_) call on the line above is what actually
supplies the system colors — which is what the 2014 note was asking for.

The style.css path (use == false) is untouched.

Reported by DieterMayerOSS in #553.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:28:32 +12:00
ispyisail 7cb9695962 edz: make EdzArchive error strings translatable (+ DE/FR)
The six user-facing error strings in EdzArchive::extract() were hard-coded
QStringLiteral, so they could not be translated (reported by plc-user in
PR #513).

Wrap them in tr() via Q_DECLARE_TR_FUNCTIONS — EdzArchive is not a QObject,
so this gives it its own translation context without pulling in a moc
dependency. The *.part.xml glob stays a QStringLiteral: it is a filename
pattern, not user-facing text.

Adds German and French translations for all six. German wording for
"Cannot read %1" is plc-user's ("Kann %1 nicht lesen.").

Note for review: the rest of QET uses French source strings translated to
en/de in the .ts files, whereas these strings are English in the source
(as merged in PR #513). This commit keeps them English rather than
rewriting strings already reviewed; happy to flip them to French sources
for consistency if preferred.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 21:04:25 +12:00
Laurent Trinques 42d2c824d2 Merge pull request #513 from ispyisail/feature/edz-import
Import EPLAN Data Portal parts (.edz) into element collections
2026-07-23 13:58:56 +02:00
ispyisail 1b8dea3946 Add consent dialog before EPLAN (.edz) import
Shows the licensing/liability warning text agreed on in PR #513
(scorpio810) before the file picker opens. Import stays disabled
until the "I have read and accept these terms" checkbox is ticked.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 21:11:35 +12:00
Laurent Trinques e1aa65f1ee Revert "Set QET version to 0.200.1 when built with Qt6"
This reverts commit 608ca984a4.
2026-07-19 13:26:34 +02:00
Laurent Trinques 88e42a435b Merge pull request #519 from ispyisail/fix/asan-memory-leaks
Fix four memory leaks found by AddressSanitizer
2026-07-19 11:51:47 +02:00
scorpio810 608ca984a4 Set QET version to 0.200.1 when built with Qt6
Use QT_VERSION_CHECK to detect Qt6 at compile time and report
version 0.200.1 instead of 0.100.1 in that case, so Qt6 builds
are clearly distinguishable from Qt5 builds.
2026-07-19 10:56:12 +02:00
Laurent Trinques 7a87754024 Merge pull request #545 from Kellermorph/terminal-name
Implement slave contact groups — label transfer, terminal assignment and UI fixes
2026-07-18 08:00:23 +02:00
Dieter Mayer 12afadd095 Fix the remaining Qt6 compile blockers
Clears the last five spots that stop master from compiling against Qt6
(all mirrored from the proven qt6-build line):

- qgimanager.h/.cpp: in Qt6 QVector is an alias for QList, so the
  deprecated QList overloads of manage()/release() collide with the
  QVector ones (same signature). Keep them on Qt5 only.
- diagramview.cpp: one unguarded QTextStream::setCodec() call (removed
  in Qt6, which defaults to UTF-8).
- print/projectprintwindow.cpp: QApplication::desktop() was removed in
  Qt6; use QWidget::screen() there, keep the old path on Qt5.
- titleblocktemplate.cpp: QDomDocument::setContent() returns a
  ParseResult in Qt6 whose operator bool is explicit; static_cast keeps
  the bool initialization working on both.

With these, master configures and builds to a running binary with
Qt 6.11 (mingw, BUILD_WITH_KF5=OFF); every change is guarded or
dual-safe, the Qt5 build is unaffected.
2026-07-17 21:01:26 +02:00
Laurent Trinques 6a4554a677 Re-enable multi-threading to load collection
The name of the elements and folders of the collection are not displayed
until we hover the item with the mouse.
This due that QtConcurent::run was disabled at loading of collection in
the goal of use QtConcurrent::run with Qt6.
Run is made to run a function once.
Map is made to run a fonction for each item of a sequence (what we need
in this case).
Remove code of run and re-enable code for map.
2026-07-17 10:44:36 +02:00
joshua ae2972a143 Fix : can't open recent file 2026-07-17 10:29:13 +02:00
scorpio810 ed1b6e9ba0 terminalstripdrawer.cpp: fix two Qt6 compile errors
- Add missing <QHash> include: QHash<QUuid, QVector<QPointF>> was
  only forward-declared transitively under Qt5's heavier headers;
  Qt6's leaner <QPainter> etc. no longer pull it in.

- Replace QPolygonF{points_} with QPolygonF(points_): under Qt6,
  QPolygonF inherits QList<QPointF>'s constructors via 'using
  QList<QPointF>::QList;', including the std::initializer_list<T>
  one. Brace-init-list construction with a single argument first
  considers only initializer-list constructors before falling
  back to regular ones, which trips up overload resolution here
  even though points_ is exactly a QList<QPointF> (QVector is a
  plain alias for QList under Qt6). Plain parenthesised
  construction sidesteps that resolution phase entirely and binds
  directly to QPolygonF(const QList<QPointF>&).
2026-07-17 10:26:43 +02:00
scorpio810 33013477ad physicalterminal.cpp: fix std::min template deduction under Qt6
QVector::size() (== QList::size() under Qt6) returns qsizetype
(64-bit), while 'level' is a plain int. std::min(level,
m_real_terminal.size()-1) therefore tries to deduce a single T
from two different argument types, which fails - GCC reports it
against the unrelated std::min(initializer_list<T>) overload,
but the real issue is the type mismatch between the two-argument
candidates. Under Qt5, QVector::size() returned int, so this
compiled fine.
Force T=int explicitly via std::min<int>(...) and cast size()
down to int (physical terminal counts are always tiny), matching
the pattern already used safely elsewhere in the codebase (e.g.
qetgraphicstableitem.cpp).
2026-07-17 10:26:43 +02:00
scorpio810 287b532953 templatescollection.cpp: fix QDomDocument::ParseResult->bool conversion
Since Qt 6.5, QDomDocument::setContent() returns a ParseResult
struct with an *explicit* operator bool(), so 'bool x =
doc.setContent(...)' (copy-initialization) no longer compiles -
explicit conversions aren't considered there.

This exact issue was already fixed in titleblocktemplate.cpp by
dropping the intermediate bool and testing the call directly in
the if condition (contextual bool conversion in an if() is fine
even for an explicit operator bool), but this second occurrence
in templatescollection.cpp used the same pattern and was missed.
Applying the same fix here for consistency.
2026-07-17 10:26:35 +02:00
scorpio810 6716c267b8 templateview.h: add missing QGraphicsGridLayout/QGraphicsLayoutItem includes
templateview.h only included <QGraphicsView> but uses
QGraphicsGridLayout (tbgrid_ member) and QGraphicsLayoutItem
(indexOf/removeItem signatures) directly. Some Qt5 header
apparently pulled these in transitively; Qt6's leaner headers
don't, so the class fields/methods silently failed to resolve
and the compiler picked bogus 'int*' overloads instead.
Other files in the same directory already get these symbols
either via the <QtWidgets> umbrella header or a direct include,
so this was an isolated gap.
2026-07-17 10:26:26 +02:00
scorpio810 62dc1e7c11 Fix QRegularExpression API misuse in ElementsLocation::setXml (Qt6 path)
The Qt6 branch of the #if QT_VERSION guard swapped QRegExp for
QRegularExpression but kept calling QRegExp-only methods
(exactMatch()/cap()), which QRegularExpression doesn't have.
Use the correct QRegularExpression API instead: match() returns
a QRegularExpressionMatch, tested with hasMatch() and read with
captured(n).
2026-07-17 10:26:17 +02:00
scorpio810 fea4752a06 Fix remaining Qt6 build errors after PR #540
- qetxml.h: add missing <QUuid> include (used in propertyUuid/
  createXmlProperty signatures but never included directly).
- machine_info.cpp: fix ambiguous QString/int operator> in
  send_info_to_debug() for it1/it2/it3; just count every
  matching file found instead of the meaningless comparison.
2026-07-17 10:25:49 +02:00
Kellermorph b025bd205d Implement slave contact groups — label transfer, terminal assignment and UI fixes 2026-07-17 09:47:32 +02:00
Laurent Trinques 118a62adb2 Merge pull request #540 from DieterMayerOSS/cleanup/qt6-deprecation-warnings
Cleanup/qt6 deprecation warnings
2026-07-16 11:57:13 +02:00
Laurent Trinques 9a35d6c404 Merge pull request #541 from DieterMayerOSS/cleanup/qt6-remaining-warnings
Fix remaining Qt6 build warnings (narrowing, nodiscard, qHash)
2026-07-16 11:56:22 +02:00
Dieter Mayer 20a7047b27 Renew element uuids when duplicating a folio
The project panel's "copy and paste" action duplicates a folio through
an XML round-trip (toXml/fromXml), and Element::fromXml adopts the uuid
stored in the XML - so every element on the duplicated folio kept the
uuid of its source element. On-diagram copy/paste already handles this
(PasteDiagramCommand::redo() calls newUuid()), but the folio-duplicate
path bypasses that command.

Since element.uuid is the PRIMARY KEY of the project database, the
duplicated elements failed to insert ("UNIQUE constraint failed:
element.uuid" spam in the log) and silently disappeared from
nomenclature/summary tables, even though they are valid on the folio.

Renew the uuid of every element on the freshly duplicated folio, exactly
as the paste command does. In-memory links established during fromXml
are pointer-based and unaffected; the new uuids are written on save.
2026-07-14 19:48:31 +02:00
Dieter Mayer a0f66d22cc Fix remaining Qt6 build warnings (narrowing, nodiscard, qHash)
Clears the 9 non-deprecation warnings from the Qt6 build:
- qHash(QColor): hash rgba() (unambiguous QRgb) instead of name(), and
  use the size_t seed signature on Qt6 (guarded for Qt5). Fixes the
  ambiguous-overload warning in terminalstripmodel.h.
- Two qsizetype->int narrowings in brace-init: explicit static_cast<int>
  (elementscene.cpp, terminalstrip.cpp).
- main.cpp: keep the QtConcurrent::run QFuture in a [[maybe_unused]]
  variable (nodiscard).
- qetapp.cpp: guard the stylesheet load on QFile::open() succeeding
  (nodiscard) instead of ignoring the result.
2026-07-14 19:27:37 +02:00
Dieter Mayer d5027c4ef9 Replace deprecated QVariant::canConvert(int)
QVariant::canConvert(int) is deprecated in Qt6. Use the non-deprecated
canConvert<T>() template (canConvert<QString>() / canConvert<int>()),
which is available on Qt5 too. Clears the last 2 -Wdeprecated-
declarations warnings.
2026-07-14 19:27:18 +02:00
Dieter Mayer e099fca5ad Guard Qt6-only deprecation replacements for Qt5 compatibility
Three deprecated APIs have replacements that only exist in newer Qt6:
- QLocale::nativeCountryName() -> nativeTerritoryName() (Qt 6.2)
- QDomDocument::setContent() overload -> ParseResult (Qt 6.5)
- qt_ntfs_permission_lookup -> QNtfsPermissionCheckGuard RAII (Qt 6.6)
Each is wrapped in QT_VERSION_CHECK so Qt5 keeps the old path. Clears
4 -Wdeprecated-declarations warnings.
2026-07-14 19:27:18 +02:00
Dieter Mayer f57c921b78 Fix trivial Qt6 deprecations (QString::count, QColor::setNamedColor)
QString::count() (no-arg) is deprecated -> size(); QColor::setNamedColor()
is deprecated -> the QColor(QString) constructor. Both replacements are
non-deprecated on Qt5 too. Clears 2 -Wdeprecated-declarations warnings.
2026-07-14 19:27:17 +02:00
Dieter Mayer c3392bf025 Wrap deprecated QSqlDatabase::exec() in QSqlQuery
QSqlDatabase::exec(const QString&) is deprecated in Qt6. Route the
PRAGMA/CREATE TABLE statements through QSqlQuery(db).exec() instead.
Clears 11 -Wdeprecated-declarations warnings; same statements, same
database connection, no behavioural change.
2026-07-14 19:27:17 +02:00
Dieter Mayer 7e08cd1285 Replace deprecated QVariant::Type with QMetaType in UserProperties
QVariant::type() and the QVariant::Type enum are deprecated in Qt6.
Switch on userType() (non-deprecated, returns the QMetaType id and
works on Qt5 too) with QMetaType enum cases. Clears 6 -Wdeprecated-
declarations warnings; the numeric type ids are unchanged.
2026-07-14 19:27:17 +02:00
Dieter Mayer 1265e51ebe Replace deprecated qAsConst with std::as_const
qAsConst was deprecated in Qt 6.6; std::as_const (C++17, already the
project standard) is the drop-in replacement. Clears 46 -Wdeprecated-
declarations warnings across 18 files. No behavioural change.
2026-07-14 19:27:16 +02:00
Dieter Mayer c211b68139 Fall back to the base language for element and folder names
NamesList::name() looked up the display name using the full locale from
langFromSetting() (e.g. "de_DE") and jumped straight to English if it was
absent. Element and folder names in the collection are keyed by 2-letter
codes (<name lang="de">), so a "de_DE" UI showed the whole collection in
English/French even though German names exist.

Try the base language ("de") before the English fallback, mirroring what
setLanguage() already does for the UI translations.
2026-07-11 21:47:04 +02:00
Kellermorph b543adcb46 Restore comments 2026-07-10 15:04:04 +02:00
Kellermorph f62ce7e4ca Update terminal name 2026-07-10 14:36:47 +02:00
Kellermorph c884d32dbe Feature: Add terminal name label display in element editor 2026-07-09 14:02:27 +02:00
Kellermorph 2db6c3968a feat: add backup dialog when opening an existing project 2026-07-07 21:42:45 +02:00
Laurent Trinques 14253930ae Merge pull request #509 from Kellermorph/master
Add Custom Guides
2026-07-07 16:34:56 +02:00
Laurent Trinques 82cd4d359a macOS fix: add explicit QGraphicsLayoutItem include in helpercell.h
MOC on macOS does not resolve QGraphicsLayoutItem through the bulk
QtWidgets include, causing an 'Undefined interface' error at build time.
Adding an explicit include resolves this. Linux builds are unaffected. Thanks hairykiwi 8ef4e04
2026-07-06 14:45:58 +02:00
Gerhard Schwanzer dcec0bf7ff Skip actively locked autosave files
Check the QLockFile in staleFiles() before returning a no-KF5 recovery candidate, matching the KAutoSaveFile contract that actively owned autosave files are not stale.

Extend the no-KF5 Catch test so a child process keeps the autosave lock alive while allStaleFiles() runs, then verify recovery after the child is killed.

Assisted-by: pi coding agent / Mika (OpenAI GPT-5.5)
2026-07-05 17:39:38 +02:00
Gerhard Schwanzer e6124e941a Add Qt-only autosave recovery fallback
Provide a small KAutoSaveFile-compatible implementation for the no-KF5 build path and use it to keep the existing crash-recovery code active when BUILD_WITH_KF5=OFF.

The normal KF5 build still uses the KDE KAutoSaveFile implementation.

Assisted-by: pi coding agent / Mika (OpenAI GPT-5.5)
2026-07-05 13:23:49 +02:00
Gerhard Schwanzer d0cea474a6 Fix Qt-only build without KF5
The BUILD_WITH_KF5 option was checked with DEFINED, so passing -DBUILD_WITH_KF5=OFF still entered the KF5 setup path.

Skip the KF5 setup when disabled and provide small Qt-only replacements for the KDE color widgets used by .ui files in that build mode.

Assisted-by: pi coding agent / Mika (OpenAI GPT-5.5)
2026-07-05 11:10:44 +02:00
Laurent Trinques 5dac26d9c7 Merge pull request #524 from ispyisail/fix/collection-unicode-path
Fix #391: collection panel blank when path contains accented chars or is too long (Windows)
2026-06-29 23:11:17 +02:00
Laurent Trinques ef04497ca6 Translate debug message to English 2026-06-27 19:41:28 +02:00
Laurent Trinques 58000283e6 Merge pull request #522 from ispyisail/fix/issue-283-table-center-alignment
fix(#283): restore center alignment when loading table config
2026-06-27 13:58:19 +02:00
plc-user 6aa14a7536 Merge pull request #518 from ispyisail/fix/terminal-data-leak
looks plausible, compiles fine

thank you @ispyisail
2026-06-23 09:39:46 +02:00
plc-user 6ce688a709 Merge pull request #520 from ispyisail/fix/element-editor-first-click-481
fixed:
view jumps, but graphic primitives stay at position
all parts can be moved as before
compile-warning is gone

thank you @ispyisail
2026-06-23 09:26:02 +02:00
Shane Ringrose 28357b0f55 fix(editor): correct initializer list order to silence -Wreorder warning
m_first_move was initialized before _linestyle in the constructor
initializer list, but _linestyle is declared first in the class. Reorder
to match declaration order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 07:04:34 +12:00