Skip to content

Commit e5fe4dd

Browse files
committed
feat: libportal support & multiple bug fixes
1 parent 4d76b60 commit e5fe4dd

18 files changed

+231
-60
lines changed
194 Bytes
Binary file not shown.

src/MainWindow.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "interface/fragment/StatusFragment.h"
2727
#include "interface/QMessageOverlay.h"
2828
#include "interface/TrayIcon.h"
29+
#include "utils/AutoStartManager.h"
2930
#include "utils/Common.h"
3031
#include "utils/dbus/ClientProxy.h"
3132
#include "utils/dbus/IpcHandler.h"
@@ -96,11 +97,12 @@ MainWindow::MainWindow(bool statupInTray,
9697
_eelEditor = new EELEditor(this);
9798
_trayIcon = new TrayIcon(this);
9899
_ipcHandler = new IpcHandler(_audioService, this);
100+
_autostart = new AutostartManager(this);
99101

100102
_appMgrFragment = new FragmentHost<AppManagerFragment*>(new AppManagerFragment(_audioService->appManager(), this), WAF::BottomSide, this);
101103
_statusFragment = new FragmentHost<StatusFragment*>(new StatusFragment(this), WAF::BottomSide, this);
102104
_presetFragment = new FragmentHost<PresetFragment*>(new PresetFragment(_audioService, this), WAF::LeftSide, this);
103-
_settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment(_trayIcon, _audioService, this), WAF::BottomSide, this);
105+
_settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment(_trayIcon, _audioService, _autostart, this), WAF::BottomSide, this);
104106
}
105107

106108
// Prepare base UI
@@ -322,6 +324,7 @@ MainWindow::MainWindow(bool statupInTray,
322324
if (AppConfig::instance().get<bool>(AppConfig::LiveprogAutoExtract))
323325
{
324326
AssetManager::instance().extractAll();
327+
325328
}
326329
}
327330

@@ -358,6 +361,7 @@ MainWindow::MainWindow(bool statupInTray,
358361

359362
// Liveprog
360363
ui->liveprog->coupleIDE(_eelEditor);
364+
ui->liveprog->updateList();
361365
connect(ui->liveprog, &LiveprogSelectionWidget::liveprogReloadRequested, _audioService, &IAudioService::reloadLiveprog);
362366
connect(ui->liveprog, &LiveprogSelectionWidget::unitLabelUpdateRequested, ui->info, qOverload<const QString&>(&FadingLabel::setAnimatedText));
363367
}
@@ -432,6 +436,16 @@ MainWindow::~MainWindow()
432436
}
433437

434438
// Overrides
439+
void MainWindow::showEvent(QShowEvent *event)
440+
{
441+
if(_firstShowEvent) {
442+
_firstShowEvent = false;
443+
// Deferred auto-start setup re-check
444+
_autostart->setup();
445+
}
446+
QMainWindow::showEvent(event);
447+
}
448+
435449
void MainWindow::closeEvent(QCloseEvent *event)
436450
{
437451
AppConfig::instance().setBytes(AppConfig::LastWindowGeometry, saveGeometry());
@@ -667,7 +681,7 @@ void MainWindow::loadConfig()
667681
ui->eqfiltertype->setCurrentIndex(DspConfig::instance().get<int>(DspConfig::tone_filtertype));
668682

669683
// Parse EQ String to QMap
670-
QString rawEqString = chopFirstLastChar(DspConfig::instance().get<QString>(DspConfig::tone_eq));
684+
QString rawEqString = chopDoubleQuotes(DspConfig::instance().get<QString>(DspConfig::tone_eq));
671685
bool isOldFormat = rawEqString.split(";").count() == 15;
672686

673687
if (isOldFormat)
@@ -1266,7 +1280,7 @@ void MainWindow::launchFirstRunSetup()
12661280
{
12671281
QHBoxLayout *lbLayout = new QHBoxLayout;
12681282
QMessageOverlay *lightBox = new QMessageOverlay(this);
1269-
FirstLaunchWizard *wiz = new FirstLaunchWizard(lightBox);
1283+
FirstLaunchWizard *wiz = new FirstLaunchWizard(_autostart, lightBox);
12701284
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(lightBox);
12711285
QPropertyAnimation *a = new QPropertyAnimation(eff, "opacity");
12721286

src/MainWindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
class IAudioService;
3131
class AppConfig;
32+
class AutostartManager;
3233
class EELParser;
3334
class ConfigContainer;
3435
class StyleHelper;
@@ -64,6 +65,7 @@ class MainWindow :
6465
~MainWindow();
6566

6667
protected:
68+
void showEvent(QShowEvent* event) override;
6769
void resizeEvent(QResizeEvent* event) override;
6870
void closeEvent(QCloseEvent *event) override;
6971

@@ -115,6 +117,7 @@ private slots:
115117

116118
bool _startupInTraySwitch;
117119
TrayIcon *_trayIcon;
120+
AutostartManager *_autostart;
118121

119122
EELEditor *_eelEditor;
120123

@@ -127,6 +130,7 @@ private slots:
127130
IpcHandler* _ipcHandler = nullptr;
128131

129132
bool _blockApply = false;
133+
bool _firstShowEvent = true;
130134

131135
QString _currentImpulseResponse = "";
132136
QString _currentVdc = "";

src/config/AppConfig.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "AppConfig.h"
22

33
#include "ConfigIO.h"
4+
#include "utils/AutoStartManager.h"
45
#include "utils/Common.h"
56

67
#include <QStandardPaths>
@@ -30,6 +31,11 @@ AppConfig::AppConfig()
3031
DEFINE_KEY(ExecutablePath, "");
3132
DEFINE_KEY(VdcLastDatabaseId, -1);
3233
DEFINE_KEY(LastWindowGeometry, QByteArray());
34+
#ifdef USE_PORTALS
35+
DEFINE_KEY(AutoStartEnabled, false);
36+
#else
37+
DEFINE_KEY(AutoStartEnabled, QFile(AutostartManager::getAutostartPath()).exists());
38+
#endif
3339

3440
DEFINE_KEY(AudioOutputUseDefault, true);
3541
DEFINE_KEY(AudioOutputDevice, "");

src/config/AppConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class AppConfig :
5959
ExecutablePath,
6060
VdcLastDatabaseId,
6161
LastWindowGeometry,
62+
AutoStartEnabled,
6263

6364
AudioOutputUseDefault,
6465
AudioOutputDevice,
@@ -135,7 +136,7 @@ class AppConfig :
135136
#define DEFINE_USER_PATH(name,key) \
136137
QString get##name##Path(QString subdir = "") const \
137138
{ \
138-
QString current = chopFirstLastChar(get<QString>(key)); \
139+
QString current = chopDoubleQuotes(get<QString>(key)); \
139140
if (!QDir(current).exists()) \
140141
{ \
141142
QDir().mkpath(current); \

src/data/AssetManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int AssetManager::extractGroup(AssetType type, bool allowOverride)
5353
}
5454

5555
sourceFile.copy(targetFile.fileName());
56+
targetFile.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther);
5657
i++;
5758
}
5859

src/interface/LiveprogSelectionWidget.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ void LiveprogSelectionWidget::updateFromEelEditor(QString path)
114114
}
115115
}
116116

117+
void LiveprogSelectionWidget::updateList()
118+
{
119+
ui->files->enumerateFiles();
120+
}
117121

118122
void LiveprogSelectionWidget::onEditScript()
119123
{

src/interface/LiveprogSelectionWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class LiveprogSelectionWidget : public QWidget
1919
~LiveprogSelectionWidget();
2020

2121
void coupleIDE(EELEditor *editor);
22+
void updateList();
2223

2324
bool isActive() const;
2425
void setActive(bool active);

src/interface/fragment/FirstLaunchWizard.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
#include <utils/DesktopServices.h>
1818

19-
FirstLaunchWizard::FirstLaunchWizard(QWidget *parent) :
19+
FirstLaunchWizard::FirstLaunchWizard(AutostartManager *autostart, QWidget *parent) :
2020
QWidget(parent),
21-
ui(new Ui::FirstLaunchWizard)
21+
ui(new Ui::FirstLaunchWizard),
22+
_autostart(autostart)
2223
{
2324
ui->setupUi(this);
2425
ui->stackedWidget->setCurrentIndex(0);
@@ -52,18 +53,32 @@ FirstLaunchWizard::FirstLaunchWizard(QWidget *parent) :
5253
ui->p3_systray_enable->setChecked(AppConfig::instance().get<bool>(AppConfig::TrayIconEnabled));
5354
ui->p3_systray_minOnBoot->setEnabled(AppConfig::instance().get<bool>(AppConfig::TrayIconEnabled));
5455

55-
ui->p3_systray_minOnBoot->setChecked(AutostartManager::isEnabled());
56+
ui->p3_systray_minOnBoot->setChecked(_autostart->isEnabled());
5657

5758
connect(ui->p3_systray_disable, &QRadioButton::clicked, this, &FirstLaunchWizard::onSystrayRadioSelected);
5859
connect(ui->p3_systray_enable, &QRadioButton::clicked, this, &FirstLaunchWizard::onSystrayRadioSelected);
5960
connect(ui->p3_systray_minOnBoot, &QCheckBox::stateChanged, this, &FirstLaunchWizard::onSystrayAutostartToggled);
61+
62+
connect(&AppConfig::instance(), &AppConfig::updated, this, &FirstLaunchWizard::onAppConfigUpdated);
6063
}
6164

6265
FirstLaunchWizard::~FirstLaunchWizard()
6366
{
67+
disconnect(&AppConfig::instance(), &AppConfig::updated, this, &FirstLaunchWizard::onAppConfigUpdated);
6468
delete ui;
6569
}
6670

71+
void FirstLaunchWizard::onAppConfigUpdated(const AppConfig::Key &key, const QVariant &value)
72+
{
73+
switch(key)
74+
{
75+
case AppConfig::AutoStartEnabled:
76+
ui->p3_systray_minOnBoot->setChecked(value.toBool());
77+
default:
78+
break;
79+
}
80+
}
81+
6782
void FirstLaunchWizard::showEvent(QShowEvent *ev)
6883
{
6984
QWidget::showEvent(ev);
@@ -81,5 +96,5 @@ void FirstLaunchWizard::onSystrayRadioSelected()
8196

8297
void FirstLaunchWizard::onSystrayAutostartToggled(bool isChecked)
8398
{
84-
AutostartManager::setEnabled(isChecked);
99+
_autostart->setEnabled(isChecked);
85100
}

src/interface/fragment/FirstLaunchWizard.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <QWidget>
66

77
class IAudioService;
8+
class AutostartManager;
89

910
namespace Ui
1011
{
@@ -17,7 +18,7 @@ class FirstLaunchWizard :
1718
Q_OBJECT
1819

1920
public:
20-
explicit FirstLaunchWizard(QWidget *parent = nullptr);
21+
explicit FirstLaunchWizard(AutostartManager *autostart, QWidget *parent = nullptr);
2122
~FirstLaunchWizard();
2223

2324
protected:
@@ -29,10 +30,11 @@ class FirstLaunchWizard :
2930
private slots:
3031
void onSystrayRadioSelected();
3132
void onSystrayAutostartToggled(bool isChecked);
33+
void onAppConfigUpdated(const AppConfig::Key &key, const QVariant &value);
3234

3335
private:
3436
Ui::FirstLaunchWizard *ui;
35-
37+
AutostartManager *_autostart;
3638
};
3739

3840
#endif // FIRSTLAUNCHWIZARD_H

0 commit comments

Comments
 (0)