feat: enhance app download dialog

This commit is contained in:
uncor3
2026-02-10 05:19:50 -08:00
parent b22990c4cd
commit 54d08044de
9 changed files with 76 additions and 29 deletions
+11 -6
View File
@@ -21,6 +21,7 @@
#define APPDOWNLOADBASEDIALOG_H
#include <QDialog>
#include <QNetworkAccessManager>
#include <QProcess>
#include <QProgressBar>
#include <QPushButton>
@@ -34,6 +35,14 @@ public:
const QString &bundleId,
QWidget *parent = nullptr);
QNetworkAccessManager *m_manager = new QNetworkAccessManager(this);
QPushButton *m_actionButton;
QProgressBar *m_progressBar;
QTimer *m_progressTimer;
QProcess *m_downloadProcess;
QString m_appName;
QVBoxLayout *m_layout;
public slots:
void updateProgressBar(int percentage);
@@ -51,12 +60,8 @@ protected:
void addProgressBar(int index);
void tryToDownload(const QString &bundleId, const QString &outputDir,
bool promptToOpenDir, bool close = false);
QProgressBar *m_progressBar;
QTimer *m_progressTimer;
QProcess *m_downloadProcess;
QString m_appName;
QPushButton *m_actionButton;
QVBoxLayout *m_layout;
private:
bool m_operationInProgress = false;
QString m_bundleId;
uint m_tries = 0;
+45 -12
View File
@@ -18,11 +18,15 @@
*/
#include "appdownloaddialog.h"
#include "Backdrop.h"
#include "iDescriptor-ui.h"
#include "iDescriptor.h"
#include "libipatool-go.h"
#include <QDesktopServices>
#include <QFileDialog>
#include <QLabel>
#include <QNetworkAccessManager>
#include <QPointer>
#include <QPushButton>
#include <QStandardPaths>
#include <QVBoxLayout>
@@ -38,15 +42,38 @@ AppDownloadDialog::AppDownloadDialog(const QString &appName,
{
setWindowTitle("Download " + appName + " IPA");
setModal(true);
// setFixedSize(500, 270);
setFixedWidth(500);
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(this->layout());
m_loadingWidget = new ZLoadingWidget(this);
layout()->addWidget(m_loadingWidget);
QVBoxLayout *contentLayout = new QVBoxLayout(this);
contentLayout->setContentsMargins(0, 0, 0, 0);
m_bgLabel = new QLabel();
// FIMXE: causes infinite scaling for some reason, need to investigate
// m_bgLabel->setScaledContents(true);
// m_bgLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
// contentLayout->addWidget(m_bgLabel);
QPointer<AppDownloadDialog> safeThis = this;
fetchAppIconFromApple(
m_manager, bundleId,
[safeThis](const QPixmap &icon, const QJsonObject &appInfo) {
if (auto dialog = safeThis.data()) {
if (!icon.isNull()) {
QPixmap blurred = BackDrop::blurPixmap(icon, 30);
dialog->m_bgLabel->setPixmap(blurred.scaled(
dialog->size(), Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation));
}
dialog->m_loadingWidget->stop(true);
}
});
QLabel *descLabel = new QLabel(description);
descLabel->setWordWrap(true);
descLabel->setStyleSheet("font-size: 14px; color: #666;");
layout->insertWidget(1, descLabel);
contentLayout->insertWidget(1, descLabel);
// Directory selection UI
QHBoxLayout *dirLayout = new QHBoxLayout();
@@ -64,7 +91,7 @@ AppDownloadDialog::AppDownloadDialog(const QString &appName,
dirLayout->addWidget(m_dirLabel, 1);
m_dirButton = new QPushButton("Choose...");
m_dirButton->setStyleSheet("font-size: 14px; padding: 4px 12px;");
// m_dirButton->setStyleSheet("font-size: 14px; padding: 4px 12px;");
connect(m_dirButton, &QPushButton::clicked, this, [this]() {
QString dir = QFileDialog::getExistingDirectory(
this, "Select Directory to Save IPA", m_outputDir);
@@ -75,22 +102,28 @@ AppDownloadDialog::AppDownloadDialog(const QString &appName,
});
dirLayout->addWidget(m_dirButton);
layout->insertLayout(2, dirLayout);
contentLayout->insertLayout(2, dirLayout);
QHBoxLayout *buttonLayout = new QHBoxLayout();
m_actionButton = new QPushButton("Download IPA");
m_actionButton->setFixedHeight(40);
// m_actionButton->setFixedHeight(40);
m_actionButton->setDefault(true);
connect(m_actionButton, &QPushButton::clicked, this,
&AppDownloadDialog::onDownloadClicked);
layout->addWidget(m_actionButton);
buttonLayout->addWidget(m_actionButton);
QPushButton *cancelButton = new QPushButton("Cancel");
cancelButton->setFixedHeight(40);
cancelButton->setStyleSheet(
"background-color: #f0f0f0; color: #333; border: 1px solid #ddd; "
"border-radius: 6px; font-size: 16px;");
// cancelButton->setFixedHeight(40);
// cancelButton->setStyleSheet(
// "background-color: #f0f0f0; color: #333; border: 1px solid #ddd; "
// "border-radius: 6px; font-size: 16px;");
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
layout->addWidget(cancelButton);
buttonLayout->addWidget(cancelButton);
contentLayout->addLayout(buttonLayout);
m_loadingWidget->setupContentWidget(contentLayout);
}
void AppDownloadDialog::onDownloadClicked()
+10
View File
@@ -22,6 +22,7 @@
#include "appdownloadbasedialog.h"
#include "iDescriptor-ui.h"
#include "zloadingwidget.h"
#include <QDialog>
#include <QLabel>
#include <QPushButton>
@@ -34,6 +35,13 @@ public:
const QString &description,
QWidget *parent = nullptr);
protected:
void resizeEvent(QResizeEvent *event) override
{
QWidget::resizeEvent(event);
m_bgLabel->setFixedSize(event->size());
}
private slots:
void onDownloadClicked();
@@ -42,6 +50,8 @@ private:
QPushButton *m_dirButton;
ZLabel *m_dirLabel;
QString m_bundleId;
QLabel *m_bgLabel;
ZLoadingWidget *m_loadingWidget;
};
#endif // APPDOWNLOADDIALOG_H
+2 -2
View File
@@ -45,13 +45,13 @@ AppInstallDialog::AppInstallDialog(const QString &appName,
setWindowTitle("Install " + appName + " - iDescriptor");
setModal(true);
setFixedWidth(500);
m_manager = new QNetworkAccessManager(this);
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(this->layout());
// App info section
QHBoxLayout *appInfoLayout = new QHBoxLayout();
QLabel *iconLabel = new QLabel();
::fetchAppIconFromApple(
m_manager, bundleId, [iconLabel](const QPixmap &pixmap) {
m_manager, bundleId,
[iconLabel](const QPixmap &pixmap, const QJsonObject &appInfo) {
if (!pixmap.isNull()) {
QPixmap scaled =
pixmap.scaled(64, 64, Qt::KeepAspectRatioByExpanding,
+1 -3
View File
@@ -21,13 +21,12 @@
#define APPINSTALLDIALOG_H
#include "appdownloadbasedialog.h"
#include "iDescriptor.h"
#include <QComboBox>
#include <QDialog>
#include <QFutureWatcher>
#include <QLabel>
#include <QNetworkAccessManager>
#include <QTemporaryDir>
#include "iDescriptor.h"
class AppInstallDialog : public AppDownloadBaseDialog
{
@@ -51,7 +50,6 @@ private:
QLabel *m_statusLabel;
QFutureWatcher<IdeviceFfiError *> *m_installWatcher;
QTemporaryDir *m_tempDir = nullptr;
QNetworkAccessManager *m_manager = nullptr;
void updateDeviceList();
void performInstallation(const QString &ipaPath, const QString &ipaName,
const QString &deviceUdid);
+2 -1
View File
@@ -570,7 +570,8 @@ void AppsWidget::createAppCard(
connect(iconLabel, &QObject::destroyed, reply, &QNetworkReply::abort);
} else if (!bundleId.isEmpty()) {
fetchAppIconFromApple(
m_networkManager, bundleId, [safeIconLabel](const QPixmap &pixmap) {
m_networkManager, bundleId,
[safeIconLabel](const QPixmap &pixmap, const QJsonObject &appInfo) {
// Check if iconLabel still exists
if (safeIconLabel && !pixmap.isNull()) {
QPixmap scaled =
+1 -1
View File
@@ -36,7 +36,7 @@
#include <QWheelEvent>
#include <QWidget>
#ifdef Q_OS_MAC
#ifdef __APPLE__
#include "./platform/macos.h"
#endif
+3 -3
View File
@@ -491,9 +491,9 @@ void get_battery_info(DiagnosticsRelay *diagRelay, plist_t &diagnostics);
// void parseOldDeviceBattery(PlistNavigator &ioreg, DeviceInfo &d);
// void parseDeviceBattery(PlistNavigator &ioreg, DeviceInfo &d);
void fetchAppIconFromApple(QNetworkAccessManager *manager,
const QString &bundleId,
std::function<void(const QPixmap &)> callback);
void fetchAppIconFromApple(
QNetworkAccessManager *manager, const QString &bundleId,
std::function<void(const QPixmap &, const QJsonObject &)> callback);
void _get_cable_info(const iDescriptorDevice *device, plist_t &response);
+1 -1
View File
@@ -59,7 +59,7 @@ SponsorAppCard::SponsorAppCard(QWidget *parent) : QWidget{parent}
QString websiteUrl = "https://www.shopify.com";
::fetchAppIconFromApple(
m_networkManager, bundleId, [iconLabel](const QPixmap &pixmap) {
m_networkManager, bundleId, [iconLabel](const QPixmap &pixmap, const QJsonObject &appInfo) {
if (!pixmap.isNull()) {
QPixmap scaled =
pixmap.scaled(64, 64, Qt::KeepAspectRatioByExpanding,