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

Clean up MixxxMainWindow and RecordingManager #2872

Merged
merged 5 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
57 changes: 20 additions & 37 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
/***************************************************************************
mixxx.cpp - description
-------------------
begin : Mon Feb 18 09:48:17 CET 2002
copyright : (C) 2002 by Tue and Ken Haste Andersen
email :
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "mixxx.h"

#include <QDesktopServices>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QGLFormat>
#include <QGLWidget>
#include <QGuiApplication>
#include <QInputMethod>
#include <QLocale>
Expand Down Expand Up @@ -90,9 +72,10 @@
#endif

#if defined(Q_OS_LINUX)
#include <QtX11Extras/QX11Info>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>

#include <QtX11Extras/QX11Info>
// Xlibint.h predates C++ and defines macros which conflict
// with references to std::max and std::min
#undef max
Expand Down Expand Up @@ -140,7 +123,7 @@ const int MixxxMainWindow::kMicrophoneCount = 4;
const int MixxxMainWindow::kAuxiliaryCount = 4;

MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args)
: m_pWidgetParent(nullptr),
: m_pRootWidget(nullptr),
m_pLaunchImage(nullptr),
m_pSettingsManager(nullptr),
m_pEffectsManager(nullptr),
Expand Down Expand Up @@ -192,8 +175,8 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args)
// First load launch image to show a the user a quick responds
m_pSkinLoader = new SkinLoader(m_pSettingsManager->settings());
m_pLaunchImage = m_pSkinLoader->loadLaunchImage(this);
m_pWidgetParent = (QWidget*)m_pLaunchImage;
setCentralWidget(m_pWidgetParent);
m_pRootWidget = (QWidget*)m_pLaunchImage;
setCentralWidget(m_pRootWidget);

show();
pApp->processEvents();
Expand Down Expand Up @@ -485,7 +468,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {

launchProgress(63);

QWidget* oldWidget = m_pWidgetParent;
QWidget* oldWidget = m_pRootWidget;

// Load default styles that can be overridden by skins
QFile file(":/skins/default.qss");
Expand All @@ -500,7 +483,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {

// Load skin to a QWidget that we set as the central widget. Assignment
// intentional in next line.
if (!(m_pWidgetParent = m_pSkinLoader->loadConfiguredSkin(this, m_pKeyboard,
if (!(m_pRootWidget = m_pSkinLoader->loadConfiguredSkin(this, m_pKeyboard,
xeruf marked this conversation as resolved.
Show resolved Hide resolved
m_pPlayerManager,
m_pControllerManager,
m_pLibrary,
Expand All @@ -510,7 +493,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
reportCriticalErrorAndQuit(
"default skin cannot be loaded see <b>mixxx</b> trace for more information.");

m_pWidgetParent = oldWidget;
m_pRootWidget = oldWidget;
//TODO (XXX) add dialog to warn user and launch skin choice page
}

Expand Down Expand Up @@ -648,7 +631,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
// this has to be after the OpenGL widgets are created or depending on a
// million different variables the first waveform may be horribly
// corrupted. See bug 521509 -- bkgood ?? -- vrince
setCentralWidget(m_pWidgetParent);
setCentralWidget(m_pRootWidget);
// The launch image widget is automatically disposed, but we still have a
// pointer to it.
m_pLaunchImage = nullptr;
Expand Down Expand Up @@ -680,7 +663,7 @@ void MixxxMainWindow::finalize() {

// GUI depends on KeyboardEventFilter, PlayerManager, Library
qDebug() << t.elapsed(false).debugMillisWithUnit() << "deleting skin";
m_pWidgetParent = nullptr;
m_pRootWidget = nullptr;
QPointer<QWidget> pSkin(centralWidget());
setCentralWidget(nullptr);
if (!pSkin.isNull()) {
Expand Down Expand Up @@ -1449,11 +1432,11 @@ void MixxxMainWindow::rebootMixxxView() {
// supports since the controls from the previous skin will be left over.
m_pMenuBar->onNewSkinAboutToLoad();

if (m_pWidgetParent) {
m_pWidgetParent->hide();
if (m_pRootWidget) {
m_pRootWidget->hide();
WaveformWidgetFactory::instance()->destroyWidgets();
delete m_pWidgetParent;
m_pWidgetParent = NULL;
delete m_pRootWidget;
m_pRootWidget = NULL;
}

// Workaround for changing skins while fullscreen, just go out of fullscreen
Expand All @@ -1465,7 +1448,7 @@ void MixxxMainWindow::rebootMixxxView() {

// Load skin to a QWidget that we set as the central widget. Assignment
// intentional in next line.
if (!(m_pWidgetParent = m_pSkinLoader->loadConfiguredSkin(this,
if (!(m_pRootWidget = m_pSkinLoader->loadConfiguredSkin(this,
m_pKeyboard,
m_pPlayerManager,
m_pControllerManager,
Expand All @@ -1481,7 +1464,7 @@ void MixxxMainWindow::rebootMixxxView() {
return;
}

setCentralWidget(m_pWidgetParent);
setCentralWidget(m_pRootWidget);
#ifdef __LINUX__
// don't adjustSize() on Linux as this wouldn't use the entire available area
// to paint the new skin with X11
Expand All @@ -1494,13 +1477,13 @@ void MixxxMainWindow::rebootMixxxView() {
slotViewFullScreen(true);
} else if (!initSize.isEmpty()) {
// Not all OSs and/or window managers keep the window inside of the screen, so force it.
int newX = initPosition.x() + (initSize.width() - m_pWidgetParent->width()) / 2;
int newY = initPosition.y() + (initSize.height() - m_pWidgetParent->height()) / 2;
int newX = initPosition.x() + (initSize.width() - m_pRootWidget->width()) / 2;
int newY = initPosition.y() + (initSize.height() - m_pRootWidget->height()) / 2;

const QScreen* primaryScreen = getPrimaryScreen();
if (primaryScreen) {
newX = std::max(0, std::min(newX, primaryScreen->geometry().width() - m_pWidgetParent->width()));
newY = std::max(0, std::min(newY, primaryScreen->geometry().height() - m_pWidgetParent->height()));
newX = std::max(0, std::min(newX, primaryScreen->geometry().width() - m_pRootWidget->width()));
newY = std::max(0, std::min(newY, primaryScreen->geometry().height() - m_pRootWidget->height()));
move(newX,newY);
} else {
qWarning() << "Unable to move window inside screen borders.";
Expand Down
82 changes: 26 additions & 56 deletions src/mixxx.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/***************************************************************************
mixxx.h - description
-------------------
begin : Mon Feb 18 09:48:17 CET 2002
copyright : (C) 2002 by Tue and Ken Haste Andersen
email :
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef MIXXX_H
#define MIXXX_H
#pragma once

#include <QMainWindow>
#include <QSharedPointer>
Expand All @@ -31,44 +13,43 @@
#include "util/db/dbconnectionpool.h"
#include "soundio/sounddeviceerror.h"

class BroadcastManager;
class ChannelHandleFactory;
class ControlPushButton;
class ControllerManager;
class ControlPushButton;
class DlgDeveloperTools;
class DlgPreferences;
class EffectsManager;
class EngineMaster;
class GuiTick;
class VisualsManager;
class KeyboardEventFilter;
class LaunchImage;
class Library;
class TrackCollectionManager;
class KeyboardEventFilter;
class PlayerManager;
class RecordingManager;
class SettingsManager;
class BroadcastManager;
class SkinLoader;
class SoundManager;
class TrackCollectionManager;
class VinylControlManager;
class VisualsManager;
class WMainMenuBar;

typedef QSharedPointer<SettingsManager> SettingsManagerPointer;

// This Class is the base class for Mixxx. It sets up the main
// window and providing a menubar.
// For the main view, an instance of class MixxxView is
// created which creates your view.
/// This Class is the base class for Mixxx. It sets up the main
/// window and providing a menubar.
/// For the main view, an instance of class MixxxView is
/// created which creates your view.
class MixxxMainWindow : public QMainWindow {
Q_OBJECT
public:
// Constructor. files is a list of command line arguments
MixxxMainWindow(QApplication *app, const CmdlineArgs& args);
~MixxxMainWindow() override;

void finalize();

// creates the menu_bar and inserts the file Menu
/// creates the menu_bar and inserts the file Menu
void createMenuBar();
void connectMenuBar();
void setInhibitScreensaver(mixxx::ScreenSaverPreference inhibit);
Expand All @@ -83,45 +64,45 @@ class MixxxMainWindow : public QMainWindow {
void rebootMixxxView();

void slotFileLoadSongPlayer(int deck);
// toggle keyboard on-off
/// toggle keyboard on-off
void slotOptionsKeyboard(bool toggle);
// Preference dialog
/// Preference dialog
void slotOptionsPreferences();
// shows an about dlg
/// shows an about dlalogg
xeruf marked this conversation as resolved.
Show resolved Hide resolved
void slotHelpAbout();
// toggle full screen mode
/// toggle full screen mode
void slotViewFullScreen(bool toggle);
// Open the developer tools dialog.
/// Open the developer tools dialog.
void slotDeveloperTools(bool enable);
void slotDeveloperToolsClosed();

void slotUpdateWindowTitle(TrackPointer pTrack);
void slotChangedPlayingDeck(int deck);

// Warn the user when inputs are not configured.
/// Warn the user when inputs are not configured.
void slotNoMicrophoneInputConfigured();
void slotNoAuxiliaryInputConfigured();
void slotNoDeckPassthroughInputConfigured();
void slotNoVinylControlInputConfigured();

signals:
void skinLoaded();
// used to uncheck the menu when the dialog of develeoper tools is closed
/// used to uncheck the menu when the dialog of develeoper tools is closed
void developerToolsDlgClosed(int r);
void closeDeveloperToolsDlgChecked(int r);
void fullScreenChanged(bool fullscreen);

protected:
// Event filter to block certain events (eg. tooltips if tooltips are disabled)
/// Event filter to block certain events (eg. tooltips if tooltips are disabled)
bool eventFilter(QObject *obj, QEvent *event) override;
void closeEvent(QCloseEvent *event) override;
bool event(QEvent* e) override;

private:
void initialize(QApplication *app, const CmdlineArgs& args);

// progresses the launch image progress bar
// this must be called from the GUi thread only
/// progresses the launch image progress bar
/// this must be called from the GUI thread only
void launchProgress(int progress);

void initializeWindow();
Expand All @@ -138,28 +119,22 @@ class MixxxMainWindow : public QMainWindow {
SoundDeviceError err, bool* retryClicked);
QDialog::DialogCode noOutputDlg(bool* continueClicked);

// Pointer to the root GUI widget
QWidget* m_pWidgetParent;
QWidget* m_pRootWidget;
xeruf marked this conversation as resolved.
Show resolved Hide resolved
LaunchImage* m_pLaunchImage;

SettingsManager* m_pSettingsManager;

// The effects processing system
/// The effects processing system
EffectsManager* m_pEffectsManager;

// The mixing engine.
/// The mixing engine.
EngineMaster* m_pEngine;

// The skin loader.
// TODO(rryan): doesn't need to be a member variable
SkinLoader* m_pSkinLoader;
SkinLoader* m_pSkinLoader; // TODO(rryan): doesn't need to be a member variable

// The sound manager
SoundManager* m_pSoundManager;

// Keeps track of players
PlayerManager* m_pPlayerManager;
// RecordingManager
RecordingManager* m_pRecordingManager;
#ifdef __BROADCAST__
BroadcastManager* m_pBroadcastManager;
Expand All @@ -173,26 +148,23 @@ class MixxxMainWindow : public QMainWindow {

KeyboardEventFilter* m_pKeyboard;

// The Mixxx database connection pool
mixxx::DbConnectionPoolPtr m_pDbConnectionPool;

TrackCollectionManager* m_pTrackCollectionManager;

// The library management object
Library* m_pLibrary;

parented_ptr<WMainMenuBar> m_pMenuBar;

DlgDeveloperTools* m_pDeveloperToolsDlg;

/** Pointer to preference dialog */
DlgPreferences* m_pPrefDlg;

ConfigObject<ConfigValueKbd>* m_pKbdConfig;
ConfigObject<ConfigValueKbd>* m_pKbdConfigEmpty;

mixxx::TooltipsPreference m_toolTipsCfg;
// Timer that tracks how long Mixxx has been running.
/// Timer that tracks how long Mixxx has been running.
Timer m_runtime_timer;

const CmdlineArgs& m_cmdLineArgs;
Expand All @@ -203,5 +175,3 @@ class MixxxMainWindow : public QMainWindow {
static const int kMicrophoneCount;
static const int kAuxiliaryCount;
};

#endif
12 changes: 3 additions & 9 deletions src/recording/recordingmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Created 03/26/2011 by Tobias Rafreider
#include "recording/recordingmanager.h"

#include <QMutex>
#include <QDir>
#include <QtDebug>
#include <QDebug>
#include <QMessageBox>
#include <QMutex>
#include <QStorageInfo>

#include <climits>

#include "control/controlproxy.h"
Expand All @@ -16,10 +13,8 @@
#include "engine/sidechain/enginesidechain.h"
#include "errordialoghandler.h"
#include "recording/defs_recording.h"
#include "recording/recordingmanager.h"

// one gibibyte
#define MIN_DISK_FREE 1024 * 1024 * 1024ll
#define MIN_DISK_FREE 1024 * 1024 * 1024ll // one gibibyte

RecordingManager::RecordingManager(UserSettingsPointer pConfig, EngineMaster* pEngine)
: m_pConfig(pConfig),
Expand All @@ -46,7 +41,6 @@ RecordingManager::RecordingManager(UserSettingsPointer pConfig, EngineMaster* pE
m_split_size = getFileSplitSize();
m_split_time = getFileSplitSeconds();


// Register EngineRecord with the engine sidechain.
EngineSideChain* pSidechain = pEngine->getSideChain();
if (pSidechain) {
Expand Down
Loading