Skip to content

Commit 50557e4

Browse files
committed
Better setup wizard design
1 parent e503366 commit 50557e4

File tree

3 files changed

+85
-1703
lines changed

3 files changed

+85
-1703
lines changed

src/interface/fragment/FirstLaunchWizard.cpp

Lines changed: 20 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,16 @@ FirstLaunchWizard::FirstLaunchWizard(IAudioService *audioService, QWidget *paren
2626

2727
QTimer::singleShot(500, [&] {
2828
ui->p1_icon->startAnimation();
29-
});
30-
ui->p2_icon->startAnimation();
29+
});
3130
ui->p3_icon->startAnimation();
3231
ui->p4_icon->startAnimation();
3332

3433
ui->stackedWidget->setAnimation(QEasingCurve::Type::OutCirc);
3534
connect(ui->p1_next, &QPushButton::clicked, [&] {
36-
37-
// always skip
38-
#if 1 //defined(USE_PULSEAUDIO)
39-
// Pulseaudio: skip device selection
40-
ui->stackedWidget->slideInIdx(2);
41-
#else
4235
ui->stackedWidget->slideInIdx(1);
43-
#endif
44-
});
45-
connect(ui->p2_next, &QPushButton::clicked, [&] {
46-
ui->stackedWidget->slideInIdx(2);
4736
});
4837
connect(ui->p3_next, &QPushButton::clicked, [&] {
49-
ui->stackedWidget->slideInIdx(3);
38+
ui->stackedWidget->slideInIdx(2);
5039
});
5140
connect(ui->p4_next, &QPushButton::clicked, [&] {
5241
emit wizardFinished();
@@ -55,48 +44,17 @@ FirstLaunchWizard::FirstLaunchWizard(IAudioService *audioService, QWidget *paren
5544
QDesktopServices::openUrl(QUrl("https://t.me/joinchat/FTKC2A2bolHkFAyO-fuPjw"));
5645
});
5746

58-
refreshDevices();
59-
6047
ui->p3_systray_disable->setChecked(!AppConfig::instance().get<bool>(AppConfig::TrayIconEnabled));
6148
ui->p3_systray_enable->setChecked(AppConfig::instance().get<bool>(AppConfig::TrayIconEnabled));
6249
ui->p3_systray_minOnBoot->setEnabled(AppConfig::instance().get<bool>(AppConfig::TrayIconEnabled));
6350

64-
QString autostart_path = AutostartManager::getAutostartPath("jdsp-gui.desktop");
65-
bool autostart_enabled = AutostartManager::inspectDesktopFile(autostart_path, AutostartManager::Exists);
66-
67-
ui->p3_systray_minOnBoot->setChecked(autostart_enabled);
51+
ui->p3_systray_minOnBoot->setChecked(AutostartManager::inspectDesktopFile(AutostartManager::getAutostartPath("jdsp-gui.desktop"),
52+
AutostartManager::Exists));
6853

69-
auto systray_radio = [this] {
70-
if (lockslot)
71-
{
72-
return;
73-
}
54+
connect(ui->p3_systray_disable, &QRadioButton::clicked, this, &FirstLaunchWizard::onSystrayRadioSelected);
55+
connect(ui->p3_systray_enable, &QRadioButton::clicked, this, &FirstLaunchWizard::onSystrayRadioSelected);
7456

75-
AppConfig::instance().set(AppConfig::TrayIconEnabled, ui->p3_systray_enable->isChecked());
76-
ui->p3_systray_minOnBoot->setEnabled(ui->p3_systray_enable->isChecked());
77-
};
78-
79-
connect(ui->p3_systray_disable, &QRadioButton::clicked, this, systray_radio);
80-
connect(ui->p3_systray_enable, &QRadioButton::clicked, this, systray_radio);
81-
82-
auto systray_autostart_radio = [this, autostart_path]
83-
{
84-
if (ui->p3_systray_minOnBoot->isChecked())
85-
{
86-
AutostartManager::saveDesktopFile(autostart_path, AppConfig::instance().get<QString>(AppConfig::ExecutablePath),
87-
AutostartManager::inspectDesktopFile(autostart_path, AutostartManager::Delayed));
88-
}
89-
else
90-
{
91-
QFile(autostart_path).remove();
92-
}
93-
};
94-
95-
connect(ui->p3_systray_minOnBoot, &QPushButton::clicked, this, systray_autostart_radio);
96-
97-
connect(ui->p2_dev_mode_auto, &QRadioButton::clicked, this, &FirstLaunchWizard::onDeviceUpdated);
98-
connect(ui->p2_dev_mode_manual, &QRadioButton::clicked, this, &FirstLaunchWizard::onDeviceUpdated);
99-
connect(ui->p2_dev_select, qOverload<int>(&QComboBox::currentIndexChanged), this, &FirstLaunchWizard::onDeviceUpdated);
57+
connect(ui->p3_systray_minOnBoot, &QCheckBox::stateChanged, this, &FirstLaunchWizard::onSystrayAutostartToggled);
10058

10159
}
10260

@@ -111,63 +69,28 @@ void FirstLaunchWizard::resizeEvent(QResizeEvent *ev)
11169
ui->stackedWidget->setMinimumHeight(ev->size().height() * 0.7);
11270
}
11371

114-
void FirstLaunchWizard::refreshDevices()
72+
void FirstLaunchWizard::onSystrayRadioSelected()
11573
{
116-
lockslot = true;
117-
ui->p2_dev_select->clear();
118-
119-
ui->p2_dev_mode_auto->setChecked(AppConfig::instance().get<bool>(AppConfig::AudioOutputUseDefault));
120-
ui->p2_dev_mode_manual->setChecked(!AppConfig::instance().get<bool>(AppConfig::AudioOutputUseDefault));
121-
122-
auto devices = audioService->sinkDevices();
123-
124-
ui->p2_dev_select->addItem("...", 0);
125-
for (const auto& device : devices)
126-
{
127-
ui->p2_dev_select->addItem(QString("%1 (%2)")
128-
.arg(QString::fromStdString(device.description))
129-
.arg(QString::fromStdString(device.name)), QString::fromStdString(device.name));
130-
}
131-
132-
auto current = AppConfig::instance().get<QString>(AppConfig::AudioOutputDevice);
133-
134-
bool notFound = true;
135-
136-
for (int i = 0; i < ui->p2_dev_select->count(); i++)
74+
if (lockslot)
13775
{
138-
if (ui->p2_dev_select->itemData(i) == current)
139-
{
140-
notFound = false;
141-
ui->p2_dev_select->setCurrentIndex(i);
142-
break;
143-
}
76+
return;
14477
}
14578

146-
if (notFound)
147-
{
148-
QString name = QString("Unknown (%1)").arg(current);
149-
ui->p2_dev_select->addItem(name, current);
150-
ui->p2_dev_select->setCurrentText(name);
151-
}
152-
lockslot = false;
79+
AppConfig::instance().set(AppConfig::TrayIconEnabled, ui->p3_systray_enable->isChecked());
80+
ui->p3_systray_minOnBoot->setEnabled(ui->p3_systray_enable->isChecked());
15381
}
15482

155-
void FirstLaunchWizard::onDeviceUpdated()
83+
void FirstLaunchWizard::onSystrayAutostartToggled(bool isChecked)
15684
{
157-
if (lockslot)
85+
auto path = AutostartManager::getAutostartPath("jdsp-gui.desktop");
86+
if (isChecked)
15887
{
159-
return;
88+
AutostartManager::saveDesktopFile(path,
89+
AppConfig::instance().get<QString>(AppConfig::ExecutablePath),
90+
AutostartManager::inspectDesktopFile(path, AutostartManager::Delayed));
16091
}
161-
162-
AppConfig::instance().set(AppConfig::AudioOutputUseDefault, ui->p2_dev_mode_auto->isChecked());
163-
164-
if (!ui->p2_dev_mode_auto->isChecked())
92+
else
16593
{
166-
if (ui->p2_dev_select->currentData() == "---")
167-
{
168-
return;
169-
}
170-
171-
AppConfig::instance().set(AppConfig::AudioOutputDevice, ui->p2_dev_select->currentData());
94+
QFile(path).remove();
17295
}
17396
}

src/interface/fragment/FirstLaunchWizard.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,15 @@ class FirstLaunchWizard :
2626
protected:
2727
void resizeEvent(QResizeEvent* ev) override;
2828

29+
private slots:
30+
void onSystrayRadioSelected();
31+
void onSystrayAutostartToggled(bool isChecked);
32+
2933
private:
3034
Ui::FirstLaunchWizard *ui;
3135
bool lockslot = false;
3236
IAudioService* audioService;
3337

34-
void refreshDevices();
35-
36-
private slots:
37-
void onDeviceUpdated();
38-
3938
};
4039

4140
#endif // FIRSTLAUNCHWIZARD_H

0 commit comments

Comments
 (0)