mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-22 03:45:51 +08:00
WIP: Implement Installed Apps Widget and AFC2 file explorer
- Added InstalledAppsWidget for displaying installed applications on the device. - Created AppTabWidget for individual app representation with icon and details. - Integrated fetching of app icons from Apple and displaying them in the widget. - Implemented search functionality to filter installed apps. - Added functionality to manage favorite places in SettingsManager. - Introduced methods to save, remove, and retrieve favorite places with proper cleanup of invalid entries. - Enhanced UI with responsive design and improved user interaction. - Added support for AFC2 and improved file exploration capabilities.
This commit is contained in:
@@ -28,8 +28,6 @@
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPixmap>
|
||||
@@ -45,62 +43,6 @@
|
||||
#include <QWidget>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
// Callback: void(QPixmap)
|
||||
// TODO : move to utils
|
||||
void fetchAppIconFromApple(const QString &bundleId,
|
||||
std::function<void(const QPixmap &)> callback,
|
||||
QObject *context)
|
||||
{
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(context);
|
||||
QString url =
|
||||
QString("https://itunes.apple.com/lookup?bundleId=%1").arg(bundleId);
|
||||
|
||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url)));
|
||||
QObject::connect(
|
||||
reply, &QNetworkReply::finished, context,
|
||||
[reply, callback, manager, context]() {
|
||||
QByteArray data = reply->readAll();
|
||||
reply->deleteLater();
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
callback(QPixmap());
|
||||
manager->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject obj = doc.object();
|
||||
QJsonArray results = obj.value("results").toArray();
|
||||
if (results.isEmpty()) {
|
||||
callback(QPixmap());
|
||||
manager->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject appInfo = results.at(0).toObject();
|
||||
QString iconUrl = appInfo.value("artworkUrl100").toString();
|
||||
if (iconUrl.isEmpty()) {
|
||||
callback(QPixmap());
|
||||
manager->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the icon image
|
||||
QNetworkReply *iconReply =
|
||||
manager->get(QNetworkRequest(QUrl(iconUrl)));
|
||||
QObject::connect(iconReply, &QNetworkReply::finished, context,
|
||||
[iconReply, callback, manager]() {
|
||||
QByteArray iconData = iconReply->readAll();
|
||||
iconReply->deleteLater();
|
||||
QPixmap pixmap;
|
||||
pixmap.loadFromData(iconData);
|
||||
callback(pixmap);
|
||||
manager->deleteLater();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
AppsWidget::AppsWidget(QWidget *parent) : QWidget(parent), m_isLoggedIn(false)
|
||||
{
|
||||
// m_searchProcess = new QProcess(this);
|
||||
|
||||
Reference in New Issue
Block a user