diff --git a/resources.qrc b/resources.qrc index f558183..a261ef6 100644 --- a/resources.qrc +++ b/resources.qrc @@ -43,6 +43,7 @@ resources/icons/MaterialSymbolsLightKeyboardArrowUp.png resources/icons/MaterialSymbolsLightKeyboardArrowDown.png resources/icons/IcOutlineRefresh.png + resources/icons/StreamlineFreehandChargingFlashWireless.png qml/MapView.qml resources/iphone.png resources/ios-version.png diff --git a/resources/icons/StreamlineFreehandChargingFlashWireless.png b/resources/icons/StreamlineFreehandChargingFlashWireless.png new file mode 100644 index 0000000..9e2e62d Binary files /dev/null and b/resources/icons/StreamlineFreehandChargingFlashWireless.png differ diff --git a/src/iDescriptor-ui.h b/src/iDescriptor-ui.h index 1e4d2fb..208f25b 100644 --- a/src/iDescriptor-ui.h +++ b/src/iDescriptor-ui.h @@ -367,6 +367,7 @@ enum class iDescriptorTool { */ NetworkDevices, iFuse, + EnableWifiConnections, Unknown }; @@ -663,7 +664,7 @@ private: if (m_animation) return; - m_animation = new QPropertyAnimation(this, "shimmerOffset", this); + m_animation = new QPropertyAnimation(this, "shimmerOffset"); m_animation->setDuration(1200); m_animation->setStartValue(0.0); m_animation->setEndValue(1.0); diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 6c68925..09171d0 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -24,6 +24,8 @@ #include #include +const QString SEEN_DEVICE_PREFIX = "seenDevices/"; + SettingsManager *SettingsManager::sharedInstance() { static SettingsManager instance; @@ -133,6 +135,17 @@ void SettingsManager::setAutoConnectWirelessDevices(bool enabled) m_settings->sync(); } +bool SettingsManager::autoEnableWifiConnections() const +{ + return m_settings->value("autoEnableWifiConnections", true).toBool(); +} + +void SettingsManager::setAutoEnableWifiConnections(bool enabled) +{ + m_settings->setValue("autoEnableWifiConnections", enabled); + m_settings->sync(); +} + #ifndef __APPLE__ bool SettingsManager::unmountiFuseOnExit() const { @@ -250,6 +263,7 @@ void SettingsManager::resetToDefaults() setAutoRaiseWindow(true); setSwitchToNewDevice(true); setAutoConnectWirelessDevices(true); + setAutoEnableWifiConnections(true); #ifndef __APPLE__ setUnmountiFuseOnExit(false); #endif @@ -525,4 +539,58 @@ void SettingsManager::setIsSleepyDeviceWarningDismissed(bool dismissed) { m_settings->setValue("sleepyDeviceWarningDismissed", dismissed); m_settings->sync(); +} + +bool SettingsManager::hasSeenDevice(const QString &udid) const +{ + const QString trimmed = udid.trimmed(); + if (trimmed.isEmpty()) { + return false; + } + return m_settings->value(SEEN_DEVICE_PREFIX + trimmed, false).toBool(); +} + +void SettingsManager::setHasSeenDevice(const QString &udid, bool seen) +{ + const QString trimmed = udid.trimmed(); + if (trimmed.isEmpty()) { + return; + } + + const QString key = SEEN_DEVICE_PREFIX + trimmed; + if (seen) { + m_settings->setValue(key, true); + } else { + m_settings->remove(key); + } + m_settings->sync(); +} + +QStringList SettingsManager::seenDeviceUdids() const +{ + QStringList udids; + const QStringList allKeys = m_settings->allKeys(); + + for (const QString &key : allKeys) { + if (!key.startsWith(SEEN_DEVICE_PREFIX)) { + continue; + } + + if (m_settings->value(key, false).toBool()) { + udids.append(key.mid(SEEN_DEVICE_PREFIX.length())); + } + } + + return udids; +} + +void SettingsManager::clearSeenDevices() +{ + const QStringList allKeys = m_settings->allKeys(); + for (const QString &key : allKeys) { + if (key.startsWith(SEEN_DEVICE_PREFIX)) { + m_settings->remove(key); + } + } + m_settings->sync(); } \ No newline at end of file diff --git a/src/settingsmanager.h b/src/settingsmanager.h index 75fbd15..b174b37 100644 --- a/src/settingsmanager.h +++ b/src/settingsmanager.h @@ -80,6 +80,9 @@ public: bool autoConnectWirelessDevices() const; void setAutoConnectWirelessDevices(bool enabled); + bool autoEnableWifiConnections() const; + void setAutoEnableWifiConnections(bool enabled); + #ifndef __APPLE__ bool unmountiFuseOnExit() const; void setUnmountiFuseOnExit(bool enabled); @@ -143,6 +146,11 @@ public: void setIsSleepyDeviceWarningDismissed(bool dismissed); void dismissSleepyDeviceWarning(); + bool hasSeenDevice(const QString &udid) const; + void setHasSeenDevice(const QString &udid, bool seen = true); + QStringList seenDeviceUdids() const; + void clearSeenDevices(); + signals: void favoritePlacesChanged(); void recentLocationsChanged(); diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 57f1af8..9be7865 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -111,6 +111,10 @@ void SettingsWidget::setupUI() m_autoUpdateCheck = new QCheckBox("Automatically check for updates"); generalLayout->addWidget(m_autoUpdateCheck); + m_autoEnableWifiConnections = + new QCheckBox("Automatically enable Wi-Fi connections"); + generalLayout->addWidget(m_autoEnableWifiConnections); + // Theme selection auto *themeLayout = new QHBoxLayout(); themeLayout->addWidget(new QLabel("Theme:")); @@ -306,6 +310,7 @@ void SettingsWidget::loadSettings() m_autoUpdateCheck->setChecked(sm->autoCheckUpdates()); m_autoRaiseWindow->setChecked(sm->autoRaiseWindow()); m_switchToNewDevice->setChecked(sm->switchToNewDevice()); + m_autoEnableWifiConnections->setChecked(sm->autoEnableWifiConnections()); m_autoConnectWirelessDevices->setChecked(sm->autoConnectWirelessDevices()); m_wirelessFileServerPort->setValue(sm->wirelessFileServerPort()); @@ -357,6 +362,8 @@ void SettingsWidget::connectSignals() &SettingsWidget::onSettingChanged); connect(m_switchToNewDevice, &QCheckBox::toggled, this, &SettingsWidget::onSettingChanged); + connect(m_autoEnableWifiConnections, &QCheckBox::toggled, this, + &SettingsWidget::onSettingChanged); connect(m_autoConnectWirelessDevices, &QCheckBox::toggled, this, &SettingsWidget::onSettingChanged); #ifndef __APPLE__ @@ -493,6 +500,7 @@ void SettingsWidget::saveSettings() sm->setAutoCheckUpdates(m_autoUpdateCheck->isChecked()); sm->setAutoRaiseWindow(m_autoRaiseWindow->isChecked()); sm->setSwitchToNewDevice(m_switchToNewDevice->isChecked()); + sm->setAutoEnableWifiConnections(m_autoEnableWifiConnections->isChecked()); sm->setAutoConnectWirelessDevices( m_autoConnectWirelessDevices->isChecked()); sm->setWirelessFileServerPort(m_wirelessFileServerPort->value()); diff --git a/src/settingswidget.h b/src/settingswidget.h index b6f8611..32f1eb7 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -57,6 +57,7 @@ private: QComboBox *m_themeCombo; QCheckBox *m_autoRaiseWindow; QCheckBox *m_switchToNewDevice; + QCheckBox *m_autoEnableWifiConnections; #ifndef __APPLE__ QCheckBox *m_unmount_iFuseDrives; #endif diff --git a/src/toolboxwidget.cpp b/src/toolboxwidget.cpp index e877021..698e94a 100644 --- a/src/toolboxwidget.cpp +++ b/src/toolboxwidget.cpp @@ -166,6 +166,8 @@ void ToolboxWidget::setupUI() {iDescriptorTool::Shutdown, "Shut down the device", true, ""}); moreToolWidgets.append({iDescriptorTool::RecoveryMode, "Enter device recovery mode", true, ""}); + moreToolWidgets.append({iDescriptorTool::EnableWifiConnections, + "Make device connectable via Wi-Fi", true, ""}); for (int i = 0; i < moreToolWidgets.size(); ++i) { const auto &tool = moreToolWidgets[i]; @@ -250,6 +252,11 @@ ToolboxItemWidget *ToolboxWidget::createToolbox(iDescriptorTool tool, iconName = ":/resources/icons/StreamlineUltimateMultipleUsersNetwork.png"; break; + case iDescriptorTool::EnableWifiConnections: + title = "Enable Wi-Fi Connections"; + iconName = + ":/resources/icons/StreamlineFreehandChargingFlashWireless.png"; + break; default: title = "Unknown Tool"; break; @@ -515,6 +522,26 @@ void ToolboxWidget::onToolboxClicked(iDescriptorTool tool, bool requiresDevice) m_networkDevicesWidget->activateWindow(); } } break; + + case iDescriptorTool::EnableWifiConnections: { + connect( + device->service_manager, + &CXX::ServiceManager::enable_wifi_connections_result, this, + [this](bool success) { + if (success) { + QMessageBox::information( + this, "Success", + "Wi-Fi connections enabled successfully. You can now " + "connect to this device wirelessly."); + } else { + QMessageBox::warning(this, "Failure", + "Failed to enable Wi-Fi connections."); + } + }, + Qt::SingleShotConnection); + + device->service_manager->enable_wifi_connections(); + } break; default: qDebug() << "Clicked on unimplemented tool"; break;