From 8ec38d3ee0acf18a588537e0155688995a77b55f Mon Sep 17 00:00:00 2001 From: uncor3 Date: Wed, 28 Jan 2026 16:04:19 +0300 Subject: [PATCH] feat(ui): check for Bonjour in AirPlay widget, make AirPlay widget resizeable --- lib/uxplay | 2 +- src/airplaywindow.cpp | 32 +++++++++++++++++++++++++------- src/diagnosedialog.cpp | 20 +++++++------------- src/iDescriptor-ui.h | 1 + src/mainwindow.cpp | 5 ++--- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/lib/uxplay b/lib/uxplay index f8459c2..e61b6e1 160000 --- a/lib/uxplay +++ b/lib/uxplay @@ -1 +1 @@ -Subproject commit f8459c25ec1b119d448297e687223f06a22b324f +Subproject commit e61b6e1c023018be8b9be9bdb5cb56a8c0c6ace4 diff --git a/src/airplaywindow.cpp b/src/airplaywindow.cpp index 35106c3..4646c0b 100644 --- a/src/airplaywindow.cpp +++ b/src/airplaywindow.cpp @@ -55,6 +55,8 @@ #include #include +#include "diagnosedialog.h" +#include "platform/windows/check_deps.h" #include "toolboxwidget.h" AirPlaySettings::AirPlaySettings() @@ -69,9 +71,8 @@ QStringList AirPlaySettings::toArgs() const // FPS args << "-fps" << QString::number(fps); - // FIXME: causes seg fault on Windows ? // Allow new connections to take over - // args << "-nohold"; + args << "-nohold"; return args; } @@ -139,7 +140,27 @@ AirPlayWindow::AirPlayWindow(QWidget *parent) m_serverThread(nullptr), m_serverRunning(false), m_clientConnected(false) { setupUI(); + setMinimumSize(800, 600); + QTimer::singleShot(0, this, [this]() { + /* HACK: qt ignores resize() calls so let's workaround */ + setMinimumSize(0, 0); + }); +/* FIXME: this can be handled better, add linux support */ +#ifdef WIN32 + bool bonjour = IsBonjourServiceInstalled(); + if (!bonjour) { + QMessageBox::warning( + this, "Bonjour Service Not Installed", + "Bonjour service is not installed on your system. Please install " + "it to enable AirPlay functionality."); + + DiagnoseDialog *diagnoseDialog = new DiagnoseDialog(); + diagnoseDialog->show(); + QTimer::singleShot(0, this, &AirPlayWindow::close); + return; + } +#endif QTimer::singleShot(500, this, &AirPlayWindow::startAirPlayServer); } @@ -154,8 +175,6 @@ AirPlayWindow::~AirPlayWindow() void AirPlayWindow::setupUI() { setWindowTitle("AirPlay Receiver - iDescriptor"); - setMinimumSize(800, 600); - resize(1000, 700); // Create stacked widget m_stackedWidget = new QStackedWidget(this); @@ -163,7 +182,7 @@ void AirPlayWindow::setupUI() m_tutorialWidget = new QWidget(); m_tutorialLayout = new QVBoxLayout(m_tutorialWidget); - m_tutorialLayout->setContentsMargins(40, 40, 40, 40); + m_tutorialLayout->setContentsMargins(0, 0, 0, 0); m_tutorialLayout->setSpacing(20); m_loadingIndicator = new QProcessIndicator(); @@ -173,7 +192,7 @@ void AirPlayWindow::setupUI() QHBoxLayout *loadingLayout = new QHBoxLayout(); m_loadingLabel = new QLabel("Starting AirPlay Server..."); - + loadingLayout->setContentsMargins(0, 40, 0, 0); loadingLayout->addStretch(); loadingLayout->addWidget(m_loadingLabel); loadingLayout->addSpacing(5); @@ -211,7 +230,6 @@ void AirPlayWindow::setupUI() // Video display m_videoLabel = new QLabel(); - m_videoLabel->setMinimumSize(640, 480); m_videoLabel->setAlignment(Qt::AlignCenter); m_videoLabel->setScaledContents(false); streamingLayout->addWidget(m_videoLabel, 1); diff --git a/src/diagnosedialog.cpp b/src/diagnosedialog.cpp index 0c5d925..598e501 100644 --- a/src/diagnosedialog.cpp +++ b/src/diagnosedialog.cpp @@ -18,34 +18,29 @@ */ #include "diagnosedialog.h" +#include "iDescriptor-ui.h" #include DiagnoseDialog::DiagnoseDialog(QWidget *parent) : QDialog(parent) { setupUI(); - setWindowTitle("System Dependencies"); setModal(true); - resize(500, 400); - - // Set clean close behavior setAttribute(Qt::WA_DeleteOnClose, true); } void DiagnoseDialog::setupUI() { + setMinimumSize(MIN_MAIN_WINDOW_SIZE.width(), MIN_MAIN_WINDOW_SIZE.height() / 2); QVBoxLayout *mainLayout = new QVBoxLayout(this); - QScrollArea *scrollArea = new QScrollArea(this); - scrollArea->setWidgetResizable(true); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); mainLayout->setContentsMargins(10, 10, 10, 10); - // Add the main diagnose widget + /* + TODO: either subclass DiagnoseWidget or + modify its layout to better fit dialog + */ m_diagnoseWidget = new DiagnoseWidget(); - scrollArea->setWidget(m_diagnoseWidget); - // Close button QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(); @@ -56,8 +51,7 @@ void DiagnoseDialog::setupUI() buttonLayout->addWidget(m_closeButton); - // Layout assembly - mainLayout->addWidget(scrollArea); + mainLayout->addWidget(m_diagnoseWidget); mainLayout->addLayout(buttonLayout); } diff --git a/src/iDescriptor-ui.h b/src/iDescriptor-ui.h index 431e7e8..1d7e53d 100644 --- a/src/iDescriptor-ui.h +++ b/src/iDescriptor-ui.h @@ -45,6 +45,7 @@ #define COLOR_RED QColor(255, 0, 0) // Red #define COLOR_BLUE QColor("#2b5693") #define COLOR_ACCENT_BLUE QColor("#0b5ed7") +#define MIN_MAIN_WINDOW_SIZE QSize(900, 600) class ResponsiveGraphicsView : public QGraphicsView { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ae53251..58cf5ef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -136,9 +136,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); - const QSize minSize(900, 600); - setMinimumSize(minSize); - resize(minSize); + setMinimumSize(MIN_MAIN_WINDOW_SIZE); + resize(MIN_MAIN_WINDOW_SIZE); m_ZTabWidget = new ZTabWidget(this); m_ZTabWidget->setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false);