@@ -61,14 +61,6 @@ MainWindow::MainWindow(bool statupInTray,
6161{
6262 ui->setupUi (this );
6363
64- {
65- _startupInTraySwitch = statupInTray;
66-
67- _styleHelper = new StyleHelper (this );
68- _eelEditor = new EELEditor (this );
69- _trayIcon = new TrayIcon (this );
70- }
71-
7264 // Prepare audio subsystem
7365 {
7466 Log::information (" ============ Initializing audio service ============" );
@@ -93,6 +85,20 @@ MainWindow::MainWindow(bool statupInTray,
9385 connect (&DspConfig::instance (), &DspConfig::updatedExternally, _audioService, &IAudioService::update);
9486 }
9587
88+ // Allocate resources
89+ {
90+ _startupInTraySwitch = statupInTray;
91+
92+ _styleHelper = new StyleHelper (this );
93+ _eelEditor = new EELEditor (this );
94+ _trayIcon = new TrayIcon (this );
95+
96+ _appMgrFragment = new FragmentHost<AppManagerFragment*>(new AppManagerFragment (_audioService->appManager (), this ), WAF::BottomSide, this );
97+ _statusFragment = new FragmentHost<StatusFragment*>(new StatusFragment (this ), WAF::BottomSide, this );
98+ _presetFragment = new FragmentHost<PresetFragment*>(new PresetFragment (_audioService, this ), WAF::LeftSide, this );
99+ _settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment (_trayIcon, _audioService, this ), WAF::BottomSide, this );
100+ }
101+
96102 // Prepare base UI
97103 {
98104 Log::information (" ============ Initializing user interface ============" );
@@ -124,11 +130,6 @@ MainWindow::MainWindow(bool statupInTray,
124130 // GraphicEQ
125131 ui->graphicEq ->setEnableSwitchVisible (true );
126132 ui->graphicEq ->setAutoEqAvailable (true );
127-
128- // Timer (TODO)
129- _refreshTick = new QTimer (this );
130- connect (_refreshTick, &QTimer::timeout, this , &MainWindow::fireTimerSignal);
131- _refreshTick->start (1000 );
132133 }
133134
134135 // Allocate pointers and init important variables
@@ -155,7 +156,6 @@ MainWindow::MainWindow(bool statupInTray,
155156 // timer->start(200);
156157
157158 connect (_eelEditor, &EELEditor::executionRequested, [this ](QString path){
158- bool isSameFile = path == ui->liveprog ->currentLiveprog ();
159159 if (QFileInfo::exists (path) && QFileInfo (path).isFile ())
160160 {
161161 ui->liveprog ->setCurrentLiveprog (path);
@@ -169,7 +169,7 @@ MainWindow::MainWindow(bool statupInTray,
169169
170170 applyConfig ();
171171
172- if (isSameFile )
172+ if (path == ui-> liveprog -> currentLiveprog () )
173173 {
174174 _audioService->reloadLiveprog ();
175175 }
@@ -234,16 +234,11 @@ MainWindow::MainWindow(bool statupInTray,
234234 _trayIcon->setTrayVisible (AppConfig::instance ().get <bool >(AppConfig::TrayIconEnabled) || _startupInTraySwitch);
235235 }
236236
237- // Load config and initialize less important stuff
237+ // Load config and connect fragment signals
238238 {
239239 connect (&DspConfig::instance (), &DspConfig::configBuffered, this , &MainWindow::loadConfig);
240240 DspConfig::instance ().load ();
241241
242- _appMgrFragment = new FragmentHost<AppManagerFragment*>(new AppManagerFragment (_audioService->appManager (), this ), WAF::BottomSide, this );
243- _statusFragment = new FragmentHost<StatusFragment*>(new StatusFragment (this ), WAF::BottomSide, this );
244- _presetFragment = new FragmentHost<PresetFragment*>(new PresetFragment (_audioService, this ), WAF::LeftSide, this );
245- _settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment (_trayIcon, _audioService, this ), WAF::BottomSide, this );
246-
247242 connect (_settingsFragment->fragment (), &SettingsFragment::launchSetupWizard, this , &MainWindow::launchFirstRunSetup);
248243 connect (_settingsFragment->fragment (), &SettingsFragment::requestEelScriptExtract, this , &MainWindow::extractDefaultEelScripts);
249244 connect (_settingsFragment->fragment (), &SettingsFragment::reopenSettings, _settingsFragment, &FragmentHost<SettingsFragment*>::slideOutIn);
@@ -263,6 +258,7 @@ MainWindow::MainWindow(bool statupInTray,
263258 ui->toolButton ->setIconSize (QSize (16 ,16 ));
264259 ui->disableFX ->setIconSize (QSize (16 ,16 ));
265260
261+ // Attach menu
266262 QMenu *menu = new QMenu ();
267263 menu->addAction (tr (" Apps" ), _appMgrFragment, &FragmentHost<AppManagerFragment*>::slideIn);
268264 menu->addAction (tr (" Driver status" ), _statusFragment, [this ](){
@@ -315,9 +311,20 @@ MainWindow::MainWindow(bool statupInTray,
315311
316312 // Setup file selectors
317313 {
314+ // DDC
318315 ui->ddc_files ->setCurrentDirectory (AppConfig::instance ().getVdcPath ());
319316 ui->ddc_files ->setFileTypes (QStringList (" *.vdc" ));
317+ connect (ui->ddc_files , &FileSelectionWidget::fileChanged, this , &MainWindow::setVdcFile);
320318
319+ ui->ddcTable ->setModel (new VdcDatabaseModel (ui->ddcTable ));
320+ ui->ddcTable ->setColumnHidden (2 , true );
321+ ui->ddcTable ->setColumnHidden (3 , true );
322+ ui->ddcTable ->setColumnHidden (4 , true );
323+ ui->ddcTable ->resizeColumnsToContents ();
324+ determineVdcSelection ();
325+
326+ // Convolver
327+ determineIrsSelection ();
321328 ui->conv_files ->setCurrentDirectory (AppConfig::instance ().getIrsPath ());
322329 ui->conv_files ->setFileTypes (QStringList (std::initializer_list<QString>({" *.irs" , " *.wav" , " *.flac" })));
323330 ui->conv_files ->setBookmarkDirectory (QDir (AppConfig::instance ().getPath (" irs_favorites" )));
@@ -327,25 +334,11 @@ MainWindow::MainWindow(bool statupInTray,
327334 ui->conv_fav ->setFileActionsVisible (true );
328335 ui->conv_fav ->setNavigationBarVisible (false );
329336
330- connect (ui->ddc_files , &FileSelectionWidget::fileChanged, this , &MainWindow::setVdcFile);
331337 connect (ui->conv_files , &FileSelectionWidget::fileChanged, this , &MainWindow::setIrsFile);
332338 connect (ui->conv_fav , &FileSelectionWidget::fileChanged, this , &MainWindow::setIrsFile);
333-
334- connect (ui->conv_files , &FileSelectionWidget::bookmarkAdded, ui->conv_fav , &FileSelectionWidget::enumerateFiles);
335-
336339 connect (ui->conv_files , &FileSelectionWidget::fileChanged, ui->conv_fav , &FileSelectionWidget::clearCurrentFile);
337340 connect (ui->conv_fav , &FileSelectionWidget::fileChanged, ui->conv_files , &FileSelectionWidget::clearCurrentFile);
338-
339- // DDC
340- ui->ddcTable ->setModel (new VdcDatabaseModel (ui->ddcTable ));
341- ui->ddcTable ->setColumnHidden (2 , true );
342- ui->ddcTable ->setColumnHidden (3 , true );
343- ui->ddcTable ->setColumnHidden (4 , true );
344- ui->ddcTable ->resizeColumnsToContents ();
345- determineVdcSelection ();
346-
347- // Convolver
348- determineIrsSelection ();
341+ connect (ui->conv_files , &FileSelectionWidget::bookmarkAdded, ui->conv_fav , &FileSelectionWidget::enumerateFiles);
349342
350343 // Liveprog
351344 ui->liveprog ->coupleIDE (_eelEditor);
@@ -361,43 +354,24 @@ MainWindow::MainWindow(bool statupInTray,
361354 }
362355 }
363356
364- // Connect UI signals
357+ // Connect remaining signals
365358 {
366359 connectActions ();
367- }
368360
369- // Connect non-UI signals (DBus/ACW/...)
370- {
371361 connect (&AppConfig::instance (), &AppConfig::themeChanged, this , [this ]()
372362 {
373363 _styleHelper->SetStyle ();
374364 ui->frame ->setStyleSheet (QString (" QFrame#frame{background-color: %1;}" ).arg (qApp->palette ().window ().color ().lighter ().name ()));
375365 ui->tabhost ->setStyleSheet (QString (" QWidget#tabHostPage1,QWidget#tabHostPage2,QWidget#tabHostPage3,QWidget#tabHostPage4,QWidget#tabHostPage5,QWidget#tabHostPage6,QWidget#tabHostPage7{background-color: %1;}" ).arg (qApp->palette ().window ().color ().lighter ().name ()));
376366 ui->tabbar ->redrawTabBar ();
377367 ui->eq_widget ->setAccentColor (palette ().highlight ().color ());
378- _spectrumReloadSignalQueued = true ;
379368 });
380369
381- connect (&AppConfig::instance (), &AppConfig::updated, this , [this ](const AppConfig::Key& key, const QVariant& value)
382- {
383- switch (key)
384- {
385- case AppConfig::EqualizerShowHandles:
386- ui->eq_widget ->setAlwaysDrawHandles (value.toBool ());
387- break ;
388- case AppConfig::TrayIconEnabled:
389- _trayIcon->setTrayVisible (value.toBool ());
390- break ;
391- default :
392- break ;
393- }
394-
395- });
370+ connect (&AppConfig::instance (), &AppConfig::updated, this , &MainWindow::onAppConfigUpdated);
396371 }
397372
398- // Lateinit less important UI stuff and setup tabbar
373+ // Tabs and other UI related things
399374 {
400- // toggleSpectrum(AppConfig::instance().get<bool>(AppConfig::SpectrumEnabled), true);
401375 restoreGraphicEQView ();
402376 ui->eq_widget ->setAlwaysDrawHandles (AppConfig::instance ().get <bool >(AppConfig::EqualizerShowHandles));
403377
@@ -455,16 +429,6 @@ MainWindow::~MainWindow()
455429 delete ui;
456430}
457431
458- void MainWindow::fireTimerSignal ()
459- {
460- if (_spectrumReloadSignalQueued)
461- {
462- // restartSpectrum();
463- }
464-
465- _spectrumReloadSignalQueued = false ;
466- }
467-
468432// Overrides
469433void MainWindow::closeEvent (QCloseEvent *event)
470434{
@@ -535,6 +499,21 @@ void MainWindow::onConvolverInfoChanged(const ConvolverInfoEventArgs& args)
535499 ui->ir_details_frames ->setText (QString::number (args.frames ));
536500}
537501
502+ void MainWindow::onAppConfigUpdated (const AppConfig::Key &key, const QVariant &value)
503+ {
504+ switch (key)
505+ {
506+ case AppConfig::EqualizerShowHandles:
507+ ui->eq_widget ->setAlwaysDrawHandles (value.toBool ());
508+ break ;
509+ case AppConfig::TrayIconEnabled:
510+ _trayIcon->setTrayVisible (value.toBool ());
511+ break ;
512+ default :
513+ break ;
514+ }
515+ }
516+
538517// Fragment handler
539518void MainWindow::onFragmentRequested ()
540519{
@@ -571,9 +550,6 @@ void MainWindow::onRelinkRequested()
571550{
572551 _audioService->reloadService ();
573552 DspConfig::instance ().commit ();
574-
575- // TODO
576- _spectrumReloadSignalQueued = true ;
577553}
578554
579555// User preset management
@@ -884,7 +860,7 @@ void MainWindow::applyConfig()
884860// Predefined presets
885861void MainWindow::onEqPresetUpdated ()
886862{
887- if (ui->eqpreset ->currentText () == " Custom" )
863+ if (ui->eqpreset ->currentText () == " Custom" || _blockApply )
888864 {
889865 return ;
890866 }
@@ -903,7 +879,7 @@ void MainWindow::onEqPresetUpdated()
903879
904880void MainWindow::onBs2bPresetUpdated ()
905881{
906- if (ui->crossfeed_mode ->currentText () == " ..." )
882+ if (ui->crossfeed_mode ->currentText () == " ..." || _blockApply )
907883 {
908884 return ;
909885 }
@@ -929,7 +905,7 @@ void MainWindow::onBs2bPresetUpdated()
929905
930906void MainWindow::onReverbPresetUpdated ()
931907{
932- if (ui->roompresets ->currentText () == " ..." )
908+ if (ui->roompresets ->currentText () == " ..." || _blockApply )
933909 {
934910 return ;
935911 }
@@ -1191,7 +1167,7 @@ void MainWindow::setEq(const QVector<double> &data)
11911167void MainWindow::resetEQ ()
11921168{
11931169 ui->eqpreset ->setCurrentIndex (0 );
1194- _blockApply = true ; // TODO: get rid of _blockApply guards
1170+ _blockApply = true ;
11951171 ui->eq_dyn_widget ->load (DEFAULT_GRAPHICEQ);
11961172 _blockApply = false ;
11971173 setEq (PresetProvider::EQ::defaultPreset ());
@@ -1310,27 +1286,27 @@ void MainWindow::connectActions()
13101286 connect (ui->eqpreset , qOverload<int >(&QComboBox::currentIndexChanged), this , &MainWindow::onEqPresetUpdated);
13111287 connect (ui->roompresets , qOverload<int >(&QComboBox::currentIndexChanged), this , &MainWindow::onReverbPresetUpdated);
13121288
1313- connect (ui->eq_widget , SIGNAL ( bandsUpdated ()), this , SLOT ( applyConfig ()) );
1314- connect (ui->eq_widget , SIGNAL ( mouseReleased ()), this , SLOT ( determineEqPresetName ()) );
1289+ connect (ui->eq_widget , &LiquidEqualizerWidget:: bandsUpdated, this , &MainWindow:: applyConfig);
1290+ connect (ui->eq_widget , &LiquidEqualizerWidget:: mouseReleased, this , &MainWindow:: determineEqPresetName);
13151291
1316- connect (ui->conv_adv_wave_edit , &QAbstractButton::clicked, this , &MainWindow::onConvolverWaveformEdit);
1292+ connect (ui->conv_adv_wave_edit , &QAbstractButton::clicked, this , &MainWindow::onConvolverWaveformEdit);
13171293
1318- connect (ui->graphicEq , &GraphicEQFilterGUI::mouseUp, this , &MainWindow::applyConfig);
1319- connect (ui->eq_dyn_widget , &GraphicEQFilterGUI::mouseUp, this , &MainWindow::applyConfig);
1294+ connect (ui->graphicEq , &GraphicEQFilterGUI::mouseUp, this , &MainWindow::applyConfig);
1295+ connect (ui->eq_dyn_widget , &GraphicEQFilterGUI::mouseUp, this , &MainWindow::applyConfig);
13201296
13211297 connect (ui->graphicEq , &GraphicEQFilterGUI::updateModelEnd, this , &MainWindow::applyConfig);
13221298 connect (ui->eq_dyn_widget , &GraphicEQFilterGUI::updateModelEnd, this , &MainWindow::applyConfig);
13231299
13241300 connect (ui->ddcTable ->selectionModel (), &QItemSelectionModel::selectionChanged, this , &MainWindow::onVdcDatabaseSelected);
1325- connect (ui->liveprog , &LiveprogSelectionWidget::toggled, this , &MainWindow::applyConfig);
1301+ connect (ui->liveprog , &LiveprogSelectionWidget::toggled, this , &MainWindow::applyConfig);
13261302 connect (ui->liveprog , &LiveprogSelectionWidget::scriptChanged, this , &MainWindow::applyConfig);
13271303
13281304 connect (ui->graphicEq , &GraphicEQFilterGUI::autoeqClicked, this , &MainWindow::onAutoEqImportRequested);
13291305
1330- connect (ui->eq_r_fixed , &QRadioButton::clicked, this , &MainWindow::onEqModeUpdated);
1331- connect (ui->eq_r_flex , &QRadioButton::clicked, this , &MainWindow::onEqModeUpdated);
1306+ connect (ui->eq_r_fixed , &QRadioButton::clicked, this , &MainWindow::onEqModeUpdated);
1307+ connect (ui->eq_r_flex , &QRadioButton::clicked, this , &MainWindow::onEqModeUpdated);
13321308
1333- connect (_eelEditor, &EELEditor::scriptSaved, ui->liveprog , &LiveprogSelectionWidget::updateFromEelEditor);
1309+ connect (_eelEditor, &EELEditor::scriptSaved, ui->liveprog , &LiveprogSelectionWidget::updateFromEelEditor);
13341310}
13351311
13361312// Setup wizard
0 commit comments