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 / Effect widgets: use '---' placeholder instead of 'None' #3485

Merged
merged 4 commits into from
Jan 8, 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
2 changes: 2 additions & 0 deletions src/effects/effectsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "moc_effectsmanager.cpp"
#include "util/assert.h"

const QString EffectsManager::kNoEffectString = QStringLiteral("---");

namespace {
const QString kEffectGroupSeparator = "_";
const QString kGroupClose = "]";
Expand Down
2 changes: 2 additions & 0 deletions src/effects/effectsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class EffectsBackend;
class EffectsManager : public QObject {
Q_OBJECT
public:
static const QString kNoEffectString;

typedef bool (*EffectManifestFilterFnc)(EffectManifest* pManifest);

EffectsManager(QObject* pParent,
Expand Down
23 changes: 14 additions & 9 deletions src/preferences/dialog/dlgprefeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ void DlgPrefEQ::slotPopulateDeckEffectSelectors() {
currentIndex = i;
}
}
//: Displayed when no effect is selected
box->addItem(tr("None"), QVariant(QString("")));
// Add empty item, no effect
box->addItem(EffectsManager::kNoEffectString);

if (selectedEffectId.isEmpty()) {
currentIndex = availableEQEffects.size(); // selects "None"
// Configured effect has no id, clear selection
currentIndex = availableEQEffects.size();
} else if (currentIndex < 0 && !selectedEffectName.isEmpty() ) {
// current selection is not part of the new list
// So we need to add it
Expand All @@ -254,10 +256,12 @@ void DlgPrefEQ::slotPopulateDeckEffectSelectors() {
currentIndex = i;
}
}
//: Displayed when no effect is selected
box->addItem(tr("None"), QVariant(QString("")));
// Add empty item, no effect
box->addItem(EffectsManager::kNoEffectString);

if (selectedEffectId.isEmpty()) {
currentIndex = availableQuickEffects.size(); // selects "None"
// Configured effect has no id, clear selection
currentIndex = availableQuickEffects.size();
} else if (currentIndex < 0 && !selectedEffectName.isEmpty()) {
// current selection is not part of the new list
// So we need to add it
Expand Down Expand Up @@ -671,12 +675,13 @@ void DlgPrefEQ::setUpMasterEQ() {
for (const auto& pManifest : availableMasterEQEffects) {
comboBoxMasterEq->addItem(pManifest->name(), QVariant(pManifest->id()));
}
//: Displayed when no effect is selected
comboBoxMasterEq->addItem(tr("None"), QVariant());
// Add empty item, no effect
comboBoxMasterEq->addItem(EffectsManager::kNoEffectString);

int masterEqIndex = comboBoxMasterEq->findData(configuredEffect);
if (masterEqIndex < 0) {
masterEqIndex = availableMasterEQEffects.size(); // selects "None"
// Configured effect not in list, clear selection
masterEqIndex = availableMasterEQEffects.size();
}
comboBoxMasterEq->setCurrentIndex(masterEqIndex);

Expand Down
10 changes: 7 additions & 3 deletions src/preferences/dialog/dlgprefsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ DlgPrefSound::DlgPrefSound(QWidget* pParent,
m_loading(false) {
setupUi(this);

connect(m_pSoundManager, &SoundManager::devicesUpdated, this, &DlgPrefSound::refreshDevices);
connect(m_pSoundManager,
&SoundManager::devicesUpdated,
this,
&DlgPrefSound::refreshDevices);

apiComboBox->clear();
apiComboBox->addItem(tr("None"), "None");
apiComboBox->addItem(SoundManagerConfig::kEmptyComboBox,
SoundManagerConfig::kDefaultAPI);
updateAPIs();
connect(apiComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
Expand Down Expand Up @@ -611,7 +615,7 @@ void DlgPrefSound::updateAudioBufferSizes(int sampleRateIndex) {
* just changes and we need to display new devices.
*/
void DlgPrefSound::refreshDevices() {
if (m_config.getAPI() == "None") {
if (m_config.getAPI() == SoundManagerConfig::kDefaultAPI) {
m_outputDevices.clear();
m_inputDevices.clear();
} else {
Expand Down
12 changes: 8 additions & 4 deletions src/preferences/dialog/dlgprefsounditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
* @param isInput true if this is representing an AudioInput, false otherwise
* @param index the index of the represented AudioPath, if applicable
*/
DlgPrefSoundItem::DlgPrefSoundItem(QWidget* parent, AudioPathType type,
const QList<SoundDevicePointer>& devices, bool isInput,
unsigned int index)
DlgPrefSoundItem::DlgPrefSoundItem(
QWidget* parent,
AudioPathType type,
const QList<SoundDevicePointer>& devices,
bool isInput,
unsigned int index)
: QWidget(parent),
m_type(type),
m_index(index),
Expand All @@ -27,7 +30,8 @@ DlgPrefSoundItem::DlgPrefSoundItem(QWidget* parent, AudioPathType type,
setupUi(this);
typeLabel->setText(AudioPath::getTrStringFromType(type, index));

deviceComboBox->addItem(tr("None"), QVariant::fromValue(SoundDeviceId()));
deviceComboBox->addItem(SoundManagerConfig::kEmptyComboBox,
QVariant::fromValue(SoundDeviceId()));

// Set the focus policy for QComboBoxes (and wide QDoubleSpinBoxes) and
// connect them to the custom event filter below so they don't accept focus
Expand Down
2 changes: 1 addition & 1 deletion src/soundio/soundmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ QList<SoundDevicePointer> SoundManager::getDeviceList(
const QString& filterAPI, bool bOutputDevices, bool bInputDevices) const {
//qDebug() << "SoundManager::getDeviceList";

if (filterAPI == "None") {
if (filterAPI == SoundManagerConfig::kDefaultAPI) {
return QList<SoundDevicePointer>();
}

Expand Down
3 changes: 2 additions & 1 deletion src/soundio/soundmanagerconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// this (7) represents latency values from 1 ms to about 80 ms -- bkgood
const unsigned int SoundManagerConfig::kMaxAudioBufferSizeIndex = 7;

const QString SoundManagerConfig::kDefaultAPI = QString("None");
const QString SoundManagerConfig::kDefaultAPI = QStringLiteral("None");
const QString SoundManagerConfig::kEmptyComboBox = QStringLiteral("---");
// Sample Rate even the cheap sound Devices will support most likely
const unsigned int SoundManagerConfig::kFallbackSampleRate = 48000;
const unsigned int SoundManagerConfig::kDefaultDeckCount = 2;
Expand Down
1 change: 1 addition & 0 deletions src/soundio/soundmanagerconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SoundManagerConfig {
};
static const unsigned int kMaxAudioBufferSizeIndex;
static const QString kDefaultAPI;
static const QString kEmptyComboBox;
static const unsigned int kFallbackSampleRate;
static const unsigned int kDefaultDeckCount;
static const int kDefaultAudioBufferSizeIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/widget/weffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void WEffect::effectUpdated() {
description = tr("%1: %2").arg(pManifest->name(), pManifest->description());
}
} else {
name = tr("None");
name = EffectsManager::kNoEffectString;
description = tr("No effect loaded.");
}
setText(name);
Expand Down
2 changes: 1 addition & 1 deletion src/widget/weffectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void WEffectChain::setEffectChainSlot(EffectChainSlotPointer pEffectChainSlot) {
}

void WEffectChain::chainUpdated() {
QString name = tr("None");
QString name = EffectsManager::kNoEffectString;
QString description = tr("No effect chain loaded.");
if (m_pEffectChainSlot) {
EffectChainPointer pChain = m_pEffectChainSlot->getEffectChain();
Expand Down
2 changes: 1 addition & 1 deletion src/widget/weffectparameterbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void WEffectParameterBase::parameterUpdated() {
m_pEffectParameterSlot->name(),
m_pEffectParameterSlot->description()));
} else {
setText(tr("None"));
setText(EffectsManager::kNoEffectString);
setBaseTooltip(tr("No effect loaded."));
}
}
5 changes: 2 additions & 3 deletions src/widget/weffectselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ void WEffectSelector::populate() {
setItemData(i, QVariant(QStringLiteral("<b>") + name + QStringLiteral("</b><br/>") +
description), Qt::ToolTipRole);
}

//: Displayed when no effect is loaded
addItem(tr("None"), QVariant());
// Add empty item, no effect
addItem(EffectsManager::kNoEffectString);
setItemData(visibleEffectManifests.size(), QVariant(tr("No effect loaded.")),
Qt::ToolTipRole);

Expand Down