mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
remove icon handling and simplify tab creation
This commit is contained in:
+14
-125
@@ -42,13 +42,10 @@ void handleCallback(const idevice_event_t *event, void *userData)
|
||||
|
||||
switch (event->event) {
|
||||
case IDEVICE_DEVICE_ADD: {
|
||||
// this should never happen iDescriptor does not support network devices
|
||||
// yet
|
||||
// for some reason even though we are only listening for USB devices, we
|
||||
// still get network devices on macOS
|
||||
/* this should never happen iDescriptor does not support network devices
|
||||
but for some reason even though we are only listening for USB devices,
|
||||
we still get network devices on macOS*/
|
||||
if (event->conn_type == CONNECTION_NETWORK) {
|
||||
warn("Network devices are not supported but a network device was "
|
||||
"received in event listener. Please report this issue.");
|
||||
return;
|
||||
}
|
||||
qDebug() << "Device added: " << QString::fromUtf8(event->udid);
|
||||
@@ -138,38 +135,16 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->mainTabWidget->widget(3)->layout()->addWidget(
|
||||
new JailbrokenWidget(this));
|
||||
|
||||
// // QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
// // QGraphicsSvgItem *svgItem = new
|
||||
// QGraphicsSvgItem("://icons/ArrowMoveDownRight.svg");
|
||||
// // scene->addItem(svgItem);
|
||||
|
||||
// // // Fit to view
|
||||
// // svgItem->setFlags(QGraphicsItem::ItemClipsToShape);
|
||||
// // svgItem->setCacheMode(QGraphicsItem::NoCache);
|
||||
// // svgItem->setZValue(0);
|
||||
// // svgItem->setScale(2.0); // or calculate scale to fit the view
|
||||
|
||||
// // ui->graphicsView->setScene(scene);
|
||||
// // ui->graphicsView->setRenderHint(QPainter::Antialiasing);
|
||||
// // ui->graphicsView->fitInView(svgItem, Qt::KeepAspectRatio);
|
||||
|
||||
// #include "./imobiledevice.cpp"
|
||||
customTabWidget->tabBar()->setMinimumWidth(150);
|
||||
customTabWidget->tabBar()->setMinimumWidth(75);
|
||||
customTabWidget->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
customTabWidget->setStyleSheet("QTabWidget::pane {"
|
||||
" border: 1px solid #ccc;"
|
||||
" background-color: rgb(240, 240, 240);"
|
||||
// " border: 1px solid #ccc;"
|
||||
"}"
|
||||
"QTabBar::tab {"
|
||||
" background-color: rgb(220, 220, 220);"
|
||||
" padding: 5px;"
|
||||
"}");
|
||||
customTabWidget->tabBar()->setMinimumHeight(100);
|
||||
|
||||
customTabWidget->tabBar()->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
|
||||
// customTabWidget->tabBar()->setMinimumHeight(100);
|
||||
irecv_error_t res_recovery =
|
||||
irecv_device_event_subscribe(&context, handleCallbackRecovery, nullptr);
|
||||
|
||||
@@ -191,15 +166,14 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
DeviceMenuWidget *deviceWidget = new DeviceMenuWidget(device, this);
|
||||
m_device_menu_widgets[device->udid] = deviceWidget;
|
||||
// Get device icon and product type for tab
|
||||
QPixmap deviceIcon = getDeviceIcon(device->deviceInfo.productType);
|
||||
QString tabTitle =
|
||||
QString::fromStdString(device->deviceInfo.productType);
|
||||
|
||||
// Add tab with custom icon
|
||||
DeviceTabWidget *customTabWidget =
|
||||
qobject_cast<DeviceTabWidget *>(ui->tabWidget);
|
||||
int mostRecentDevice = customTabWidget->addTabWithIcon(
|
||||
deviceWidget, deviceIcon, tabTitle);
|
||||
int mostRecentDevice =
|
||||
customTabWidget->addTabCustom(deviceWidget, tabTitle);
|
||||
customTabWidget->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
|
||||
@@ -258,7 +232,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// int mostRecentDevice = customTabWidget->addTabWithIcon(
|
||||
// placeholderWidget, placeholderIcon, tabTitle);
|
||||
int mostRecentDevice = ui->tabWidget->addTab(
|
||||
placeholderWidget, getDeviceIcon(udid.toStdString()),
|
||||
placeholderWidget, QIcon(),
|
||||
QString::fromStdString(udid.toStdString()));
|
||||
// customTabWidget->setSizePolicy(QSizePolicy::Expanding,
|
||||
// QSizePolicy::Preferred);
|
||||
@@ -297,11 +271,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
QString tabTitle =
|
||||
QString::fromStdString(device->deviceInfo.productType);
|
||||
QPixmap placeholderIcon(16, 16);
|
||||
placeholderIcon.fill(Qt::red);
|
||||
|
||||
int mostRecentDevice = customTabWidget->addTabWithIcon(
|
||||
deviceWidget, placeholderIcon, tabTitle);
|
||||
int mostRecentDevice =
|
||||
customTabWidget->addTabCustom(deviceWidget, tabTitle);
|
||||
// int mostRecentDevice = ui->tabWidget->addTab(
|
||||
// placeholderWidget, getDeviceIcon(udid.toStdString()),
|
||||
// QString::fromStdString(udid.toStdString()));
|
||||
@@ -335,29 +307,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
});
|
||||
}
|
||||
|
||||
QPixmap MainWindow::getDeviceIcon(const std::string &productType)
|
||||
{
|
||||
// Create a simple colored icon based on device type
|
||||
QPixmap icon(16, 16);
|
||||
icon.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&icon);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
if (productType.find("iPhone") != std::string::npos) {
|
||||
painter.setBrush(QColor(0, 122, 255)); // iOS blue
|
||||
painter.drawEllipse(2, 2, 12, 12);
|
||||
} else if (productType.find("iPad") != std::string::npos) {
|
||||
painter.setBrush(QColor(255, 149, 0)); // Orange
|
||||
painter.drawRect(2, 2, 12, 12);
|
||||
} else {
|
||||
painter.setBrush(QColor(128, 128, 128)); // Gray for unknown
|
||||
painter.drawEllipse(2, 2, 12, 12);
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
void MainWindow::updateNoDevicesConnected()
|
||||
{
|
||||
qDebug() << "Is there no devices connected? "
|
||||
@@ -408,7 +357,6 @@ void MainWindow::onRecoveryDeviceAdded(QObject *recoveryDeviceInfoObj)
|
||||
|
||||
m_device_menu_widgets[added_ecid] = recoveryDeviceInfoWidget;
|
||||
// Get device icon and product type for tab
|
||||
QPixmap deviceIcon = getDeviceIcon(device->product.toStdString());
|
||||
// QString tabTitle =
|
||||
// QString::fromStdString(device->product.toStdString());
|
||||
QString tabTitle = QString::fromStdString("recovery mode device");
|
||||
@@ -416,8 +364,8 @@ void MainWindow::onRecoveryDeviceAdded(QObject *recoveryDeviceInfoObj)
|
||||
// Add tab with custom icon
|
||||
DeviceTabWidget *customTabWidget =
|
||||
qobject_cast<DeviceTabWidget *>(ui->tabWidget);
|
||||
int mostRecentDevice = customTabWidget->addTabWithIcon(
|
||||
recoveryDeviceInfoWidget, deviceIcon, tabTitle);
|
||||
int mostRecentDevice =
|
||||
customTabWidget->addTabCustom(recoveryDeviceInfoWidget, tabTitle);
|
||||
customTabWidget->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
|
||||
@@ -441,24 +389,6 @@ void MainWindow::onRecoveryDeviceAdded(QObject *recoveryDeviceInfoObj)
|
||||
this, "Error",
|
||||
"An error occurred while processing device information");
|
||||
}
|
||||
|
||||
// RecoveryDeviceInfoWidget *recoveryDeviceInfoWidget = new
|
||||
// RecoveryDeviceInfoWidget(recoveryDeviceInfoObj); QPixmap recoveryIcon(16,
|
||||
// 16); recoveryIcon.fill(Qt::transparent); QPainter painter(&recoveryIcon);
|
||||
// painter.setRenderHint(QPainter::Antialiasing);
|
||||
// painter.setBrush(QColor(255, 59, 48)); // Red for recovery mode
|
||||
// painter.drawRoundedRect(2, 2, 12, 12, 2, 2);
|
||||
|
||||
// DeviceTabWidget *customTabWidget = qobject_cast<DeviceTabWidget
|
||||
// *>(ui->tabWidget);
|
||||
|
||||
// int mostRecentDevice =
|
||||
// customTabWidget->addTabWithIcon(recoveryDeviceInfoWidget, recoveryIcon,
|
||||
// "Recovery Mode");
|
||||
|
||||
// ui->tabWidget->setCurrentIndex(mostRecentDevice);
|
||||
|
||||
// recoveryDeviceInfoObj->deleteLater(); // Clean up
|
||||
}
|
||||
|
||||
void MainWindow::onRecoveryDeviceRemoved(QObject *deviceInfoObj)
|
||||
@@ -565,45 +495,4 @@ void MainWindow::onDeviceInitFailed(QString udid, lockdownd_error_t err)
|
||||
errorDialog.setIcon(QMessageBox::Warning);
|
||||
errorDialog.setStandardButtons(QMessageBox::Ok);
|
||||
errorDialog.exec();
|
||||
}
|
||||
|
||||
// void MainWindow::on_pushButton_clicked()
|
||||
// {
|
||||
// QMainWindow *newWin = new QMainWindow();
|
||||
// newWin->setWindowTitle("New Window");
|
||||
// newWin->resize(600, 400);
|
||||
// newWin->show(); // show non-modally
|
||||
// }
|
||||
|
||||
// // // mainwindow.cpp
|
||||
// // void MainWindow::openNewWindow() {
|
||||
// // QMainWindow* newWin = new QMainWindow();
|
||||
// // newWin->setWindowTitle("New Window");
|
||||
// // newWin->resize(600, 400);
|
||||
// // newWin->show(); // show non-modally
|
||||
// // }
|
||||
|
||||
// void MainWindow::on_pushButton_2_clicked()
|
||||
// {
|
||||
// DetailWindow *dWindow = new DetailWindow("iDeviceDetails", 42);
|
||||
// dWindow->show();
|
||||
// }
|
||||
|
||||
// void MainWindow::on_pushButton_3_clicked()
|
||||
// {
|
||||
// QMessageBox::StandardButton reply;
|
||||
// reply = QMessageBox::question(this, "Confirm Action", "Do you want to
|
||||
// continue?",
|
||||
// QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
// if (reply == QMessageBox::Yes)
|
||||
// {
|
||||
// // user clicked Yes
|
||||
// DetailWindow *dWindow = new DetailWindow("yess", 42);
|
||||
// dWindow->show();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // user clicked No
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user