Commit fba333f7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Allow to compile against qt6

parent 72c8bddf
Pipeline #203470 failed with stage
in 5 minutes and 48 seconds
......@@ -77,12 +77,18 @@ include_directories(${AvogadroLibs_INCLUDE_DIRS})
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS
Core
Gui
Script
Svg
Widgets
Xml
)
if (QT_MAJOR_VERSION STREQUAL "6")
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core5Compat StateMachine)
else()
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Script)
endif()
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Archive
Config
......
......@@ -30,7 +30,10 @@ target_sources(science PRIVATE
generate_export_header(science)
target_link_libraries(science Qt5::Xml KF5::UnitConversion KF5::WidgetsAddons KF5::I18n)
target_link_libraries(science Qt::Xml KF5::UnitConversion KF5::WidgetsAddons KF5::I18n)
if (QT_MAJOR_VERSION STREQUAL "6")
target_link_libraries(science Qt6::Core5Compat)
endif()
set_target_properties(science PROPERTIES VERSION ${KALZIUMLIB_VERSION} SOVERSION ${KALZIUMLIB_SOVERSION} )
install(TARGETS science ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -80,7 +80,11 @@ bool SpectrumParser::startElement(const QString &, const QString &localName, con
bool SpectrumParser::endElement(const QString &, const QString &localName, const QString &)
{
if (localName == QLatin1String("spectrum")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
int num = currentElementID.midRef(1).toInt();
#else
int num = QStringView(currentElementID).mid(1).toInt();
#endif
d->currentSpectrum->setParentElementNumber(num);
d->spectra.append(d->currentSpectrum);
......
......@@ -7,7 +7,7 @@ set(elementparsertest_SRCS xmlreadingtest.cpp)
add_executable(elementparsertest ${elementparsertest_SRCS})
target_link_libraries(elementparsertest science Qt5::Core Qt5::Xml)
target_link_libraries(elementparsertest science Qt::Core Qt::Xml)
ecm_mark_nongui_executable(elementparsertest)
########### next target ###############
......@@ -17,7 +17,7 @@ set(isotopeparsertest_SRCS isotopereadingtest.cpp)
add_executable(isotopeparsertest ${isotopeparsertest_SRCS})
ecm_mark_nongui_executable(isotopeparsertest)
target_link_libraries(isotopeparsertest science Qt5::Core Qt5::Xml)
target_link_libraries(isotopeparsertest science Qt::Core Qt::Xml)
########### next target ###############
......@@ -26,6 +26,6 @@ set(spectrumtest_SRCS spectrumreadingtests.cpp)
add_executable(spectrumtest ${spectrumtest_SRCS})
ecm_mark_nongui_executable(spectrumtest)
target_link_libraries(spectrumtest science Qt5::Core Qt5::Xml)
target_link_libraries(spectrumtest science Qt::Core Qt::Xml)
......@@ -196,10 +196,14 @@ target_link_libraries(kalzium
KF5::TextWidgets
KF5::UnitConversion
KF5::XmlGui
Qt::Script
Qt::Svg
science
)
if (QT_MAJOR_VERSION STREQUAL "5")
target_link_libraries(kalzium Qt::Script)
else()
target_link_libraries(kalzium Qt::StateMachine)
endif()
if (HAVE_OPENBABEL)
target_link_libraries(kalzium ${OPENBABEL_LIBRARIES})
if (EIGEN3_FOUND AND AvogadroLibs_FOUND)
......
......@@ -17,9 +17,11 @@
#include <QFileDialog>
#include <QMessageBox>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QScriptClass>
#include <QScriptEngine>
#include <QScriptValue>
#endif
#include <QVarLengthArray>
#include <KLocalizedString>
......@@ -118,6 +120,7 @@ void titrationCalculator::plot()
if (!mreporto.isEmpty()) {
uid.note->setText(i18n("Theoretical curve") + ": " + mreporto);
for (int i = int(xmin); i < int(xmax); ++i) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
double id = i;
QScriptEngine myEngine;
QByteArray ban = mreporto.toLatin1();
......@@ -134,6 +137,9 @@ void titrationCalculator::plot()
kpor->addPoint(id, tvalue);
redplot = redplot + ' ' + QString::number((id * 10) + 5).replace(QChar(','), QChar('.')) + ','
+ QString::number((ymax - tvalue) * 10).replace(QChar(','), QChar('.'));
#else
#pragma "NEED TO PORT QTSCRIPT";
#endif
}
}
temponu = 0;
......
......@@ -49,7 +49,11 @@ void DetailedGraphicalOverview::setBackgroundColor(QColor bgColor)
// add a gradient
QLinearGradient grad(QPointF(0, 0), QPointF(0, height()));
grad.setColorAt(0, bgColor);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qreal h, s, v, a;
#else
float h, s, v, a;
#endif
bgColor.getHsvF(&h, &s, &v, &a);
bgColor.setHsvF(h, s, v * 0.6, a);
grad.setColorAt(1, bgColor);
......
......@@ -126,7 +126,7 @@ void Kalzium::setupActions()
look_action_schemes->setItems(schemes);
look_action_schemes->setToolBarMode(KSelectAction::MenuMode);
look_action_schemes->setToolButtonPopupMode(QToolButton::InstantPopup);
connect(look_action_schemes, SIGNAL(triggered(int)), this, SLOT(slotSwitchtoLookScheme(int)));
connect(look_action_schemes, &KSelectAction::indexTriggered, this, &Kalzium::slotSwitchtoLookScheme);
// the action for switching look: gradients
look_action_gradients = actionCollection()->add<KSelectAction>(QStringLiteral("view_look_onlygradients"));
......@@ -134,7 +134,7 @@ void Kalzium::setupActions()
look_action_gradients->setItems(gradients);
look_action_gradients->setToolBarMode(KSelectAction::MenuMode);
look_action_gradients->setToolButtonPopupMode(QToolButton::InstantPopup);
connect(look_action_gradients, SIGNAL(triggered(int)), this, SLOT(slotSwitchtoLookGradient(int)));
connect(look_action_gradients, &KSelectAction::indexTriggered, this, &Kalzium::slotSwitchtoLookGradient);
// the action for switching tables
QStringList table_schemes = pseTables::instance()->tables();
......@@ -142,14 +142,14 @@ void Kalzium::setupActions()
table_action->setText(i18n("&Tables"));
table_action->setItems(table_schemes);
table_action->setCurrentItem(Prefs::table());
connect(table_action, SIGNAL(triggered(int)), this, SLOT(slotSwitchtoTable(int)));
connect(table_action, &KSelectAction::indexTriggered, this, &Kalzium::slotSwitchtoTable);
// the actions for switching numeration
numeration_action = actionCollection()->add<KSelectAction>(QStringLiteral("view_numerationtype"));
numeration_action->setText(i18n("&Numeration"));
numeration_action->setItems(KalziumNumerationTypeFactory::instance()->numerations());
numeration_action->setCurrentItem(Prefs::numeration());
connect(numeration_action, SIGNAL(triggered(int)), this, SLOT(slotSwitchtoNumeration(int)));
connect(numeration_action, SIGNAL(indexTriggered(int)), this, SLOT(slotSwitchtoNumeration(int)));
// tools actions
m_pPlotAction = actionCollection()->addAction(QStringLiteral("tools_plotdata"));
......@@ -251,7 +251,7 @@ void Kalzium::setupSidebars()
m_legendWidget = new LegendWidget(this);
m_legendDock = new QDockWidget(i18n("Legend"), this);
m_legendDock->setObjectName(QStringLiteral("kalzium-legend"));
m_legendDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
m_legendDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
m_legendDock->setWidget(m_legendWidget);
connect(m_legendDock, &QDockWidget::dockLocationChanged, m_legendWidget, &LegendWidget::setDockArea);
......@@ -262,11 +262,11 @@ void Kalzium::setupSidebars()
m_tableDock = new QDockWidget(i18n("Table Information"), this);
m_tableDock->setWidget(m_TableInfoWidget);
m_tableDock->setObjectName(QStringLiteral("kalzium-tableinfo"));
m_tableDock->setFeatures(QDockWidget::AllDockWidgetFeatures);
m_tableDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
m_dockWin = new QDockWidget(i18n("Information"), this);
m_dockWin->setObjectName(QStringLiteral("kalzium-sidebar"));
m_dockWin->setFeatures(QDockWidget::AllDockWidgetFeatures);
m_dockWin->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
m_dockWin->setMinimumWidth(250);
m_toolbox = new QToolBox(m_dockWin);
......@@ -296,7 +296,7 @@ void Kalzium::setupSidebars()
void Kalzium::slotExportTable()
{
QString fileName = QFileDialog::getSaveFileName(this, i18n("Save Kalzium's Table In"), QString(), i18n("Image files (*.png *.xpm *.jpg *.svg)"));
const QString fileName = QFileDialog::getSaveFileName(this, i18n("Save Kalzium's Table In"), QString(), i18n("Image files (*.png *.xpm *.jpg *.svg)"));
if (fileName.endsWith(QLatin1String(".svg"))) {
m_periodicTable->generateSvg(fileName);
......
......@@ -140,7 +140,11 @@ QBrush KalziumElementProperty::getElementBrush(int el)
QColor color = getElementColor(el);
QLinearGradient grad(QPointF(0, 0), QPointF(0, 40));
grad.setColorAt(0, color);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
qreal h, s, v, a;
#else
float h, s, v, a;
#endif
color.getHsvF(&h, &s, &v, &a);
color.setHsvF(h, s, v * 0.7, a);
grad.setColorAt(1, color);
......
......@@ -199,7 +199,11 @@ LegendItem::LegendItem(const QPair<QString, QColor> &pair, LegendWidget *parent)
setLayout(ItemLayout);
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void LegendItem::enterEvent(QEnterEvent *event)
#else
void LegendItem::enterEvent(QEvent *event)
#endif
{
Q_EMIT legenItemHoovered(legendItemColor);
QWidget::enterEvent(event);
......
......@@ -78,7 +78,11 @@ private:
QColor legendItemColor;
protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment