mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
feat(linux-airplay): add option "use legacy ports"
This commit is contained in:
+46
-3
@@ -64,6 +64,10 @@
|
||||
AirPlaySettings::AirPlaySettings()
|
||||
: fps(SettingsManager::sharedInstance()->airplayFps()),
|
||||
noHold(SettingsManager::sharedInstance()->airplayNoHold())
|
||||
#ifdef __linux__
|
||||
,
|
||||
useLegacyPorts(SettingsManager::sharedInstance()->airplayUseLegacyPorts())
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,6 +82,13 @@ QStringList AirPlaySettings::toArgs() const
|
||||
if (noHold)
|
||||
args << "-nohold";
|
||||
|
||||
#ifdef __linux__
|
||||
// We probably need this only on linux
|
||||
// https://github.com/iDescriptor/iDescriptor/issues/73
|
||||
if (useLegacyPorts)
|
||||
args << "-p";
|
||||
#endif
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
@@ -120,6 +131,13 @@ void AirPlaySettingsDialog::setupUI()
|
||||
SettingsManager::sharedInstance()->airplayNoHold());
|
||||
videoLayout->addRow(m_noHoldCheckbox);
|
||||
|
||||
#ifdef __linux__
|
||||
m_useLegacyPortsCheckbox = new QCheckBox("Use legacy ports");
|
||||
m_useLegacyPortsCheckbox->setChecked(
|
||||
SettingsManager::sharedInstance()->airplayUseLegacyPorts());
|
||||
videoLayout->addRow(m_useLegacyPortsCheckbox);
|
||||
#endif
|
||||
|
||||
mainLayout->addWidget(videoGroup);
|
||||
// Buttons
|
||||
QDialogButtonBox *buttonBox =
|
||||
@@ -127,14 +145,30 @@ void AirPlaySettingsDialog::setupUI()
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
connectSignals();
|
||||
}
|
||||
|
||||
AirPlaySettings AirPlaySettingsDialog::getSettings() const
|
||||
void AirPlaySettingsDialog::connectSignals()
|
||||
{
|
||||
connect(m_fpsComboBox, &QComboBox::currentTextChanged, this,
|
||||
[this]() { m_settingsChanged = true; });
|
||||
connect(m_noHoldCheckbox, &QCheckBox::toggled, this,
|
||||
[this]() { m_settingsChanged = true; });
|
||||
#ifdef __linux__
|
||||
connect(m_useLegacyPortsCheckbox, &QCheckBox::toggled, this,
|
||||
[this]() { m_settingsChanged = true; });
|
||||
#endif
|
||||
}
|
||||
|
||||
QPair<bool, AirPlaySettings> AirPlaySettingsDialog::getSettings() const
|
||||
{
|
||||
AirPlaySettings settings;
|
||||
settings.fps = m_fpsComboBox->currentText().toInt();
|
||||
settings.noHold = m_noHoldCheckbox->isChecked();
|
||||
return settings;
|
||||
#ifdef __linux__
|
||||
settings.useLegacyPorts = m_useLegacyPortsCheckbox->isChecked();
|
||||
#endif
|
||||
return {m_settingsChanged, settings};
|
||||
}
|
||||
|
||||
AirPlayWidget::AirPlayWidget(QWidget *parent)
|
||||
@@ -308,11 +342,20 @@ void AirPlayWidget::showSettingsDialog()
|
||||
{
|
||||
AirPlaySettingsDialog dialog(this);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
AirPlaySettings newSettings = dialog.getSettings();
|
||||
QPair<bool, AirPlaySettings> result = dialog.getSettings();
|
||||
// if not changed, do nothing
|
||||
if (!result.first) {
|
||||
return;
|
||||
}
|
||||
AirPlaySettings newSettings = result.second;
|
||||
|
||||
// Save settings
|
||||
SettingsManager::sharedInstance()->setAirplayFps(newSettings.fps);
|
||||
SettingsManager::sharedInstance()->setAirplayNoHold(newSettings.noHold);
|
||||
#ifdef __linux__
|
||||
SettingsManager::sharedInstance()->setAirplayUseLegacyPorts(
|
||||
newSettings.useLegacyPorts);
|
||||
#endif
|
||||
|
||||
QMessageBox::information(this, "Settings Saved",
|
||||
"AirPlay will be restarted to apply the new "
|
||||
|
||||
+9
-1
@@ -76,6 +76,9 @@ public:
|
||||
explicit AirPlaySettings();
|
||||
int fps;
|
||||
bool noHold;
|
||||
#ifdef __linux__
|
||||
bool useLegacyPorts;
|
||||
#endif
|
||||
|
||||
QStringList toArgs() const;
|
||||
};
|
||||
@@ -85,14 +88,19 @@ class AirPlaySettingsDialog : public QDialog
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AirPlaySettingsDialog(QWidget *parent = nullptr);
|
||||
AirPlaySettings getSettings() const;
|
||||
QPair<bool, AirPlaySettings> getSettings() const;
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
void connectSignals();
|
||||
|
||||
QComboBox *m_fpsComboBox;
|
||||
QCheckBox *m_noHoldCheckbox;
|
||||
#ifdef __linux__
|
||||
QCheckBox *m_useLegacyPortsCheckbox;
|
||||
#endif
|
||||
AirPlaySettings m_settings;
|
||||
bool m_settingsChanged = false;
|
||||
};
|
||||
|
||||
class AirPlayWidget : public Tool
|
||||
|
||||
@@ -281,6 +281,7 @@ void SettingsManager::resetToDefaults()
|
||||
setAirplayNoHold(true);
|
||||
setWirelessFileServerPort(8080);
|
||||
#ifdef __linux__
|
||||
setAirplayUseLegacyPorts(true);
|
||||
setShowV4L2(false);
|
||||
#endif
|
||||
setIsSleepyDeviceWarningDismissed(false);
|
||||
@@ -469,6 +470,17 @@ void SettingsManager::setAirplayNoHold(bool noHold)
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
bool SettingsManager::airplayUseLegacyPorts() const
|
||||
{
|
||||
return m_settings->value("airplayUseLegacyPorts", true).toBool();
|
||||
}
|
||||
|
||||
void SettingsManager::setAirplayUseLegacyPorts(bool enabled)
|
||||
{
|
||||
m_settings->setValue("airplayUseLegacyPorts", enabled);
|
||||
m_settings->sync();
|
||||
}
|
||||
|
||||
bool SettingsManager::showV4L2() const
|
||||
{
|
||||
return m_settings->value("showV4L2", false).toBool();
|
||||
|
||||
@@ -126,6 +126,8 @@ public:
|
||||
void setAirplayNoHold(bool noHold);
|
||||
|
||||
#ifdef __linux__
|
||||
bool airplayUseLegacyPorts() const;
|
||||
void setAirplayUseLegacyPorts(bool enabled);
|
||||
bool showV4L2() const;
|
||||
void setShowV4L2(bool show);
|
||||
#endif
|
||||
|
||||
@@ -233,6 +233,11 @@ void SettingsWidget::setupUI()
|
||||
airplayLayout->addWidget(m_noHoldCheckbox);
|
||||
|
||||
#ifdef __linux__
|
||||
m_useLegacyPortsCheckbox = new QCheckBox("Use legacy ports");
|
||||
m_useLegacyPortsCheckbox->setToolTip(
|
||||
"Use legacy AirPlay port behavior for compatibility.");
|
||||
airplayLayout->addWidget(m_useLegacyPortsCheckbox);
|
||||
|
||||
m_showV4L2CheckBox = new QCheckBox("Show V4L2 Button on AirPlay Widget");
|
||||
airplayLayout->addWidget(m_showV4L2CheckBox);
|
||||
#endif
|
||||
@@ -342,6 +347,7 @@ void SettingsWidget::loadSettings()
|
||||
m_fpsComboBox->setCurrentText(QString::number(sm->airplayFps()));
|
||||
m_noHoldCheckbox->setChecked(sm->airplayNoHold());
|
||||
#ifdef __linux__
|
||||
m_useLegacyPortsCheckbox->setChecked(sm->airplayUseLegacyPorts());
|
||||
m_showV4L2CheckBox->setChecked(sm->showV4L2());
|
||||
#endif
|
||||
|
||||
@@ -422,6 +428,8 @@ void SettingsWidget::connectSignals()
|
||||
connect(m_noHoldCheckbox, &QCheckBox::toggled, this,
|
||||
&SettingsWidget::onSettingChanged);
|
||||
#ifdef __linux__
|
||||
connect(m_useLegacyPortsCheckbox, &QCheckBox::toggled, this,
|
||||
&SettingsWidget::onSettingChanged);
|
||||
connect(m_showV4L2CheckBox, &QCheckBox::toggled, this,
|
||||
&SettingsWidget::onSettingChanged);
|
||||
#endif
|
||||
@@ -534,6 +542,7 @@ void SettingsWidget::saveSettings()
|
||||
sm->setAirplayFps(m_fpsComboBox->currentText().toInt());
|
||||
sm->setAirplayNoHold(m_noHoldCheckbox->isChecked());
|
||||
#ifdef __linux__
|
||||
sm->setAirplayUseLegacyPorts(m_useLegacyPortsCheckbox->isChecked());
|
||||
sm->setShowV4L2(m_showV4L2CheckBox->isChecked());
|
||||
#endif
|
||||
m_applyButton->setEnabled(false);
|
||||
|
||||
@@ -76,6 +76,7 @@ private:
|
||||
QCheckBox *m_noHoldCheckbox;
|
||||
|
||||
#ifdef __linux__
|
||||
QCheckBox *m_useLegacyPortsCheckbox;
|
||||
QCheckBox *m_showV4L2CheckBox;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user