Skip to content

Commit

Permalink
Merge pull request #14 from Pavo-IM/hyperlink-textfield
Browse files Browse the repository at this point in the history
Make OpenCore Desktop Guide url a hyperlink
  • Loading branch information
Pavo-IM authored Jun 27, 2020
2 parents 5b31893 + 9a1bc23 commit 442d615
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 12 deletions.
12 changes: 12 additions & 0 deletions OC Gen-X.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
CFE8A230249E662400D72669 /* AppIcon.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFE8A22F249E662400D72669 /* AppIcon.xcassets */; };
CFEA3A7C249E3FB500EDE7CB /* Bootstrap.efi in Resources */ = {isa = PBXBuildFile; fileRef = CFEA3A7B249E3FB500EDE7CB /* Bootstrap.efi */; };
CFEACE92249E5C8300A7F0B3 /* IntelMausi.kext in Resources */ = {isa = PBXBuildFile; fileRef = CFEACE91249E5C8300A7F0B3 /* IntelMausi.kext */; };
D5B5BBF824A7B6CC004E5D7C /* HyperlinkTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B5BBF724A7B6CC004E5D7C /* HyperlinkTextField.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -104,6 +105,7 @@
CFE8A22F249E662400D72669 /* AppIcon.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = AppIcon.xcassets; sourceTree = "<group>"; };
CFEA3A7B249E3FB500EDE7CB /* Bootstrap.efi */ = {isa = PBXFileReference; lastKnownFileType = file; path = Bootstrap.efi; sourceTree = "<group>"; };
CFEACE91249E5C8300A7F0B3 /* IntelMausi.kext */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.kernel-extension"; path = IntelMausi.kext; sourceTree = "<group>"; };
D5B5BBF724A7B6CC004E5D7C /* HyperlinkTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HyperlinkTextField.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -190,6 +192,7 @@
CF4C2008243D067000D2F187 /* Kexts */,
CF4C2035243D077E00D2F187 /* OC Files */,
CF4C200A243D069000D2F187 /* Drivers */,
D5B5BBF924A7B6FB004E5D7C /* Views */,
CF59E727241DA2D500A7C5EC /* AppDelegate.swift */,
CF59E739241DA57A00A7C5EC /* MainVC.swift */,
CF59E73D241DA7F500A7C5EC /* MainWindowController.swift */,
Expand Down Expand Up @@ -219,6 +222,14 @@
path = Config;
sourceTree = "<group>";
};
D5B5BBF924A7B6FB004E5D7C /* Views */ = {
isa = PBXGroup;
children = (
D5B5BBF724A7B6CC004E5D7C /* HyperlinkTextField.swift */,
);
path = Views;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -327,6 +338,7 @@
CF59E73A241DA57A00A7C5EC /* MainVC.swift in Sources */,
CF6F111C241E96F400B70805 /* Booter.swift in Sources */,
CF6F1122241E971E00B70805 /* Misc.swift in Sources */,
D5B5BBF824A7B6CC004E5D7C /* HyperlinkTextField.swift in Sources */,
CF6F1124241E972600B70805 /* NVRAM.swift in Sources */,
CF59E728241DA2D500A7C5EC /* AppDelegate.swift in Sources */,
CF6F1128241E973E00B70805 /* UEFI.swift in Sources */,
Expand Down
25 changes: 14 additions & 11 deletions OC Gen-X/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Y5K-fp-3dO">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Y5K-fp-3dO" customClass="HyperlinkTextField" customModule="OC_Gen_X" customModuleProvider="target">
<rect key="frame" x="18" y="57" width="761" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" alignment="center" title="https://dortania.github.io/OpenCore-Desktop-Guide/" id="O9I-Ci-F3S">
<font key="font" metaFont="system"/>
Expand Down Expand Up @@ -1594,17 +1594,17 @@ Add watchdog=0 to disable WatchDog timer (if you get accidental reboots).</strin
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="genx" id="0kh-i3-vbn"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="iLc-rs-VxX">
<rect key="frame" x="146" y="33" width="504" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="User Notice: This Application is not endorsed by the Opencore Development team." id="MCU-YO-XvG">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iLc-rs-VxX">
<rect key="frame" x="18" y="33" width="761" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="User Notice: This Application is not endorsed by the Opencore Development team." id="MCU-YO-XvG">
<font key="font" metaFont="system"/>
<color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j04-3g-RJW">
<rect key="frame" x="190" y="20" width="416" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Support and bugs should be reported direct to the apps github repo" id="uic-lw-BZa">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="j04-3g-RJW">
<rect key="frame" x="18" y="20" width="761" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Support and bugs should be reported direct to the apps github repo" id="uic-lw-BZa">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -1614,26 +1614,29 @@ Add watchdog=0 to disable WatchDog timer (if you get accidental reboots).</strin
<constraints>
<constraint firstAttribute="trailing" secondItem="UIh-RX-3Ag" secondAttribute="trailing" id="2Aa-if-5FR"/>
<constraint firstItem="Z7c-dp-thl" firstAttribute="leading" secondItem="ZeK-sO-E8j" secondAttribute="leading" constant="20" id="44I-ye-TeM"/>
<constraint firstItem="Y5K-fp-3dO" firstAttribute="leading" secondItem="ZeK-sO-E8j" secondAttribute="leading" constant="20" id="84m-ii-7ma"/>
<constraint firstAttribute="trailing" relation="lessThanOrEqual" secondItem="Y5K-fp-3dO" secondAttribute="trailing" constant="20" id="8wl-aS-XhY"/>
<constraint firstItem="JJY-uW-evJ" firstAttribute="top" secondItem="UIh-RX-3Ag" secondAttribute="bottom" constant="15" id="A3L-q2-ouN"/>
<constraint firstItem="Y5K-fp-3dO" firstAttribute="centerX" secondItem="iLc-rs-VxX" secondAttribute="centerX" id="BxT-F0-KYK"/>
<constraint firstItem="Y5K-fp-3dO" firstAttribute="centerX" secondItem="ZeK-sO-E8j" secondAttribute="centerX" id="AHp-yt-g0w"/>
<constraint firstItem="iLc-rs-VxX" firstAttribute="leading" secondItem="ZeK-sO-E8j" secondAttribute="leading" constant="20" id="F3w-MQ-OHm"/>
<constraint firstAttribute="trailing" secondItem="iLc-rs-VxX" secondAttribute="trailing" constant="20" id="HNT-vB-pdT"/>
<constraint firstItem="Y5K-fp-3dO" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ZeK-sO-E8j" secondAttribute="leading" constant="20" id="J9t-67-JyJ"/>
<constraint firstItem="m6I-TH-BfI" firstAttribute="top" secondItem="ZeK-sO-E8j" secondAttribute="top" constant="7" id="KP4-Rk-q7d"/>
<constraint firstItem="UIh-RX-3Ag" firstAttribute="top" secondItem="m6I-TH-BfI" secondAttribute="bottom" constant="-4" id="LMp-Th-T6E"/>
<constraint firstAttribute="trailing" secondItem="JJY-uW-evJ" secondAttribute="trailing" constant="20" id="N8f-sI-xxF"/>
<constraint firstItem="Y5K-fp-3dO" firstAttribute="top" secondItem="Z7c-dp-thl" secondAttribute="bottom" constant="2" id="Pns-vu-SDf"/>
<constraint firstItem="m6I-TH-BfI" firstAttribute="centerX" secondItem="Wcy-uw-NdK" secondAttribute="centerX" id="Vzk-HI-IJn"/>
<constraint firstItem="j04-3g-RJW" firstAttribute="leading" secondItem="ZeK-sO-E8j" secondAttribute="leading" constant="20" id="bFa-xx-P66"/>
<constraint firstItem="Z7c-dp-thl" firstAttribute="top" secondItem="JJY-uW-evJ" secondAttribute="bottom" constant="38" id="bld-ML-nII"/>
<constraint firstItem="iLc-rs-VxX" firstAttribute="centerX" secondItem="j04-3g-RJW" secondAttribute="centerX" id="cKC-da-ysU"/>
<constraint firstAttribute="trailing" secondItem="Z7c-dp-thl" secondAttribute="trailing" constant="20" id="cL5-jR-qzA"/>
<constraint firstAttribute="bottom" secondItem="j04-3g-RJW" secondAttribute="bottom" constant="20" symbolic="YES" id="flQ-Fm-JGH"/>
<constraint firstItem="Z7c-dp-thl" firstAttribute="top" secondItem="Wcy-uw-NdK" secondAttribute="bottom" constant="8" id="fmL-5t-b9a"/>
<constraint firstItem="UIh-RX-3Ag" firstAttribute="leading" secondItem="ZeK-sO-E8j" secondAttribute="leading" id="k9z-eE-bjZ"/>
<constraint firstItem="JJY-uW-evJ" firstAttribute="leading" secondItem="Wcy-uw-NdK" secondAttribute="trailing" constant="111" id="kcE-Fe-IiH"/>
<constraint firstItem="Wcy-uw-NdK" firstAttribute="top" secondItem="UIh-RX-3Ag" secondAttribute="bottom" constant="40" id="m3d-be-2tT"/>
<constraint firstAttribute="trailing" secondItem="j04-3g-RJW" secondAttribute="trailing" constant="20" id="nb8-3q-xyw"/>
<constraint firstItem="iLc-rs-VxX" firstAttribute="top" secondItem="Y5K-fp-3dO" secondAttribute="bottom" constant="8" symbolic="YES" id="nfY-cU-1o6"/>
<constraint firstAttribute="bottom" secondItem="Y5K-fp-3dO" secondAttribute="bottom" constant="57" id="qo8-DW-Voe"/>
<constraint firstItem="UIh-RX-3Ag" firstAttribute="top" secondItem="ZeK-sO-E8j" secondAttribute="top" constant="117" id="rXX-3V-hvg"/>
<constraint firstAttribute="trailing" secondItem="Y5K-fp-3dO" secondAttribute="trailing" constant="20" id="zKc-7U-i8D"/>
<constraint firstItem="Wcy-uw-NdK" firstAttribute="centerX" secondItem="ZeK-sO-E8j" secondAttribute="centerX" id="zbL-aw-JLi"/>
</constraints>
</view>
Expand Down
13 changes: 12 additions & 1 deletion OC Gen-X/MainVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MainVC: NSViewController {
@IBOutlet weak var openUSBChecked: NSButton!
@IBOutlet weak var nvmExpressChecked: NSButton!
@IBOutlet weak var xhciChecked: NSButton!
@IBOutlet weak var textfield: NSTextField!
@IBOutlet weak var textfield: HyperlinkTextField!
@IBOutlet weak var hfsPlusChecked: NSButton!
@IBOutlet weak var snInput: NSTextField!
@IBOutlet weak var mlbInput: NSTextField!
Expand All @@ -56,6 +56,17 @@ class MainVC: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
generateButton.isEnabled = false
applyDesktopGuideHyperlink()
}

private func applyDesktopGuideHyperlink() {
// Keep it centered
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
let attributes: [NSAttributedString.Key: Any] = [.paragraphStyle : paragraphStyle, .font: textfield.font ?? NSFont.systemFontSize]

guard let url = NSURL(string: "https://dortania.github.io/OpenCore-Desktop-Guide/") else { return }
textfield.setHyperlinkWithTitle(title: "https://dortania.github.io/OpenCore-Desktop-Guide/", URL: url, additionalAttributes: attributes)
}

@IBAction func systemTypeChecked(_ sender: NSButton) {
Expand Down
35 changes: 35 additions & 0 deletions OC Gen-X/Views/HyperlinkTextField.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// HyperlinkTextField.swift
// OC Gen-X
//
// Created by Stephen Heaps on 2020-06-27.
// Copyright © 2020 Henry Brock. All rights reserved.
//

import AppKit

/// Subclass of NSTextField used to display hyperlinks. From https://stackoverflow.com/a/34093140 with minor additionalAttributes update.
class HyperlinkTextField: NSTextField {

/// Set content to be a hyperlink
///
/// Based on code at <https://developer.apple.com/library/mac/qa/qa1487/_index.html>
///
/// - parameters:
/// - title: text displayed in field
/// - URL: destination of hyperlink
func setHyperlinkWithTitle(title: String, URL: NSURL, additionalAttributes: [NSAttributedString.Key: Any]?) {
allowsEditingTextAttributes = true
isSelectable = true

let attributedString = NSMutableAttributedString(string: title, attributes: additionalAttributes ?? [:])
attributedString.addAttribute(.link, value: URL, range: NSRange(location: 0, length: attributedString.length))

attributedStringValue = attributedString
}

/// Always display a pointing-hand cursor
override func resetCursorRects() {
addCursorRect(bounds, cursor: NSCursor.pointingHand)
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ i.e: Haswell, Skylake, Coffeelake etc..
* *Acidanthera Development Team* for Opencore (This app is not endorsed or promoted by Acidanthera)
* *Dortania Team* for the Opencore Guide.
* *Hackintosh x86* for testing and logo's
* Minor contributions from *@StephenHeaps*


0 comments on commit 442d615

Please sign in to comment.