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

Preferences: Remove all references to MixxxMainWindow #4109

Merged
merged 6 commits into from
Jul 21, 2021
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/util/sandbox.cpp
src/util/semanticversion.cpp
src/util/screensaver.cpp
src/util/screensavermanager.cpp
src/util/sleepableqthread.cpp
src/util/stat.cpp
src/util/statmodel.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "util/font.h"
#include "util/logger.h"
#include "util/screensaver.h"
#include "util/screensavermanager.h"
#include "util/statsmanager.h"
#include "util/time.h"
#include "util/translations.h"
Expand Down Expand Up @@ -261,6 +262,13 @@ void CoreServices::initialize(QApplication* pApp) {
m_pVCManager->init();
#endif

// Inhibit Screensaver
m_pScreensaverManager = std::make_shared<ScreensaverManager>(pConfig);
connect(&PlayerInfo::instance(),
&PlayerInfo::currentPlayingDeckChanged,
m_pScreensaverManager.get(),
&ScreensaverManager::slotCurrentPlayingDeckChanged);

emit initializationProgressUpdate(50, tr("library"));
CoverArtCache::createInstance();

Expand Down
8 changes: 8 additions & 0 deletions src/coreservices.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LV2Backend;
namespace mixxx {

class DbConnectionPool;
class ScreensaverManager;

class CoreServices : public QObject {
Q_OBJECT
Expand All @@ -39,6 +40,7 @@ class CoreServices : public QObject {
void initializeSettings();
// FIXME: should be private, but WMainMenuBar needs it initialized early
void initializeKeyboard();
void initializeScreensaverManager();
void initialize(QApplication* pApp);
void shutdown();

Expand Down Expand Up @@ -100,6 +102,10 @@ class CoreServices : public QObject {
return m_pSettingsManager->settings();
}

std::shared_ptr<ScreensaverManager> getScreensaverManager() const {
return m_pScreensaverManager;
}

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

Expand Down Expand Up @@ -132,6 +138,8 @@ class CoreServices : public QObject {
std::shared_ptr<ConfigObject<ConfigValueKbd>> m_pKbdConfig;
std::shared_ptr<ConfigObject<ConfigValueKbd>> m_pKbdConfigEmpty;

std::shared_ptr<mixxx::ScreensaverManager> m_pScreensaverManager;

std::unique_ptr<ControlPushButton> m_pTouchShift;

Timer m_runtime_timer;
Expand Down
77 changes: 13 additions & 64 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,10 @@ MixxxMainWindow::MixxxMainWindow(
this,
&MixxxMainWindow::initializationProgressUpdate);

// Inhibit the screensaver if the option is set. (Do it before creating the preferences dialog)
UserSettingsPointer pConfig = m_pCoreServices->getSettings();
int inhibit = pConfig->getValue<int>(ConfigKey("[Config]", "InhibitScreensaver"), -1);
if (inhibit == -1) {
inhibit = static_cast<int>(mixxx::ScreenSaverPreference::PREVENT_ON);
pConfig->setValue<int>(ConfigKey("[Config]", "InhibitScreensaver"), inhibit);
}
m_inhibitScreensaver = static_cast<mixxx::ScreenSaverPreference>(inhibit);
if (m_inhibitScreensaver == mixxx::ScreenSaverPreference::PREVENT_ON) {
mixxx::ScreenSaverHelper::inhibit();
}

m_pCoreServices->initialize(pApp);

UserSettingsPointer pConfig = m_pCoreServices->getSettings();

// Set the visibility of tooltips, default "1" = ON
m_toolTipsCfg = static_cast<mixxx::TooltipsPreference>(
pConfig->getValue(ConfigKey("[Controls]", "Tooltips"),
Expand Down Expand Up @@ -229,7 +219,7 @@ MixxxMainWindow::MixxxMainWindow(

// Initialize preference dialog
m_pPrefDlg = new DlgPreferences(
this,
m_pCoreServices->getScreensaverManager(),
m_pSkinLoader,
m_pCoreServices->getSoundManager(),
m_pCoreServices->getPlayerManager(),
Expand All @@ -241,6 +231,15 @@ MixxxMainWindow::MixxxMainWindow(
m_pCoreServices->getLibrary());
m_pPrefDlg->setWindowIcon(QIcon(":/images/icons/mixxx.svg"));
m_pPrefDlg->setHidden(true);
connect(m_pPrefDlg,
&DlgPreferences::tooltipModeChanged,
this,
&MixxxMainWindow::slotTooltipModeChanged);
connect(m_pPrefDlg,
&DlgPreferences::reloadUserInterface,
this,
&MixxxMainWindow::rebootMixxxView,
Qt::DirectConnection);

// Connect signals to the menubar. Should be done before emit newSkinLoaded.
connectMenuBar();
Expand Down Expand Up @@ -346,20 +345,12 @@ MixxxMainWindow::MixxxMainWindow(
&PlayerInfo::currentPlayingTrackChanged,
this,
&MixxxMainWindow::slotUpdateWindowTitle);
connect(&PlayerInfo::instance(),
&PlayerInfo::currentPlayingDeckChanged,
this,
&MixxxMainWindow::slotChangedPlayingDeck);
}

MixxxMainWindow::~MixxxMainWindow() {
Timer t("~MixxxMainWindow");
t.start();

if (m_inhibitScreensaver != mixxx::ScreenSaverPreference::PREVENT_OFF) {
mixxx::ScreenSaverHelper::uninhibit();
}

// Save the current window state (position, maximized, etc)
// Note(ronso0): Unfortunately saveGeometry() also stores the fullscreen state.
// On next start restoreGeometry would enable fullscreen mode even though that
Expand Down Expand Up @@ -440,10 +431,6 @@ MixxxMainWindow::~MixxxMainWindow() {
delete m_pGuiTick;
delete m_pVisualsManager;

if (m_inhibitScreensaver != mixxx::ScreenSaverPreference::PREVENT_OFF) {
mixxx::ScreenSaverHelper::uninhibit();
}

m_pCoreServices->shutdown();
}

Expand Down Expand Up @@ -985,17 +972,6 @@ void MixxxMainWindow::slotNoAuxiliaryInputConfigured() {
}
}

void MixxxMainWindow::slotChangedPlayingDeck(int deck) {
if (m_inhibitScreensaver == mixxx::ScreenSaverPreference::PREVENT_ON_PLAY) {
if (deck==-1) {
// If no deck is playing, allow the screensaver to run.
mixxx::ScreenSaverHelper::uninhibit();
} else {
mixxx::ScreenSaverHelper::inhibit();
}
}
}

void MixxxMainWindow::slotHelpAbout() {
DlgAbout* about = new DlgAbout(this);
about->show();
Expand All @@ -1018,10 +994,7 @@ void MixxxMainWindow::slotShowKeywheel(bool toggle) {
}
}

void MixxxMainWindow::setToolTipsCfg(mixxx::TooltipsPreference tt) {
UserSettingsPointer pConfig = m_pCoreServices->getSettings();
pConfig->set(ConfigKey("[Controls]","Tooltips"),
ConfigValue(static_cast<int>(tt)));
void MixxxMainWindow::slotTooltipModeChanged(mixxx::TooltipsPreference tt) {
m_toolTipsCfg = tt;
}

Expand Down Expand Up @@ -1219,30 +1192,6 @@ bool MixxxMainWindow::confirmExit() {
return true;
}

void MixxxMainWindow::setInhibitScreensaver(mixxx::ScreenSaverPreference newInhibit)
{
UserSettingsPointer pConfig = m_pCoreServices->getSettings();

if (m_inhibitScreensaver != mixxx::ScreenSaverPreference::PREVENT_OFF) {
mixxx::ScreenSaverHelper::uninhibit();
}

if (newInhibit == mixxx::ScreenSaverPreference::PREVENT_ON) {
mixxx::ScreenSaverHelper::inhibit();
} else if (newInhibit == mixxx::ScreenSaverPreference::PREVENT_ON_PLAY
&& PlayerInfo::instance().getCurrentPlayingDeck()!=-1) {
mixxx::ScreenSaverHelper::inhibit();
}
int inhibit_int = static_cast<int>(newInhibit);
pConfig->setValue<int>(ConfigKey("[Config]","InhibitScreensaver"), inhibit_int);
m_inhibitScreensaver = newInhibit;
}

mixxx::ScreenSaverPreference MixxxMainWindow::getInhibitScreensaver()
{
return m_inhibitScreensaver;
}

void MixxxMainWindow::initializationProgressUpdate(int progress, const QString& serviceName) {
if (m_pLaunchImage) {
m_pLaunchImage->progress(progress, serviceName);
Expand Down
7 changes: 3 additions & 4 deletions src/mixxxmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class MixxxMainWindow : public QMainWindow {
void setInhibitScreensaver(mixxx::ScreenSaverPreference inhibit);
mixxx::ScreenSaverPreference getInhibitScreensaver();

void setToolTipsCfg(mixxx::TooltipsPreference tt);
inline mixxx::TooltipsPreference getToolTipsCfg() { return m_toolTipsCfg; }

inline GuiTick* getGuiTick() { return m_pGuiTick; };

public slots:
Expand All @@ -78,14 +75,16 @@ class MixxxMainWindow : public QMainWindow {
void slotDeveloperToolsClosed();

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

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

private slots:
void slotTooltipModeChanged(mixxx::TooltipsPreference tt);

signals:
void skinLoaded();
/// used to uncheck the menu when the dialog of developer tools is closed
Expand Down
29 changes: 24 additions & 5 deletions src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "util/widgethelper.h"

DlgPreferences::DlgPreferences(
MixxxMainWindow* mixxx,
std::shared_ptr<mixxx::ScreensaverManager> pScreensaverManager,
std::shared_ptr<mixxx::skin::SkinLoader> pSkinLoader,
std::shared_ptr<SoundManager> pSoundManager,
std::shared_ptr<PlayerManager> pPlayerManager,
Expand Down Expand Up @@ -133,17 +133,36 @@ DlgPreferences::DlgPreferences(
"ic_preferences_vinyl.svg");
#endif // __VINYLCONTROL__

addPageWidget(PreferencesPage(
new DlgPrefInterface(this, mixxx, pSkinLoader, m_pConfig),
new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type)),
DlgPrefInterface* pInterfacePage = new DlgPrefInterface(this,
pScreensaverManager,
pSkinLoader,
m_pConfig);
connect(pInterfacePage,
&DlgPrefInterface::tooltipModeChanged,
this,
&DlgPreferences::tooltipModeChanged);
connect(pInterfacePage,
&DlgPrefInterface::reloadUserInterface,
this,
&DlgPreferences::reloadUserInterface,
Qt::DirectConnection);
addPageWidget(PreferencesPage(pInterfacePage,
new QTreeWidgetItem(
contentsTreeWidget, QTreeWidgetItem::Type)),
tr("Interface"),
"ic_preferences_interface.svg");

DlgPrefWaveform* pWaveformPage = new DlgPrefWaveform(this, m_pConfig, pLibrary);
addPageWidget(PreferencesPage(
new DlgPrefWaveform(this, mixxx, m_pConfig, pLibrary),
pWaveformPage,
new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type)),
tr("Waveforms"),
"ic_preferences_waveforms.svg");
connect(pWaveformPage,
&DlgPrefWaveform::reloadUserInterface,
this,
&DlgPreferences::reloadUserInterface,
Qt::DirectConnection);

addPageWidget(PreferencesPage(
new DlgPrefColors(this, m_pConfig, pLibrary),
Expand Down
10 changes: 8 additions & 2 deletions src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include <memory>

#include "control/controlpushbutton.h"
#include "preferences/constants.h"
#include "preferences/dialog/dlgpreferencepage.h"
#include "preferences/dialog/ui_dlgpreferencesdlg.h"
#include "preferences/settingsmanager.h"
#include "preferences/usersettings.h"

class MixxxMainWindow;
class SoundManager;
class DlgPrefSound;
class DlgPrefLibrary;
Expand Down Expand Up @@ -51,6 +51,7 @@ class DlgPrefModplug;
#endif // __MODPLUG__

namespace mixxx {
class ScreensaverManager;
namespace skin {
class SkinLoader;
}
Expand All @@ -70,7 +71,8 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
QTreeWidgetItem* pTreeItem;
};

DlgPreferences(MixxxMainWindow* mixxx,
DlgPreferences(
std::shared_ptr<mixxx::ScreensaverManager> pScreensaverManager,
std::shared_ptr<mixxx::skin::SkinLoader> pSkinLoader,
std::shared_ptr<SoundManager> pSoundManager,
std::shared_ptr<PlayerManager> pPlayerManager,
Expand Down Expand Up @@ -104,6 +106,10 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
// Emitted if the user clicks Reset to Defaults.
void resetToDefaults();

signals:
void reloadUserInterface();
void tooltipModeChanged(mixxx::TooltipsPreference tooltipMode);

protected:
bool eventFilter(QObject*, QEvent*);
void moveEvent(QMoveEvent* e);
Expand Down
Loading