add tip for saving changes before exiting widget layout editor

This commit is contained in:
True Zhuanjia committed 2026-08-25 18:20:48 +08:00
1 parent 78f385d732
commit 0e8903d233
3 files changed
+119 -5

No files matched your search

+4 -5
View File
@@ -2637,7 +2637,6 @@
</state> </state>
<connections> <connections>
<action selector="closeTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="sc6-Mq-rbQ"/> <action selector="closeTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="sc6-Mq-rbQ"/>
<action selector="undoTapped:" destination="xSZ-i2-Jts" eventType="touchUpInside" id="d4b-0R-vJU"/>
</connections> </connections>
</button> </button>
<button autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F7X-l4-cl3" userLabel="Undo"> <button autoresizesSubviews="NO" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F7X-l4-cl3" userLabel="Undo">
@@ -3977,19 +3976,19 @@
<image name="tray.full.fill" catalog="system" width="128" height="88"/> <image name="tray.full.fill" catalog="system" width="128" height="88"/>
<image name="video.and.waveform" catalog="system" width="128" height="94"/> <image name="video.and.waveform" catalog="system" width="128" height="94"/>
<systemColor name="linkColor"> <systemColor name="linkColor">
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="systemBackgroundColor"> <systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor> </systemColor>
<systemColor name="systemBrownColor"> <systemColor name="systemBrownColor">
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.67450980392156867" green="0.49803921568627452" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="systemGray3Color"> <systemColor name="systemGray3Color">
<color red="0.78039215689999997" green="0.78039215689999997" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.7803921568627451" green="0.7803921568627451" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
<systemColor name="systemTealColor"> <systemColor name="systemTealColor">
<color red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.0" green="0.76470588235294112" blue="0.81568627450980391" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor> </systemColor>
</resources> </resources>
</document> </document>
@@ -5978,6 +5978,35 @@
} }
} }
}, },
"Exit Directly" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Exit Directly"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "直接退出"
}
}
}
},
"Cannot select two touchpad controls at the same time" : { "Cannot select two touchpad controls at the same time" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -16411,6 +16440,64 @@
} }
} }
}, },
"Save Changes" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Save Changes"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "保存修改"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "儲存修改"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "儲存修改"
}
}
}
},
"Save changes before closing?" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Save changes before closing?"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "关闭前是否保存修改?"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "關閉前是否儲存修改?"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "關閉前是否儲存修改?"
}
}
}
},
"Saving over the 'Default' profile is not allowed" : { "Saving over the 'Default' profile is not allowed" : {
"extractionState" : "manual", "extractionState" : "manual",
"localizations" : { "localizations" : {
@@ -208,6 +208,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
private var latestTouchLocation: CGPoint = .zero private var latestTouchLocation: CGPoint = .zero
private var vibrationGenerator = UIImpactFeedbackGenerator(style: .medium) private var vibrationGenerator = UIImpactFeedbackGenerator(style: .medium)
private var widgetSizeTransition: WidgetSizeTransition = .keepWidgetSize private var widgetSizeTransition: WidgetSizeTransition = .keepWidgetSize
private var hasSavedSinceLastWidgetReload = false
override var supportedInterfaceOrientations: UIInterfaceOrientationMask { override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
let dataMan = DataManager() let dataMan = DataManager()
@@ -390,6 +391,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
} }
self.loadWidgets(from: oscProfile) self.loadWidgets(from: oscProfile)
self.hasSavedSinceLastWidgetReload = false
if !self.quickSwitchEnabled { if !self.quickSwitchEnabled {
self.originalTrackPointEnabled = OnScreenWidgetView.trackPointEnabled self.originalTrackPointEnabled = OnScreenWidgetView.trackPointEnabled
@@ -1158,6 +1160,31 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
} }
@IBAction func closeTapped(_ sender: Any?) { @IBAction func closeTapped(_ sender: Any?) {
guard profilesManager.getSelectedProfile().name != "Default",
!hasSavedSinceLastWidgetReload else {
dismissLayoutEditor()
return
}
AlertControllerUtil.cancelButtonString = "Exit Directly".localized
AlertControllerUtil.showAlert(
in: self,
title: "Save Changes".localized,
message: "Save changes before closing?".localized,
withCancel: true,
buttonTitle: "Save".localized,
countdown: 0,
completion: { [weak self] in
guard let self else { return }
if !AlertControllerUtil.actionCancelled {
self.saveTapped(nil)
}
self.dismissLayoutEditor()
}
)
}
private func dismissLayoutEditor() {
clearSickInput() clearSickInput()
dismiss(animated: true) { dismiss(animated: true) {
OnScreenWidgetView.trackPointEnabled = self.originalTrackPointEnabled OnScreenWidgetView.trackPointEnabled = self.originalTrackPointEnabled
@@ -1573,6 +1600,7 @@ final class LayoutOnScreenControlsViewController: UIViewController, OnScreenWidg
clearSickInput() clearSickInput()
OSCProfilesManager.setLayoutViewBounds(view.bounds) OSCProfilesManager.setLayoutViewBounds(view.bounds)
let success = profilesManager.updateSelectedProfile(layoutOSC.oscButtonLayerPool) let success = profilesManager.updateSelectedProfile(layoutOSC.oscButtonLayerPool)
hasSavedSinceLastWidgetReload = success
guard sender != nil else { return } guard sender != nil else { return }
let message = success let message = success
? LocalizationHelper.localizedString(forKey: "profileSaveTip") ? LocalizationHelper.localizedString(forKey: "profileSaveTip")