Skip to content

Commit

Permalink
feat: add --relink to CLI options
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Jul 12, 2024
1 parent ff82151 commit bfdaccf
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 40 deletions.
41 changes: 6 additions & 35 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ MainWindow::MainWindow(IAudioService* audioService,
_startupInTraySwitch = statupInTray;

_styleHelper = new StyleHelper(this);
_eelEditor = new EELEditor(this);
// TODO _eelEditor = new EELEditor(this);
_trayIcon = new TrayIcon(this);
_autostart = new AutostartManager(this);

_appMgrFragment = new FragmentHost<AppManagerFragment*>(new AppManagerFragment(_audioService->appManager(), this), WAF::BottomSide, this);
_statusFragment = new FragmentHost<StatusFragment*>(new StatusFragment(this), WAF::BottomSide, this);
_presetFragment = new FragmentHost<PresetFragment*>(new PresetFragment(_audioService, this), WAF::LeftSide, this);
_settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment(_trayIcon, _audioService, _autostart, this), WAF::BottomSide, this);
// TODO _appMgrFragment = new FragmentHost<AppManagerFragment*>(new AppManagerFragment(_audioService->appManager(), this), WAF::BottomSide, this);
// TODO _statusFragment = new FragmentHost<StatusFragment*>(new StatusFragment(this), WAF::BottomSide, this);
// TODO _presetFragment = new FragmentHost<PresetFragment*>(new PresetFragment(_audioService, this), WAF::LeftSide, this);
// TODO _settingsFragment = new FragmentHost<SettingsFragment*>(new SettingsFragment(_trayIcon, _audioService, _autostart, this), WAF::BottomSide, this);
}

// Prepare base UI
Expand Down Expand Up @@ -116,27 +116,6 @@ MainWindow::MainWindow(IAudioService* audioService,
ciArgs.channels = ciArgs.frames = -1;
onConvolverInfoChanged(ciArgs);
connect(_audioService, &IAudioService::convolverInfoChanged, this, &MainWindow::onConvolverInfoChanged);

_eelEditor->attachHost(_audioService);
connect(_eelEditor, &EELEditor::executionRequested, [this](QString path){
if (QFileInfo::exists(path) && QFileInfo(path).isFile())
{
ui->liveprog->setCurrentLiveprog(path);
}
else
{
QMessageBox::critical(_eelEditor, tr("Cannot execute script"),
tr("The current EEL file (at '%1') does not exist anymore on the filesystem. Please reopen the file manually.").arg(path));
return;
}

applyConfig();

if(path == ui->liveprog->currentLiveprog())
{
_audioService->reloadLiveprog();
}
});
}

// Prepare tray icon
Expand Down Expand Up @@ -220,9 +199,7 @@ MainWindow::MainWindow(IAudioService* audioService,
connect(&DspConfig::instance(), &DspConfig::configBuffered, this, &MainWindow::loadConfig);
DspConfig::instance().load();

connect(_settingsFragment->fragment(), &SettingsFragment::launchSetupWizard, this, &MainWindow::launchFirstRunSetup);
connect(_settingsFragment->fragment(), &SettingsFragment::reopenSettings, _settingsFragment, &FragmentHost<SettingsFragment*>::slideOutIn);
connect(_styleHelper, &StyleHelper::iconColorChanged, _settingsFragment->fragment(), &SettingsFragment::updateButtonStyle);
//connect(_styleHelper, &StyleHelper::iconColorChanged, _settingsFragment->fragment(), &SettingsFragment::updateButtonStyle);
}

// Init 3-dot menu button
Expand Down Expand Up @@ -264,8 +241,6 @@ MainWindow::MainWindow(IAudioService* audioService,
menu->addAction(tr("Load from file"), this, SLOT(loadExternalFile()));
menu->addAction(tr("Save to file"), this, SLOT(saveExternalFile()));
menu->addSeparator();
menu->addAction(tr("Open LiveprogIDE"), _eelEditor, &EELEditor::show);
menu->addSeparator();
menu->addAction(tr("What's this... (Select UI element)"), this, []()
{
QWhatsThis::enterWhatsThisMode();
Expand Down Expand Up @@ -329,8 +304,6 @@ MainWindow::MainWindow(IAudioService* audioService,
connect(ui->conv_files, &FileSelectionWidget::bookmarkAdded, ui->conv_fav, &FileSelectionWidget::enumerateFiles);

// Liveprog
ui->liveprog->coupleIDE(_eelEditor);
ui->liveprog->updateList();
connect(ui->liveprog, &LiveprogSelectionWidget::liveprogReloadRequested, _audioService, &IAudioService::reloadLiveprog);
connect(ui->liveprog, &LiveprogSelectionWidget::unitLabelUpdateRequested, ui->info, qOverload<const QString&>(&FadingLabel::setAnimatedText));
}
Expand Down Expand Up @@ -1333,8 +1306,6 @@ void MainWindow::connectActions()

connect(ui->eq_r_fixed, &QRadioButton::clicked, this, &MainWindow::onEqModeUpdated);
connect(ui->eq_r_flex, &QRadioButton::clicked, this, &MainWindow::onEqModeUpdated);

connect(_eelEditor, &EELEditor::scriptSaved, ui->liveprog, &LiveprogSelectionWidget::updateFromEelEditor);
}

// Setup wizard
Expand Down
9 changes: 9 additions & 0 deletions src/utils/CliRemoteController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,15 @@ bool CliRemoteController::showStatus() const
return true;
}

bool CliRemoteController::relinkAudioPipeline() const
{
if(!requireConnectionAndLog())
return false;

service->relinkAudioPipeline();
return true;
}

// Helper to warn about failed connection
bool CliRemoteController::checkConnectionAndLog() const
{
Expand Down
3 changes: 3 additions & 0 deletions src/utils/CliRemoteController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CliRemoteController : public QObject
Q_INVOKABLE bool deletePresetRule(const QString& keyValue) const;
Q_INVOKABLE bool listOutputDevices() const;
Q_INVOKABLE bool showStatus() const;
Q_INVOKABLE bool relinkAudioPipeline() const;

private:
me::timschneeberger::jdsp4linux::Service* service = nullptr;
Expand Down Expand Up @@ -64,6 +65,8 @@ class CliRemoteController : public QObject
OPT(_addPresetRule, ARGS("set-preset-rule", "Add/modify preset rule (Remote)", "deviceId[:routeId]=presetName"))
OPT(_deletePresetRule, ARGS("delete-preset-rule", "Delete preset rule by device id and route id (Remote)", "deviceId[:routeId]"))

OPT(_relinkAudioPipeline, ARGS("relink", "Relink audio pipeline (Remote)"))

#undef ARGS
#undef OPT
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dbus/ClientProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp manifest.xml -i data/PresetRule.h --adaptor ServerAdaptor --proxy ClientProxy
*
* qdbusxml2cpp is Copyright (C) 2022 The Qt Company Ltd.
* qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
Expand Down
8 changes: 7 additions & 1 deletion src/utils/dbus/ClientProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp manifest.xml -i data/PresetRule.h --adaptor ServerAdaptor --proxy ClientProxy
*
* qdbusxml2cpp is Copyright (C) 2022 The Qt Company Ltd.
* qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
Expand Down Expand Up @@ -150,6 +150,12 @@ public Q_SLOTS: // METHODS
return asyncCallWithArgumentList(QStringLiteral("loadPreset"), argumentList);
}

inline QDBusPendingReply<> relinkAudioPipeline()
{
QList<QVariant> argumentList;
return asyncCallWithArgumentList(QStringLiteral("relinkAudioPipeline"), argumentList);
}

inline QDBusPendingReply<> savePreset(const QString &name)
{
QList<QVariant> argumentList;
Expand Down
6 changes: 6 additions & 0 deletions src/utils/dbus/IpcHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ QList<IOutputDevice> IpcHandler::getOutputDevices() const
return QVector<IOutputDevice>(devices.begin(), devices.end()).toList();
}

void IpcHandler::relinkAudioPipeline() const
{
_service->reloadService();
DspConfig::instance().commit();
}

void IpcHandler::setInternal(const QString &key, const QDBusVariant &value) const
{
QMetaEnum meta = QMetaEnum::fromType<DspConfig::Key>();
Expand Down
4 changes: 3 additions & 1 deletion src/utils/dbus/IpcHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public slots:
void deletePresetRule(const QString &deviceId, const QString &routeId) const;
QList<PresetRule> getPresetRules() const;

QList<IOutputDevice> getOutputDevices() const;
QList<IOutputDevice> getOutputDevices() const;

void relinkAudioPipeline() const;

private:
QDBusConnection _connection = QDBusConnection::sessionBus();
Expand Down
8 changes: 7 additions & 1 deletion src/utils/dbus/ServerAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp manifest.xml -i data/PresetRule.h --adaptor ServerAdaptor --proxy ClientProxy
*
* qdbusxml2cpp is Copyright (C) 2022 The Qt Company Ltd.
* qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd.
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
Expand Down Expand Up @@ -163,6 +163,12 @@ void ServiceAdaptor::loadPreset(const QString &name)
QMetaObject::invokeMethod(parent(), "loadPreset", Q_ARG(QString, name));
}

void ServiceAdaptor::relinkAudioPipeline()
{
// handle method call me.timschneeberger.jdsp4linux.Service.relinkAudioPipeline
QMetaObject::invokeMethod(parent(), "relinkAudioPipeline");
}

void ServiceAdaptor::savePreset(const QString &name)
{
// handle method call me.timschneeberger.jdsp4linux.Service.savePreset
Expand Down
5 changes: 4 additions & 1 deletion src/utils/dbus/ServerAdaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file was generated by qdbusxml2cpp version 0.8
* Command line was: qdbusxml2cpp manifest.xml -i data/PresetRule.h --adaptor ServerAdaptor --proxy ClientProxy
*
* qdbusxml2cpp is Copyright (C) 2022 The Qt Company Ltd.
* qdbusxml2cpp is Copyright (C) 2023 The Qt Company Ltd.
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
Expand All @@ -20,6 +20,7 @@ class QByteArray;
template<class T> class QList;
template<class Key, class Value> class QMap;
class QString;
class QStringList;
class QVariant;
QT_END_NAMESPACE

Expand Down Expand Up @@ -110,6 +111,7 @@ class ServiceAdaptor: public QDBusAbstractAdaptor
" <annotation value=\"QList&lt;IOutputDevice&gt;\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
" <arg direction=\"out\" type=\"a(issss)\" name=\"devices\"/>\n"
" </method>\n"
" <method name=\"relinkAudioPipeline\"/>\n"
" </interface>\n"
"")
public:
Expand Down Expand Up @@ -146,6 +148,7 @@ public Q_SLOTS: // METHODS
QList<PresetRule> getPresetRules();
QStringList getPresets();
void loadPreset(const QString &name);
void relinkAudioPipeline();
void savePreset(const QString &name);
void set(const QString &key, const QDBusVariant &value);
void setAndCommit(const QString &key, const QDBusVariant &value);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/dbus/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;IOutputDevice&gt;"/>
<arg name="devices" type="a(issss)" direction="out"/>
</method>

<method name="relinkAudioPipeline" />
</interface>
</node>
</node>

0 comments on commit bfdaccf

Please sign in to comment.