Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1692,9 +1692,7 @@ if(QT6)
else()
add_executable(mixxx WIN32 src/main.cpp)
endif()
# ugly hack to get #include "preferences/dialog/ui_dlgpreferencesdlg.h" to work in
# src/qmldlgpreferencesproxy.h, which is #included from src/qmlapplication.h.
target_include_directories(mixxx PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/mixxx-lib_autogen/include")

set_target_properties(mixxx-lib PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
target_link_libraries(mixxx PRIVATE mixxx-lib mixxx-gitinfostore)

Expand Down
16 changes: 16 additions & 0 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "mixer/playerinfo.h"
#include "mixer/playermanager.h"
#include "moc_coreservices.cpp"
#include "preferences/dialog/dlgpreferences.h"
#include "preferences/settingsmanager.h"
#ifdef __MODPLUG__
#include "preferences/dialog/dlgprefmodplug.h"
Expand Down Expand Up @@ -527,6 +528,21 @@ bool CoreServices::initializeDatabase() {
return MixxxDb::initDatabaseSchema(dbConnection);
}

std::shared_ptr<QDialog> CoreServices::makeDlgPreferences() const {
// Note: We return here the base class pointer to make the coreservices.h usable
// in test classes where header included from dlgpreferences.h are not accessible.
std::shared_ptr<DlgPreferences> pDlgPreferences = std::make_shared<DlgPreferences>(
getScreensaverManager(),
nullptr,
getSoundManager(),
getControllerManager(),
getVinylControlManager(),
getEffectsManager(),
getSettingsManager(),
getLibrary());
return pDlgPreferences;
}

void CoreServices::finalize() {
VERIFY_OR_DEBUG_ASSERT(m_isInitialized) {
qDebug() << "Skipping CoreServices finalization because it was never initialized.";
Expand Down
2 changes: 2 additions & 0 deletions src/coreservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class CoreServices : public QObject {
return m_pScreensaverManager;
}

std::shared_ptr<QDialog> makeDlgPreferences() const;

signals:
void initializationProgressUpdate(int progress, const QString& serviceName);

Expand Down
14 changes: 3 additions & 11 deletions src/qml/qmlapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,11 @@ QmlApplication::QmlApplication(

// FIXME: DlgPreferences has some initialization logic that must be executed
// before the GUI is shown, at least for the effects system.
m_pDlgPreferences = std::make_shared<DlgPreferences>(
m_pCoreServices->getScreensaverManager(),
nullptr,
m_pCoreServices->getSoundManager(),
m_pCoreServices->getControllerManager(),
m_pCoreServices->getVinylControlManager(),
m_pCoreServices->getEffectsManager(),
m_pCoreServices->getSettingsManager(),
m_pCoreServices->getLibrary());
std::shared_ptr<QDialog> pDlgPreferences = m_pCoreServices->makeDlgPreferences();
// Without this, QApplication will quit when the last QWidget QWindow is
// closed because it does not take into account the window created by
// the QQmlApplicationEngine.
m_pDlgPreferences->setAttribute(Qt::WA_QuitOnClose, false);
pDlgPreferences->setAttribute(Qt::WA_QuitOnClose, false);

// Any uncreateable non-singleton types registered here require arguments
// that we don't want to expose to QML directly. Instead, they can be
Expand All @@ -78,7 +70,7 @@ QmlApplication::QmlApplication(
// system, which would improve nothing, or we had to expose them as
// singletons to that they can be accessed by components instantiated by
// QML, which would also be suboptimal.
QmlDlgPreferencesProxy::s_pInstance = new QmlDlgPreferencesProxy(m_pDlgPreferences, this);
QmlDlgPreferencesProxy::s_pInstance = new QmlDlgPreferencesProxy(pDlgPreferences, this);
QmlEffectsManagerProxy::s_pInstance = new QmlEffectsManagerProxy(
pCoreServices->getEffectsManager(), this);
QmlPlayerManagerProxy::s_pInstance =
Expand Down
2 changes: 0 additions & 2 deletions src/qml/qmlapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <QQmlApplicationEngine>

#include "coreservices.h"
#include "preferences/dialog/dlgpreferences.h"

namespace mixxx {
namespace qml {
Expand All @@ -28,7 +27,6 @@ class QmlApplication : public QObject {

std::unique_ptr<QQmlApplicationEngine> m_pAppEngine;
QFileSystemWatcher m_fileWatcher;
std::shared_ptr<DlgPreferences> m_pDlgPreferences;
};

} // namespace qml
Expand Down
6 changes: 4 additions & 2 deletions src/qml/qmldlgpreferencesproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace mixxx {
namespace qml {

QmlDlgPreferencesProxy::QmlDlgPreferencesProxy(
std::shared_ptr<DlgPreferences> pDlgPreferences, QObject* parent)
std::shared_ptr<QDialog> pDlgPreferences,
QObject* parent)
: QObject(parent),
m_pDlgPreferences(pDlgPreferences) {
}
Expand All @@ -17,7 +18,8 @@ void QmlDlgPreferencesProxy::show() {

// static
QmlDlgPreferencesProxy* QmlDlgPreferencesProxy::create(
QQmlEngine* pQmlEngine, QJSEngine* pJsEngine) {
QQmlEngine* pQmlEngine,
QJSEngine* pJsEngine) {
Q_UNUSED(pQmlEngine);

// The implementation of this method is mostly taken from the code example
Expand Down
8 changes: 4 additions & 4 deletions src/qml/qmldlgpreferencesproxy.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <QDialog>
#include <QObject>
#include <QtQml>
#include <memory>

#include "preferences/dialog/dlgpreferences.h"

namespace mixxx {
namespace qml {

Expand All @@ -14,7 +14,7 @@ class QmlDlgPreferencesProxy : public QObject {
QML_SINGLETON
public:
explicit QmlDlgPreferencesProxy(
std::shared_ptr<DlgPreferences> pDlgPreferences,
std::shared_ptr<QDialog> pDlgPreferences,
QObject* parent = nullptr);

Q_INVOKABLE void show();
Expand All @@ -24,7 +24,7 @@ class QmlDlgPreferencesProxy : public QObject {

private:
static inline QJSEngine* s_pJsEngine = nullptr;
std::shared_ptr<DlgPreferences> m_pDlgPreferences;
std::shared_ptr<QDialog> m_pDlgPreferences;
};

} // namespace qml
Expand Down