mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-11-18 17:24:04 +01:00
enable qt5
This commit is contained in:
1 parent
ad9d03296e
commit
f8499cb09e
11 files changed
+66
-23
No files matched your search
@@ -25,6 +25,7 @@ jobs:
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
# RHEL8 has no Qt6, the gui is built with Qt5
|
||||
dnf -y install rpm-build qt5-qtbase-devel qt5-qtsvg-devel \
|
||||
libpng-devel zlib-devel expat-devel libtiff-devel
|
||||
|
||||
@@ -33,8 +34,10 @@ jobs:
|
||||
cmake -S . -B build \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DSLS_USE_GUI=ON \
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON \
|
||||
-DSLS_USE_MOENCH=ON \
|
||||
-DSLS_INSTALL_VERSIONED_BINARIES=ON
|
||||
grep -q '^Qt5_DIR:PATH=/' build/CMakeCache.txt
|
||||
cmake --build build -j 2
|
||||
|
||||
- name: Build RPMs
|
||||
|
||||
@@ -32,6 +32,8 @@ jobs:
|
||||
-DSLS_USE_GUI=ON \
|
||||
-DSLS_USE_MOENCH=ON \
|
||||
-DSLS_INSTALL_VERSIONED_BINARIES=ON
|
||||
# Qt6, not a fallback to Qt5
|
||||
grep -q '^Qt6_DIR:PATH=/' build/CMakeCache.txt
|
||||
cmake --build build -j 2
|
||||
|
||||
- name: Build RPMs
|
||||
|
||||
+6
-3
@@ -538,9 +538,12 @@ set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
|
||||
|
||||
set(CPACK_RPM_GUI_PACKAGE_REQUIRES
|
||||
"qt6-qtbase, qt6-qtbase-gui"
|
||||
)
|
||||
# The Qt the gui was built with, Qt5 on RHEL8 and Qt6 on RHEL9
|
||||
if(SLS_QT STREQUAL "Qt5")
|
||||
set(CPACK_RPM_GUI_PACKAGE_REQUIRES "qt5-qtbase, qt5-qtbase-gui")
|
||||
else()
|
||||
set(CPACK_RPM_GUI_PACKAGE_REQUIRES "qt6-qtbase, qt6-qtbase-gui")
|
||||
endif()
|
||||
|
||||
#control which RPMs are generated
|
||||
set(CPACK_COMPONENTS_ALL cli receiver zmq gui)
|
||||
|
||||
@@ -5,8 +5,23 @@ set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
|
||||
# Qt6 when it is there, Qt 5.15 otherwise (RHEL8 has no Qt6 packages). To build
|
||||
# with Qt5 where both are installed: -DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON
|
||||
# Concurrent is needed for the acquisition thread in qDrawPlot.cpp
|
||||
find_package(Qt6 6.2 REQUIRED COMPONENTS Widgets Gui Core Concurrent)
|
||||
set(SLS_QT_COMPONENTS Widgets Gui Core Concurrent)
|
||||
if(SLS_USE_TESTS)
|
||||
list(APPEND SLS_QT_COMPONENTS Test)
|
||||
endif()
|
||||
find_package(Qt6 6.2 QUIET COMPONENTS ${SLS_QT_COMPONENTS})
|
||||
if(Qt6_FOUND)
|
||||
set(SLS_QT Qt6)
|
||||
else()
|
||||
find_package(Qt5 5.15 REQUIRED COMPONENTS ${SLS_QT_COMPONENTS})
|
||||
set(SLS_QT Qt5)
|
||||
endif()
|
||||
message(STATUS "slsDetectorGui: using ${SLS_QT} ${${SLS_QT}_VERSION}")
|
||||
# the gui RPM depends on the same Qt
|
||||
set(SLS_QT ${SLS_QT} PARENT_SCOPE)
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
@@ -43,9 +58,9 @@ target_link_libraries(slsDetectorPlotting
|
||||
PUBLIC
|
||||
slsProjectOptions
|
||||
slsSupportStatic
|
||||
Qt6::Widgets
|
||||
Qt6::Gui
|
||||
Qt6::Core
|
||||
${SLS_QT}::Widgets
|
||||
${SLS_QT}::Gui
|
||||
${SLS_QT}::Core
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
)
|
||||
@@ -125,7 +140,7 @@ target_link_libraries(slsDetectorGui PUBLIC
|
||||
slsDetectorPlotting
|
||||
PNG::PNG
|
||||
ZLIB::ZLIB
|
||||
Qt6::Concurrent
|
||||
${SLS_QT}::Concurrent
|
||||
|
||||
PRIVATE
|
||||
slsProjectWarnings
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
#include <QPalette>
|
||||
#include <QPointF>
|
||||
#include <QRect>
|
||||
#include <QRgb>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
@@ -19,6 +21,16 @@
|
||||
namespace sls {
|
||||
namespace plot {
|
||||
|
||||
// Position of a mouse or gesture event in the widget. Qt5 has another name for
|
||||
// it. Not for wheel events, they have position() in both.
|
||||
template <class Event> QPointF eventPos(const Event *e) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
return e->position();
|
||||
#else
|
||||
return e->localPos();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Palettes offered by the image scale panel. Color / BW1 / BW2 are the
|
||||
// original three and stay first (the b / B / c shortcuts use those indices).
|
||||
// Gain4 is the fixed, muted palette for the 0..3 gain bits and is *not* in the
|
||||
|
||||
@@ -1453,7 +1453,7 @@ void SlsQt1DPlot::paintEvent(QPaintEvent *event) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void SlsQt1DPlot::mousePressEvent(QMouseEvent *event) {
|
||||
const QPointF pos = event->position();
|
||||
const QPointF pos = sls::plot::eventPos(event);
|
||||
const Geometry g = computeGeometry();
|
||||
if (zoomAllowed()) {
|
||||
if (event->button() == Qt::LeftButton &&
|
||||
@@ -1490,7 +1490,7 @@ void SlsQt1DPlot::mousePressEvent(QMouseEvent *event) {
|
||||
}
|
||||
|
||||
void SlsQt1DPlot::mouseMoveEvent(QMouseEvent *event) {
|
||||
const QPointF pos = event->position();
|
||||
const QPointF pos = sls::plot::eventPos(event);
|
||||
const Geometry g = computeGeometry();
|
||||
const bool inside = g.plot.contains(pos.toPoint());
|
||||
if (inside != m_trackValid || pos != m_trackPos) {
|
||||
|
||||
@@ -632,7 +632,7 @@ void SlsQtFastImage::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() != Qt::LeftButton || !m_zoomEnabled || !hasImage())
|
||||
return;
|
||||
m_panning = true;
|
||||
m_panStart = e->position();
|
||||
m_panStart = plot::eventPos(e);
|
||||
m_panStartArea = visibleArea();
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
}
|
||||
@@ -642,12 +642,12 @@ void SlsQtFastImage::mouseMoveEvent(QMouseEvent *e) {
|
||||
return;
|
||||
const Mapping m = mapping();
|
||||
if (m_panning) {
|
||||
const QPointF delta = (e->position() - m_panStart) / m.scale;
|
||||
const QPointF delta = (plot::eventPos(e) - m_panStart) / m.scale;
|
||||
showArea(m_panStartArea.translated(-delta.x(), delta.y()));
|
||||
return;
|
||||
}
|
||||
|
||||
updateHover(e->position());
|
||||
updateHover(plot::eventPos(e));
|
||||
}
|
||||
|
||||
// Finds the pixel under the cursor, for the readout
|
||||
@@ -703,8 +703,8 @@ bool SlsQtFastImage::event(QEvent *e) {
|
||||
const auto *gesture = static_cast<QNativeGestureEvent *>(e);
|
||||
if (gesture->gestureType() == Qt::ZoomNativeGesture) {
|
||||
// value() is the change of size since the previous event
|
||||
zoomAt(gesture->position(), std::max(0.1, 1 + gesture->value()));
|
||||
updateHover(gesture->position());
|
||||
zoomAt(plot::eventPos(gesture), std::max(0.1, 1 + gesture->value()));
|
||||
updateHover(plot::eventPos(gesture));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void SlsQtScaleHisto::paintEvent(QPaintEvent *) {
|
||||
void SlsQtScaleHisto::mousePressEvent(QMouseEvent *e) {
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
const double x = e->position().x();
|
||||
const double x = plot::eventPos(e).x();
|
||||
const double toLo = std::abs(x - kLoMarker * width());
|
||||
const double toHi = std::abs(x - kHiMarker * width());
|
||||
if (std::min(toLo, toHi) > kGrabDistance)
|
||||
@@ -145,7 +145,7 @@ void SlsQtScaleHisto::mousePressEvent(QMouseEvent *e) {
|
||||
void SlsQtScaleHisto::mouseMoveEvent(QMouseEvent *e) {
|
||||
if (!isDragging())
|
||||
return;
|
||||
m_dragX = std::clamp(e->position().x(), 0.0, double(width()));
|
||||
m_dragX = std::clamp(plot::eventPos(e).x(), 0.0, double(width()));
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -210,11 +210,11 @@ SlsQtScalePanel::SlsQtScalePanel(SlsQtFastImage *view, QWidget *parent)
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
connect(
|
||||
m_paletteCombo, &QComboBox::currentIndexChanged, this,
|
||||
m_paletteCombo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
[this](int i) { m_view->setPalette(static_cast<plot::Palette>(i)); });
|
||||
connect(m_imageLogCombo, &QComboBox::currentIndexChanged, this,
|
||||
connect(m_imageLogCombo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
[this](int i) { m_view->setLogScale(i == 1); });
|
||||
connect(m_histoLogCombo, &QComboBox::currentIndexChanged, this,
|
||||
connect(m_histoLogCombo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
&SlsQtScalePanel::refresh);
|
||||
connect(m_histo, &SlsQtScaleHisto::rangeChanged, this,
|
||||
[this](double lo, double hi) {
|
||||
|
||||
@@ -108,6 +108,11 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
// Qt6 always scales with the screen, Qt5 has to be asked
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
QApplication app(argc, argv);
|
||||
// Use the same (platform independent) widget style everywhere so that the
|
||||
// gui looks the same on linux and macOS. Fusion is built into Qt.
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
# QtTest suite for the plotting widgets. Needs no display:
|
||||
# QT_QPA_PLATFORM=offscreen bin/plotting_test
|
||||
|
||||
find_package(Qt6 6.2 REQUIRED COMPONENTS Test)
|
||||
|
||||
add_executable(plotting_test
|
||||
plotting_test.cpp
|
||||
)
|
||||
target_link_libraries(plotting_test PRIVATE
|
||||
slsDetectorPlotting
|
||||
Qt6::Test
|
||||
${SLS_QT}::Test
|
||||
)
|
||||
set_target_properties(plotting_test PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
||||
@@ -625,9 +625,14 @@ void PlottingTest::imageTouchpadZoom() {
|
||||
// a pinch magnifies by 1 + value
|
||||
view.resetView();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QNativeGestureEvent pinch(Qt::ZoomNativeGesture,
|
||||
QPointingDevice::primaryPointingDevice(), 2,
|
||||
cursor, cursor, cursor, 0.18, QPointF());
|
||||
#else
|
||||
QNativeGestureEvent pinch(Qt::ZoomNativeGesture, cursor, cursor, cursor,
|
||||
0.18, 0, 0);
|
||||
#endif
|
||||
QCoreApplication::sendEvent(&view, &pinch);
|
||||
}
|
||||
QVERIFY(nearRect(view.visibleArea(), wheel));
|
||||
|
||||
Reference in new issue
Block a user