diff --git a/build/depends.py b/build/depends.py index 7d2ba3ed3438..32b9712714d4 100644 --- a/build/depends.py +++ b/build/depends.py @@ -748,6 +748,7 @@ def sources(self, build): "preferences/broadcastsettings.cpp", "preferences/broadcastsettings_legacy.cpp", "preferences/broadcastsettingsmodel.cpp", + "preferences/effectsettingsmodel.cpp", "preferences/broadcastprofile.cpp", "preferences/upgrade.cpp", "preferences/dlgpreferencepage.cpp", @@ -769,26 +770,26 @@ def sources(self, build): "effects/effectchainmanager.cpp", "effects/effectsbackend.cpp", - "effects/native/nativebackend.cpp", - "effects/native/bitcrushereffect.cpp", - "effects/native/balanceeffect.cpp", - "effects/native/linkwitzriley8eqeffect.cpp", - "effects/native/bessel4lvmixeqeffect.cpp", - "effects/native/bessel8lvmixeqeffect.cpp", - "effects/native/threebandbiquadeqeffect.cpp", - "effects/native/biquadfullkilleqeffect.cpp", - "effects/native/loudnesscontoureffect.cpp", - "effects/native/graphiceqeffect.cpp", - "effects/native/parametriceqeffect.cpp", - "effects/native/flangereffect.cpp", - "effects/native/filtereffect.cpp", - "effects/native/moogladder4filtereffect.cpp", - "effects/native/reverbeffect.cpp", - "effects/native/echoeffect.cpp", - "effects/native/autopaneffect.cpp", - "effects/native/phasereffect.cpp", - "effects/native/metronomeeffect.cpp", - "effects/native/tremoloeffect.cpp", + "effects/builtin/builtinbackend.cpp", + "effects/builtin/bitcrushereffect.cpp", + "effects/builtin/balanceeffect.cpp", + "effects/builtin/linkwitzriley8eqeffect.cpp", + "effects/builtin/bessel4lvmixeqeffect.cpp", + "effects/builtin/bessel8lvmixeqeffect.cpp", + "effects/builtin/threebandbiquadeqeffect.cpp", + "effects/builtin/biquadfullkilleqeffect.cpp", + "effects/builtin/loudnesscontoureffect.cpp", + "effects/builtin/graphiceqeffect.cpp", + "effects/builtin/parametriceqeffect.cpp", + "effects/builtin/flangereffect.cpp", + "effects/builtin/filtereffect.cpp", + "effects/builtin/moogladder4filtereffect.cpp", + "effects/builtin/reverbeffect.cpp", + "effects/builtin/echoeffect.cpp", + "effects/builtin/autopaneffect.cpp", + "effects/builtin/phasereffect.cpp", + "effects/builtin/metronomeeffect.cpp", + "effects/builtin/tremoloeffect.cpp", "engine/effects/engineeffectsmanager.cpp", "engine/effects/engineeffectrack.cpp", diff --git a/src/broadcast/broadcastmanager.cpp b/src/broadcast/broadcastmanager.cpp index 2a377538a060..ff9f9d4d3252 100644 --- a/src/broadcast/broadcastmanager.cpp +++ b/src/broadcast/broadcastmanager.cpp @@ -93,13 +93,13 @@ void BroadcastManager::slotControlEnabled(double v) { bool atLeastOneEnabled = false; QList profiles = m_pBroadcastSettings->profiles(); for(BroadcastProfilePtr profile : profiles) { - if(profile->getEnabled()) { + if (profile->getEnabled()) { atLeastOneEnabled = true; break; } } - if(!atLeastOneEnabled) { + if (!atLeastOneEnabled) { m_pBroadcastEnabled->set(false); emit(broadcastEnabled(0.0)); QMessageBox::warning(nullptr, tr("Action failed"), @@ -112,7 +112,7 @@ void BroadcastManager::slotControlEnabled(double v) { m_pStatusCO->forceSet(STATUSCO_UNCONNECTED); QList profiles = m_pBroadcastSettings->profiles(); for(BroadcastProfilePtr profile : profiles) { - if(profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) { + if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) { profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED); } } @@ -133,9 +133,9 @@ void BroadcastManager::slotProfilesChanged() { QVector workers = m_pNetworkStream->outputWorkers(); for(NetworkOutputStreamWorkerPtr pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast(pWorker); - if(connection) { + if (connection) { BroadcastProfilePtr profile = connection->profile(); - if(profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE + if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE && !profile->getEnabled()) { profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED); } @@ -145,10 +145,10 @@ void BroadcastManager::slotProfilesChanged() { } bool BroadcastManager::addConnection(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; - if(findConnectionForProfile(profile).isNull() == false) { + if (findConnectionForProfile(profile).isNull() == false) { return false; } @@ -164,11 +164,11 @@ bool BroadcastManager::addConnection(BroadcastProfilePtr profile) { } bool BroadcastManager::removeConnection(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; ShoutConnectionPtr connection = findConnectionForProfile(profile); - if(connection) { + if (connection) { disconnect(profile.data(), SIGNAL(connectionStatusChanged(int)), this, SLOT(slotConnectionStatusChanged(int))); @@ -188,10 +188,10 @@ ShoutConnectionPtr BroadcastManager::findConnectionForProfile(BroadcastProfilePt QVector workers = m_pNetworkStream->outputWorkers(); for(NetworkOutputStreamWorkerPtr pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast(pWorker); - if(connection.isNull()) + if (connection.isNull()) continue; - if(connection->profile() == profile) { + if (connection->profile() == profile) { return connection; } } @@ -207,7 +207,7 @@ void BroadcastManager::slotConnectionStatusChanged(int newState) { // Collect status info QList profiles = m_pBroadcastSettings->profiles(); for (BroadcastProfilePtr profile : profiles) { - if(!profile->getEnabled()) { + if (!profile->getEnabled()) { continue; } enabledCount++; diff --git a/src/effects/native/autopaneffect.cpp b/src/effects/builtin/autopaneffect.cpp similarity index 99% rename from src/effects/native/autopaneffect.cpp rename to src/effects/builtin/autopaneffect.cpp index c36c20c18562..b1b76df88c4b 100644 --- a/src/effects/native/autopaneffect.cpp +++ b/src/effects/builtin/autopaneffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/autopaneffect.h" +#include "effects/builtin/autopaneffect.h" #include diff --git a/src/effects/native/autopaneffect.h b/src/effects/builtin/autopaneffect.h similarity index 100% rename from src/effects/native/autopaneffect.h rename to src/effects/builtin/autopaneffect.h diff --git a/src/effects/native/balanceeffect.cpp b/src/effects/builtin/balanceeffect.cpp similarity index 100% rename from src/effects/native/balanceeffect.cpp rename to src/effects/builtin/balanceeffect.cpp diff --git a/src/effects/native/balanceeffect.h b/src/effects/builtin/balanceeffect.h similarity index 100% rename from src/effects/native/balanceeffect.h rename to src/effects/builtin/balanceeffect.h diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/builtin/bessel4lvmixeqeffect.cpp similarity index 97% rename from src/effects/native/bessel4lvmixeqeffect.cpp rename to src/effects/builtin/bessel4lvmixeqeffect.cpp index 1ded86f70e33..d04873ca60f1 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/builtin/bessel4lvmixeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/bessel4lvmixeqeffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" // static diff --git a/src/effects/native/bessel4lvmixeqeffect.h b/src/effects/builtin/bessel4lvmixeqeffect.h similarity index 97% rename from src/effects/native/bessel4lvmixeqeffect.h rename to src/effects/builtin/bessel4lvmixeqeffect.h index 62f07a1766d2..87ac83bd9b2d 100644 --- a/src/effects/native/bessel4lvmixeqeffect.h +++ b/src/effects/builtin/bessel4lvmixeqeffect.h @@ -6,7 +6,7 @@ #include "control/controlproxy.h" #include "effects/effect.h" #include "effects/effectprocessor.h" -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include "engine/effects/engineeffect.h" #include "engine/effects/engineeffectparameter.h" #include "engine/enginefilterbessel4.h" diff --git a/src/effects/native/bessel8lvmixeqeffect.cpp b/src/effects/builtin/bessel8lvmixeqeffect.cpp similarity index 97% rename from src/effects/native/bessel8lvmixeqeffect.cpp rename to src/effects/builtin/bessel8lvmixeqeffect.cpp index 2dac780a0de1..f119f655212f 100644 --- a/src/effects/native/bessel8lvmixeqeffect.cpp +++ b/src/effects/builtin/bessel8lvmixeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/bessel8lvmixeqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" // static diff --git a/src/effects/native/bessel8lvmixeqeffect.h b/src/effects/builtin/bessel8lvmixeqeffect.h similarity index 97% rename from src/effects/native/bessel8lvmixeqeffect.h rename to src/effects/builtin/bessel8lvmixeqeffect.h index 625c061c718d..a65a21dad8e0 100644 --- a/src/effects/native/bessel8lvmixeqeffect.h +++ b/src/effects/builtin/bessel8lvmixeqeffect.h @@ -1,7 +1,7 @@ #ifndef BESSEL8LVMIXEQEFFECT_H #define BESSEL8LVMIXEQEFFECT_H -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include diff --git a/src/effects/native/biquadfullkilleqeffect.cpp b/src/effects/builtin/biquadfullkilleqeffect.cpp similarity index 99% rename from src/effects/native/biquadfullkilleqeffect.cpp rename to src/effects/builtin/biquadfullkilleqeffect.cpp index 6970a493f35a..6adba364a120 100644 --- a/src/effects/native/biquadfullkilleqeffect.cpp +++ b/src/effects/builtin/biquadfullkilleqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/biquadfullkilleqeffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" namespace { diff --git a/src/effects/native/biquadfullkilleqeffect.h b/src/effects/builtin/biquadfullkilleqeffect.h similarity index 98% rename from src/effects/native/biquadfullkilleqeffect.h rename to src/effects/builtin/biquadfullkilleqeffect.h index 4215f70d342f..4b016058a705 100644 --- a/src/effects/native/biquadfullkilleqeffect.h +++ b/src/effects/builtin/biquadfullkilleqeffect.h @@ -8,7 +8,7 @@ #include "engine/effects/engineeffectparameter.h" #include "engine/enginefilterbiquad1.h" #include "engine/enginefilterbessel4.h" -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include "engine/enginefilterdelay.h" #include "util/class.h" #include "util/defs.h" diff --git a/src/effects/native/bitcrushereffect.cpp b/src/effects/builtin/bitcrushereffect.cpp similarity index 99% rename from src/effects/native/bitcrushereffect.cpp rename to src/effects/builtin/bitcrushereffect.cpp index ba88ae9c40a6..04dc81884fad 100644 --- a/src/effects/native/bitcrushereffect.cpp +++ b/src/effects/builtin/bitcrushereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/bitcrushereffect.h" +#include "effects/builtin/bitcrushereffect.h" #include "util/sample.h" diff --git a/src/effects/native/bitcrushereffect.h b/src/effects/builtin/bitcrushereffect.h similarity index 100% rename from src/effects/native/bitcrushereffect.h rename to src/effects/builtin/bitcrushereffect.h diff --git a/src/effects/builtin/builtinbackend.cpp b/src/effects/builtin/builtinbackend.cpp new file mode 100644 index 000000000000..9c870a0aba1f --- /dev/null +++ b/src/effects/builtin/builtinbackend.cpp @@ -0,0 +1,59 @@ + +#include + +#include "effects/builtin/builtinbackend.h" +#include "effects/builtin/flangereffect.h" +#include "effects/builtin/bitcrushereffect.h" +#include "effects/builtin/balanceeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" +#include "effects/builtin/threebandbiquadeqeffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" +#include "effects/builtin/graphiceqeffect.h" +#include "effects/builtin/parametriceqeffect.h" +#include "effects/builtin/filtereffect.h" +#include "effects/builtin/moogladder4filtereffect.h" +#ifndef __MACAPPSTORE__ +#include "effects/builtin/reverbeffect.h" +#endif +#include "effects/builtin/echoeffect.h" +#include "effects/builtin/autopaneffect.h" +#include "effects/builtin/phasereffect.h" +#include "effects/builtin/loudnesscontoureffect.h" +#include "effects/builtin/metronomeeffect.h" +#include "effects/builtin/tremoloeffect.h" + +BuiltInBackend::BuiltInBackend(QObject* pParent) + : EffectsBackend(pParent, EffectBackendType::BuiltIn) { + // Keep this list in a reasonable order + // Mixing EQs + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + // Compensations EQs + registerEffect(); + registerEffect(); + registerEffect(); + // Fading Effects + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + // Fancy effects + registerEffect(); + registerEffect(); + registerEffect(); +#ifndef __MACAPPSTORE__ + registerEffect(); +#endif + registerEffect(); + registerEffect(); + registerEffect(); +} + +BuiltInBackend::~BuiltInBackend() { + //qDebug() << debugString() << "destroyed"; +} diff --git a/src/effects/builtin/builtinbackend.h b/src/effects/builtin/builtinbackend.h new file mode 100644 index 000000000000..b797f293040e --- /dev/null +++ b/src/effects/builtin/builtinbackend.h @@ -0,0 +1,19 @@ +#ifndef BUILTINBACKEND_H +#define BUILTINBACKEND_H + +#include "effects/defs.h" +#include "effects/effectsbackend.h" + +class BuiltInBackend : public EffectsBackend { + Q_OBJECT + public: + BuiltInBackend(QObject* pParent); + virtual ~BuiltInBackend(); + + private: + QString debugString() const { + return "BuiltInBackend"; + } +}; + +#endif /* BUILTINBACKEND_H */ diff --git a/src/effects/native/echoeffect.cpp b/src/effects/builtin/echoeffect.cpp similarity index 99% rename from src/effects/native/echoeffect.cpp rename to src/effects/builtin/echoeffect.cpp index 3928f1206eaa..1d0451d75d2f 100644 --- a/src/effects/native/echoeffect.cpp +++ b/src/effects/builtin/echoeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/echoeffect.h" +#include "effects/builtin/echoeffect.h" #include diff --git a/src/effects/native/echoeffect.h b/src/effects/builtin/echoeffect.h similarity index 100% rename from src/effects/native/echoeffect.h rename to src/effects/builtin/echoeffect.h diff --git a/src/effects/native/equalizer_util.h b/src/effects/builtin/equalizer_util.h similarity index 96% rename from src/effects/native/equalizer_util.h rename to src/effects/builtin/equalizer_util.h index 0ed7828dd9f9..1ab188a826fe 100644 --- a/src/effects/native/equalizer_util.h +++ b/src/effects/builtin/equalizer_util.h @@ -1,5 +1,5 @@ -#ifndef EFFECTS_NATIVE_EQUALIZER_UTIL_H -#define EFFECTS_NATIVE_EQUALIZER_UTIL_H +#ifndef EFFECTS_BUILTIN_EQUALIZER_UTIL_H +#define EFFECTS_BUILTIN_EQUALIZER_UTIL_H #include @@ -94,4 +94,4 @@ class EqualizerUtil { }; -#endif /* EFFECTS_NATIVE_EQUALIZER_UTIL_H */ +#endif /* EFFECTS_BUILTIN_EQUALIZER_UTIL_H */ diff --git a/src/effects/native/filtereffect.cpp b/src/effects/builtin/filtereffect.cpp similarity index 99% rename from src/effects/native/filtereffect.cpp rename to src/effects/builtin/filtereffect.cpp index ef5fc9b3c159..aece10b9a065 100644 --- a/src/effects/native/filtereffect.cpp +++ b/src/effects/builtin/filtereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/filtereffect.h" +#include "effects/builtin/filtereffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/filtereffect.h b/src/effects/builtin/filtereffect.h similarity index 100% rename from src/effects/native/filtereffect.h rename to src/effects/builtin/filtereffect.h diff --git a/src/effects/native/flangereffect.cpp b/src/effects/builtin/flangereffect.cpp similarity index 99% rename from src/effects/native/flangereffect.cpp rename to src/effects/builtin/flangereffect.cpp index 968c86bcfc0f..a4e39d709dd3 100644 --- a/src/effects/native/flangereffect.cpp +++ b/src/effects/builtin/flangereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/flangereffect.h" +#include "effects/builtin/flangereffect.h" #include diff --git a/src/effects/native/flangereffect.h b/src/effects/builtin/flangereffect.h similarity index 100% rename from src/effects/native/flangereffect.h rename to src/effects/builtin/flangereffect.h diff --git a/src/effects/native/graphiceqeffect.cpp b/src/effects/builtin/graphiceqeffect.cpp similarity index 99% rename from src/effects/native/graphiceqeffect.cpp rename to src/effects/builtin/graphiceqeffect.cpp index c30a68e76b98..d73ea07c71f4 100644 --- a/src/effects/native/graphiceqeffect.cpp +++ b/src/effects/builtin/graphiceqeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/graphiceqeffect.h" +#include "effects/builtin/graphiceqeffect.h" #include "util/math.h" #define Q 1.2247449 diff --git a/src/effects/native/graphiceqeffect.h b/src/effects/builtin/graphiceqeffect.h similarity index 100% rename from src/effects/native/graphiceqeffect.h rename to src/effects/builtin/graphiceqeffect.h diff --git a/src/effects/native/linkwitzriley8eqeffect.cpp b/src/effects/builtin/linkwitzriley8eqeffect.cpp similarity index 98% rename from src/effects/native/linkwitzriley8eqeffect.cpp rename to src/effects/builtin/linkwitzriley8eqeffect.cpp index 73ac792550c0..61ee64b4018e 100644 --- a/src/effects/native/linkwitzriley8eqeffect.cpp +++ b/src/effects/builtin/linkwitzriley8eqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/linkwitzriley8eqeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" static const unsigned int kStartupSamplerate = 44100; diff --git a/src/effects/native/linkwitzriley8eqeffect.h b/src/effects/builtin/linkwitzriley8eqeffect.h similarity index 100% rename from src/effects/native/linkwitzriley8eqeffect.h rename to src/effects/builtin/linkwitzriley8eqeffect.h diff --git a/src/effects/native/loudnesscontoureffect.cpp b/src/effects/builtin/loudnesscontoureffect.cpp similarity index 99% rename from src/effects/native/loudnesscontoureffect.cpp rename to src/effects/builtin/loudnesscontoureffect.cpp index 160d5a0d0785..fd1781f73bab 100644 --- a/src/effects/native/loudnesscontoureffect.cpp +++ b/src/effects/builtin/loudnesscontoureffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/loudnesscontoureffect.h" +#include "effects/builtin/loudnesscontoureffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/loudnesscontoureffect.h b/src/effects/builtin/loudnesscontoureffect.h similarity index 100% rename from src/effects/native/loudnesscontoureffect.h rename to src/effects/builtin/loudnesscontoureffect.h diff --git a/src/effects/native/lvmixeqbase.h b/src/effects/builtin/lvmixeqbase.h similarity index 100% rename from src/effects/native/lvmixeqbase.h rename to src/effects/builtin/lvmixeqbase.h diff --git a/src/effects/native/metronomeclick.h b/src/effects/builtin/metronomeclick.h similarity index 100% rename from src/effects/native/metronomeclick.h rename to src/effects/builtin/metronomeclick.h diff --git a/src/effects/native/metronomeeffect.cpp b/src/effects/builtin/metronomeeffect.cpp similarity index 100% rename from src/effects/native/metronomeeffect.cpp rename to src/effects/builtin/metronomeeffect.cpp diff --git a/src/effects/native/metronomeeffect.h b/src/effects/builtin/metronomeeffect.h similarity index 100% rename from src/effects/native/metronomeeffect.h rename to src/effects/builtin/metronomeeffect.h diff --git a/src/effects/native/moogladder4filtereffect.cpp b/src/effects/builtin/moogladder4filtereffect.cpp similarity index 99% rename from src/effects/native/moogladder4filtereffect.cpp rename to src/effects/builtin/moogladder4filtereffect.cpp index 604003c8b5d5..bcb521c6ee1c 100644 --- a/src/effects/native/moogladder4filtereffect.cpp +++ b/src/effects/builtin/moogladder4filtereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/moogladder4filtereffect.h" +#include "effects/builtin/moogladder4filtereffect.h" #include "util/math.h" diff --git a/src/effects/native/moogladder4filtereffect.h b/src/effects/builtin/moogladder4filtereffect.h similarity index 100% rename from src/effects/native/moogladder4filtereffect.h rename to src/effects/builtin/moogladder4filtereffect.h diff --git a/src/effects/native/parametriceqeffect.cpp b/src/effects/builtin/parametriceqeffect.cpp similarity index 99% rename from src/effects/native/parametriceqeffect.cpp rename to src/effects/builtin/parametriceqeffect.cpp index fc2ebf2638a2..c58c6de042d9 100644 --- a/src/effects/native/parametriceqeffect.cpp +++ b/src/effects/builtin/parametriceqeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/parametriceqeffect.h" +#include "effects/builtin/parametriceqeffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/parametriceqeffect.h b/src/effects/builtin/parametriceqeffect.h similarity index 100% rename from src/effects/native/parametriceqeffect.h rename to src/effects/builtin/parametriceqeffect.h diff --git a/src/effects/native/phasereffect.cpp b/src/effects/builtin/phasereffect.cpp similarity index 99% rename from src/effects/native/phasereffect.cpp rename to src/effects/builtin/phasereffect.cpp index cf1af0cc4f79..1556d3b8aaf1 100644 --- a/src/effects/native/phasereffect.cpp +++ b/src/effects/builtin/phasereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/phasereffect.h" +#include "effects/builtin/phasereffect.h" #include diff --git a/src/effects/native/phasereffect.h b/src/effects/builtin/phasereffect.h similarity index 100% rename from src/effects/native/phasereffect.h rename to src/effects/builtin/phasereffect.h diff --git a/src/effects/native/reverbeffect.cpp b/src/effects/builtin/reverbeffect.cpp similarity index 99% rename from src/effects/native/reverbeffect.cpp rename to src/effects/builtin/reverbeffect.cpp index b3130fb5dc7d..bd198fa5c445 100644 --- a/src/effects/native/reverbeffect.cpp +++ b/src/effects/builtin/reverbeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/reverbeffect.h" +#include "effects/builtin/reverbeffect.h" #include diff --git a/src/effects/native/reverbeffect.h b/src/effects/builtin/reverbeffect.h similarity index 100% rename from src/effects/native/reverbeffect.h rename to src/effects/builtin/reverbeffect.h diff --git a/src/effects/native/threebandbiquadeqeffect.cpp b/src/effects/builtin/threebandbiquadeqeffect.cpp similarity index 99% rename from src/effects/native/threebandbiquadeqeffect.cpp rename to src/effects/builtin/threebandbiquadeqeffect.cpp index 7c591dd0b946..c7c112c8bbf6 100644 --- a/src/effects/native/threebandbiquadeqeffect.cpp +++ b/src/effects/builtin/threebandbiquadeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/threebandbiquadeqeffect.h" +#include "effects/builtin/threebandbiquadeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" namespace { diff --git a/src/effects/native/threebandbiquadeqeffect.h b/src/effects/builtin/threebandbiquadeqeffect.h similarity index 100% rename from src/effects/native/threebandbiquadeqeffect.h rename to src/effects/builtin/threebandbiquadeqeffect.h diff --git a/src/effects/native/tremoloeffect.cpp b/src/effects/builtin/tremoloeffect.cpp similarity index 99% rename from src/effects/native/tremoloeffect.cpp rename to src/effects/builtin/tremoloeffect.cpp index 3d4b42954312..17200a7d1cc1 100644 --- a/src/effects/native/tremoloeffect.cpp +++ b/src/effects/builtin/tremoloeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/tremoloeffect.h" +#include "effects/builtin/tremoloeffect.h" namespace { // Used to avoid gain discontinuities when changing parameters too fast diff --git a/src/effects/native/tremoloeffect.h b/src/effects/builtin/tremoloeffect.h similarity index 100% rename from src/effects/native/tremoloeffect.h rename to src/effects/builtin/tremoloeffect.h diff --git a/src/effects/defs.h b/src/effects/defs.h index ec6b4f3467c8..1db1f3388e22 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -11,6 +11,12 @@ enum class EffectEnableState { Enabling }; +enum class EffectBackendType { + BuiltIn, + LV2, + Unknown +}; + enum class SignalProcessingStage { Prefader, Postfader diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index e495e8a963fb..538cecdae7a1 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -7,6 +7,7 @@ #include #include "effects/effectmanifestparameter.h" +#include "effects/defs.h" // An EffectManifest is a full description of the metadata associated with an // effect (e.g. name, author, version, description, etc.) and the parameters of @@ -23,7 +24,8 @@ class EffectManifest final { public: EffectManifest() - : m_isMixingEQ(false), + : m_backendType(EffectBackendType::Unknown), + m_isMixingEQ(false), m_isMasterEQ(false), m_effectRampsFromDry(false), m_metaknobDefault(0.5) { @@ -58,6 +60,13 @@ class EffectManifest final { } } + const EffectBackendType& backendType() const { + return m_backendType; + } + void setBackendType(const EffectBackendType& type) { + m_backendType = type; + } + const QString& author() const { return m_author; } @@ -125,6 +134,39 @@ class EffectManifest final { m_metaknobDefault = metaknobDefault; } + QString backendName() { + switch (m_backendType) { + case EffectBackendType::BuiltIn: + return QString("Built-in"); + case EffectBackendType::LV2: + return QString("LV2"); + default: + return QString("Unknown"); + } + } + + // Use this when showing the string in the GUI + QString translatedBackendName() { + switch (m_backendType) { + case EffectBackendType::BuiltIn: + //: Used for effects that are built into Mixxx + return QObject::tr("Built-in"); + case EffectBackendType::LV2: + return QString("LV2"); + default: + return QString(); + } + } + static EffectBackendType backendTypeFromString(const QString& name) { + if (name == "Built-in") { + return EffectBackendType::BuiltIn; + } else if (name == "LV2") { + return EffectBackendType::LV2; + } else { + return EffectBackendType::Unknown; + } + } + private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -133,6 +175,7 @@ class EffectManifest final { QString m_id; QString m_name; QString m_shortName; + EffectBackendType m_backendType; QString m_author; QString m_version; QString m_description; diff --git a/src/effects/effectprocessor.h b/src/effects/effectprocessor.h index 4401b5ccfc72..b493511aa28b 100644 --- a/src/effects/effectprocessor.h +++ b/src/effects/effectprocessor.h @@ -127,7 +127,7 @@ class EffectProcessorImpl : public EffectProcessor { // static EffectManifest getManifest(); // This is the only non-static method that subclasses need to implement. - // TODO(Be): remove ChannelHandle& argument? No (native) effects use it. Why should + // TODO(Be): remove ChannelHandle& argument? No (built-in) effects use it. Why should // effects be concerned with the ChannelHandle& when process() takes care of giving // it the appropriate ChannelStateHolder? virtual void processChannel(const ChannelHandle& handle, diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 04901d3890a8..dc2e9974fd0a 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -3,9 +3,10 @@ #include "effects/effectsbackend.h" #include "effects/effectsmanager.h" -EffectsBackend::EffectsBackend(QObject* pParent, QString name) +EffectsBackend::EffectsBackend(QObject* pParent, + EffectBackendType type) : QObject(pParent), - m_name(name) { + m_type(type) { } EffectsBackend::~EffectsBackend() { @@ -13,10 +14,6 @@ EffectsBackend::~EffectsBackend() { m_effectIds.clear(); } -const QString EffectsBackend::getName() const { - return m_name; -} - void EffectsBackend::registerEffect(const QString& id, EffectManifestPointer pManifest, EffectInstantiatorPointer pInstantiator) { @@ -25,6 +22,8 @@ void EffectsBackend::registerEffect(const QString& id, return; } + pManifest->setBackendType(m_type); + m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); m_effectIds.append(id); emit(effectRegistered(pManifest)); diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index f0cf69da2331..e1d2c327b6c6 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -6,8 +6,10 @@ #include #include +#include "effects/defs.h" #include "effects/effect.h" #include "effects/effectinstantiator.h" +#include "preferences/usersettings.h" class EffectsManager; class EffectsBackend; @@ -19,11 +21,9 @@ class EffectProcessor; class EffectsBackend : public QObject { Q_OBJECT public: - EffectsBackend(QObject* pParent, QString name); + EffectsBackend(QObject* pParent, EffectBackendType type); virtual ~EffectsBackend(); - virtual const QString getName() const; - // returns a list sorted like it should be displayed in the GUI virtual const QList getEffectIds() const; virtual EffectManifestPointer getManifest(const QString& effectId) const; @@ -48,6 +48,8 @@ class EffectsBackend : public QObject { new EffectProcessorInstantiator())); } + EffectBackendType m_type; + private: class RegisteredEffect { public: @@ -67,7 +69,6 @@ class EffectsBackend : public QObject { EffectInstantiatorPointer m_pInitator; }; - QString m_name; QMap m_registeredEffects; QList m_effectIds; }; diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 52ccec8c3d0a..533c7c046b73 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include "engine/effects/engineeffectsmanager.h" #include "effects/effectchainmanager.h" #include "effects/effectsbackend.h" @@ -68,7 +70,10 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { - return QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()) < 0; + // Sort built-in effects first before external plugins + int backendNameComparision = static_cast(pManifest1->backendType()) - static_cast(pManifest2->backendType()); + int displayNameComparision = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); + return (backendNameComparision ? (backendNameComparision < 0) : (displayNameComparision < 0)); } void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { @@ -95,9 +100,9 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { } void EffectsManager::slotBackendRegisteredEffect(EffectManifestPointer pManifest) { - auto insertion_point = qLowerBound(m_availableEffectManifests.begin(), - m_availableEffectManifests.end(), - pManifest, alphabetizeEffectManifests); + auto insertion_point = std::lower_bound(m_availableEffectManifests.begin(), + m_availableEffectManifests.end(), + pManifest, alphabetizeEffectManifests); m_availableEffectManifests.insert(insertion_point, pManifest); m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); } @@ -310,6 +315,22 @@ EffectButtonParameterSlotPointer EffectsManager::getEffectButtonParameterSlot( return pParameterSlot; } +void EffectsManager::setEffectVisibility(EffectManifestPointer pManifest, bool visible) { + if (visible && !m_visibleEffectManifests.contains(pManifest)) { + auto insertion_point = std::lower_bound(m_visibleEffectManifests.begin(), + m_visibleEffectManifests.end(), + pManifest, alphabetizeEffectManifests); + m_visibleEffectManifests.insert(insertion_point, pManifest); + emit(visibleEffectsUpdated()); + } else if (!visible) { + m_visibleEffectManifests.removeOne(pManifest); + emit(visibleEffectsUpdated()); + } +} + +bool EffectsManager::getEffectVisibility(EffectManifestPointer pManifest) { + return m_visibleEffectManifests.contains(pManifest); +} void EffectsManager::setup() { // These controls are used inside EQ Effects diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index 87fe16629597..09db79b56934 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -79,6 +79,9 @@ class EffectsManager : public QObject { inline const QList& getAvailableEffectManifests() const { return m_availableEffectManifests; }; + inline const QList& getVisibleEffectManifests() const { + return m_visibleEffectManifests; + }; const QList getAvailableEffectManifestsFiltered( EffectManifestFilterFnc filter) const; bool isEQ(const QString& effectId) const; @@ -88,6 +91,9 @@ class EffectsManager : public QObject { EffectManifestPointer getEffectManifest(const QString& effectId) const; EffectPointer instantiateEffect(const QString& effectId); + void setEffectVisibility(EffectManifestPointer pManifest, bool visibility); + bool getEffectVisibility(EffectManifestPointer pManifest); + // Temporary, but for setting up all the default EffectChains and EffectRacks void setup(); @@ -101,6 +107,7 @@ class EffectsManager : public QObject { signals: // TODO() Not connected. Can be used when we implement effect PlugIn loading at runtime void availableEffectsUpdated(EffectManifestPointer); + void visibleEffectsUpdated(); private slots: void slotBackendRegisteredEffect(EffectManifestPointer pManifest); @@ -118,6 +125,7 @@ class EffectsManager : public QObject { EffectChainManager* m_pEffectChainManager; QList m_effectsBackends; QList m_availableEffectManifests; + QList m_visibleEffectManifests; EngineEffectsManager* m_pEngineEffectsManager; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 403396bac2b2..f32956cd2af1 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -2,7 +2,7 @@ #include "effects/lv2/lv2manifest.h" LV2Backend::LV2Backend(QObject* pParent) - : EffectsBackend(pParent, tr("LV2")) { + : EffectsBackend(pParent, EffectBackendType::LV2) { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); @@ -27,6 +27,7 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); + lv2Manifest->getEffectManifest()->setBackendType(m_type); m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } diff --git a/src/effects/lv2/lv2backend.h b/src/effects/lv2/lv2backend.h index 2f8c79be39cc..1a8c3e747915 100644 --- a/src/effects/lv2/lv2backend.h +++ b/src/effects/lv2/lv2backend.h @@ -1,14 +1,16 @@ #ifndef LV2BACKEND_H #define LV2BACKEND_H +#include "effects/defs.h" #include "effects/effectsbackend.h" #include "effects/lv2/lv2manifest.h" +#include "preferences/usersettings.h" #include class LV2Backend : public EffectsBackend { Q_OBJECT public: - LV2Backend(QObject* pParent=NULL); + LV2Backend(QObject* pParent); virtual ~LV2Backend(); void enumeratePlugins(); diff --git a/src/effects/native/nativebackend.cpp b/src/effects/native/nativebackend.cpp deleted file mode 100644 index 4cd3e8656720..000000000000 --- a/src/effects/native/nativebackend.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -#include - -#include "effects/native/nativebackend.h" -#include "effects/native/flangereffect.h" -#include "effects/native/bitcrushereffect.h" -#include "effects/native/balanceeffect.h" -#include "effects/native/linkwitzriley8eqeffect.h" -#include "effects/native/bessel8lvmixeqeffect.h" -#include "effects/native/bessel4lvmixeqeffect.h" -#include "effects/native/threebandbiquadeqeffect.h" -#include "effects/native/biquadfullkilleqeffect.h" -#include "effects/native/graphiceqeffect.h" -#include "effects/native/parametriceqeffect.h" -#include "effects/native/filtereffect.h" -#include "effects/native/moogladder4filtereffect.h" -#ifndef __MACAPPSTORE__ -#include "effects/native/reverbeffect.h" -#endif -#include "effects/native/echoeffect.h" -#include "effects/native/autopaneffect.h" -#include "effects/native/phasereffect.h" -#include "effects/native/loudnesscontoureffect.h" -#include "effects/native/metronomeeffect.h" -#include "effects/native/tremoloeffect.h" - -NativeBackend::NativeBackend(QObject* pParent) - : EffectsBackend(pParent, tr("Native")) { - // Keep this list in a reasonable order - // Mixing EQs - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - // Compensations EQs - registerEffect(); - registerEffect(); - registerEffect(); - // Fading Effects - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - // Fancy effects - registerEffect(); - registerEffect(); - registerEffect(); -#ifndef __MACAPPSTORE__ - registerEffect(); -#endif - registerEffect(); - registerEffect(); - registerEffect(); -} - -NativeBackend::~NativeBackend() { - //qDebug() << debugString() << "destroyed"; -} diff --git a/src/effects/native/nativebackend.h b/src/effects/native/nativebackend.h deleted file mode 100644 index b9ef6411b585..000000000000 --- a/src/effects/native/nativebackend.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NATIVEBACKEND_H -#define NATIVEBACKEND_H - -#include "effects/effectsbackend.h" - -class NativeBackend : public EffectsBackend { - Q_OBJECT - public: - NativeBackend(QObject* pParent=NULL); - virtual ~NativeBackend(); - - private: - QString debugString() const { - return "NativeBackend"; - } -}; - -#endif /* NATIVEBACKEND_H */ diff --git a/src/encoder/encodermp3.cpp b/src/encoder/encodermp3.cpp index 7503a486350b..034dce3b1a5c 100644 --- a/src/encoder/encodermp3.cpp +++ b/src/encoder/encodermp3.cpp @@ -180,27 +180,27 @@ EncoderMp3::EncoderMp3(EncoderCallback* pCallback) * * Should not happen on Linux, but many lame binaries for Windows are modified. */ - if(!lame_init || - !lame_set_num_channels || - !lame_set_in_samplerate || - !lame_set_out_samplerate || - !lame_close || - !lame_set_brate || - !lame_set_mode || - !lame_set_quality || - !lame_set_bWriteVbrTag || - !lame_encode_buffer_float || - !lame_init_params || - !lame_encode_flush || - !lame_set_VBR || - !lame_set_VBR_q || - !lame_set_VBR_mean_bitrate_kbps || - !lame_get_lametag_frame || - !get_lame_version || - !id3tag_init || - !id3tag_set_title || - !id3tag_set_artist || - !id3tag_set_album) + if (!lame_init || + !lame_set_num_channels || + !lame_set_in_samplerate || + !lame_set_out_samplerate || + !lame_close || + !lame_set_brate || + !lame_set_mode || + !lame_set_quality || + !lame_set_bWriteVbrTag || + !lame_encode_buffer_float || + !lame_init_params || + !lame_encode_flush || + !lame_set_VBR || + !lame_set_VBR_q || + !lame_set_VBR_mean_bitrate_kbps || + !lame_get_lametag_frame || + !get_lame_version || + !id3tag_init || + !id3tag_set_title || + !id3tag_set_artist || + !id3tag_set_album) { m_library->unload(); delete m_library; diff --git a/src/library/itunes/itunesfeature.cpp b/src/library/itunes/itunesfeature.cpp index 161863f13ac1..211baa8a00ac 100644 --- a/src/library/itunes/itunesfeature.cpp +++ b/src/library/itunes/itunesfeature.cpp @@ -170,7 +170,7 @@ void ITunesFeature::activate(bool forceReload) { m_future_watcher.setFuture(m_future); m_title = tr("(loading) iTunes"); // calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pITunesTrackModel)); diff --git a/src/library/rhythmbox/rhythmboxfeature.cpp b/src/library/rhythmbox/rhythmboxfeature.cpp index 122291e4b4bd..ce6232a3b872 100644 --- a/src/library/rhythmbox/rhythmboxfeature.cpp +++ b/src/library/rhythmbox/rhythmboxfeature.cpp @@ -125,7 +125,7 @@ void RhythmboxFeature::activate() { m_track_watcher.setFuture(m_track_future); m_title = "(loading) Rhythmbox"; //calls a slot in the sidebar model such that 'Rhythmbox (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pRhythmboxTrackModel)); diff --git a/src/library/stardelegate.cpp b/src/library/stardelegate.cpp index 374ea82531f4..1332334fb200 100644 --- a/src/library/stardelegate.cpp +++ b/src/library/stardelegate.cpp @@ -80,8 +80,8 @@ void StarDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, void StarDelegate::commitAndCloseEditor() { StarEditor* editor = qobject_cast(sender()); - emit commitData(editor); - emit closeEditor(editor); + emit(commitData(editor)); + emit(closeEditor(editor)); } void StarDelegate::cellEntered(const QModelIndex& index) { diff --git a/src/library/stareditor.cpp b/src/library/stareditor.cpp index 00ae6b02112e..ee37bfd04413 100644 --- a/src/library/stareditor.cpp +++ b/src/library/stareditor.cpp @@ -114,7 +114,7 @@ void StarEditor::leaveEvent(QEvent*) { } void StarEditor::mouseReleaseEvent(QMouseEvent* /* event */) { - emit editingFinished(); + emit(editingFinished()); } int StarEditor::starAtPosition(int x) { diff --git a/src/library/traktor/traktorfeature.cpp b/src/library/traktor/traktorfeature.cpp index c44f53d1e65d..cf54086b5b06 100644 --- a/src/library/traktor/traktorfeature.cpp +++ b/src/library/traktor/traktorfeature.cpp @@ -154,7 +154,7 @@ void TraktorFeature::activate() { m_future_watcher.setFuture(m_future); m_title = tr("(loading) Traktor"); //calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pTraktorTableModel)); diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 088fc9445bc7..9322c74ee598 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -32,7 +32,7 @@ #include "dialog/dlgdevelopertools.h" #include "engine/enginemaster.h" #include "effects/effectsmanager.h" -#include "effects/native/nativebackend.h" +#include "effects/builtin/builtinbackend.h" #ifdef __LILV__ #include "effects/lv2/lv2backend.h" #endif @@ -198,8 +198,8 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // Create effect backends. We do this after creating EngineMaster to allow // effect backends to refer to controls that are produced by the engine. - NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager); - m_pEffectsManager->addEffectsBackend(pNativeBackend); + BuiltInBackend* pBuiltInBackend = new BuiltInBackend(m_pEffectsManager); + m_pEffectsManager->addEffectsBackend(pBuiltInBackend); #ifdef __LILV__ LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pLV2Backend); diff --git a/src/preferences/broadcastprofile.cpp b/src/preferences/broadcastprofile.cpp index 289d24f65b34..dac503b96a0d 100644 --- a/src/preferences/broadcastprofile.cpp +++ b/src/preferences/broadcastprofile.cpp @@ -105,7 +105,7 @@ QString BroadcastProfile::stripForbiddenChars(const QString& str) { BroadcastProfilePtr BroadcastProfile::loadFromFile( const QString& filename) { QFileInfo xmlFile(filename); - if(!xmlFile.exists()) + if (!xmlFile.exists()) return BroadcastProfilePtr(nullptr); QString profileFilename = xmlFile.baseName(); @@ -124,7 +124,7 @@ bool BroadcastProfile::equals(BroadcastProfilePtr other) { } bool BroadcastProfile::valuesEquals(BroadcastProfilePtr other) { - if(getEnabled() == other->getEnabled() + if (getEnabled() == other->getEnabled() && secureCredentialStorage() == other->secureCredentialStorage() && getHost() == other->getHost() && getPort() == other->getPort() @@ -244,7 +244,7 @@ void BroadcastProfile::adoptDefaultValues() { bool BroadcastProfile::loadValues(const QString& filename) { QDomElement doc = XmlParse::openXMLFile(filename, kDoctype); - if(doc.childNodes().size() < 1) + if (doc.childNodes().size() < 1) return false; m_secureCredentials = (bool)XmlParse::selectNodeInt(doc, kSecureCredentials); @@ -261,7 +261,7 @@ bool BroadcastProfile::loadValues(const QString& filename) { m_serverType = XmlParse::selectNodeQString(doc, kServertype); m_login = XmlParse::selectNodeQString(doc, kLogin); - if(m_secureCredentials) { + if (m_secureCredentials) { m_password = getSecurePassword(m_login); } else { m_password = XmlParse::selectNodeQString(doc, kPassword); @@ -318,7 +318,7 @@ bool BroadcastProfile::save(const QString& filename) { XmlParse::addElement(doc, docRoot, kServertype, m_serverType); XmlParse::addElement(doc, docRoot, kLogin, m_login); - if(m_secureCredentials) { + if (m_secureCredentials) { setSecurePassword(m_login, m_password); } else { XmlParse::addElement(doc, docRoot, kPassword, m_password); @@ -365,7 +365,7 @@ bool BroadcastProfile::save(const QString& filename) { doc.appendChild(docRoot); QFile xmlFile(filename); - if(xmlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + if (xmlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream fileStream(&xmlFile); doc.save(fileStream, 4); xmlFile.close(); @@ -379,7 +379,7 @@ void BroadcastProfile::setProfileName(const QString &profileName) { QString oldName(m_profileName); m_profileName = QString(profileName); - emit profileNameChanged(oldName, m_profileName); + emit(profileNameChanged(oldName, m_profileName)); } QString BroadcastProfile::getProfileName() const { @@ -388,7 +388,7 @@ QString BroadcastProfile::getProfileName() const { void BroadcastProfile::setConnectionStatus(int newState) { m_connectionStatus = newState; - emit connectionStatusChanged(connectionStatus()); + emit(connectionStatusChanged(connectionStatus())); } int BroadcastProfile::connectionStatus() { @@ -418,7 +418,7 @@ bool BroadcastProfile::setSecurePassword(const QString& login, const QString& pa writeJob.start(); loop.exec(); - if(writeJob.error() == Error::NoError) { + if (writeJob.error() == Error::NoError) { kLogger.debug() << "setSecureValue: write successful"; return true; } else { @@ -449,7 +449,7 @@ QString BroadcastProfile::getSecurePassword(const QString& login) { readJob.start(); loop.exec(); - if(readJob.error() == Error::NoError) { + if (readJob.error() == Error::NoError) { kLogger.debug() << "getSecureValue: read successful"; return readJob.textData(); } else { @@ -495,7 +495,7 @@ bool BroadcastProfile::getEnabled() const { void BroadcastProfile::setEnabled(bool value) { m_enabled = value; - emit statusChanged(m_enabled); + emit(statusChanged(m_enabled)); } QString BroadcastProfile::getHost() const { diff --git a/src/preferences/broadcastsettings.cpp b/src/preferences/broadcastsettings.cpp index b00ec8af10ab..b99078177b95 100644 --- a/src/preferences/broadcastsettings.cpp +++ b/src/preferences/broadcastsettings.cpp @@ -25,7 +25,7 @@ BroadcastSettings::BroadcastSettings( void BroadcastSettings::loadProfiles() { QDir profilesFolder(getProfilesFolder()); - if(!profilesFolder.exists()) { + if (!profilesFolder.exists()) { kLogger.info() << "Profiles folder doesn't exist. Creating it."; profilesFolder.mkpath(profilesFolder.absolutePath()); } @@ -45,7 +45,7 @@ void BroadcastSettings::loadProfiles() { // It's important to take into account that the "legacy" settings are left // in mixxx.cfg for retro-compatibility during alpha and beta testing. - if(files.size() > 0) { + if (files.size() > 0) { kLogger.info() << "Found" << files.size() << "profile(s)"; // Load profiles from filesystem @@ -53,7 +53,7 @@ void BroadcastSettings::loadProfiles() { BroadcastProfilePtr profile = BroadcastProfile::loadFromFile(fileInfo.absoluteFilePath()); - if(profile) + if (profile) addProfile(profile); } } else { @@ -70,10 +70,10 @@ void BroadcastSettings::loadProfiles() { } bool BroadcastSettings::addProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; - if(m_profiles.size() >= BROADCAST_MAX_CONNECTIONS) { + if (m_profiles.size() >= BROADCAST_MAX_CONNECTIONS) { kLogger.warning() << "addProfile: connection limit reached." << "can't add more than" << QString::number(BROADCAST_MAX_CONNECTIONS) << "connections."; @@ -91,16 +91,16 @@ bool BroadcastSettings::addProfile(BroadcastProfilePtr profile) { this, SLOT(onConnectionStatusChanged(int))); m_profiles.insert(profile->getProfileName(), BroadcastProfilePtr(profile)); - emit profileAdded(profile); + emit(profileAdded(profile)); return true; } BroadcastProfilePtr BroadcastSettings::createProfile(const QString& profileName) { QFileInfo xmlFile(filePathForProfile(profileName)); - if(!xmlFile.exists()) { + if (!xmlFile.exists()) { BroadcastProfilePtr profile(new BroadcastProfile(profileName)); - if(addProfile(profile)) { + if (addProfile(profile)) { saveProfile(profile); return profile; } @@ -109,7 +109,7 @@ BroadcastProfilePtr BroadcastSettings::createProfile(const QString& profileName) } bool BroadcastSettings::saveProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; return profile->save(filePathForProfile(profile)); @@ -122,14 +122,14 @@ QString BroadcastSettings::filePathForProfile(const QString& profileName) { } QString BroadcastSettings::filePathForProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return QString(); return filePathForProfile(profile->getProfileName()); } bool BroadcastSettings::deleteFileForProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; return deleteFileForProfile(profile->getProfileName()); @@ -137,7 +137,7 @@ bool BroadcastSettings::deleteFileForProfile(BroadcastProfilePtr profile) { bool BroadcastSettings::deleteFileForProfile(const QString& profileName) { QFileInfo xmlFile(filePathForProfile(profileName)); - if(xmlFile.exists()) { + if (xmlFile.exists()) { return QFile::remove(xmlFile.absoluteFilePath()); } return false; @@ -153,26 +153,26 @@ void BroadcastSettings::saveAll() { for(auto kv : m_profiles.values()) { saveProfile(kv); } - emit profilesChanged(); + emit(profilesChanged()); } void BroadcastSettings::deleteProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; deleteFileForProfile(profile); m_profiles.remove(profile->getProfileName()); - emit profileRemoved(profile); + emit(profileRemoved(profile)); } void BroadcastSettings::onProfileNameChanged(QString oldName, QString newName) { - if(!m_profiles.contains(oldName)) + if (!m_profiles.contains(oldName)) return; BroadcastProfilePtr profile = m_profiles.take(oldName); - if(profile) { + if (profile) { m_profiles.insert(newName, profile); - emit profileRenamed(oldName, profile); + emit(profileRenamed(oldName, profile)); deleteFileForProfile(oldName); saveProfile(profile); @@ -192,7 +192,7 @@ QList BroadcastSettings::profiles() { } void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { - if(!pModel) { + if (!pModel) { return; } // TODO(Palakis): lock both lists against modifications while syncing @@ -200,7 +200,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { // Step 1: find profiles to delete from the settings for(BroadcastProfilePtr actualProfile : m_profiles.values()) { QString profileName = actualProfile->getProfileName(); - if(!pModel->getProfileByName(profileName)) { + if (!pModel->getProfileByName(profileName)) { // If profile exists in settings but not in the model, // remove the profile from the settings deleteProfile(actualProfile); @@ -212,7 +212,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { // Check if profile already exists in settings BroadcastProfilePtr existingProfile = m_profiles.value(profileCopy->getProfileName()); - if(!existingProfile) { + if (!existingProfile) { // If no profile with the same name exists, add the new // profile to the settings. // The BroadcastProfile instance is a copy to separate it @@ -225,7 +225,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { for(BroadcastProfilePtr profileCopy : pModel->profiles()) { BroadcastProfilePtr actualProfile = m_profiles.value(profileCopy->getProfileName()); - if(actualProfile) { + if (actualProfile) { profileCopy->copyValuesTo(actualProfile); } } diff --git a/src/preferences/broadcastsettings_legacy.cpp b/src/preferences/broadcastsettings_legacy.cpp index 60a944370919..cab4536736e0 100644 --- a/src/preferences/broadcastsettings_legacy.cpp +++ b/src/preferences/broadcastsettings_legacy.cpp @@ -31,7 +31,7 @@ const char* kStreamWebsite = "stream_website"; } void BroadcastSettings::loadLegacySettings(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; // For each value, the current value is kept if it can't be found in the diff --git a/src/preferences/broadcastsettingsmodel.cpp b/src/preferences/broadcastsettingsmodel.cpp index 81f733183b60..eb2927798c23 100644 --- a/src/preferences/broadcastsettingsmodel.cpp +++ b/src/preferences/broadcastsettingsmodel.cpp @@ -15,7 +15,7 @@ BroadcastSettingsModel::BroadcastSettingsModel() { } void BroadcastSettingsModel::resetFromSettings(BroadcastSettingsPointer pSettings) { - if(!pSettings) { + if (!pSettings) { return; } @@ -35,7 +35,7 @@ void BroadcastSettingsModel::resetFromSettings(BroadcastSettingsPointer pSetting } bool BroadcastSettingsModel::addProfileToModel(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; int position = m_profiles.size(); @@ -57,11 +57,11 @@ bool BroadcastSettingsModel::addProfileToModel(BroadcastProfilePtr profile) { } void BroadcastSettingsModel::deleteProfileFromModel(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; int position = m_profiles.keys().indexOf(profile->getProfileName()); - if(position > -1) { + if (position > -1) { beginRemoveRows(QModelIndex(), position, position); endRemoveRows(); } @@ -120,13 +120,13 @@ QVariant BroadcastSettingsModel::data(const QModelIndex& index, int role) const QVariant BroadcastSettingsModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(orientation == Qt::Horizontal) { - if(role == Qt::DisplayRole) { - if(section == kColumnEnabled) { + if (orientation == Qt::Horizontal) { + if (role == Qt::DisplayRole) { + if (section == kColumnEnabled) { return tr("Enabled"); - } else if(section == kColumnName) { + } else if (section == kColumnName) { return tr("Name"); - } else if(section == kColumnStatus) { + } else if (section == kColumnStatus) { return tr("Status"); } } @@ -135,27 +135,27 @@ QVariant BroadcastSettingsModel::headerData(int section, Qt::Orientation orienta } Qt::ItemFlags BroadcastSettingsModel::flags(const QModelIndex& index) const { - if(index.column() == kColumnEnabled) + if (index.column() == kColumnEnabled) return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; - if(index.column() == kColumnName) + if (index.column() == kColumnName) return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; } bool BroadcastSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { - if(index.isValid()) { + if (index.isValid()) { BroadcastProfilePtr profile = m_profiles.values().at(index.row()); - if(profile) { - if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { + if (profile) { + if (index.column() == kColumnEnabled && role == Qt::CheckStateRole) { profile->setEnabled(value.toBool()); } - if(index.column() == kColumnName && role == Qt::EditRole) { + if (index.column() == kColumnName && role == Qt::EditRole) { QString newName = value.toString(); newName = newName.trimmed(); - if(!newName.isNull() && !newName.isEmpty()) + if (!newName.isNull() && !newName.isEmpty()) profile->setProfileName(newName); } } @@ -206,18 +206,18 @@ QColor BroadcastSettingsModel::connectionStatusColor(BroadcastProfilePtr profile } void BroadcastSettingsModel::onProfileNameChanged(QString oldName, QString newName) { - if(!m_profiles.contains(oldName)) + if (!m_profiles.contains(oldName)) return; BroadcastProfilePtr profile = m_profiles.take(oldName); - if(profile) { + if (profile) { m_profiles.insert(newName, profile); } // Refresh the whole name column QModelIndex start = this->index(0, kColumnName); QModelIndex end = this->index(this->rowCount()-1, kColumnName); - emit dataChanged(start, end); + emit(dataChanged(start, end)); } void BroadcastSettingsModel::onConnectionStatusChanged(int newStatus) { @@ -225,6 +225,6 @@ void BroadcastSettingsModel::onConnectionStatusChanged(int newStatus) { // Refresh the whole status column QModelIndex start = this->index(0, kColumnStatus); QModelIndex end = this->index(this->rowCount()-1, kColumnStatus); - emit dataChanged(start, end); + emit(dataChanged(start, end)); } diff --git a/src/preferences/configobject.cpp b/src/preferences/configobject.cpp index bbbccdfa0c65..c8aabe5f4319 100644 --- a/src/preferences/configobject.cpp +++ b/src/preferences/configobject.cpp @@ -266,7 +266,7 @@ template ConfigObject::ConfigObject(const QDomNode& QDomNode ctrl = node.firstChild(); while (!ctrl.isNull()) { - if(ctrl.nodeName() == "control") { + if (ctrl.nodeName() == "control") { QString group = XmlParse::selectNodeQString(ctrl, "group"); QString key = XmlParse::selectNodeQString(ctrl, "key"); ConfigKey k(group, key); diff --git a/src/preferences/dialog/dlgprefbeats.cpp b/src/preferences/dialog/dlgprefbeats.cpp index 8cdb1714dc99..508dac3bdd34 100644 --- a/src/preferences/dialog/dlgprefbeats.cpp +++ b/src/preferences/dialog/dlgprefbeats.cpp @@ -48,7 +48,7 @@ DlgPrefBeats::~DlgPrefBeats() { } void DlgPrefBeats::loadSettings() { - if(m_pconfig->getValueString( + if (m_pconfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_BEAT_PLUGIN_ID)).isEmpty()) { slotResetToDefaults(); slotApply(); // Write to config file so AnalyzerBeats can get the data diff --git a/src/preferences/dialog/dlgprefbroadcast.cpp b/src/preferences/dialog/dlgprefbroadcast.cpp index a992eabb08a6..3a21555ec1e6 100644 --- a/src/preferences/dialog/dlgprefbroadcast.cpp +++ b/src/preferences/dialog/dlgprefbroadcast.cpp @@ -142,7 +142,7 @@ void DlgPrefBroadcast::slotUpdate() { } void DlgPrefBroadcast::applyModel() { - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { setValuesToProfile(m_pProfileListSelection); } m_pBroadcastSettings->applyModel(m_pSettingsModel); @@ -187,7 +187,7 @@ void DlgPrefBroadcast::slotApply() { applyModel(); bool broadcastingEnabled = m_pBroadcastEnabled->toBool(); - if(!broadcastingEnabled && connectOnApply->isChecked()) { + if (!broadcastingEnabled && connectOnApply->isChecked()) { m_pBroadcastEnabled->set(true); // Reset state of "Connect on Apply" checkbox @@ -233,7 +233,7 @@ void DlgPrefBroadcast::enableCustomMetadataChanged(int value) { } void DlgPrefBroadcast::btnCreateConnectionClicked() { - if(m_pSettingsModel->rowCount() >= BROADCAST_MAX_CONNECTIONS) { + if (m_pSettingsModel->rowCount() >= BROADCAST_MAX_CONNECTIONS) { QMessageBox::warning(this, tr("Action failed"), tr("You can't create more than %1 source connections.") .arg(BROADCAST_MAX_CONNECTIONS)); @@ -253,7 +253,7 @@ void DlgPrefBroadcast::btnCreateConnectionClicked() { } while(!existingProfile.isNull()); BroadcastProfilePtr newProfile(new BroadcastProfile(newName)); - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { m_pProfileListSelection->copyValuesTo(newProfile); } m_pSettingsModel->addProfileToModel(newProfile); @@ -267,7 +267,7 @@ void DlgPrefBroadcast::connectionListItemSelected(const QModelIndex& selected) { Qt::DisplayRole).toString(); BroadcastProfilePtr profile = m_pSettingsModel->getProfileByName(selectedName); - if(profile) { + if (profile) { getValuesFromProfile(profile); m_pProfileListSelection = profile; } @@ -277,12 +277,12 @@ void DlgPrefBroadcast::updateModel() { // Resetting the model will clear the current list selection // so store the name of the current selection before resetting QString selected(""); - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { selected = m_pProfileListSelection->getProfileName(); } m_pSettingsModel->resetFromSettings(m_pBroadcastSettings); - if(!selected.isEmpty()) { + if (!selected.isEmpty()) { // Restore previous selection with the name fetched before selectConnectionRowByName(selected); } @@ -324,7 +324,7 @@ void DlgPrefBroadcast::selectConnectionRowByName(QString rowName) { } void DlgPrefBroadcast::getValuesFromProfile(BroadcastProfilePtr profile) { - if(!profile) { + if (!profile) { return; } @@ -442,7 +442,7 @@ void DlgPrefBroadcast::getValuesFromProfile(BroadcastProfilePtr profile) { } void DlgPrefBroadcast::setValuesToProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; profile->setSecureCredentialStorage(rbPasswordKeychain->isChecked()); @@ -496,26 +496,26 @@ void DlgPrefBroadcast::setValuesToProfile(BroadcastProfilePtr profile) { } void DlgPrefBroadcast::btnRemoveConnectionClicked() { - if(m_pSettingsModel->rowCount() < 2) { + if (m_pSettingsModel->rowCount() < 2) { QMessageBox::information(this, tr("Action failed"), tr("At least one source connection is required.")); return; } - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { QString profileName = m_pProfileListSelection->getProfileName(); auto response = QMessageBox::question(this, tr("Confirmation required"), tr("Are you sure you want to delete '%1'?") .arg(profileName), QMessageBox::Yes, QMessageBox::No); - if(response == QMessageBox::Yes) { + if (response == QMessageBox::Yes) { m_pSettingsModel->deleteProfileFromModel(m_pProfileListSelection); } } } void DlgPrefBroadcast::btnRenameConnectionClicked() { - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { QString profileName = m_pProfileListSelection->getProfileName(); bool ok = false; @@ -523,9 +523,9 @@ void DlgPrefBroadcast::btnRenameConnectionClicked() { QInputDialog::getText(this, tr("Renaming '%1'").arg(profileName), tr("New name for '%1':").arg(profileName), QLineEdit::Normal, profileName, &ok); - if(ok && newName != profileName) { + if (ok && newName != profileName) { BroadcastProfilePtr existingProfile = m_pSettingsModel->getProfileByName(newName); - if(!existingProfile) { + if (!existingProfile) { // Requested name not used already m_pProfileListSelection->setProfileName(newName); getValuesFromProfile(m_pProfileListSelection); @@ -545,7 +545,7 @@ void DlgPrefBroadcast::btnDisconnectAllClicked() { tr("Are you sure you want to disconnect every active source connection?"), QMessageBox::Yes, QMessageBox::No); - if(response == QMessageBox::Yes) { + if (response == QMessageBox::Yes) { m_pBroadcastEnabled->set(false); broadcastEnabledChanged(0.0); } diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 49a710b00fe2..90c6c27a62a2 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -12,39 +12,70 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, m_pEffectsManager(pEffectsManager) { setupUi(this); - connect(availableEffectsList, - SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + m_availableEffectsModel.resetFromEffectManager(pEffectsManager); + for (auto& profile : m_availableEffectsModel.profiles()) { + EffectManifestPointer pManifest = profile->pManifest; + + // Users are likely to have lots of external plugins installed and + // many of them are useless for DJing. To avoid cluttering the list + // shown in WEffectSelector, blacklist external plugins by default. + bool defaultValue = (pManifest->backendType() == EffectBackendType::BuiltIn); + bool visible = m_pConfig->getValue(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", + pManifest->id()), defaultValue); + profile->bIsVisible = visible; + m_pEffectsManager->setEffectVisibility(pManifest, visible); + } + availableEffectsList->setModel(&m_availableEffectsModel); + + connect(availableEffectsList->selectionModel(), + SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, - SLOT(slotEffectSelected(QListWidgetItem*, QListWidgetItem*))); + SLOT(availableEffectsListItemSelected(const QModelIndex&))); + + // Highlight first row + availableEffectsList->selectRow(0); + + #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + availableEffectsList->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); + availableEffectsList->setColumnWidth(1, 200); + availableEffectsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); + #else + availableEffectsList->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + availableEffectsList->setColumnWidth(1, 200); + availableEffectsList->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); + #endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +} + +DlgPrefEffects::~DlgPrefEffects() { } void DlgPrefEffects::slotUpdate() { clear(); - const QList availableEffectManifests = - m_pEffectsManager->getAvailableEffectManifests(); - - for (const auto& pManifest : availableEffectManifests) { - QListWidgetItem* pItem = new QListWidgetItem(); - pItem->setData(Qt::UserRole, pManifest->id()); - pItem->setText(pManifest->displayName()); - availableEffectsList->addItem(pItem); - } + m_availableEffectsModel.resetFromEffectManager(m_pEffectsManager); - if (!availableEffectManifests.isEmpty()) { - availableEffectsList->setCurrentRow(0); + if (!m_availableEffectsModel.isEmpty()) { + availableEffectsList->selectRow(0); } } void DlgPrefEffects::slotApply() { - // Nothing to apply. + for (EffectProfilePtr profile : m_availableEffectsModel.profiles()) { + EffectManifestPointer pManifest = profile->pManifest; + m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); + + // Effects from different backends can have same Effect IDs. + // Add backend name to group to uniquely identify those effects. + // Use untranslated value to keep the group language independent. + m_pConfig->set(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), + ConfigValue(profile->bIsVisible)); + } } void DlgPrefEffects::slotResetToDefaults() { - // Nothing to reset. + slotUpdate(); } void DlgPrefEffects::clear() { - availableEffectsList->clear(); effectName->clear(); effectAuthor->clear(); effectDescription->clear(); @@ -52,24 +83,17 @@ void DlgPrefEffects::clear() { effectType->clear(); } -void DlgPrefEffects::slotEffectSelected(QListWidgetItem* pCurrent, - QListWidgetItem* pPrevious) { - Q_UNUSED(pPrevious); - if (pCurrent == NULL) { +void DlgPrefEffects::availableEffectsListItemSelected(const QModelIndex& selected) { + QString effectId = m_availableEffectsModel.data(selected, Qt::UserRole).toString(); + + if (effectId == QVariant().toString()) return; - } - QString effectId = pCurrent->data(Qt::UserRole).toString(); - EffectManifestPointer pManifest; - EffectsBackend* pBackend; - m_pEffectsManager->getEffectManifestAndBackend(effectId, &pManifest, &pBackend); + + EffectManifestPointer pManifest = m_pEffectsManager->getEffectManifest(effectId); effectName->setText(pManifest->name()); effectAuthor->setText(pManifest->author()); effectDescription->setText(pManifest->description()); effectVersion->setText(pManifest->version()); - if (pBackend != NULL) { - effectType->setText(pBackend->getName()); - } else { - effectType->clear(); - } + effectType->setText(pManifest->translatedBackendName()); } diff --git a/src/preferences/dialog/dlgprefeffects.h b/src/preferences/dialog/dlgprefeffects.h index 301f038fe6cf..5665c5f5a007 100644 --- a/src/preferences/dialog/dlgprefeffects.h +++ b/src/preferences/dialog/dlgprefeffects.h @@ -4,6 +4,7 @@ #include "preferences/usersettings.h" #include "preferences/dialog/ui_dlgprefeffectsdlg.h" #include "preferences/dlgpreferencepage.h" +#include "preferences/effectsettingsmodel.h" class EffectsManager; @@ -13,21 +14,22 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg { DlgPrefEffects(QWidget* pParent, UserSettingsPointer pConfig, EffectsManager* pEffectsManager); - virtual ~DlgPrefEffects() {} + virtual ~DlgPrefEffects(); void slotUpdate(); void slotApply(); void slotResetToDefaults(); private slots: - void slotEffectSelected(QListWidgetItem* pCurrent, - QListWidgetItem* pPrevious); + void availableEffectsListItemSelected(const QModelIndex& selected); private: void clear(); + EffectSettingsModel m_availableEffectsModel; UserSettingsPointer m_pConfig; EffectsManager* m_pEffectsManager; + EffectSettingsModel* m_pAvailableEffectsModel; }; #endif /* DLGPREFEFFECTS_H */ diff --git a/src/preferences/dialog/dlgprefeffectsdlg.ui b/src/preferences/dialog/dlgprefeffectsdlg.ui index 03279c2912a6..4719789a2afb 100644 --- a/src/preferences/dialog/dlgprefeffectsdlg.ui +++ b/src/preferences/dialog/dlgprefeffectsdlg.ui @@ -43,28 +43,40 @@ - - - - 0 - 0 - - - - - 140 - 0 - - + - 140 + 400 16777215 - - false + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + true + + + Qt::NoPen + + + true + + + true + + + false + + + false + diff --git a/src/preferences/dialog/dlgprefeq.cpp b/src/preferences/dialog/dlgprefeq.cpp index be5fe1176b9d..df028ef50985 100644 --- a/src/preferences/dialog/dlgprefeq.cpp +++ b/src/preferences/dialog/dlgprefeq.cpp @@ -20,8 +20,8 @@ #include #include "preferences/dialog/dlgprefeq.h" -#include "effects/native/biquadfullkilleqeffect.h" -#include "effects/native/filtereffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" +#include "effects/builtin/filtereffect.h" #include "effects/effectslot.h" #include "engine/enginefilterbessel4.h" #include "control/controlobject.h" diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index 19c7de45c339..bab257d4192f 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -95,15 +95,15 @@ void DlgPrefKey::loadSettings() { qDebug() << "Key plugin ID:" << m_pConfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); - if(m_pConfig->getValueString( + if (m_pConfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)) == "") { slotResetToDefaults(); slotApply(); // Write to config file so AnalyzerKey can get the data return; } - QString pluginid = m_pConfig->getValueString( - ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); + QString pluginid = m_pConfig->getValueString( + ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); m_selectedAnalyzer = pluginid; m_bAnalyzerEnabled = static_cast(m_pConfig->getValueString( diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp new file mode 100644 index 000000000000..48e87ba020ea --- /dev/null +++ b/src/preferences/effectsettingsmodel.cpp @@ -0,0 +1,144 @@ +#include + + +namespace { +const int kColumnEnabled = 0; +const int kColumnName = 1; +const int kColumnType = 2; +const int kNumberOfColumns = 3; +} + +EffectSettingsModel::EffectSettingsModel() { +} + +EffectSettingsModel::~EffectSettingsModel() { +} + +void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager) { + if (!pEffectsManager) { + return; + } + + beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1); + endRemoveRows(); + m_profiles.clear(); + + for (EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { + const bool visibility = pEffectsManager->getEffectVisibility(pManifest); + addProfileToModel(EffectProfilePtr(new EffectProfile(pManifest, visibility))); + } +} + +bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { + if (!profile) + return false; + + int position = m_profiles.size(); + beginInsertRows(QModelIndex(), position, position); + + m_profiles.push_back(EffectProfilePtr(profile)); + + endInsertRows(); + return true; +} + +void EffectSettingsModel::deleteProfileFromModel(EffectProfilePtr profile) { + if (!profile) + return; + + int position = m_profiles.indexOf(profile); + if (position > -1) { + beginRemoveRows(QModelIndex(), position, position); + endRemoveRows(); + } + m_profiles.removeAll(profile); +} + +int EffectSettingsModel::rowCount(const QModelIndex& parent) const { + Q_UNUSED(parent); + return m_profiles.size(); +} + +int EffectSettingsModel::columnCount(const QModelIndex& parent) const { + Q_UNUSED(parent); + return kNumberOfColumns; +} + +QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { + int rowIndex = index.row(); + if (!index.isValid() || rowIndex >= m_profiles.size()) { + return QVariant(); + } + + EffectProfilePtr profile = m_profiles.at(rowIndex); + if (profile) { + if (role == Qt::UserRole) { + return profile->pManifest->id(); + } + int column = index.column(); + if (column == kColumnEnabled) { + if (role == Qt::CheckStateRole) { + return (profile->bIsVisible ? Qt::Checked : Qt::Unchecked); + } else if (role == Qt::TextAlignmentRole) { + return Qt::AlignCenter; + } + } else if (column == kColumnName && role == Qt::DisplayRole) { + return profile->pManifest->displayName(); + } else if (column == kColumnType && role == Qt::DisplayRole) { + return profile->pManifest->translatedBackendName(); + } + } + + return QVariant(); +} + +QVariant EffectSettingsModel::headerData(int section, Qt::Orientation orientation, + int role) const { + if (orientation == Qt::Horizontal) { + if (role == Qt::DisplayRole) { + if (section == kColumnEnabled) { + return tr("Visible"); + } else if (section == kColumnName) { + return tr("Name"); + } else if (section == kColumnType) { + return tr("Type"); + } + } + } + return QVariant(); +} + +Qt::ItemFlags EffectSettingsModel::flags(const QModelIndex& index) const { + if (index.column() == kColumnEnabled) + return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; + + if (index.column() == kColumnName) + return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; + + if (index.column() == kColumnType) + return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; + + return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; +} + +bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { + if (index.isValid()) { + EffectProfilePtr profile = m_profiles.at(index.row()); + if (profile) { + if (index.column() == kColumnEnabled && role == Qt::CheckStateRole) { + profile->bIsVisible = value.toBool(); + } + } + } + return true; +} + +QAbstractItemDelegate* EffectSettingsModel::delegateForColumn(const int i, QObject* parent) { + Q_UNUSED(i); + Q_UNUSED(parent); + return nullptr; +} + +bool EffectSettingsModel::isEmpty() const { + return m_profiles.isEmpty(); +} diff --git a/src/preferences/effectsettingsmodel.h b/src/preferences/effectsettingsmodel.h new file mode 100644 index 000000000000..c89bea82eb5b --- /dev/null +++ b/src/preferences/effectsettingsmodel.h @@ -0,0 +1,53 @@ +#ifndef PREFERENCES_EFFECTSETTINGSMODEL_H +#define PREFERENCES_EFFECTSETTINGSMODEL_H + +#include +#include +#include +#include + +#include "effects/effectmanifest.h" +#include "effects/effectsmanager.h" + +struct EffectProfile { + EffectManifestPointer pManifest; + bool bIsVisible; + + EffectProfile(EffectManifestPointer _pManifest, bool _bIsVisible) { + pManifest = _pManifest; + bIsVisible = _bIsVisible; + } +}; +typedef QSharedPointer EffectProfilePtr; + +class EffectSettingsModel : public QAbstractTableModel { + Q_OBJECT + public: + EffectSettingsModel(); + ~EffectSettingsModel(); + + void resetFromEffectManager(EffectsManager* pEffectsManager); + + bool addProfileToModel(EffectProfilePtr profile); + void deleteProfileFromModel(EffectProfilePtr profile); + QList profiles() { + return m_profiles; + } + + int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + Qt::ItemFlags flags(const QModelIndex& index) const; + bool setData(const QModelIndex& index, const QVariant& value, + int role = Qt::EditRole); + QAbstractItemDelegate* delegateForColumn(const int i, QObject* parent); + + bool isEmpty() const; + + private: + QList m_profiles; +}; + +#endif // PREFERENCES_EFFECTSETTINGSMODEL_H diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index d0f76210e55d..f7a12d3cb3f5 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -2052,7 +2052,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg bool directionOptionSet = false; int directionOption = ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET; - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "ConnectValueFromWidget", &nodeValue)) { if (nodeValue) { directionOption = directionOption | ControlParameterWidgetConnection::DIR_FROM_WIDGET; @@ -2062,7 +2062,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg directionOptionSet = true; } - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "ConnectValueToWidget", &nodeValue)) { if (nodeValue) { directionOption = directionOption | ControlParameterWidgetConnection::DIR_TO_WIDGET; @@ -2081,14 +2081,14 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg int emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS; - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "EmitOnDownPress", &nodeValue)) { if (nodeValue) { emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS; } else { emitOption = ControlParameterWidgetConnection::EMIT_ON_RELEASE; } - } else if(m_pContext->hasNodeSelectBool( + } else if (m_pContext->hasNodeSelectBool( con, "EmitOnPressAndRelease", &nodeValue)) { if (nodeValue) { emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE; diff --git a/src/soundio/sounddevicenetwork.cpp b/src/soundio/sounddevicenetwork.cpp index 4390dc7e6199..621a4f86ac13 100644 --- a/src/soundio/sounddevicenetwork.cpp +++ b/src/soundio/sounddevicenetwork.cpp @@ -272,7 +272,7 @@ void SoundDeviceNetwork::writeProcess() { QVector workers = m_pNetworkStream->outputWorkers(); for(auto pWorker : workers) { - if(pWorker.isNull()) { + if (pWorker.isNull()) { continue; } @@ -333,7 +333,7 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker } QSharedPointer> pFifo = pWorker->getOutputFifo(); - if(pFifo) { + if (pFifo) { // interval = copyCount // Check for desired kNetworkLatencyFrames + 1/2 interval to // avoid big jitter due to interferences with sync code @@ -380,7 +380,7 @@ void SoundDeviceNetwork::workerWriteSilence(NetworkOutputStreamWorkerPtr pWorker } QSharedPointer> pFifo = pWorker->getOutputFifo(); - if(pFifo) { + if (pFifo) { int writeAvailable = pFifo->writeAvailable(); int writeRequired = frames * m_iNumOutputChannels; if (writeAvailable < writeRequired) { diff --git a/src/sources/soundsourceffmpeg.cpp b/src/sources/soundsourceffmpeg.cpp index 31dbfb77d85c..d1525dcd01cd 100644 --- a/src/sources/soundsourceffmpeg.cpp +++ b/src/sources/soundsourceffmpeg.cpp @@ -364,7 +364,7 @@ SoundSource::OpenResult SoundSourceFFmpeg::tryOpen( } // Add stream parameters to context - if(avcodec_parameters_to_context(pCodecContext,pAudioStream->codecpar)) { + if (avcodec_parameters_to_context(pCodecContext,pAudioStream->codecpar)) { kLogger.warning() << "Failed to find to set Code parameter for AVCodecContext" << pAudioStream->index; @@ -559,7 +559,7 @@ bool SoundSourceFFmpeg::readFramesToCache(unsigned int count, SINT offset) { continue; } - if(l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { + if (l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { kLogger.warning() << "readFramesToCache: Warning can't decode frame!"; } @@ -572,7 +572,7 @@ bool SoundSourceFFmpeg::readFramesToCache(unsigned int count, SINT offset) { continue; } - if(l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { + if (l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { kLogger.warning() << "readFramesToCache: Warning can't decode frame!"; } @@ -739,7 +739,7 @@ bool SoundSourceFFmpeg::getBytesFromCache(CSAMPLE* buffer, SINT offset, // If cache is empty then return without crash. if (m_SCache.isEmpty()) { kLogger.debug() << "getBytesFromCache: Cache is empty can't return bytes"; - if(l_pBuffer != nullptr) + if (l_pBuffer != nullptr) { memset(l_pBuffer, 0x00, l_lLeft); } @@ -839,7 +839,7 @@ bool SoundSourceFFmpeg::getBytesFromCache(CSAMPLE* buffer, SINT offset, continue; } else { kLogger.debug() << "getBytesFromCache: Buffer run out. Shouldn't happen!"; - if(l_pBuffer != nullptr) + if (l_pBuffer != nullptr) { memset(l_pBuffer, 0x00, l_lLeft); } diff --git a/src/sources/soundsourceoggvorbis.cpp b/src/sources/soundsourceoggvorbis.cpp index 04ecaa532137..9637172b0e04 100644 --- a/src/sources/soundsourceoggvorbis.cpp +++ b/src/sources/soundsourceoggvorbis.cpp @@ -42,7 +42,7 @@ SoundSource::OpenResult SoundSourceOggVorbis::tryOpen( OpenMode /*mode*/, const OpenParams& /*config*/) { m_pFile = std::make_unique(getLocalFileName()); - if(!m_pFile->open(QFile::ReadOnly)) { + if (!m_pFile->open(QFile::ReadOnly)) { kLogger.warning() << "Failed to open file for" << getUrlString(); diff --git a/src/test/baseeffecttest.h b/src/test/baseeffecttest.h index 412918aa1180..0102f5fc8dd6 100644 --- a/src/test/baseeffecttest.h +++ b/src/test/baseeffecttest.h @@ -19,7 +19,7 @@ class TestEffectBackend : public EffectsBackend { public: - TestEffectBackend() : EffectsBackend(NULL, "TestBackend") { + TestEffectBackend() : EffectsBackend(NULL, EffectBackendType::Unknown) { } // Expose as public diff --git a/src/test/nativeeffects_test.cpp b/src/test/nativeeffects_test.cpp index 046cc75a0891..9b899bc451aa 100644 --- a/src/test/nativeeffects_test.cpp +++ b/src/test/nativeeffects_test.cpp @@ -4,18 +4,18 @@ #include #include "control/controlpotmeter.h" -#include "effects/native/autopaneffect.h" -#include "effects/native/bessel4lvmixeqeffect.h" -#include "effects/native/bessel8lvmixeqeffect.h" -#include "effects/native/bitcrushereffect.h" -#include "effects/native/echoeffect.h" -#include "effects/native/filtereffect.h" -#include "effects/native/flangereffect.h" -#include "effects/native/graphiceqeffect.h" -#include "effects/native/linkwitzriley8eqeffect.h" -#include "effects/native/moogladder4filtereffect.h" -#include "effects/native/phasereffect.h" -#include "effects/native/reverbeffect.h" +#include "effects/builtin/autopaneffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" +#include "effects/builtin/bitcrushereffect.h" +#include "effects/builtin/echoeffect.h" +#include "effects/builtin/filtereffect.h" +#include "effects/builtin/flangereffect.h" +#include "effects/builtin/graphiceqeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" +#include "effects/builtin/moogladder4filtereffect.h" +#include "effects/builtin/phasereffect.h" +#include "effects/builtin/reverbeffect.h" #include "engine/channelhandle.h" #include "engine/effects/groupfeaturestate.h" #include "test/baseeffecttest.h" @@ -31,7 +31,7 @@ class EffectsBenchmarkTest : public BaseEffectTest { }; template -void benchmarkNativeEffectDefaultParameters(const mixxx::EngineParameters& bufferParameters, +void benchmarkBuiltInEffectDefaultParameters(const mixxx::EngineParameters& bufferParameters, benchmark::State* pState, EffectsManager* pEffectsManager) { EffectManifestPointer pManifest = EffectType::getManifest(); @@ -65,7 +65,7 @@ void benchmarkNativeEffectDefaultParameters(const mixxx::EngineParameters& buffe #define FOR_COMMON_BUFFER_SIZES(bm) bm->Arg(32)->Arg(64)->Arg(128)->Arg(256)->Arg(512)->Arg(1024)->Arg(2048)->Arg(4096); #define DECLARE_EFFECT_BENCHMARK(EffectName) \ -TEST_F(EffectsBenchmarkTest, BM_NativeEffects_DefaultParameters_##EffectName) { \ +TEST_F(EffectsBenchmarkTest, BM_BuiltInEffects_DefaultParameters_##EffectName) { \ ControlPotmeter loEqFrequency( \ ConfigKey("[Mixer Profile]", "LoEQFrequency"), 0., 22040); \ loEqFrequency.setDefaultValue(250.0); \ @@ -75,10 +75,10 @@ TEST_F(EffectsBenchmarkTest, BM_NativeEffects_DefaultParameters_##EffectName) { mixxx::EngineParameters bufferParameters( \ mixxx::AudioSignal::SampleRate(44100), \ state.range_x()); \ - benchmarkNativeEffectDefaultParameters( \ + benchmarkBuiltInEffectDefaultParameters( \ bufferParameters, &state, m_pEffectsManager); \ } \ -FOR_COMMON_BUFFER_SIZES(BENCHMARK(BM_NativeEffects_DefaultParameters_##EffectName)); +FOR_COMMON_BUFFER_SIZES(BENCHMARK(BM_BuiltInEffects_DefaultParameters_##EffectName)); DECLARE_EFFECT_BENCHMARK(Bessel4LVMixEQEffect) DECLARE_EFFECT_BENCHMARK(Bessel8LVMixEQEffect) diff --git a/src/widget/weffectselector.cpp b/src/widget/weffectselector.cpp index 75b101a7d4ee..11aaf2f330cd 100644 --- a/src/widget/weffectselector.cpp +++ b/src/widget/weffectselector.cpp @@ -27,6 +27,8 @@ void WEffectSelector::setup(const QDomNode& node, const SkinContext& context) { node, context, m_pChainSlot); if (m_pEffectSlot != nullptr) { + connect(m_pEffectsManager, SIGNAL(visibleEffectsUpdated()), + this, SLOT(populate())); connect(m_pEffectSlot.data(), SIGNAL(updated()), this, SLOT(slotEffectUpdated())); connect(this, SIGNAL(currentIndexChanged(int)), @@ -44,14 +46,12 @@ void WEffectSelector::populate() { blockSignals(true); clear(); - // TODO(xxx): filter out blacklisted effects - // https://bugs.launchpad.net/mixxx/+bug/1653140 - const QList availableEffectManifests = - m_pEffectsManager->getAvailableEffectManifests(); + const QList visibleEffectManifests = + m_pEffectsManager->getVisibleEffectManifests(); QFontMetrics metrics(font()); - for (int i = 0; i < availableEffectManifests.size(); ++i) { - const EffectManifestPointer pManifest = availableEffectManifests.at(i); + for (int i = 0; i < visibleEffectManifests.size(); ++i) { + const EffectManifestPointer pManifest = visibleEffectManifests.at(i); QString elidedDisplayName = metrics.elidedText(pManifest->displayName(), Qt::ElideMiddle, width() - 2); @@ -70,7 +70,7 @@ void WEffectSelector::populate() { //: Displayed when no effect is loaded addItem(tr("None"), QVariant()); - setItemData(availableEffectManifests.size(), QVariant(tr("No effect loaded.")), + setItemData(visibleEffectManifests.size(), QVariant(tr("No effect loaded.")), Qt::ToolTipRole); slotEffectUpdated(); diff --git a/src/widget/wwidgetgroup.cpp b/src/widget/wwidgetgroup.cpp index 3fa1d2cae4fe..a38c199388e3 100644 --- a/src/widget/wwidgetgroup.cpp +++ b/src/widget/wwidgetgroup.cpp @@ -223,5 +223,5 @@ void WWidgetGroup::setHighlight(int highlight) { style()->unpolish(this); style()->polish(this); update(); - emit highlightChanged(m_highlight); + emit(highlightChanged(m_highlight)); }