Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECDC-4485: Update QPlot to Qt6 #28

Merged
merged 18 commits into from
Feb 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
- Switching to Qt6 support
- Fixing deprecated calls
  • Loading branch information
madsipsen committed Jan 22, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit fbd1bbcd78a61f0598eeb371bccd968af304caf1
2 changes: 1 addition & 1 deletion cmake/QtLibraryConfig.cmake
Original file line number Diff line number Diff line change
@@ -8,4 +8,4 @@ endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5 COMPONENTS Widgets PrintSupport REQUIRED)
find_package(Qt6 COMPONENTS Widgets PrintSupport Core5Compat REQUIRED)
10 changes: 7 additions & 3 deletions src/QPlot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ add_doxygen_source_deps(${HEADERS})
add_subdirectory(qcustomplot)

set(${this_target}_RESOURCES resources/qplot.qrc)
qt5_add_resources(RCC_SOURCES ${${this_target}_RESOURCES})
qt_add_resources(RCC_SOURCES ${${this_target}_RESOURCES})

add_library(QPlot STATIC
${HEADERS}
@@ -55,8 +55,12 @@ set_target_properties(QPlot
OUTPUT_NAME qplot
)

target_link_libraries(QPlot
PUBLIC Qt5::Widgets Qt5::PrintSupport)
target_link_libraries(
QPlot
PUBLIC Qt6::Widgets
PUBLIC Qt6::PrintSupport
PUBLiC Qt6::Core5Compat
)

install(TARGETS QPlot
EXPORT qplot_targets
4 changes: 1 addition & 3 deletions src/QPlot/KnightRiderWidget.cpp
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@ namespace QPlot
KnightRiderWidget::KnightRiderWidget(QWidget* parent)
: QWidget(parent)
{
QFontDatabase fdb;

// int id1 = fdb.addApplicationFont(":/fonts/SF_Fedora_Titles.ttf");
// int id2 = fdb.addApplicationFont(":/fonts/Ruben.ttf");

@@ -137,7 +135,7 @@ void KnightRiderWidget::paint_text(QPainter* painter, const QRect& rect, int fla
void KnightRiderWidget::paintEvent(QPaintEvent*)
{
QPalette pal = palette();
pal.setColor(QPalette::Background, min_color());
pal.setColor(QPalette::Base, min_color());
setPalette(pal);

QPainter painter(this);
22 changes: 12 additions & 10 deletions src/QPlot/QPlot.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <QPlot/QPlot.h>
#include <QPlot/GradientSelector.h>

#include <QRegExp>

inline void initQPlotResources() { Q_INIT_RESOURCE(qplot); }

namespace QPlot
@@ -374,9 +376,9 @@ void GenericPlot::mousePressEvent(QMouseEvent *event)
{
emit mousePress(event);

Draggable *trc = qobject_cast<Draggable*>(itemAt(event->localPos(), true));
Draggable *trc = qobject_cast<Draggable*>(itemAt(event->position(), true));
if ((event->button() == Qt::LeftButton) && (trc != nullptr)) {
trc->startMoving(event->localPos());
trc->startMoving(event->position());
return;
}

@@ -391,17 +393,17 @@ void GenericPlot::mouseMoveEvent(QMouseEvent *event)
QVariant details;
QCPLayerable *clickedLayerable = layerableAt(event->pos(), true, &details);
if (QCPColorMap *ap = qobject_cast<QCPColorMap*>(clickedLayerable)) {
double co_x = xAxis->pixelToCoord(event->x());
double co_y = yAxis->pixelToCoord(event->y());
double co_x = xAxis->pixelToCoord(event->position().x());
double co_y = yAxis->pixelToCoord(event->position().y());
int x{0}, y{0};
ap->data()->coordToCell(co_x, co_y, &x, &y);
emit mouseHover(static_cast<double>(x), static_cast<double>(y));
} //else
//emit mouseHover(co_x, co_y);

if (event->buttons() == Qt::NoButton) {
Draggable *trc = qobject_cast<Draggable*>(itemAt(event->localPos(), false));
Button *button = qobject_cast<Button*>(itemAt(event->localPos(), false));
Draggable *trc = qobject_cast<Draggable*>(itemAt(event->position(), false));
Button *button = qobject_cast<Button*>(itemAt(event->position(), false));

if (trc && trc->visible())
setCursor(Qt::SizeHorCursor);
@@ -419,16 +421,16 @@ void GenericPlot::mouseReleaseEvent(QMouseEvent *event)
emit mouseRelease(event);

if ((mMousePressPos-event->pos()).manhattanLength() < 5) {
double co_x = xAxis->pixelToCoord(event->x());
double co_y = yAxis->pixelToCoord(event->y());
double co_x = xAxis->pixelToCoord(event->position().x());
double co_y = yAxis->pixelToCoord(event->position().y());

QCPAbstractItem *ai = qobject_cast<QCPAbstractItem*>(itemAt(event->localPos(), false));
QCPAbstractItem *ai = qobject_cast<QCPAbstractItem*>(itemAt(event->position(), false));

if (Button* button = qobject_cast<Button*>(ai))
if (button->visible())
this->executeButton(button);

if (qobject_cast<QCPColorScale*>(layoutElementAt(event->localPos())))
if (qobject_cast<QCPColorScale*>(layoutElementAt(event->position())))
selectGradient();

if (!ai)
2 changes: 1 addition & 1 deletion src/QPlot/QPlotButton.cpp
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ Button::Button(QCustomPlot *parentPlot,
setPixmap(pixmap);
setSelectable(false);

if (second_point == (Qt::AlignBottom | Qt::AlignRight))
if (second_point == static_cast<int>(Qt::AlignBottom | Qt::AlignRight))
{
bottomRight->setType(QCPItemPosition::ptAbsolute);
bottomRight->setParentAnchor(topLeft);
4 changes: 2 additions & 2 deletions src/QPlot/QPlotDraggable.cpp
Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@ void Draggable::movePx(double x, double y)

void Draggable::onMouseMove(QMouseEvent *event)
{
pos_current_ = QPointF(event->localPos().x() + grip_delta_.x(),
event->localPos().y() + grip_delta_.y());
pos_current_ = QPointF(event->position().x() + grip_delta_.x(),
event->position().y() + grip_delta_.y());
}

void Draggable::moveToWantedPos()
Loading