[AltServer] Adds “Search FAQ” button to ErrorDetailsViewController

This commit is contained in:
Riley Testut
2022-11-14 16:07:13 -06:00
parent cf9d577050
commit 324ec7907a
2 changed files with 45 additions and 4 deletions

View File

@@ -389,14 +389,14 @@
<objects>
<viewController storyboardIdentifier="errorDetailsViewController" id="vPa-1q-slD" customClass="ErrorDetailsViewController" customModule="AltServer" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="umL-zC-zP8">
<rect key="frame" x="0.0" y="0.0" width="450" height="88"/>
<rect key="frame" x="0.0" y="0.0" width="450" height="124"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="16" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aUr-m2-nXm">
<rect key="frame" x="20" y="20" width="410" height="48"/>
<rect key="frame" x="20" y="20" width="410" height="84"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8GZ-nV-XXA">
<rect key="frame" x="-2" y="32" width="40" height="16"/>
<rect key="frame" x="-2" y="68" width="40" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="Label" id="V5D-v5-MVX">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -404,21 +404,47 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="j2o-2b-63k">
<rect key="frame" x="-2" y="0.0" width="92" height="16"/>
<rect key="frame" x="-2" y="36" width="92" height="16"/>
<textFieldCell key="cell" selectable="YES" title="Multiline Label" id="3jf-Z7-88l">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stackView distribution="equalSpacing" orientation="vertical" alignment="trailing" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="XOa-gj-Rz2">
<rect key="frame" x="0.0" y="0.0" width="410" height="20"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iS8-eX-YvA">
<rect key="frame" x="312" y="-7" width="105" height="32"/>
<buttonCell key="cell" type="push" title="Search FAQ" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Fpi-GA-lVc">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="searchFAQ:" target="vPa-1q-slD" id="WIx-Uo-GVu"/>
</connections>
</button>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstItem="XOa-gj-Rz2" firstAttribute="width" secondItem="aUr-m2-nXm" secondAttribute="width" id="AGA-99-d6r"/>
</constraints>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>

View File

@@ -44,5 +44,20 @@ private extension ErrorDetailsViewController
let detailedDescription = error.formattedDetailedDescription(with: font)
self.detailedDescriptionLabel.attributedStringValue = detailedDescription
}
@IBAction func searchFAQ(_ sender: NSButton)
{
guard let error else { return }
let baseURL = URL(string: "https://faq.altstore.io/getting-started/error-codes")!
var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false)!
let nsError = error as NSError
let query = [nsError.domain, "\(error.displayCode)"].joined(separator: "+")
components.queryItems = [URLQueryItem(name: "q", value: query)]
let url = components.url ?? baseURL
NSWorkspace.shared.open(url)
}
}