mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
implement device_became_wired
This commit is contained in:
@@ -63,11 +63,11 @@ void DeviceSidebarItem::setupUI()
|
||||
m_deviceLabel->setWordWrap(true);
|
||||
nameLayout->addWidget(m_deviceLabel);
|
||||
if (m_wireless) {
|
||||
auto wirelessIcon = new ZIconLabel(
|
||||
m_wirelessIcon = new ZIconLabel(
|
||||
QIcon(":/resources/icons/QlementineIconsWireless116.png"),
|
||||
"Wireless", 1.0, this);
|
||||
nameLayout->setSpacing(5);
|
||||
nameLayout->addWidget(wirelessIcon);
|
||||
nameLayout->addWidget(m_wirelessIcon);
|
||||
}
|
||||
headerLayout->addLayout(nameLayout);
|
||||
|
||||
@@ -177,6 +177,15 @@ void DeviceSidebarItem::setupUI()
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
void DeviceSidebarItem::gotWired()
|
||||
{
|
||||
m_wireless = false;
|
||||
if (m_wirelessIcon) {
|
||||
m_wirelessIcon->deleteLater();
|
||||
m_wirelessIcon = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSidebarItem::setSelected(bool selected)
|
||||
{
|
||||
m_selected = selected;
|
||||
@@ -389,6 +398,14 @@ DeviceSidebarWidget::DeviceSidebarWidget(QWidget *parent)
|
||||
connect(AppContext::sharedInstance(),
|
||||
&AppContext::currentDeviceSelectionChanged, this,
|
||||
&DeviceSidebarWidget::setCurrentSelection);
|
||||
|
||||
// Device became wired -> update sidebar item
|
||||
connect(AppContext::sharedInstance(), &AppContext::deviceBecameWired, this,
|
||||
[this](const QString &udid) {
|
||||
if (m_deviceItems.contains(udid)) {
|
||||
m_deviceItems[udid]->gotWired();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DeviceSidebarItem *DeviceSidebarWidget::addDevice(const QString &deviceName,
|
||||
|
||||
@@ -44,8 +44,7 @@ public:
|
||||
void setCollapsed(bool collapsed);
|
||||
bool isCollapsed() const { return m_collapsed; }
|
||||
|
||||
// protected:
|
||||
// void paintEvent(QPaintEvent *event) override;
|
||||
void gotWired();
|
||||
signals:
|
||||
void deviceSelected(const QString &uuid);
|
||||
void navigationRequested(const QString &uuid, const QString §ion);
|
||||
@@ -76,6 +75,7 @@ private:
|
||||
QPushButton *m_galleryButton;
|
||||
QPushButton *m_filesButton;
|
||||
QButtonGroup *m_navigationGroup;
|
||||
ZIconLabel *m_wirelessIcon;
|
||||
};
|
||||
|
||||
#ifndef DEVICEPENDINGSIDEBARITEM_H
|
||||
|
||||
+19
-4
@@ -123,6 +123,9 @@ mod qobject {
|
||||
|
||||
#[qsignal]
|
||||
fn sleepy_time_detected(self: Pin<&mut Core>);
|
||||
|
||||
#[qsignal]
|
||||
fn device_became_wired(self: Pin<&mut Core>, udid: &QString);
|
||||
}
|
||||
impl cxx_qt::Threading for Core {}
|
||||
}
|
||||
@@ -747,10 +750,22 @@ async fn init_idescriptor_device<
|
||||
lockdown: Arc::new(Mutex::new(lc)),
|
||||
};
|
||||
|
||||
APP_DEVICE_STATE
|
||||
.lock()
|
||||
.await
|
||||
.insert(udid.to_string(), device_services);
|
||||
{
|
||||
let mut state = APP_DEVICE_STATE.lock().await;
|
||||
if let Some(mut old) = state.insert(udid.to_string(), device_services) {
|
||||
eprintln!(
|
||||
"device became wired - UDID {}",
|
||||
udid
|
||||
);
|
||||
if let Some(task) = old.heartbeat_task.take() {
|
||||
task.abort();
|
||||
}
|
||||
let udid_for_signal = udid.clone();
|
||||
qt_thread.queue(move |core_qobj| {
|
||||
core_qobj.device_became_wired(&QString::from(udid_for_signal));
|
||||
}).ok();
|
||||
}
|
||||
}
|
||||
|
||||
if is_wireless {
|
||||
match hb {
|
||||
|
||||
Reference in New Issue
Block a user