Skip to content

Commit 1b4aa97

Browse files
author
ThePBone
committed
Implement keyboard control for sliders
1 parent 1bc21ca commit 1b4aa97

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

config/appconfigwrapper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ void AppConfigWrapper::setTheme(QString thm){
127127
saveAppConfig();
128128
}
129129
QString AppConfigWrapper::getTheme(){
130-
return appconf->getString("theme.name");
130+
QString name = appconf->getString("theme.name");
131+
if(name.isEmpty()) name = "Fusion";
132+
return name;
131133
}
132134
QString AppConfigWrapper::getIrsPath(){
133135
QString irs_path = chopFirstLastChar(appconf->getString("convolver.default.irspath",false));

dialog/qanimatedslider.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "qanimatedslider.h"
2-
#include <QEvent>
2+
#include <QKeyEvent>
33
/*
44
* MIT License
55
@@ -79,5 +79,28 @@ void QAnimatedSlider::setDuration(int duration)
7979
mDuration = duration;
8080
}
8181

82+
bool QAnimatedSlider::event(QEvent *ev)
83+
{
84+
ev->ignore();
85+
if(ev->type() == QEvent::Type::KeyRelease){
86+
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(ev);
87+
switch (keyEvent->key()) {
88+
case Qt::Key::Key_Up:
89+
case Qt::Key::Key_Down:
90+
case Qt::Key::Key_Left:
91+
case Qt::Key::Key_Right:
92+
case Qt::Key::Key_PageUp:
93+
case Qt::Key::Key_PageDown:
94+
cValue = value();
95+
emit valueChangedA(cValue);
96+
return true;
97+
default:
98+
QSlider::event(ev);
99+
}
100+
101+
}
102+
return QSlider::event(ev);
103+
}
104+
82105

83106

dialog/qanimatedslider.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@ class QAnimatedSlider : public QSlider
7575
int cValue = 0;
7676
int mDuration = 300;
7777
QEasingCurve mEasingCurve = QEasingCurve(QEasingCurve::Type::InOutCirc);
78+
bool event(QEvent *event) override;
7879
};
7980
#endif // QANIMATEDSLIDER_H

mainwindow.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ MainWindow::MainWindow(QString exepath, bool statupInTray, bool allowMultipleIns
143143
else trayIcon->hide();
144144

145145
connect(m_dbus, &DBusProxy::propertiesCommitted, this, [this](){
146-
conf->setConfigMap(m_dbus->FetchPropertyMap());
147-
LoadConfig(Context::DBus);
146+
//conf->setConfigMap(m_dbus->FetchPropertyMap());
147+
//LoadConfig(Context::DBus);
148148
});
149149

150150
connect(m_appwrapper,&AppConfigWrapper::styleChanged,this,[this](){
@@ -717,8 +717,10 @@ void MainWindow::LoadConfig(Context ctx){
717717
if(eqReloadRequired)
718718
ui->eq_widget->setBands(eq_data,false);
719719

720-
if(ctx != Context::DBus) UpdateEqStringFromWidget();
721-
UpdateDynsysStringFromWidget();
720+
if(ctx != Context::DBus){
721+
UpdateEqStringFromWidget();
722+
UpdateDynsysStringFromWidget();
723+
}
722724
UpdateAllUnitLabels();
723725

724726
QString ir = conf->getString("conv_ir_path",false);
@@ -1012,9 +1014,7 @@ void MainWindow::SetEQ(const QVector<float> data){
10121014
lockapply=true;
10131015
ui->eq_widget->setBands(QVector<float>(data));
10141016
lockapply=false;
1015-
QTimer::singleShot(510,this,[this](){
1016-
OnUpdate(true);
1017-
});
1017+
OnUpdate(true);
10181018
}
10191019
void MainWindow::ResetEQ(){
10201020
ui->reset_eq->setEnabled(false);
@@ -1067,9 +1067,11 @@ AppConfigWrapper* MainWindow::getACWrapper(){
10671067

10681068
//---Connect UI-Signals
10691069
void MainWindow::ConnectActions(){
1070-
QList<QWidget*> registerValueChange(
1071-
{ui->convcc,ui->vbfreq,ui->vbgain,ui->vbmode,ui->difflvl,ui->vhplvl,ui->roomsize,ui->roomwidth,ui->roomdamp,
1072-
ui->wet,ui->dry,ui->colmwide,ui->colmmidimg,ui->colmdepth,ui->vclvl,ui->vcmode,ui->gain,ui->maxgain,ui->maxvol,
1070+
QList<QWidget*> registerValueChange({ui->vbmode,ui->vcmode});
1071+
1072+
QList<QAnimatedSlider*> registerValueAChange(
1073+
{ui->convcc,ui->vbfreq,ui->vbgain,ui->difflvl,ui->vhplvl,ui->roomsize,ui->roomwidth,ui->roomdamp,
1074+
ui->wet,ui->dry,ui->colmwide,ui->colmmidimg,ui->colmdepth,ui->vclvl,ui->gain,ui->maxgain,ui->maxvol,
10731075
ui->outputpan,ui->limiter,ui->outvolume,ui->vcurelvl,ui->axmode,ui->barkfreq,ui->barkcon,ui->comprelease,ui->compgain,
10741076
ui->compwidth,ui->comp_ratio,ui->comp_thres,ui->compattack,ui->comprelease,ui->a_adapt,ui->a_crest,ui->a_maxatk,ui->a_maxrel,
10751077
ui->a_kneewidth,ui->dyn_xcoeff1,ui->dyn_xcoeff2,ui->dyn_ycoeff1,ui->dyn_ycoeff2,ui->dyn_bassgain,ui->dyn_sidegain1,ui->dyn_sidegain2});
@@ -1091,6 +1093,9 @@ void MainWindow::ConnectActions(){
10911093
foreach (QWidget* w, registerValueChange)
10921094
connect(w, SIGNAL(valueChanged(int)), this, SLOT(UpdateUnitLabel(int)));
10931095

1096+
foreach (QWidget* w, registerValueAChange)
1097+
connect(w, SIGNAL(valueChangedA(int)), this, SLOT(UpdateUnitLabel(int)));
1098+
10941099
foreach (QWidget* w, registerSliderRelease)
10951100
connect(w, SIGNAL(sliderReleased()), this, SLOT(OnRelease()));
10961101

misc/presetprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const QMap<COLM_UNIT> Colm::COLM_LOOKUP_TABLE(){
141141
return std::move(table);
142142
}
143143

144-
const std::initializer_list<int> Colm::lookupPreset(QString preset){
144+
const INT_LIST Colm::lookupPreset(QString preset){
145145
auto table = COLM_LOOKUP_TABLE();
146146
if(table.contains(preset))
147147
return table[preset];

misc/presetprovider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "initializableqmap.h"
2121

2222
#define FLOAT_LIST QVector<float>
23-
#define INT_LIST std::initializer_list<int>
23+
#define INT_LIST QVector<int>
2424

2525
#define EQ_UNIT QString,FLOAT_LIST
2626
#define DYNSYS_UNIT QString,INT_LIST

0 commit comments

Comments
 (0)