mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-22 03:45:51 +08:00
bugfix removeDevice and style changes
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
@@ -1,6 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/ArrowMoveDownRight.svg</file>
|
||||
<file>icons/video-x-generic.png</file>
|
||||
<file>qml/MapView.qml</file>
|
||||
<file>resources/dump.js</file>
|
||||
<file>resources/iphone.png</file>
|
||||
|
||||
@@ -147,14 +147,17 @@ void DeviceManagerWidget::removeDevice(const std::string &uuid)
|
||||
{
|
||||
|
||||
qDebug() << "Removing:" << QString::fromStdString(uuid);
|
||||
std::pair<DeviceMenuWidget *, DeviceSidebarItem *> &d =
|
||||
m_deviceWidgets[uuid];
|
||||
DeviceMenuWidget *deviceWidget = m_deviceWidgets[uuid].first;
|
||||
DeviceSidebarItem *sidebarItem = m_deviceWidgets[uuid].second;
|
||||
|
||||
if (d.first != nullptr && d.second != nullptr) {
|
||||
if (deviceWidget != nullptr && sidebarItem != nullptr) {
|
||||
qDebug() << "Device exists removing:" << QString::fromStdString(uuid);
|
||||
// TODO: cleanups
|
||||
m_deviceWidgets.remove(uuid);
|
||||
delete d.first;
|
||||
delete d.second;
|
||||
m_stackedWidget->removeWidget(deviceWidget);
|
||||
m_sidebar->removeFromSidebar(sidebarItem);
|
||||
deviceWidget->deleteLater();
|
||||
// delete d.second;
|
||||
|
||||
if (m_deviceWidgets.count() > 0) {
|
||||
setCurrentDevice(m_deviceWidgets.firstKey());
|
||||
|
||||
@@ -33,13 +33,14 @@ void DeviceSidebarItem::setupUI()
|
||||
QVBoxLayout *headerLayout = new QVBoxLayout(m_headerWidget);
|
||||
headerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->setSpacing(2);
|
||||
m_headerWidget->setStyleSheet("ClickableWidget { }");
|
||||
m_headerWidget->setStyleSheet(
|
||||
"ClickableWidget { background-color: #ff0000ff; }");
|
||||
connect(m_headerWidget, &ClickableWidget::clicked, this,
|
||||
[this]() { emit deviceSelected(m_uuid); });
|
||||
|
||||
// Device name label
|
||||
m_deviceLabel = new QLabel(m_deviceName);
|
||||
m_deviceLabel->setStyleSheet("QLabel { font-weight: bold; color: #333; }");
|
||||
m_deviceLabel->setStyleSheet("QLabel { font-weight: bold; }");
|
||||
m_deviceLabel->setWordWrap(true);
|
||||
headerLayout->addWidget(m_deviceLabel);
|
||||
|
||||
@@ -96,6 +97,7 @@ void DeviceSidebarItem::setupUI()
|
||||
" text-align: center; "
|
||||
" border-radius: 3px; "
|
||||
" font-size: 11px; "
|
||||
" color: #212529; "
|
||||
"} "
|
||||
"QPushButton:checked { "
|
||||
" background-color: #0d6efd; "
|
||||
@@ -225,6 +227,11 @@ DeviceSidebarWidget::DeviceSidebarWidget(QWidget *parent) : QWidget(parent)
|
||||
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_scrollArea->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
// Make the scroll area and its viewport transparent
|
||||
m_scrollArea->setStyleSheet(
|
||||
"QScrollArea { background: transparent; border: none; }");
|
||||
m_scrollArea->viewport()->setStyleSheet("background: transparent;");
|
||||
|
||||
// Create content widget
|
||||
m_contentWidget = new QWidget();
|
||||
m_contentLayout = new QVBoxLayout(m_contentWidget);
|
||||
@@ -232,6 +239,9 @@ DeviceSidebarWidget::DeviceSidebarWidget(QWidget *parent) : QWidget(parent)
|
||||
m_contentLayout->setSpacing(10);
|
||||
m_contentLayout->addStretch(); // Push items to top
|
||||
|
||||
// Ensure the content widget is also transparent
|
||||
m_contentWidget->setStyleSheet("background: transparent;");
|
||||
|
||||
m_scrollArea->setWidget(m_contentWidget);
|
||||
mainLayout->addWidget(m_scrollArea);
|
||||
|
||||
@@ -267,6 +277,13 @@ DeviceSidebarItem *DeviceSidebarWidget::addToSidebar(const QString &deviceName,
|
||||
return item;
|
||||
}
|
||||
|
||||
void DeviceSidebarWidget::removeFromSidebar(DeviceSidebarItem *item)
|
||||
{
|
||||
m_deviceSidebarItems.removeAll(item);
|
||||
m_contentLayout->removeWidget(item);
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
DevicePendingSidebarItem *
|
||||
DeviceSidebarWidget::addPendingToSidebar(const QString &uuid)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
DeviceSidebarItem *addToSidebar(const QString &deviceName,
|
||||
const std::string &uuid);
|
||||
|
||||
void removeFromSidebar(DeviceSidebarItem *item);
|
||||
DevicePendingSidebarItem *addPendingToSidebar(const QString &uuid);
|
||||
void removePendingFromSidebar(DevicePendingSidebarItem *item);
|
||||
void setDeviceNavigationSection(int deviceIndex, const QString §ion);
|
||||
|
||||
+21
-11
@@ -84,8 +84,8 @@ GalleryWidget::GalleryWidget(iDescriptorDevice *device, QWidget *parent)
|
||||
void GalleryWidget::setupUI()
|
||||
{
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
m_mainLayout->setContentsMargins(10, 10, 10, 10);
|
||||
m_mainLayout->setSpacing(10);
|
||||
m_mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
// m_mainLayout->setSpacing(10);
|
||||
|
||||
// Setup controls at the top
|
||||
setupControlsLayout();
|
||||
@@ -99,7 +99,21 @@ void GalleryWidget::setupUI()
|
||||
m_listView->setIconSize(QSize(120, 120));
|
||||
m_listView->setSpacing(10);
|
||||
m_listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_listView->setUniformItemSizes(true);
|
||||
// m_listView->setGridSize(QSize(140, 300)); // Fixed grid size
|
||||
// m_listView->setIconSize(QSize(120, 300));
|
||||
|
||||
m_listView->setStyleSheet(
|
||||
"QListView { "
|
||||
" border-top: 1px solid #c1c1c1ff; " // Gray border for the ListView
|
||||
" background-color: transparent; " // Optional: background
|
||||
" padding: 0px;"
|
||||
"} "
|
||||
"QListView::item { "
|
||||
" width: 150px; "
|
||||
" height: 150px; "
|
||||
" margin: 2px; "
|
||||
"}");
|
||||
// Create and set model
|
||||
m_model = new PhotoModel(m_device, this);
|
||||
m_listView->setModel(m_model);
|
||||
@@ -142,11 +156,12 @@ void GalleryWidget::setupUI()
|
||||
void GalleryWidget::setupControlsLayout()
|
||||
{
|
||||
m_controlsLayout = new QHBoxLayout();
|
||||
m_controlsLayout->setSpacing(15);
|
||||
m_controlsLayout->setSpacing(5);
|
||||
m_controlsLayout->setContentsMargins(7, 7, 7, 7);
|
||||
|
||||
// Sort order combo box
|
||||
QLabel *sortLabel = new QLabel("Sort:");
|
||||
sortLabel->setStyleSheet("font-weight: bold; color: #555;");
|
||||
sortLabel->setStyleSheet("font-weight: bold;");
|
||||
m_sortComboBox = new QComboBox();
|
||||
m_sortComboBox->addItem("Newest First",
|
||||
static_cast<int>(PhotoModel::NewestFirst));
|
||||
@@ -155,9 +170,7 @@ void GalleryWidget::setupControlsLayout()
|
||||
m_sortComboBox->setCurrentIndex(0); // Default to Newest First
|
||||
m_sortComboBox->setStyleSheet("QComboBox { "
|
||||
" padding: 5px 10px; "
|
||||
" border: 1px solid #ccc; "
|
||||
" border-radius: 4px; "
|
||||
" background-color: white; "
|
||||
" min-width: 100px; "
|
||||
"} "
|
||||
"QComboBox:hover { "
|
||||
@@ -174,7 +187,7 @@ void GalleryWidget::setupControlsLayout()
|
||||
|
||||
// Filter combo box
|
||||
QLabel *filterLabel = new QLabel("Filter:");
|
||||
filterLabel->setStyleSheet("font-weight: bold; color: #555;");
|
||||
filterLabel->setStyleSheet("font-weight: bold;");
|
||||
m_filterComboBox = new QComboBox();
|
||||
m_filterComboBox->addItem("All Media", static_cast<int>(PhotoModel::All));
|
||||
m_filterComboBox->addItem("Images Only",
|
||||
@@ -246,10 +259,7 @@ void GalleryWidget::setupControlsLayout()
|
||||
QWidget *controlsWidget = new QWidget();
|
||||
controlsWidget->setLayout(m_controlsLayout);
|
||||
controlsWidget->setStyleSheet("QWidget { "
|
||||
" background-color: #f8f9fa; "
|
||||
" border: 1px solid #dee2e6; "
|
||||
" border-radius: 6px; "
|
||||
" padding: 10px; "
|
||||
" padding: 2px; "
|
||||
"}");
|
||||
|
||||
m_mainLayout->addWidget(controlsWidget);
|
||||
|
||||
+4
-3
@@ -116,6 +116,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("iDescriptor");
|
||||
|
||||
m_deviceManager = new DeviceManagerWidget(this);
|
||||
ui->stackedWidget->insertWidget(1, m_deviceManager);
|
||||
@@ -124,7 +125,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
// settings button
|
||||
QPushButton *settingsButton = new QPushButton();
|
||||
settingsButton->setIcon(QIcon::fromTheme("settings"));
|
||||
settingsButton->setIcon(QIcon::fromTheme("preferences-system"));
|
||||
settingsButton->setToolTip("Settings");
|
||||
settingsButton->setFlat(true);
|
||||
settingsButton->setCursor(Qt::PointingHandCursor);
|
||||
@@ -140,13 +141,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
settingsDialog.setLayout(layout);
|
||||
settingsDialog.exec();
|
||||
});
|
||||
ui->centralwidget->layout()->addWidget(settingsButton);
|
||||
|
||||
// ui->centralwidget->layout()->addWidget(settingsButton);
|
||||
ui->mainTabWidget->widget(1)->layout()->addWidget(new AppsWidget(this));
|
||||
ui->mainTabWidget->widget(2)->layout()->addWidget(new ToolboxWidget(this));
|
||||
ui->mainTabWidget->widget(3)->layout()->addWidget(
|
||||
new JailbrokenWidget(this));
|
||||
|
||||
ui->statusbar->addPermanentWidget(settingsButton);
|
||||
irecv_error_t res_recovery =
|
||||
irecv_device_event_subscribe(&context, handleCallbackRecovery, nullptr);
|
||||
|
||||
|
||||
@@ -15,6 +15,21 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="mainTabWidget">
|
||||
<property name="currentIndex">
|
||||
|
||||
@@ -47,9 +47,13 @@ MediaPreviewDialog::MediaPreviewDialog(iDescriptorDevice *device,
|
||||
Qt::WindowCloseButtonHint);
|
||||
|
||||
// Use full screen size
|
||||
const QSize screenSize = QApplication::primaryScreen()->availableSize();
|
||||
const QSize screenSize = QApplication::primaryScreen()->size();
|
||||
resize(screenSize);
|
||||
|
||||
// Add window transparency
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setWindowOpacity(0.99);
|
||||
|
||||
setupUI();
|
||||
loadMedia();
|
||||
}
|
||||
@@ -702,4 +706,26 @@ void MediaPreviewDialog::onVolumeChanged(int value)
|
||||
qDebug() << "Volume changed to:" << value << "%" << "(" << volume
|
||||
<< ")";
|
||||
}
|
||||
}
|
||||
|
||||
bool MediaPreviewDialog::event(QEvent *event)
|
||||
{
|
||||
// catch platform Close (Cmd+W on macOS)
|
||||
if (event->type() == QEvent::ShortcutOverride) {
|
||||
if (auto *ke = dynamic_cast<QKeyEvent *>(event)) {
|
||||
const Qt::KeyboardModifiers mods = ke->modifiers();
|
||||
if (ke->key() == Qt::Key_W &&
|
||||
(mods & (Qt::MetaModifier | Qt::ControlModifier))) {
|
||||
ke->accept();
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
if (ke->key() == Qt::Key_Escape) {
|
||||
ke->accept();
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QDialog::event(event);
|
||||
}
|
||||
@@ -40,6 +40,7 @@ protected:
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool event(QEvent *event) override; // handle ShortcutOverride
|
||||
|
||||
private slots:
|
||||
void onImageLoaded();
|
||||
|
||||
+6
-2
@@ -144,7 +144,8 @@ QVariant PhotoModel::data(const QModelIndex &index, int role) const
|
||||
if (info.fileName.endsWith(".MOV", Qt::CaseInsensitive) ||
|
||||
info.fileName.endsWith(".MP4", Qt::CaseInsensitive) ||
|
||||
info.fileName.endsWith(".M4V", Qt::CaseInsensitive)) {
|
||||
return QIcon::fromTheme("video-x-generic");
|
||||
// return QIcon::fromTheme("video-x-generic");
|
||||
return QIcon(":/icons/video-x-generic.png");
|
||||
} else {
|
||||
return QIcon::fromTheme("image-x-generic");
|
||||
}
|
||||
@@ -161,7 +162,8 @@ QVariant PhotoModel::data(const QModelIndex &index, int role) const
|
||||
if (info.fileName.endsWith(".MOV", Qt::CaseInsensitive) ||
|
||||
info.fileName.endsWith(".MP4", Qt::CaseInsensitive) ||
|
||||
info.fileName.endsWith(".M4V", Qt::CaseInsensitive)) {
|
||||
return QIcon::fromTheme("video-x-generic");
|
||||
// return QIcon::fromTheme("video-x-generic");
|
||||
return QIcon(":/icons/video-x-generic.png");
|
||||
} else {
|
||||
return QIcon::fromTheme("image-x-generic");
|
||||
}
|
||||
@@ -399,6 +401,8 @@ QPixmap PhotoModel::loadImage(iDescriptorDevice *device,
|
||||
|
||||
void PhotoModel::populatePhotoPaths()
|
||||
{
|
||||
// TODO:beginResetModel called on PhotoModel(0x600002d12a40) without calling
|
||||
// endResetModel first
|
||||
beginResetModel();
|
||||
m_allPhotos.clear();
|
||||
m_photos.clear();
|
||||
|
||||
Reference in New Issue
Block a user