Skip to content

Commit 3fccab3

Browse files
committed
Refactor status-bar code
1 parent 4683128 commit 3fccab3

File tree

8 files changed

+117
-216
lines changed

8 files changed

+117
-216
lines changed

src/MainWindow.cpp

Lines changed: 49 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ MainWindow::MainWindow(QString exepath,
381381
// Liveprog
382382
ui->liveprog->coupleIDE(_eelEditor);
383383
connect(ui->liveprog, &LiveprogSelectionWidget::liveprogReloadRequested, _audioService, &IAudioService::reloadLiveprog);
384-
connect(ui->liveprog, &LiveprogSelectionWidget::unitLabelUpdateRequested, this, &MainWindow::updateUnitLabel);
384+
connect(ui->liveprog, &LiveprogSelectionWidget::unitLabelUpdateRequested, ui->info, qOverload<const QString&>(&FadingLabel::setAnimatedText));
385385
}
386386

387387
// Populate preset lists
@@ -447,6 +447,8 @@ MainWindow::MainWindow(QString exepath,
447447
ui->tabhost->setStyleSheet(QString("QWidget#tabHostPage1,QWidget#tabHostPage2,QWidget#tabHostPage3,QWidget#tabHostPage4,QWidget#tabHostPage5,QWidget#tabHostPage6,QWidget#tabHostPage7,QWidget#tabHostPage8,QWidget#tabHostPage9{background-color: %1;}").arg(qApp->palette().window().color().lighter().name()));
448448
ui->tabbar->redrawTabBar();
449449

450+
installUnitData();
451+
450452
if (debuggerIsAttached() || system("which ddctoolbox > /dev/null 2>&1")) { // Workaround: do not call system() when GDB is attached
451453
connect(ui->ddctoolbox_install, &QAbstractButton::clicked, []{
452454
int ret = system("xdg-open https://github.com/thepbone/DDCToolbox"); // QDesktopServices::openUrl broken on some KDE systems with Qt 5.15
@@ -605,7 +607,7 @@ void MainWindow::onRelinkRequested()
605607
_spectrumReloadSignalQueued = true;
606608
}
607609

608-
// ---User preset management
610+
// User preset management
609611
void MainWindow::loadExternalFile()
610612
{
611613
QString filename = QFileDialog::getOpenFileName(this, tr("Load custom audio.conf"), "", "JamesDSP Linux configuration (*.conf)");
@@ -636,7 +638,7 @@ void MainWindow::saveExternalFile()
636638
PresetManager::instance().saveToPath(filename);
637639
}
638640

639-
// ---Config IO
641+
// Load/save
640642
void MainWindow::loadConfig()
641643
{
642644
_blockApply = true;
@@ -800,8 +802,6 @@ void MainWindow::loadConfig()
800802
ui->eq_dyn_widget->loadMap(eqData);
801803
}
802804

803-
updateAllUnitLabels();
804-
805805
determineEqPresetName();
806806
determineIrsSelection();
807807
determineVdcSelection();
@@ -912,7 +912,7 @@ void MainWindow::applyConfig()
912912
saveGraphicEQView();
913913
}
914914

915-
// ---Predefined Presets
915+
// Predefined presets
916916
void MainWindow::onEqPresetUpdated()
917917
{
918918
if (ui->eqpreset->currentText() == "Custom" || _blockApply)
@@ -954,13 +954,9 @@ void MainWindow::onBs2bPresetUpdated()
954954
break;
955955
}
956956

957-
// FIXME remove this vvv
958-
ui->info->setAnimatedText("'" + ui->crossfeed_mode->currentText() + "' has been selected", true);
959-
960957
ui->bs2b_custom_box->setEnabled(index == 99);
961958
_blockApply = false;
962959

963-
updateAllUnitLabels();
964960
applyConfig();
965961
}
966962

@@ -990,146 +986,40 @@ void MainWindow::onReverbPresetUpdated()
990986
ui->rev_lco->setValueA((int) data.p14);
991987
ui->rev_decay->setValueA((int) (data.p15 * 100));
992988
ui->rev_delay->setValueA((int) (data.p16 * 10));
993-
updateAllUnitLabels();
994989
_blockApply = false;
995990

996991
applyConfig();
997992
}
998993

999-
// ---Status
1000-
void MainWindow::updateUnitLabel(int d,
1001-
QObject *alt)
994+
// Status
995+
void MainWindow::installUnitData()
1002996
{
1003-
if (_blockApply && alt == nullptr)
1004-
{
1005-
return; // Skip if blockapply-flag is set (when setting presets, ...)
1006-
}
997+
ui->rev_width->setProperty("unit", "%");
998+
ui->rev_osf->setProperty("unit", "x");
1007999

1008-
QObject *obj;
1000+
QList<QAnimatedSlider*> div100({ui->rev_era, ui->rev_erf, ui->rev_erw, ui->rev_width, ui->rev_bass, ui->rev_spin, ui->rev_wander, ui->rev_decay,
1001+
ui->analog_tubedrive});
10091002

1010-
if (alt == nullptr)
1011-
{
1012-
obj = sender();
1013-
}
1014-
else
1015-
{
1016-
obj = alt;
1017-
}
1003+
QList<QAnimatedSlider*> div10({ui->bs2b_feed, ui->rev_delay, ui->rev_wet, ui->rev_finalwet, ui->rev_finaldry, ui->rev_width});
10181004

1019-
QString pre = "";
1020-
QString post = "";
1005+
QList<QAnimatedSlider*> unitDecibel({ui->bs2b_feed, ui->rev_wet, ui->rev_finalwet, ui->rev_finaldry, ui->analog_tubedrive, ui->postgain, ui->bass_maxgain});
1006+
QList<QAnimatedSlider*> unitMs({ui->rev_delay, ui->comp_maxattack, ui->comp_maxrelease, ui->limrelease});
1007+
QList<QAnimatedSlider*> unitHz({ui->bs2b_fcut, ui->rev_lcb, ui->rev_lcd, ui->rev_lci, ui->rev_lco});
10211008

1022-
if (obj == ui->rev_width)
1023-
{
1024-
updateTooltipLabelUnit(obj, QString::number((double) d) + "%", alt == nullptr);
1025-
}
1026-
else if (obj == ui->bs2b_feed)
1027-
{
1028-
updateTooltipLabelUnit(obj, QString::number((double) d / 10) + "dB", alt == nullptr);
1029-
}
1030-
else if (obj == ui->analog_tubedrive)
1031-
{
1032-
updateTooltipLabelUnit(obj, QString::number((double) d / 100) + "dB", alt == nullptr);
1033-
}
1034-
else if (obj == ui->rev_decay)
1035-
{
1036-
updateTooltipLabelUnit(obj, QString::number((double) d / 100), alt == nullptr);
1037-
}
1038-
else if (obj == ui->rev_delay)
1039-
{
1040-
updateTooltipLabelUnit(obj, QString::number((double) d / 10) + "ms", alt == nullptr);
1041-
}
1042-
else if (obj == ui->rev_wet || obj == ui->rev_finalwet || obj == ui->rev_finaldry)
1043-
{
1044-
updateTooltipLabelUnit(obj, QString::number((double) d / 10) + "dB", alt == nullptr);
1045-
}
1046-
else if (obj == ui->rev_era || obj == ui->rev_erf || obj == ui->rev_erw
1047-
|| obj == ui->rev_width || obj == ui->rev_bass || obj == ui->rev_spin
1048-
|| obj == ui->rev_wander)
1049-
{
1050-
updateTooltipLabelUnit(obj, QString::number((double) d / 100), alt == nullptr);
1051-
}
1052-
else if (obj == ui->eqfiltertype || obj == ui->eqinterpolator || obj == ui->conv_ir_opt)
1053-
{
1054-
// Ignore these UI elements
1055-
}
1056-
else if(obj->property("isCustomEELProperty").toBool())
1057-
{
1058-
if (obj->property("handleAsInt").toBool())
1059-
{
1060-
updateTooltipLabelUnit(obj, QString::number((int) d / 100), true);
1061-
}
1062-
else
1063-
{
1064-
updateTooltipLabelUnit(obj, QString::number((double) d / 100), true);
1065-
}
1066-
}
1067-
1068-
else
1069-
{
1070-
if (obj == ui->postgain)
1071-
{
1072-
post = "dB";
1073-
}
1074-
else if (obj == ui->comp_maxattack || obj == ui->comp_maxrelease || obj == ui->limrelease)
1075-
{
1076-
post = "ms";
1077-
}
1078-
else if (obj == ui->bass_maxgain)
1079-
{
1080-
post = "dB";
1081-
}
1082-
else if (obj == ui->bs2b_fcut)
1083-
{
1084-
post = "Hz";
1085-
}
1086-
else if (obj == ui->rev_lcb || obj == ui->rev_lcd
1087-
|| obj == ui->rev_lci || obj == ui->rev_lco)
1088-
{
1089-
post = "Hz";
1090-
}
1091-
else if (obj == ui->rev_osf)
1092-
{
1093-
post = "x";
1094-
}
1009+
foreach(auto w, div100)
1010+
w->setProperty("divisor", 100);
1011+
foreach(auto w, div10)
1012+
w->setProperty("divisor", 10);
10951013

1096-
updateTooltipLabelUnit(obj, pre + QString::number(d) + post, alt == nullptr);
1097-
}
1098-
}
1099-
1100-
void MainWindow::updateTooltipLabelUnit(QObject *sender,
1101-
const QString &text,
1102-
bool viasignal)
1103-
{
1104-
QWidget *w = qobject_cast<QWidget*>(sender);
1105-
w->setToolTip(text);
1106-
1107-
if (viasignal)
1108-
{
1109-
ui->info->setAnimatedText(text, false);
1110-
}
1014+
foreach(auto w, unitDecibel)
1015+
w->setProperty("unit", "dB");
1016+
foreach(auto w, unitMs)
1017+
w->setProperty("unit", "ms");
1018+
foreach(auto w, unitHz)
1019+
w->setProperty("unit", "Hz");
11111020
}
11121021

1113-
void MainWindow::updateAllUnitLabels()
1114-
{
1115-
QList<QComboBox*> comboboxesToBeUpdated({ ui->eqfiltertype, ui->eqinterpolator });
1116-
1117-
QList<QAnimatedSlider*> slidersToBeUpdated({
1118-
ui->analog_tubedrive, ui->stereowide_level, ui->bs2b_fcut, ui->bs2b_feed,
1119-
ui->limthreshold, ui->limrelease, ui->comp_maxrelease, ui->comp_maxattack,
1120-
ui->rev_osf, ui->rev_erf, ui->rev_era, ui->rev_erw, ui->rev_lci, ui->rev_lcb, ui->rev_lcd,
1121-
ui->rev_lco, ui->rev_finalwet, ui->rev_finaldry, ui->rev_wet, ui->rev_width, ui->rev_spin, ui->rev_wander, ui->rev_decay,
1122-
ui->rev_delay, ui->rev_bass, ui->postgain, ui->comp_aggressiveness, ui->bass_maxgain
1123-
});
1124-
1125-
foreach(auto w, slidersToBeUpdated)
1126-
updateUnitLabel(w->valueA(), w);
1127-
1128-
foreach(auto w, comboboxesToBeUpdated)
1129-
updateUnitLabel(w->currentIndex(), w);
1130-
}
1131-
1132-
// ---DDC
1022+
// DDC
11331023
void MainWindow::setVdcFile(const QString& path)
11341024
{
11351025
_currentVdc = path;
@@ -1216,7 +1106,7 @@ void MainWindow::onVdcDatabaseSelected(const QItemSelection &, const QItemSelect
12161106
applyConfig();
12171107
}
12181108

1219-
// ---IRS
1109+
// IRS
12201110
void MainWindow::setIrsFile(const QString& path)
12211111
{
12221112
_currentImpuleResponse = path;
@@ -1265,7 +1155,7 @@ void MainWindow::onConvolverWaveformEdit()
12651155
}
12661156
}
12671157

1268-
// ---Liveprog
1158+
// Liveprog
12691159
int MainWindow::extractDefaultEelScripts(bool allowOverride,
12701160
bool user)
12711161
{
@@ -1322,7 +1212,7 @@ int MainWindow::extractDefaultEelScripts(bool allowOverride,
13221212
return i;
13231213
}
13241214

1325-
// ---Helper
1215+
// EQ
13261216
void MainWindow::setEq(const QVector<double> &data)
13271217
{
13281218
_blockApply = true;
@@ -1380,7 +1270,7 @@ void MainWindow::onAutoEqImportRequested()
13801270
sel->deleteLater();
13811271
}
13821272

1383-
// ---GraphicEQ States
1273+
// GraphicEQ states
13841274
void MainWindow::restoreGraphicEQView()
13851275
{
13861276
QVariantMap state;
@@ -1411,37 +1301,29 @@ void MainWindow::saveGraphicEQView()
14111301
state);
14121302
}
14131303

1414-
// ---Connect UI-Signals
1304+
// Connections
14151305
void MainWindow::connectActions()
14161306
{
1417-
QList<QAnimatedSlider*> registerValueAChange({
1418-
ui->analog_tubedrive, ui->stereowide_level, ui->bs2b_fcut, ui->bs2b_feed, ui->bass_maxgain,
1419-
ui->limthreshold, ui->limrelease, ui->comp_maxrelease, ui->comp_maxattack, ui->comp_aggressiveness,
1420-
ui->rev_osf, ui->rev_erf, ui->rev_era, ui->rev_erw, ui->rev_lci, ui->rev_lcb, ui->rev_lcd,
1421-
ui->rev_lco, ui->rev_finalwet, ui->rev_finaldry, ui->rev_wet, ui->rev_width, ui->rev_spin, ui->rev_wander, ui->rev_decay,
1422-
ui->rev_delay, ui->rev_bass, ui->postgain
1423-
});
1424-
1425-
QList<QWidget*> registerSliderRelease({
1426-
ui->stereowide_level, ui->bs2b_fcut, ui->bs2b_feed, ui->rev_osf, ui->rev_erf, ui->rev_era, ui->rev_erw,
1427-
ui->rev_lci, ui->rev_lcb, ui->rev_lcd, ui->rev_lco, ui->rev_finalwet, ui->rev_finaldry, ui->rev_wet, ui->rev_width, ui->rev_spin,
1428-
ui->rev_wander, ui->rev_decay, ui->rev_delay, ui->rev_bass, ui->analog_tubedrive, ui->limthreshold,
1429-
ui->limrelease, ui->comp_maxrelease, ui->comp_maxattack, ui->comp_aggressiveness,
1430-
ui->bass_maxgain, ui->postgain
1431-
});
1307+
QList<QAnimatedSlider*> sliders({
1308+
ui->stereowide_level, ui->bs2b_fcut, ui->bs2b_feed, ui->rev_osf, ui->rev_erf, ui->rev_era, ui->rev_erw,
1309+
ui->rev_lci, ui->rev_lcb, ui->rev_lcd, ui->rev_lco, ui->rev_finalwet, ui->rev_finaldry, ui->rev_wet, ui->rev_width, ui->rev_spin,
1310+
ui->rev_wander, ui->rev_decay, ui->rev_delay, ui->rev_bass, ui->analog_tubedrive, ui->limthreshold,
1311+
ui->limrelease, ui->comp_maxrelease, ui->comp_maxattack, ui->comp_aggressiveness,
1312+
ui->bass_maxgain, ui->postgain
1313+
});
14321314

14331315
QList<QWidget*> registerClick({
1434-
ui->bassboost, ui->bs2b, ui->stereowidener, ui->analog, ui->reverb, ui->enable_eq, ui->enable_comp, ui->ddc_enable, ui->conv_enable,
1435-
ui->graphicEq->chk_enable
1436-
});
1437-
1438-
foreach(QWidget * w, registerValueAChange)
1439-
connect(w, SIGNAL(valueChangedA(int)), this, SLOT(updateUnitLabel(int)));
1316+
ui->bassboost, ui->bs2b, ui->stereowidener, ui->analog, ui->reverb, ui->enable_eq, ui->enable_comp, ui->ddc_enable, ui->conv_enable,
1317+
ui->graphicEq->chk_enable
1318+
});
14401319

1441-
foreach(QWidget * w, registerSliderRelease)
1442-
connect(w, SIGNAL(sliderReleased()), this, SLOT(applyConfig()));
1320+
foreach(QAnimatedSlider* w, sliders)
1321+
{
1322+
connect(w, &QAnimatedSlider::stringChanged, ui->info, qOverload<const QString&>(&FadingLabel::setAnimatedText));
1323+
connect(w, SIGNAL(valueChangedA(int)), this, SLOT(applyConfig()));
1324+
}
14431325

1444-
foreach(QWidget * w, registerClick)
1326+
foreach(QWidget* w, registerClick)
14451327
connect(w, SIGNAL(clicked()), this, SLOT(applyConfig()));
14461328

14471329
connect(ui->disableFX, SIGNAL(clicked()), this, SLOT(onPassthroughToggled()));
@@ -1483,6 +1365,7 @@ void MainWindow::connectActions()
14831365
connect(_eelEditor, &EELEditor::scriptSaved, ui->liveprog, &LiveprogSelectionWidget::updateFromEelEditor);
14841366
}
14851367

1368+
// Setup wizard
14861369
void MainWindow::launchFirstRunSetup()
14871370
{
14881371
QHBoxLayout *lbLayout = new QHBoxLayout;

src/MainWindow.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ private slots:
8484

8585
void resetEQ();
8686

87-
88-
void updateAllUnitLabels();
89-
void updateUnitLabel(int,
90-
QObject *alt = nullptr);
91-
92-
9387
void loadExternalFile();
9488
void saveExternalFile();
9589

@@ -114,6 +108,7 @@ private slots:
114108
void onVdcDatabaseSelected(const QItemSelection &, const QItemSelection &);
115109
void onAutoEqImportRequested();
116110
void onConvolverInfoChanged(const ConvolverInfoEventArgs &args);
111+
117112
private:
118113
Ui::MainWindow *ui;
119114

@@ -147,12 +142,11 @@ private slots:
147142
QString _currentVdc = "";
148143
QString _currentConvWaveformEdit = "";
149144

150-
void updateTooltipLabelUnit(QObject *sender,
151-
const QString &text,
152-
bool);
153145
void loadConfig();
154146
void connectActions();
155147

148+
void installUnitData();
149+
156150
void determineIrsSelection();
157151
void determineVdcSelection();
158152

src/interface/FadingLabel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ void FadingLabel::setAnimatedText(const QString &msg, bool highPriority)
5454

5555
lastAnimationHighPriority = highPriority;
5656
}
57+
58+
void FadingLabel::setAnimatedText(const QString &msg)
59+
{
60+
setAnimatedText(msg, false);
61+
}

src/interface/FadingLabel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class FadingLabel : public QLabel
1212
Q_OBJECT
1313
public:
1414
FadingLabel(QWidget* parent = nullptr);
15+
16+
public slots:
1517
void setAnimatedText(const QString& msg, bool highPriority);
18+
void setAnimatedText(const QString& msg);
1619

1720
private:
1821
QGraphicsOpacityEffect* effect = nullptr;

0 commit comments

Comments
 (0)