summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Holthuis <jholthuis@mixxx.org>2021-07-15 22:57:12 +0200
committerJan Holthuis <jholthuis@mixxx.org>2021-07-30 11:55:22 +0200
commit964d9056ac693f1a94375239e0552fb80dc96acf (patch)
tree9933ee1d01f06a6302410f581d76de45374bde6e
parentec6db457f78f319141801370cfcb21a79f14b70d (diff)
main: Move some generic initialization out of MixxxMainWindow
The `MixxxMainWindow` class should not be responsible for initializing `CoreServices`. Mixxx should still be able to work when there is no `MixxxMainWindow` (e.g. when we switch to a `QQmlApplication` for QML).
-rw-r--r--src/main.cpp16
-rw-r--r--src/mixxxmainwindow.cpp19
-rw-r--r--src/mixxxmainwindow.h7
3 files changed, 22 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 65db21103f..5e41d3b6c8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,8 +23,20 @@ constexpr int kFatalErrorOnStartupExitCode = 1;
constexpr int kParseCmdlineArgsErrorExitCode = 2;
int runMixxx(MixxxApplication* app, const CmdlineArgs& args) {
- auto coreServices = std::make_shared<mixxx::CoreServices>(args);
- MixxxMainWindow mainWindow(app, coreServices);
+ const auto pCoreServices = std::make_shared<mixxx::CoreServices>(args);
+ pCoreServices->initializeSettings();
+ pCoreServices->initializeKeyboard();
+
+ MixxxMainWindow mainWindow(app, pCoreServices);
+ app->installEventFilter(&mainWindow);
+
+ QObject::connect(pCoreServices.get(),
+ &mixxx::CoreServices::initializationProgressUpdate,
+ &mainWindow,
+ &MixxxMainWindow::initializationProgressUpdate);
+ pCoreServices->initialize(app);
+ mainWindow.initialize();
+
// If startup produced a fatal error, then don't even start the
// Qt event loop.
if (ErrorDialogHandler::instance()->checkError()) {
diff --git a/src/mixxxmainwindow.cpp b/src/mixxxmainwindow.cpp
index bf1b751a49..09c378e4f4 100644
--- a/src/mixxxmainwindow.cpp
+++ b/src/mixxxmainwindow.cpp
@@ -105,8 +105,6 @@ MixxxMainWindow::MixxxMainWindow(
m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON) {
DEBUG_ASSERT(pApp);
DEBUG_ASSERT(pCoreServices);
- m_pCoreServices->initializeSettings();
- m_pCoreServices->initializeKeyboard();
// These depend on the settings
createMenuBar();
m_pMenuBar->hide();
@@ -124,15 +122,9 @@ MixxxMainWindow::MixxxMainWindow(
m_pGuiTick = new GuiTick();
m_pVisualsManager = new VisualsManager();
+}
- connect(
- m_pCoreServices.get(),
- &mixxx::CoreServices::initializationProgressUpdate,
- this,
- &MixxxMainWindow::initializationProgressUpdate);
-
- m_pCoreServices->initialize(pApp);
-
+void MixxxMainWindow::initialize() {
m_pCoreServices->getControlIndicatorTimer()->setLegacyVsyncEnabled(true);
UserSettingsPointer pConfig = m_pCoreServices->getSettings();
@@ -168,6 +160,8 @@ MixxxMainWindow::MixxxMainWindow(
initializationProgressUpdate(65, tr("skin"));
+ // Install an event filter to catch certain QT events, such as tooltips.
+ // This allows us to turn off tooltips.
installEventFilter(m_pCoreServices->getKeyboardEventFilter().get());
DEBUG_ASSERT(m_pCoreServices->getPlayerManager());
@@ -274,11 +268,6 @@ MixxxMainWindow::MixxxMainWindow(
checkDirectRendering();
}
- // Install an event filter to catch certain QT events, such as tooltips.
- // This allows us to turn off tooltips.
- pApp->installEventFilter(this); // The eventfilter is located in this
- // Mixxx class as a callback.
-
// Try open player device If that fails, the preference panel is opened.
bool retryClicked;
do {
diff --git a/src/mixxxmainwindow.h b/src/mixxxmainwindow.h
index d2adb8623f..d3a1d8f9f8 100644
--- a/src/mixxxmainwindow.h
+++ b/src/mixxxmainwindow.h
@@ -50,6 +50,8 @@ class MixxxMainWindow : public QMainWindow {
MixxxMainWindow(QApplication* app, std::shared_ptr<mixxx::CoreServices> pCoreServices);
~MixxxMainWindow() override;
+ /// Initialize main window after creation. Should only be called once.
+ void initialize();
/// creates the menu_bar and inserts the file Menu
void createMenuBar();
void connectMenuBar();
@@ -82,6 +84,8 @@ class MixxxMainWindow : public QMainWindow {
void slotNoDeckPassthroughInputConfigured();
void slotNoVinylControlInputConfigured();
+ void initializationProgressUpdate(int progress, const QString& serviceName);
+
private slots:
void slotTooltipModeChanged(mixxx::TooltipsPreference tt);
@@ -97,9 +101,6 @@ class MixxxMainWindow : public QMainWindow {
bool eventFilter(QObject *obj, QEvent *event) override;
void closeEvent(QCloseEvent *event) override;
- private slots:
- void initializationProgressUpdate(int progress, const QString& serviceName);
-
private:
void initializeWindow();
void checkDirectRendering();