Skip to content

Commit

Permalink
use std::shared_ptr for managers in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Dec 14, 2020
1 parent f754682 commit f90e4ec
Show file tree
Hide file tree
Showing 28 changed files with 187 additions and 143 deletions.
4 changes: 2 additions & 2 deletions src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const QString kPresetExt(".midi.xml");
DlgPrefController::DlgPrefController(
QWidget* parent,
Controller* controller,
ControllerManager* controllerManager,
std::shared_ptr<ControllerManager> controllerManager,
UserSettingsPointer pConfig)
: DlgPreferencePage(parent),
m_pConfig(pConfig),
Expand Down Expand Up @@ -86,7 +86,7 @@ DlgPrefController::DlgPrefController(
// Connect our signals to controller manager.
connect(this,
&DlgPrefController::applyPreset,
m_pControllerManager,
m_pControllerManager.get(),
&ControllerManager::slotApplyPreset);

// Open script file links
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/dlgprefcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class PresetInfoEnumerator;
class DlgPrefController : public DlgPreferencePage {
Q_OBJECT
public:
DlgPrefController(QWidget *parent, Controller* controller,
ControllerManager* controllerManager,
UserSettingsPointer pConfig);
DlgPrefController(QWidget* parent,
Controller* controller,
std::shared_ptr<ControllerManager> controllerManager,
UserSettingsPointer pConfig);
virtual ~DlgPrefController();

QUrl helpUrl() const override;
Expand Down Expand Up @@ -106,7 +107,7 @@ class DlgPrefController : public DlgPreferencePage {
Ui::DlgPrefControllerDlg m_ui;
UserSettingsPointer m_pConfig;
const QString m_pUserDir;
ControllerManager* m_pControllerManager;
std::shared_ptr<ControllerManager> m_pControllerManager;
Controller* m_pController;
DlgControllerLearning* m_pDlgControllerLearning;
ControllerPresetPointer m_pPreset;
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "preferences/dialog/dlgpreferences.h"

DlgPrefControllers::DlgPrefControllers(DlgPreferences* pPreferences,
UserSettingsPointer pConfig,
ControllerManager* pControllerManager,
QTreeWidgetItem* pControllerTreeItem)
UserSettingsPointer pConfig,
std::shared_ptr<ControllerManager> pControllerManager,
QTreeWidgetItem* pControllerTreeItem)
: DlgPreferencePage(pPreferences),
m_pDlgPreferences(pPreferences),
m_pConfig(pConfig),
Expand All @@ -27,7 +27,7 @@ DlgPrefControllers::DlgPrefControllers(DlgPreferences* pPreferences,
});

// Connections
connect(m_pControllerManager,
connect(m_pControllerManager.get(),
&ControllerManager::devicesChanged,
this,
&DlgPrefControllers::rescanControllers);
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/dlgprefcontrollers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle
Q_OBJECT
public:
DlgPrefControllers(DlgPreferences* pDlgPreferences,
UserSettingsPointer pConfig,
ControllerManager* pControllerManager,
QTreeWidgetItem* pControllerTreeItem);
UserSettingsPointer pConfig,
std::shared_ptr<ControllerManager> pControllerManager,
QTreeWidgetItem* pControllerTreeItem);
virtual ~DlgPrefControllers();

bool handleTreeItemClick(QTreeWidgetItem* clickedItem);
Expand All @@ -47,7 +47,7 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle

DlgPreferences* m_pDlgPreferences;
UserSettingsPointer m_pConfig;
ControllerManager* m_pControllerManager;
std::shared_ptr<ControllerManager> m_pControllerManager;
QTreeWidgetItem* m_pControllerTreeItem;
QList<DlgPrefController*> m_controllerWindows;
QList<QTreeWidgetItem*> m_controllerTreeItems;
Expand Down
16 changes: 8 additions & 8 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ MixxxMainWindow::MixxxMainWindow(
// Initialize preference dialog
m_pPrefDlg = new DlgPreferences(
this,
m_pSkinLoader.get(),
m_pCoreServices->getSoundManager().get(),
m_pCoreServices->getPlayerManager().get(),
m_pCoreServices->getControllerManager().get(),
m_pCoreServices->getVinylControlManager().get(),
m_pSkinLoader,
m_pCoreServices->getSoundManager(),
m_pCoreServices->getPlayerManager(),
m_pCoreServices->getControllerManager(),
m_pCoreServices->getVinylControlManager(),
m_pCoreServices->getLV2Backend(),
m_pCoreServices->getEffectsManager().get(),
m_pCoreServices->getSettingsManager().get(),
m_pCoreServices->getLibrary().get());
m_pCoreServices->getEffectsManager(),
m_pCoreServices->getSettingsManager(),
m_pCoreServices->getLibrary());
m_pPrefDlg->setWindowIcon(QIcon(":/images/mixxx_icon.svg"));
m_pPrefDlg->setHidden(true);

Expand Down
2 changes: 1 addition & 1 deletion src/mixxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MixxxMainWindow : public QMainWindow {
QWidget* m_pCentralWidget;
LaunchImage* m_pLaunchImage;

std::unique_ptr<SkinLoader> m_pSkinLoader;
std::shared_ptr<SkinLoader> m_pSkinLoader;
GuiTick* m_pGuiTick;
VisualsManager* m_pVisualsManager;

Expand Down
4 changes: 3 additions & 1 deletion src/preferences/dialog/dlgprefcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const ConfigKey kLoopDefaultColorIndexConfigKey("[Controls]", "LoopDefaultColorI
} // anonymous namespace

DlgPrefColors::DlgPrefColors(
QWidget* parent, UserSettingsPointer pConfig, Library* pLibrary)
QWidget* parent,
UserSettingsPointer pConfig,
std::shared_ptr<Library> pLibrary)
: DlgPreferencePage(parent),
m_pConfig(pConfig),
m_colorPaletteSettings(ColorPaletteSettings(pConfig)),
Expand Down
5 changes: 4 additions & 1 deletion src/preferences/dialog/dlgprefcolors.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class Library;
class DlgPrefColors : public DlgPreferencePage, public Ui::DlgPrefColorsDlg {
Q_OBJECT
public:
DlgPrefColors(QWidget* parent, UserSettingsPointer pConfig, Library* pLibrary);
DlgPrefColors(
QWidget* parent,
UserSettingsPointer pConfig,
std::shared_ptr<Library> pLibrary);
virtual ~DlgPrefColors();

public slots:
Expand Down
8 changes: 4 additions & 4 deletions src/preferences/dialog/dlgprefeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#include "moc_dlgprefeffects.cpp"

DlgPrefEffects::DlgPrefEffects(QWidget* pParent,
UserSettingsPointer pConfig,
EffectsManager* pEffectsManager)
UserSettingsPointer pConfig,
std::shared_ptr<EffectsManager> pEffectsManager)
: DlgPreferencePage(pParent),
m_pConfig(pConfig),
m_pEffectsManager(pEffectsManager) {
setupUi(this);

m_availableEffectsModel.resetFromEffectManager(pEffectsManager);
m_availableEffectsModel.resetFromEffectManager(pEffectsManager.get());
const QList<EffectProfilePtr> effectProfiles = m_availableEffectsModel.profiles();
for (auto& profile : effectProfiles) {
EffectManifestPointer pManifest = profile->pManifest;
Expand Down Expand Up @@ -49,7 +49,7 @@ DlgPrefEffects::~DlgPrefEffects() {

void DlgPrefEffects::slotUpdate() {
clear();
m_availableEffectsModel.resetFromEffectManager(m_pEffectsManager);
m_availableEffectsModel.resetFromEffectManager(m_pEffectsManager.get());

if (!m_availableEffectsModel.isEmpty()) {
availableEffectsList->selectRow(0);
Expand Down
6 changes: 3 additions & 3 deletions src/preferences/dialog/dlgprefeffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg {
Q_OBJECT
public:
DlgPrefEffects(QWidget* pParent,
UserSettingsPointer pConfig,
EffectsManager* pEffectsManager);
UserSettingsPointer pConfig,
std::shared_ptr<EffectsManager> pEffectsManager);
virtual ~DlgPrefEffects();

void slotUpdate() override;
Expand All @@ -29,5 +29,5 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg {

EffectSettingsModel m_availableEffectsModel;
UserSettingsPointer m_pConfig;
EffectsManager* m_pEffectsManager;
std::shared_ptr<EffectsManager> m_pEffectsManager;
};
8 changes: 5 additions & 3 deletions src/preferences/dialog/dlgprefeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const QString kDefaultQuickEffectId = FilterEffect::getId();
const int kFrequencyUpperLimit = 20050;
const int kFrequencyLowerLimit = 16;

DlgPrefEQ::DlgPrefEQ(QWidget* pParent, EffectsManager* pEffectsManager,
UserSettingsPointer pConfig)
DlgPrefEQ::DlgPrefEQ(
QWidget* pParent,
std::shared_ptr<EffectsManager> pEffectsManager,
UserSettingsPointer pConfig)
: DlgPreferencePage(pParent),
m_COLoFreq(kConfigKey, "LoEQFrequency"),
m_COHiFreq(kConfigKey, "HiEQFrequency"),
Expand Down Expand Up @@ -722,7 +724,7 @@ void DlgPrefEQ::slotMasterEqEffectChanged(int effectIndex) {
if (pChainSlot) {
EffectChainPointer pChain = pChainSlot->getEffectChain();
VERIFY_OR_DEBUG_ASSERT(pChain) {
pChain = pChainSlot->getOrCreateEffectChain(m_pEffectsManager);
pChain = pChainSlot->getOrCreateEffectChain(m_pEffectsManager.get());
}
EffectPointer pEffect = m_pEffectsManager->instantiateEffect(effectId);
pChain->replaceEffect(0, pEffect);
Expand Down
8 changes: 5 additions & 3 deletions src/preferences/dialog/dlgprefeq.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
class DlgPrefEQ : public DlgPreferencePage, public Ui::DlgPrefEQDlg {
Q_OBJECT
public:
DlgPrefEQ(QWidget *parent, EffectsManager* pEffectsManager,
UserSettingsPointer _config);
DlgPrefEQ(
QWidget* parent,
std::shared_ptr<EffectsManager> pEffectsManager,
UserSettingsPointer _config);
virtual ~DlgPrefEQ();

QUrl helpUrl() const override;
Expand Down Expand Up @@ -66,7 +68,7 @@ class DlgPrefEQ : public DlgPreferencePage, public Ui::DlgPrefEQDlg {
double m_lowEqFreq, m_highEqFreq;

// Members needed for changing the effects loaded on the EQ Effect Rack
EffectsManager* m_pEffectsManager;
std::shared_ptr<EffectsManager> m_pEffectsManager;
EqualizerRackPointer m_pEQEffectRack;
QuickEffectRackPointer m_pQuickEffectRack;
OutputEffectRackPointer m_pOutputEffectRack;
Expand Down
12 changes: 11 additions & 1 deletion src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@
#include "skin/skinloader.h"
#include "util/widgethelper.h"

DlgPreferences::DlgPreferences(MixxxMainWindow* mixxx, SkinLoader* pSkinLoader, SoundManager* soundman, PlayerManager* pPlayerManager, ControllerManager* controllers, VinylControlManager* pVCManager, LV2Backend* pLV2Backend, EffectsManager* pEffectsManager, SettingsManager* pSettingsManager, Library* pLibrary)
DlgPreferences::DlgPreferences(
MixxxMainWindow* mixxx,
std::shared_ptr<SkinLoader> pSkinLoader,
std::shared_ptr<SoundManager> soundman,
std::shared_ptr<PlayerManager> pPlayerManager,
std::shared_ptr<ControllerManager> controllers,
std::shared_ptr<VinylControlManager> pVCManager,
LV2Backend* pLV2Backend,
std::shared_ptr<EffectsManager> pEffectsManager,
std::shared_ptr<SettingsManager> pSettingsManager,
std::shared_ptr<Library> pLibrary)
: m_allPages(),
m_pConfig(pSettingsManager->settings()),
m_pageSizeHint(QSize(0, 0)) {
Expand Down
18 changes: 9 additions & 9 deletions src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
QTreeWidgetItem* pTreeItem;
};

DlgPreferences(MixxxMainWindow* mixxx,
SkinLoader* pSkinLoader,
SoundManager* soundman,
PlayerManager* pPlayerManager,
ControllerManager* controllers,
VinylControlManager* pVCManager,
DlgPreferences(MixxxMainWindow* mixxx,
std::shared_ptr<SkinLoader> pSkinLoader,
std::shared_ptr<SoundManager> soundman,
std::shared_ptr<PlayerManager> pPlayerManager,
std::shared_ptr<ControllerManager> controllers,
std::shared_ptr<VinylControlManager> pVCManager,
LV2Backend* pLV2Backend,
EffectsManager* pEffectsManager,
SettingsManager* pSettingsManager,
Library* pLibrary);
std::shared_ptr<EffectsManager> pEffectsManager,
std::shared_ptr<SettingsManager> pSettingsManager,
std::shared_ptr<Library> pLibrary);
virtual ~DlgPreferences();

void addPageWidget(PreferencesPage page);
Expand Down
26 changes: 14 additions & 12 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,20 @@ bool skinFitsScreenSize(

} // namespace

DlgPrefInterface::DlgPrefInterface(QWidget * parent, MixxxMainWindow * mixxx,
SkinLoader* pSkinLoader,
UserSettingsPointer pConfig)
: DlgPreferencePage(parent),
m_pConfig(pConfig),
m_mixxx(mixxx),
m_pSkinLoader(pSkinLoader),
m_dScaleFactorAuto(1.0),
m_bUseAutoScaleFactor(false),
m_dScaleFactor(1.0),
m_bStartWithFullScreen(false),
m_bRebootMixxxView(false) {
DlgPrefInterface::DlgPrefInterface(
QWidget* parent,
MixxxMainWindow* mixxx,
std::shared_ptr<SkinLoader> pSkinLoader,
UserSettingsPointer pConfig)
: DlgPreferencePage(parent),
m_pConfig(pConfig),
m_mixxx(mixxx),
m_pSkinLoader(pSkinLoader),
m_dScaleFactorAuto(1.0),
m_bUseAutoScaleFactor(false),
m_dScaleFactor(1.0),
m_bStartWithFullScreen(false),
m_bRebootMixxxView(false) {
setupUi(this);

//
Expand Down
10 changes: 6 additions & 4 deletions src/preferences/dialog/dlgprefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ class ControlObject;
class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg {
Q_OBJECT
public:
DlgPrefInterface(QWidget *parent, MixxxMainWindow *mixxx,
SkinLoader* pSkinLoader, UserSettingsPointer pConfig);
DlgPrefInterface(
QWidget* parent,
MixxxMainWindow* mixxx,
std::shared_ptr<SkinLoader> pSkinLoader,
UserSettingsPointer pConfig);
~DlgPrefInterface() override = default;

public slots:
Expand Down Expand Up @@ -48,8 +51,7 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
UserSettingsPointer m_pConfig;
ControlObject* m_pControlTrackTimeDisplay;
MixxxMainWindow *m_mixxx;
SkinLoader* m_pSkinLoader;
PlayerManager* m_pPlayerManager;
std::shared_ptr<SkinLoader> m_pSkinLoader;

QString m_skin;
QString m_skinOnUpdate;
Expand Down
8 changes: 4 additions & 4 deletions src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace {
DlgPrefLibrary::DlgPrefLibrary(
QWidget* pParent,
UserSettingsPointer pConfig,
Library* pLibrary)
std::shared_ptr<Library> pLibrary)
: DlgPreferencePage(pParent),
m_dirListModel(),
m_pConfig(pConfig),
Expand All @@ -34,15 +34,15 @@ DlgPrefLibrary::DlgPrefLibrary(

connect(this,
&DlgPrefLibrary::requestAddDir,
m_pLibrary,
m_pLibrary.get(),
&Library::slotRequestAddDir);
connect(this,
&DlgPrefLibrary::requestRemoveDir,
m_pLibrary,
m_pLibrary.get(),
&Library::slotRequestRemoveDir);
connect(this,
&DlgPrefLibrary::requestRelocateDir,
m_pLibrary,
m_pLibrary.get(),
&Library::slotRequestRelocateDir);
connect(PushButtonAddDir,
&QPushButton::clicked,
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgpreflibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DlgPrefLibrary : public DlgPreferencePage, public Ui::DlgPrefLibraryDlg {
DlgPrefLibrary(
QWidget* pParent,
UserSettingsPointer pConfig,
Library* pLibrary);
std::shared_ptr<Library> pLibrary);
~DlgPrefLibrary() override {}

QUrl helpUrl() const override;
Expand Down Expand Up @@ -62,7 +62,7 @@ class DlgPrefLibrary : public DlgPreferencePage, public Ui::DlgPrefLibraryDlg {

QStandardItemModel m_dirListModel;
UserSettingsPointer m_pConfig;
Library* m_pLibrary;
std::shared_ptr<Library> m_pLibrary;
bool m_bAddedDirectory;
QFont m_originalTrackTableFont;
int m_iOriginalTrackTableRowHeight;
Expand Down
7 changes: 4 additions & 3 deletions src/preferences/dialog/dlgpreflv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include "moc_dlgpreflv2.cpp"
#include "util/math.h"

DlgPrefLV2::DlgPrefLV2(QWidget* pParent, LV2Backend* lv2Backend,
UserSettingsPointer pConfig,
EffectsManager* pEffectsManager)
DlgPrefLV2::DlgPrefLV2(QWidget* pParent,
LV2Backend* lv2Backend,
UserSettingsPointer pConfig,
std::shared_ptr<EffectsManager> pEffectsManager)
: DlgPreferencePage(pParent),
m_pLV2Backend(lv2Backend),
m_iCheckedParameters(0),
Expand Down
Loading

0 comments on commit f90e4ec

Please sign in to comment.