Skip to content

Commit 0730a74

Browse files
author
ThePBone
committed
Replace colm preset selection with combobox
1 parent f4c1580 commit 0730a74

File tree

8 files changed

+105
-59
lines changed

8 files changed

+105
-59
lines changed

V4L_Frontend.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ qnx: target.path = /tmp/$${TARGET}/bin
137137
else: unix:!android: target.path = /usr/bin/
138138

139139
# Set BUILDPATH variable to change the output path
140-
!isEmpty($$BUILDPATH): target.path = $$BUILDPATH
141-
!isEmpty($$BUILDPATH): DESTDIR = $$BUILDPATH
140+
# !isEmpty($$BUILDPATH): target.path = $$BUILDPATH
141+
# !isEmpty($$BUILDPATH): DESTDIR = $$BUILDPATH
142142

143143
!isEmpty(target.path): INSTALLS += target
144144

main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ int main(int argc, char *argv[])
4646
)
4747
);
4848
w.setWindowFlags(Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint);
49+
w.hide();
4950
if(!parser.isSet(tray)) w.show();
5051

5152
QApplication::setQuitOnLastWindowClosed( true );

mainwindow.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,7 @@ MainWindow::MainWindow(QString exepath, bool statupInTray, bool allowMultipleIns
126126
menu->addAction(tr("What's this..."), this,[](){QWhatsThis::enterWhatsThisMode();});
127127

128128
ui->toolButton->setMenu(menu);
129-
QMenu *menuC = new QMenu();
130-
menuC->addAction(tr("Slight"), this,[this](){ ui->colmpreset->setText(tr("Slight")); ColmPresetSelectionUpdated();});
131-
menuC->addAction(tr("Level 1"), this,[this](){ ui->colmpreset->setText(tr("Level 1")); ColmPresetSelectionUpdated();});
132-
menuC->addAction(tr("Level 2"), this,[this](){ ui->colmpreset->setText(tr("Level 2")); ColmPresetSelectionUpdated();});
133-
menuC->addAction(tr("Level 3"), this,[this](){ ui->colmpreset->setText(tr("Level 3")); ColmPresetSelectionUpdated();});
134-
menuC->addAction(tr("Level 4"), this,[this](){ ui->colmpreset->setText(tr("Level 4")); ColmPresetSelectionUpdated();});
135-
menuC->addAction(tr("Level 5"), this,[this](){ ui->colmpreset->setText(tr("Level 5")); ColmPresetSelectionUpdated();});
136-
menuC->addAction(tr("Level 6"), this,[this](){ ui->colmpreset->setText(tr("Level 6")); ColmPresetSelectionUpdated();});
137-
menuC->addAction(tr("Level 7"), this,[this](){ ui->colmpreset->setText(tr("Level 7")); ColmPresetSelectionUpdated();});
138-
menuC->addAction(tr("Extreme"), this,[this](){ ui->colmpreset->setText(tr("Extreme")); ColmPresetSelectionUpdated();});
139-
ui->colmpreset->setMenu(menuC);
129+
140130
m_stylehelper->SetStyle();
141131
ui->eq_widget->setAccentColor(palette().highlight().color());
142132

@@ -622,12 +612,8 @@ QMenu* MainWindow::buildAvailableActions()
622612
if(preset == "Unknown") continue;
623613
QAction *newEntry = new QAction(preset);
624614
connect(newEntry,&QAction::triggered,this,[=](){
625-
const auto data = PresetProvider::Colm::lookupPreset(preset);
626-
lockapply=true;
627-
ui->colmwide->setValueA(data.begin()[0]);
628-
ui->colmdepth->setValueA(data.begin()[1]);
629-
lockapply=false;
630-
OnUpdate(true);
615+
ui->colmpreset->setCurrentText(preset);
616+
ColmPresetSelectionUpdated();
631617
});
632618
colmMenu->addAction(newEntry);
633619
}
@@ -946,6 +932,7 @@ void MainWindow::LoadConfig(Context ctx){
946932
if(ctx != Context::DBus){
947933
UpdateEqStringFromWidget();
948934
UpdateDynsysStringFromWidget();
935+
UpdateColmStringFromWidget();
949936
}
950937
UpdateAllUnitLabels();
951938

@@ -1086,8 +1073,11 @@ void MainWindow::DynsysPresetSelectionUpdated(){
10861073
OnUpdate(true);
10871074
}
10881075
void MainWindow::ColmPresetSelectionUpdated(){
1089-
QString selection = ui->colmpreset->text();
1090-
const auto data = PresetProvider::Colm::lookupPreset(selection);
1076+
if(ui->colmpreset->currentText() == "...")
1077+
return;
1078+
const auto data = PresetProvider::Colm::lookupPreset(ui->colmpreset->currentText());
1079+
if(data.size() <= 1)
1080+
return;
10911081
lockapply=true;
10921082
ui->colmwide->setValueA(data.begin()[0]);
10931083
ui->colmdepth->setValueA(data.begin()[1]);
@@ -1273,6 +1263,11 @@ void MainWindow::UpdateDynsysStringFromWidget(){
12731263
ui->dyn_sidegain1->valueA(),ui->dyn_sidegain2->valueA()});
12741264
ui->dynsys_preset->setCurrentText(currentDynsysPresetName);
12751265
}
1266+
void MainWindow::UpdateColmStringFromWidget(){
1267+
QString currentColmPresetName =
1268+
PresetProvider::Colm::reverseLookup({ui->colmwide->valueA(),ui->colmdepth->valueA()});
1269+
ui->colmpreset->setCurrentText(currentColmPresetName);
1270+
}
12761271

12771272
QVariantMap MainWindow::readConfig(){
12781273
QVariantMap confmap = ConfigIO::readFile(m_appwrapper->getPath());
@@ -1322,6 +1317,9 @@ void MainWindow::ConnectActions(){
13221317
QList<QWidget*> registerDynsysUpdate(
13231318
{ui->dyn_xcoeff1,ui->dyn_xcoeff2,ui->dyn_ycoeff1,ui->dyn_ycoeff2,ui->dyn_sidegain1,ui->dyn_sidegain2});
13241319

1320+
QList<QWidget*> registerColmUpdate(
1321+
{ui->colmwide,ui->colmdepth});
1322+
13251323
foreach (QWidget* w, registerCurrentIndexChange)
13261324
connect(w, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateUnitLabel(int)));
13271325

@@ -1337,6 +1335,9 @@ void MainWindow::ConnectActions(){
13371335
foreach (QWidget* w, registerDynsysUpdate)
13381336
connect(w, SIGNAL(sliderReleased()), this, SLOT(UpdateDynsysStringFromWidget()));
13391337

1338+
foreach (QWidget* w, registerColmUpdate)
1339+
connect(w, SIGNAL(sliderReleased()), this, SLOT(UpdateColmStringFromWidget()));
1340+
13401341
connect(ui->apply, SIGNAL(clicked()), this, SLOT(ApplyConfig()));
13411342
connect(ui->disableFX, SIGNAL(clicked()), this, SLOT(DisableFX()));
13421343
connect(ui->reset_eq, SIGNAL(clicked()), this, SLOT(ResetEQ()));
@@ -1350,4 +1351,5 @@ void MainWindow::ConnectActions(){
13501351
connect(ui->dynsys_preset, SIGNAL(currentIndexChanged(int)), this, SLOT(DynsysPresetSelectionUpdated()));
13511352
connect(ui->vbmode, SIGNAL(currentIndexChanged(int)), this, SLOT(OnRelease()));
13521353
connect(ui->vcmode, SIGNAL(currentIndexChanged(int)), this, SLOT(OnRelease()));
1354+
connect(ui->colmpreset, SIGNAL(currentIndexChanged(int)), this, SLOT(ColmPresetSelectionUpdated()));
13531355
}

mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private slots:
9797
void RefreshSpectrumParameters();
9898
void UpdateEqStringFromWidget();
9999
void UpdateDynsysStringFromWidget();
100+
void UpdateColmStringFromWidget();
100101
private:
101102
ConfigContainer* conf;
102103
AppConfigWrapper* m_appwrapper;

mainwindow.ui

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@
22282228
<number>38</number>
22292229
</property>
22302230
<property name="verticalSpacing">
2231-
<number>6</number>
2231+
<number>0</number>
22322232
</property>
22332233
<property name="topMargin">
22342234
<number>0</number>
@@ -2247,37 +2247,57 @@
22472247
</widget>
22482248
</item>
22492249
<item row="0" column="1">
2250-
<widget class="QToolButton" name="colmpreset">
2251-
<property name="sizePolicy">
2252-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
2253-
<horstretch>0</horstretch>
2254-
<verstretch>0</verstretch>
2255-
</sizepolicy>
2256-
</property>
2257-
<property name="minimumSize">
2258-
<size>
2259-
<width>0</width>
2260-
<height>22</height>
2261-
</size>
2262-
</property>
2263-
<property name="maximumSize">
2264-
<size>
2265-
<width>133</width>
2266-
<height>16777215</height>
2267-
</size>
2268-
</property>
2269-
<property name="sizeIncrement">
2270-
<size>
2271-
<width>0</width>
2272-
<height>0</height>
2273-
</size>
2274-
</property>
2275-
<property name="text">
2276-
<string>...</string>
2277-
</property>
2278-
<property name="popupMode">
2279-
<enum>QToolButton::InstantPopup</enum>
2280-
</property>
2250+
<widget class="QComboBox" name="colmpreset">
2251+
<item>
2252+
<property name="text">
2253+
<string>...</string>
2254+
</property>
2255+
</item>
2256+
<item>
2257+
<property name="text">
2258+
<string>Slight</string>
2259+
</property>
2260+
</item>
2261+
<item>
2262+
<property name="text">
2263+
<string>Level 1</string>
2264+
</property>
2265+
</item>
2266+
<item>
2267+
<property name="text">
2268+
<string>Level 2</string>
2269+
</property>
2270+
</item>
2271+
<item>
2272+
<property name="text">
2273+
<string>Level 3</string>
2274+
</property>
2275+
</item>
2276+
<item>
2277+
<property name="text">
2278+
<string>Level 4</string>
2279+
</property>
2280+
</item>
2281+
<item>
2282+
<property name="text">
2283+
<string>Level 5</string>
2284+
</property>
2285+
</item>
2286+
<item>
2287+
<property name="text">
2288+
<string>Level 6</string>
2289+
</property>
2290+
</item>
2291+
<item>
2292+
<property name="text">
2293+
<string>Level 7</string>
2294+
</property>
2295+
</item>
2296+
<item>
2297+
<property name="text">
2298+
<string>Extreme</string>
2299+
</property>
2300+
</item>
22812301
</widget>
22822302
</item>
22832303
</layout>

misc/presetprovider.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,25 @@ const INT_LIST Colm::lookupPreset(const QString& preset){
148148
else
149149
return table["Unknown"];
150150
}
151+
152+
const QString Colm::reverseLookup(const QVector<int>& data){
153+
auto table = COLM_LOOKUP_TABLE();
154+
for(auto key : table.keys()){
155+
QVector<int> row(table[key]);
156+
int it = 0;
157+
bool different = false;
158+
for(auto cur_data : row){
159+
bool equal = cur_data == data.at(it);
160+
if(!equal){
161+
different = true;
162+
break;
163+
}
164+
it++;
165+
}
166+
if(!different)
167+
return key;
168+
}
169+
return "...";
170+
}
171+
151172
}

misc/presetprovider.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Colm{
4444
public:
4545
static const QMap<COLM_UNIT> COLM_LOOKUP_TABLE();
4646
static const INT_LIST lookupPreset(const QString& preset);
47+
static const QString reverseLookup(const QVector<int> &data);
4748
};
4849
}
4950
#endif // PRESETEXTENSION_H

phantom/phantomstyle.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,14 +1384,14 @@ void PhantomStyle::drawPrimitive(PrimitiveElement elem,
13841384
}
13851385
case PE_FrameDockWidget: {
13861386
painter->save();
1387-
QColor softshadow = option->palette.background().color().darker(120);
1387+
QColor softshadow = option->palette.window().color().darker(120);
13881388
QRect r = option->rect;
13891389
painter->setPen(softshadow);
13901390
painter->drawRect(r.adjusted(0, 0, -1, -1));
13911391
painter->setPen(QPen(option->palette.light(), 1));
13921392
painter->drawLine(QPoint(r.left() + 1, r.top() + 1),
13931393
QPoint(r.left() + 1, r.bottom() - 1));
1394-
painter->setPen(QPen(option->palette.background().color().darker(120)));
1394+
painter->setPen(QPen(option->palette.window().color().darker(120)));
13951395
painter->drawLine(QPoint(r.left() + 1, r.bottom() - 1),
13961396
QPoint(r.right() - 2, r.bottom() - 1));
13971397
painter->drawLine(QPoint(r.right() - 1, r.top() + 1),
@@ -1655,10 +1655,10 @@ void PhantomStyle::drawPrimitive(PrimitiveElement elem,
16551655
// TODO replace with new code
16561656
const int margin = 6;
16571657
const int offset = r.height() / 2;
1658-
painter->setPen(QPen(option->palette.background().color().darker(110)));
1658+
painter->setPen(QPen(option->palette.window().color().darker(110)));
16591659
painter->drawLine(r.topLeft().x() + margin, r.topLeft().y() + offset,
16601660
r.topRight().x() - margin, r.topRight().y() + offset);
1661-
painter->setPen(QPen(option->palette.background().color().lighter(110)));
1661+
painter->setPen(QPen(option->palette.window().color().lighter(110)));
16621662
painter->drawLine(r.topLeft().x() + margin, r.topLeft().y() + offset + 1,
16631663
r.topRight().x() - margin,
16641664
r.topRight().y() + offset + 1);
@@ -3277,14 +3277,14 @@ void PhantomStyle::drawComplexControl(ComplexControl control,
32773277
: outline.darker(110));
32783278
QColor titleBarHighlight(active
32793279
? highlight.lighter(120)
3280-
: palette.background().color().lighter(120));
3280+
: palette.window().color().lighter(120));
32813281
QColor textColor(active ? 0xffffff : 0xff000000);
32823282
QColor textAlphaColor(active ? 0xffffff : 0xff000000);
32833283

32843284
{
32853285
// Fill title
32863286
QColor titlebarColor =
3287-
QColor(active ? highlight : palette.background().color());
3287+
QColor(active ? highlight : palette.window().color());
32883288
painter->fillRect(option->rect.adjusted(1, 1, -1, 0), titlebarColor);
32893289
// Frame and rounded corners
32903290
painter->setPen(titleBarFrameBorder);

0 commit comments

Comments
 (0)