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

Build with Qt6 and optionally with QML #11608

Merged
merged 7 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
27 changes: 22 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,27 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
endif()

option(QT6 "Build with Qt6" OFF)

option(QML "Build with QML" OFF)
option(QOPENGL "Use QOpenGLWindow based widget instead of QGLWidget" ON)

if(QML AND NOT QT6)
message(FATAL_ERROR "Building with option QML=ON requires QT6=ON")
endif()

if(QOPENGL)
add_compile_definitions(MIXXX_USE_QOPENGL)
endif()

if(QML)
add_compile_definitions(MIXXX_USE_QML)
endif()

if(APPLE)
if(QT6)
# Minimum macOS version supported by Qt 6
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "Minimum macOS version the build will be able to run on")
if(NOT VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "x64-osx-min10.15")
set(VCPKG_TARGET_TRIPLET "x64-osx-min1012")
m0dB marked this conversation as resolved.
Show resolved Hide resolved
endif()
else()
if(VCPKG_TARGET_TRIPLET STREQUAL "arm64-osx-min1100")
Expand Down Expand Up @@ -1103,7 +1112,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/widget/wwidgetgroup.cpp
src/widget/wwidgetstack.cpp
)
if(QT6)
if(QML)
target_sources(mixxx-lib PRIVATE
src/qml/asyncimageprovider.cpp
src/qml/qmlapplication.cpp
Expand Down Expand Up @@ -2038,6 +2047,8 @@ if(ENGINEPRIME)
message(STATUS "Using existing system installation of libdjinterop")
target_include_directories(mixxx-lib PUBLIC ${DjInterop_INCLUDE_DIRS})
target_link_libraries(mixxx-lib PRIVATE DjInterop::DjInterop)
find_package(ZLIB 1.2.8 REQUIRED)
target_link_libraries(mixxx-lib PRIVATE ${ZLIB_LIBRARIES})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change relate to Qt6 or is it something we need in the 2.4 branch anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt6 only, and possibly because I am using the official Qt6 binary install. I suppose we should use a vcpkg buildenv with Qt6 instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will take a look to provide such a package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, with the current buildenv I get this warning for all Qt libraries when linking: warning: dylib (/Users/m0dB/Qt6/6.5.0/macos/lib/QtPrintSupport.framework/Versions/A/QtPrintSupport) was built for newer macOS version (11.0) than being linked (10.15)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use the upstream distribution of QT, right? Since Qt 6.5 they build by default with a minimum of macOS 11.00
without a technical reason qt/qtbase@f2415df, while hey still allow to build for 10.15
https://github.com/qt/qtbase/blob/38c8eb8564495b0fe345eaca700966889f1f8aa3/cmake/QtBuild.cmake#L235

If we we do not use 11.0 only API, I think we should not drop 10.15 in our own build artificially.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just noticed that it the minimum requirement is macOS 10.14
qt/qtbase@4933a5f

My build confirms it:
https://github.com/daschuer/vcpkg/actions/runs/5125452456

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and it's a good reason to use Qt6 from our own buildenv.

else()
# Fetch djinterop sources from GitHub and build them statically.

Expand Down Expand Up @@ -2318,7 +2329,9 @@ if(QT6)
foreach(COMPONENT ${QT6_NEW_COMPONENTS})
target_link_libraries(mixxx-lib PUBLIC Qt6::${COMPONENT})
endforeach()
endif()

if(QML)
set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
set_target_properties(mixxx-lib PROPERTIES AUTOMOC ON)
qt_add_qml_module(mixxx-lib
Expand Down Expand Up @@ -2416,7 +2429,7 @@ endif()


if(APPLE)
if(Qt_IS_STATIC)
if(Qt_IS_STATIC OR QT6)
target_link_libraries(mixxx-lib PRIVATE
"-weak_framework Accelerate"
"-weak_framework AppKit"
Expand Down Expand Up @@ -2520,7 +2533,11 @@ endif()
if(APPLE OR WIN32)
# qt_de.qm is just one arbitrary file in the directory that needs to be located;
# there is no particular reason to look for this file versus any other one in the directory.
find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt5_DIR}/../../../translations" "${Qt5_DIR}/../../qt5/translations" REQUIRED NO_DEFAULT_PATH)
if(QT6)
find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt6_DIR}/../../../translations" "${Qt6_DIR}/../../qt5/translations" REQUIRED NO_DEFAULT_PATH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me:

Suggested change
find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt6_DIR}/../../../translations" "${Qt6_DIR}/../../qt5/translations" REQUIRED NO_DEFAULT_PATH)
find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt6_DIR}/../../translations/Qt6" REQUIRED NO_DEFAULT_PATH)

else()
find_file(QT_TRANSLATION_FILE qt_de.qm PATHS "${Qt5_DIR}/../../../translations" "${Qt5_DIR}/../../qt5/translations" REQUIRED NO_DEFAULT_PATH)
endif()
get_filename_component(QT_TRANSLATIONS ${QT_TRANSLATION_FILE} DIRECTORY)
install(
DIRECTORY "${QT_TRANSLATIONS}"
Expand Down
2 changes: 1 addition & 1 deletion res/skins/LateNight/skin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@

<WidgetGroup>
<Layout>vertical</Layout>
<SizePolicy>me,max</SizePolicy>
<SizePolicy>me,me</SizePolicy>
<Children>
<Template src="skin:waveforms_container.xml"/>
</Children>
Expand Down
2 changes: 1 addition & 1 deletion src/control/controlsortfiltermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <QSortFilterProxyModel>
#include <QString>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
#include <QtQml>
#else
#define QML_ELEMENT
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "util/sample.h"
#include "util/timer.h"
#include "waveform/visualplayposition.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "waveform/waveformwidgetfactory.h"
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ LibraryControl::LibraryControl(Library* pLibrary)

// Auto DJ controls
m_pAutoDjAddTop = std::make_unique<ControlPushButton>(ConfigKey("[Library]","AutoDjAddTop"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
connect(m_pAutoDjAddTop.get(),
&ControlPushButton::valueChanged,
this,
&LibraryControl::slotAutoDjAddTop);
#endif

m_pAutoDjAddBottom = std::make_unique<ControlPushButton>(ConfigKey("[Library]","AutoDjAddBottom"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
connect(m_pAutoDjAddBottom.get(),
&ControlPushButton::valueChanged,
this,
Expand All @@ -200,7 +200,7 @@ LibraryControl::LibraryControl(Library* pLibrary)

m_pAutoDjAddReplace = std::make_unique<ControlPushButton>(
ConfigKey("[Library]", "AutoDjAddReplace"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
connect(m_pAutoDjAddReplace.get(),
&ControlPushButton::valueChanged,
this,
Expand All @@ -214,7 +214,7 @@ LibraryControl::LibraryControl(Library* pLibrary)
m_pSortColumnToggle = std::make_unique<ControlEncoder>(ConfigKey("[Library]", "sort_column_toggle"), false);
m_pSortFocusedColumn = std::make_unique<ControlPushButton>(
ConfigKey("[Library]", "sort_focused_column"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
connect(m_pSortColumn.get(),
&ControlEncoder::valueChanged,
this,
Expand Down Expand Up @@ -405,7 +405,7 @@ LibraryControl::LibraryControl(Library* pLibrary)
ControlDoublePrivate::insertAlias(ConfigKey("[Playlist]", "AutoDjAddTop"), ConfigKey("[Library]", "AutoDjAddTop"));
ControlDoublePrivate::insertAlias(ConfigKey("[Playlist]", "AutoDjAddBottom"), ConfigKey("[Library]", "AutoDjAddBottom"));

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
QApplication* app = qApp;
// Update controls if any widget in any Mixxx window gets or loses focus
connect(app,
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "coreservices.h"
#include "errordialoghandler.h"
#include "mixxxapplication.h"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
#include "qml/qmlapplication.h"
#else
#include "mixxxmainwindow.h"
Expand All @@ -27,7 +27,7 @@
namespace {

// Exit codes
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
constexpr int kFatalErrorOnStartupExitCode = 1;
#endif
constexpr int kParseCmdlineArgsErrorExitCode = 2;
Expand All @@ -42,7 +42,7 @@ int runMixxx(MixxxApplication* pApp, const CmdlineArgs& args) {
CmdlineArgs::Instance().parseForUserFeedback();

int exitCode;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
mixxx::qml::QmlApplication qmlApplication(pApp, pCoreServices);
exitCode = pApp->exec();
#else
Expand Down
2 changes: 1 addition & 1 deletion src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "track/track.h"
#include "util/sandbox.h"
#include "vinylcontrol/defs_vinylcontrol.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/visualsmanager.h"
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@
#undef max
#undef min

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtX11Extras/QX11Info>
#endif
#endif

namespace {
#ifdef __LINUX__
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "preferences/dialog/dlgprefeffects.h"
#include "preferences/dialog/dlgprefinterface.h"
#include "preferences/dialog/dlgprefmixer.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "preferences/dialog/dlgprefwaveform.h"
#endif

Expand Down Expand Up @@ -153,7 +153,7 @@ DlgPreferences::DlgPreferences(
tr("Interface"),
"ic_preferences_interface.svg");

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
// ugly proxy for determining whether this is being instantiated for QML or legacy QWidgets GUI
if (pSkinLoader) {
DlgPrefWaveform* pWaveformPage = new DlgPrefWaveform(this, m_pConfig, pLibrary);
Expand Down
14 changes: 7 additions & 7 deletions src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "util/timer.h"
#include "util/valuetransformer.h"
#include "util/xml.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "waveform/vsyncthread.h"
#endif
#include "waveform/waveformwidgetfactory.h"
Expand Down Expand Up @@ -73,7 +73,7 @@
#include "widget/wsizeawarestack.h"
#include "widget/wskincolor.h"
#include "widget/wslidercomposed.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "widget/wspinny.h"
#include "widget/wspinnyglsl.h"
#endif
Expand All @@ -84,7 +84,7 @@
#include "widget/wtrackproperty.h"
#include "widget/wtracktext.h"
#include "widget/wtrackwidgetgroup.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "widget/wvumeter.h"
#include "widget/wvumeterglsl.h"
#include "widget/wvumeterlegacy.h"
Expand Down Expand Up @@ -950,7 +950,7 @@ void LegacySkinParser::setupLabelWidget(const QDomElement& element, WLabel* pLab
}

QWidget* LegacySkinParser::parseOverview(const QDomElement& node) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
Q_UNUSED(node);

return nullptr;
Expand Down Expand Up @@ -996,7 +996,7 @@ QWidget* LegacySkinParser::parseOverview(const QDomElement& node) {
}

QWidget* LegacySkinParser::parseVisual(const QDomElement& node) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
Q_UNUSED(node);

return nullptr;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ QWidget* LegacySkinParser::parseRecordingDuration(const QDomElement& node) {
}

QWidget* LegacySkinParser::parseSpinny(const QDomElement& node) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
Q_UNUSED(node);

return nullptr;
Expand Down Expand Up @@ -1354,7 +1354,7 @@ QWidget* LegacySkinParser::parseSpinny(const QDomElement& node) {
}

QWidget* LegacySkinParser::parseVuMeter(const QDomElement& node) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
Q_UNUSED(node);

return nullptr;
Expand Down
4 changes: 4 additions & 0 deletions src/waveform/renderers/allshader/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,11 @@ void allshader::WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark,
// though as soon as other OS-based font and app scaling mechanics join the
// party the resulting font size is hard to predict (affects all supported OS).
font.setPixelSize(13);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
font.setWeight(75); // bold
#else
font.setWeight(QFont::Bold); // bold
#endif
font.setItalic(false);

QFontMetrics metrics(font);
Expand Down
4 changes: 4 additions & 0 deletions src/waveform/renderers/waveformrendermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ void WaveformRenderMark::generateMarkImage(WaveformMarkPointer pMark) {
// though as soon as other OS-based font and app scaling mechanics join the
// party the resulting font size is hard to predict (affects all supported OS).
font.setPixelSize(13);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
font.setWeight(75); // bold
#else
font.setWeight(QFont::Bold); // bold
#endif
font.setItalic(false);

QFontMetrics metrics(font);
Expand Down
4 changes: 4 additions & 0 deletions src/waveform/renderers/waveformwidgetrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ void WaveformWidgetRenderer::drawPassthroughLabel(QPainter* painter) {
font.setFamily("Open Sans"); // default label font
// Make the label always fit
font.setPixelSize(math_min(25, int(m_height * 0.8)));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
font.setWeight(75); // bold
#else
font.setWeight(QFont::Bold); // bold
#endif
font.setItalic(false);

QString label = QObject::tr("Passthrough");
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/visualplayposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "control/controlproxy.h"
#include "moc_visualplayposition.cpp"
#include "util/math.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#ifndef MIXXX_USE_QML
#include "waveform/vsyncthread.h"
#endif

Expand Down Expand Up @@ -51,7 +51,7 @@ void VisualPlayPosition::set(
double VisualPlayPosition::calcOffsetAtNextVSync(
VSyncThread* pVSyncThread, const VisualPlayPositionData& data) {
if (data.m_audioBufferMicroS != 0.0) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
Q_UNUSED(pVSyncThread);
const int refToVSync = 0;
const int syncIntervalTimeMicros = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/visualplayposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "control/controlvalue.h"

class ControlProxy;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#ifdef MIXXX_USE_QML
typedef void VSyncThread;
#else
class VSyncThread;
Expand Down
1 change: 0 additions & 1 deletion src/waveform/widgets/glwaveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "waveform/widgets/glwaveformwidget.h"

#include <QGLContext>
#include <QPainter>
#include <QtDebug>

Expand Down
1 change: 0 additions & 1 deletion src/waveform/widgets/qthsvwaveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "waveform/widgets/qthsvwaveformwidget.h"

#include <QGLContext>
#include <QPainter>
#include <QtDebug>

Expand Down
1 change: 0 additions & 1 deletion src/waveform/widgets/qtrgbwaveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "waveform/widgets/qtrgbwaveformwidget.h"

#include <QGLContext>
#include <QPainter>
#include <QtDebug>

Expand Down
1 change: 0 additions & 1 deletion src/waveform/widgets/qtvsynctestwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "waveform/widgets/qtvsynctestwidget.h"

#include <QGLContext>
#include <QPainter>
#include <QtDebug>

Expand Down
1 change: 0 additions & 1 deletion src/waveform/widgets/qtwaveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "waveform/widgets/qtwaveformwidget.h"

#include <QGLContext>
#include <QPainter>
#include <QtDebug>

Expand Down
Loading