Merge pull request #709 from arummler/master-continue-qt6-migration

Qt6 migration beyond signal/slot
This commit is contained in:
Laurent Trinques
2026-08-13 10:55:47 +02:00
committed by GitHub
30 changed files with 243 additions and 126 deletions
@@ -19,6 +19,7 @@
#include <QPainter>
#include <QHash>
#include <QUuid>
namespace TerminalStripDrawer {
@@ -19,6 +19,7 @@
#define TERMINALSTRIPDRAWER_H
#include <QPointer>
#include <QUuid>
#include "properties/terminalstriplayoutpattern.h"
@@ -28,6 +28,8 @@
#include "../terminalstrip.h"
#include "../../qetinformation.h"
#include <QUuid>
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
QDockWidget(parent),
ui(new Ui::TerminalStripTreeDockWidget)
@@ -20,6 +20,7 @@
#include <QDockWidget>
#include <QPointer>
#include <QHash>
class QETProject;
class QTreeWidgetItem;
+2 -2
View File
@@ -142,7 +142,7 @@ void DynamicTextFieldEditor::updateForm()
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_rotation_point_center_cb->setChecked(m_text_field.data()->rotationPointCenter());
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
//Block signals while loading the colour into the button.
//KColorButton::changed fires on a programmatic setColor() as well
@@ -182,7 +182,7 @@ void DynamicTextFieldEditor::updateForm()
void DynamicTextFieldEditor::setupWidget()
{
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
m_color_kpb = new KColorButton(this);
m_color_kpb->setObjectName(QString::fromUtf8("m_color_kpb"));
+2 -2
View File
@@ -21,7 +21,7 @@
#include "../elementitemeditor.h"
#include "../graphicspart/partdynamictextfield.h"
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
# include <KColorButton>
#endif
@@ -79,7 +79,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
QList<PartDynamicTextField*> m_parts;
QList<QMetaObject::Connection> m_connection_list;
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
KColorButton* m_color_kpb = nullptr;
#endif
+3 -3
View File
@@ -40,7 +40,7 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, QWidget *parent) :
{
ui->setupUi(this);
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
m_color_pb = new QPushButton(this);
m_color_pb->setMinimumSize(40, 24);
connect(m_color_pb, &QPushButton::clicked, this, &TerminalEditor::labelColorClicked);
@@ -93,7 +93,7 @@ void TerminalEditor::updateForm()
ui->m_label_rotation_sb->setValue(static_cast<int>(m_part->labelRotation()));
ui->m_label_frame_cb->setChecked(m_part->labelFrame());
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
QPixmap px(16, 16);
px.fill(m_part->labelColor());
m_color_pb->setIcon(QIcon(px));
@@ -410,7 +410,7 @@ void TerminalEditor::labelColorClicked()
if (m_locked) return;
m_locked = true;
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
QColor new_color = QColorDialog::getColor(m_part->labelColor(), this);
if (new_color.isValid() && m_part->labelColor() != new_color) {
auto undo = new QPropertyUndoCommand(m_part, "label_color", m_part->labelColor(), new_color);
+2 -2
View File
@@ -21,7 +21,7 @@
#include <QWidget>
#include "../elementitemeditor.h"
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#include <QPushButton>
#else
#include <KColorButton>
@@ -78,7 +78,7 @@ class TerminalEditor : public ElementItemEditor
m_change_connections;
PartTerminal *m_part = nullptr;
bool m_locked = false;
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
QPushButton *m_color_pb;
#else
KColorButton *m_color_pb;
+2 -2
View File
@@ -63,7 +63,7 @@ void TextEditor::updateForm()
m_rotation_sb -> setValue(m_text -> rotation());
m_size_sb -> setValue(m_text -> font().pointSize());
m_font_pb -> setText(m_text -> font().family());
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
m_color_pb -> setColor(m_text -> defaultTextColor());
#endif
@@ -346,7 +346,7 @@ void TextEditor::setUpWidget(QWidget *parent)
m_line_edit->setPlaceholderText(tr("Entrer votre texte ici"));
gridLayout->addWidget(m_line_edit, 0, 0, 1, 6);
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
m_color_pb = new KColorButton(parent);
m_color_pb->setObjectName(QString::fromUtf8("m_color_pb"));
+2 -2
View File
@@ -25,7 +25,7 @@
#include <QSpinBox>
#include <QLineEdit>
#include <QPushButton>
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
#include <KColorButton>
#endif
@@ -65,7 +65,7 @@ class TextEditor : public ElementItemEditor {
QSpinBox *m_size_sb;
QLineEdit *m_line_edit;
QPushButton *m_font_pb;
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
#else
KColorButton *m_color_pb;
#endif
+2 -2
View File
@@ -23,8 +23,8 @@
#include "qetgraphicsitem/element.h"
#include "qetgraphicsitem/elementtextitemgroup.h"
// Private Qt PDF engine for drawHyperlink() — not public API, stable since Qt4.
// Requires QT += gui-private in qelectrotech.pro / gui-private in CMake.
// Private Qt PDF engine for drawHyperlink() — not public API.
// Availability of Qt::GuiPrivate is verified at configure time in CMakeLists.txt.
#include <private/qpdf_p.h>
#include <QByteArray>
+10 -6
View File
@@ -28,8 +28,8 @@
#include "ui_projectprintwindow.h"
// Private Qt PDF engine for drawHyperlink() not public API, stable since Qt4
// Requires QT += gui-private in qelectrotech.pro
// Private Qt PDF engine for drawHyperlink() is not a public API.
// Availability of Qt::GuiPrivate is verified at configure time in CMakeLists.txt.
#include <private/qpdf_p.h>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
@@ -79,10 +79,14 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
print_dialog.setWindowFlags(Qt::Sheet);
#endif
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
// setOptions() is the modern spelling of the Qt4-era
// setEnabledOptions() (removed in Qt 6): replace the enabled
// option set with just PrintShowPageSize, on Qt 5 and 6 alike.
print_dialog.setOptions(QAbstractPrintDialog::PrintShowPageSize);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintShowPageSize);
#else
#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) {
delete printer_;
return;
+16 -16
View File
@@ -35,28 +35,28 @@ public:
: QTabWidget(parent)
{}
double temp_index = 0;
void wheelEvent(QWheelEvent *event) override
{
int index = currentIndex();
double delta = 0;
double scale_factor = 0.005; // Decrease or increase speed of mouse wheel (0.04 = decrease)
if (event->modifiers() & Qt::ControlModifier) {
if (index != -1) {
delta = event->delta() * scale_factor; // Read and scale the scroll value
if (delta > 0 && (temp_index > -1)) temp_index = temp_index - abs(delta);
if (delta < 0 && (temp_index < count())) temp_index = temp_index + abs(delta);
// Only intercept if Ctrl is held down
if (event->modifiers() & Qt::ControlModifier) {
int index = currentIndex();
if (index != -1) {
// angleDelta().y() is usually 120 per click.
// Dividing by 120 gives you exactly +1 (scroll up) or -1 (scroll down)
int steps = event->angleDelta().y() / 120;
index = int (temp_index);
qDebug() << "index" << index << "temp_index" << temp_index << " " << event->delta() << delta;
if (steps != 0) {
int newIndex = index - steps;
if (index >= 0 && index < count())
setCurrentIndex(index);
// qDebug() << currentIndex();
if (newIndex >= 0 && newIndex < count())
setCurrentIndex(newIndex);
}
}
event->accept(); // Mark event handled so parent widgets don't process it
} else {
// Allow the default QTabWidget wheel behavior to process if Ctrl isn't held
QTabWidget::wheelEvent(event);
}
}
};
#endif
+1 -1
View File
@@ -50,7 +50,7 @@
#include <QFontDatabase>
#include <QProcessEnvironment>
#include <QRegularExpression>
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
# include "ui/nokde/kautosavefile.h"
#else
# include <KAutoSaveFile>
+1 -1
View File
@@ -57,7 +57,7 @@
#include <QDateTime>
#include <QDebug>
#include <QDir>
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
# include "ui/nokde/kautosavefile.h"
#else
# include <KAutoSaveFile>
@@ -146,7 +146,7 @@ bool ProjectDBModel::setData(const QModelIndex &index, const QVariant &value, in
return false;
}
m_index_0_0_data.insert(role, value);
emit dataChanged(index, index, QVector<int>(role));
emit dataChanged(index, index, {role});
return true;
}
@@ -332,7 +332,7 @@ void ProjectDBModel::dataBaseUpdated()
auto row = m_record.size();
auto col = row ? m_record.first().count() : 1;
emit dataChanged(this->index(0,0), this->index(row-1, col-1), QVector<int>(Qt::DisplayRole));
emit dataChanged(this->index(0,0), this->index(row-1, col-1), {Qt::DisplayRole});
}
}
+1 -1
View File
@@ -29,7 +29,7 @@
#include "titleblock/templatescollection.h"
#include "titleblockproperties.h"
#include "diagram.h"
#ifdef BUILD_WITHOUT_KF5
#ifdef BUILD_WITHOUT_KF
# include "ui/nokde/kautosavefile.h"
#else
# include <KAutoSaveFile>
+2 -1
View File
@@ -21,6 +21,7 @@
#include <QSettings>
#include <QVariant>
#include <algorithm>
#include <utility>
namespace {
const QString SETTINGS_GROUP = QStringLiteral("shortcuts/");
@@ -143,7 +144,7 @@ void ShortcutManager::setSequence(const QString &id, const QKeySequence &sequenc
settings.setValue(key, sequence.toString());
}
for (const QPointer<QObject> &target : qAsConst(it->targets)) {
for (const QPointer<QObject> &target : std::as_const(it->targets)) {
if (target) {
target->setProperty("shortcut", QVariant::fromValue(sequence));
}
@@ -31,6 +31,7 @@
#include <QToolButton>
#include <QVBoxLayout>
#include <algorithm>
#include <utility>
/**
@brief ShortcutsConfigPage::ShortcutsConfigPage
@@ -198,7 +199,7 @@ void ShortcutsConfigPage::resetRow(int row_index)
void ShortcutsConfigPage::resetAllRows()
{
for (const Row &row : qAsConst(m_rows)) {
for (const Row &row : std::as_const(m_rows)) {
row.edit->setKeySequence(row.default_sequence);
}
checkConflicts();
@@ -211,7 +212,7 @@ void ShortcutsConfigPage::resetAllRows()
*/
void ShortcutsConfigPage::applyConf()
{
for (const Row &row : qAsConst(m_rows)) {
for (const Row &row : std::as_const(m_rows)) {
ShortcutManager::instance().setSequence(row.id, row.edit->keySequence());
}
}