mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Add context menu for playing/adding songs
This commit is contained in:
parent
338dde08d3
commit
7de6d59594
@ -27,6 +27,7 @@ class AlbumDetailView: NSViewController {
|
||||
albumTracksView.delegate = self
|
||||
albumTracksView.intercellSpacing = CGSize(width: 0, height: 18)
|
||||
albumTracksView.floatsGroupRows = false
|
||||
albumTracksView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
|
||||
|
||||
albumCoverView.wantsLayer = true
|
||||
albumCoverView.layer?.cornerRadius = 5
|
||||
@ -76,6 +77,22 @@ class AlbumDetailView: NSViewController {
|
||||
App.store.dispatch(MPDPlayTrack(queuePos: queueLength))
|
||||
}
|
||||
|
||||
@IBAction func menuActionPlaySong(_ sender: NSMenuItem) {
|
||||
guard let song = dataSource.albumSongs[albumTracksView.clickedRow].song
|
||||
else { return }
|
||||
|
||||
let queueLength = App.store.state.queueState.queue.count
|
||||
App.store.dispatch(MPDAppendTrack(song: song.mpdSong))
|
||||
App.store.dispatch(MPDPlayTrack(queuePos: queueLength))
|
||||
}
|
||||
|
||||
@IBAction func menuActionAppendSong(_ sender: NSMenuItem) {
|
||||
guard let song = dataSource.albumSongs[albumTracksView.clickedRow].song
|
||||
else { return }
|
||||
|
||||
App.store.dispatch(MPDAppendTrack(song: song.mpdSong))
|
||||
}
|
||||
|
||||
func getAlbumSongs(for album: Album) {
|
||||
App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [weak self] (mpdSongs: [MPDClient.MPDSong]) in
|
||||
self?.dataSource.setAlbumSongs(
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="823" height="561"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="823" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="m2v-pR-e9v">
|
||||
<rect key="frame" x="357" y="507" width="448" height="29"/>
|
||||
<rect key="frame" x="357" y="514" width="448" height="29"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="444" id="erC-QS-9hc"/>
|
||||
</constraints>
|
||||
@ -33,7 +33,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4Jx-I5-Nkv">
|
||||
<rect key="frame" x="357" y="480" width="448" height="19"/>
|
||||
<rect key="frame" x="357" y="487" width="448" height="19"/>
|
||||
<textFieldCell key="cell" title="Artist Name" id="ztJ-4E-qvI">
|
||||
<font key="font" metaFont="system" size="16"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -41,7 +41,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="FWd-vZ-5CT">
|
||||
<rect key="frame" x="31" y="236" width="300" height="300"/>
|
||||
<rect key="frame" x="31" y="243" width="300" height="300"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="300" id="69o-NQ-qL7"/>
|
||||
<constraint firstAttribute="width" constant="300" id="8XY-bQ-C7X"/>
|
||||
@ -50,7 +50,7 @@
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="defaultCoverArt" id="scE-kj-gex"/>
|
||||
</imageView>
|
||||
<button verticalHuggingPriority="750" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jMU-bv-TNF">
|
||||
<rect key="frame" x="31" y="177" width="119" height="35"/>
|
||||
<rect key="frame" x="31" y="184" width="119" height="35"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="33" id="2uQ-mC-4QY"/>
|
||||
<constraint firstAttribute="width" constant="119" id="h2n-ZB-Ufr"/>
|
||||
@ -63,14 +63,14 @@
|
||||
<action selector="playAlbum:" target="-2" id="LTw-Lg-yH2"/>
|
||||
</connections>
|
||||
</button>
|
||||
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BOb-Lr-10M">
|
||||
<rect key="frame" x="359" y="33" width="444" height="418"/>
|
||||
<scrollView horizontalCompressionResistancePriority="250" borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="BOb-Lr-10M">
|
||||
<rect key="frame" x="359" y="33" width="444" height="425"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="9QN-UB-b4l">
|
||||
<rect key="frame" x="0.0" y="0.0" width="444" height="418"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="444" height="425"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="ehr-qh-87Q" customClass="AlbumDetailSongListView" customModule="Persephone" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="444" height="418"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="444" height="425"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" red="0.11764705882352941" green="0.11764705882352941" blue="0.11764705882352941" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -174,7 +174,7 @@
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackDurationColumn" width="42" minWidth="40" maxWidth="1000" id="ha5-ff-2az">
|
||||
<tableColumn identifier="trackDurationColumn" width="42" minWidth="42" maxWidth="42" id="ha5-ff-2az">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Duration">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -214,17 +214,18 @@
|
||||
</tableColumns>
|
||||
<connections>
|
||||
<action trigger="doubleAction" selector="playSong:" target="-2" id="HmG-Nf-n4c"/>
|
||||
<outlet property="menu" destination="qbK-4f-3fG" id="gAm-fN-NcP"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
<nil key="backgroundColor"/>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="w9p-lE-zXP">
|
||||
<rect key="frame" x="0.0" y="420" width="444" height="16"/>
|
||||
<rect key="frame" x="-100" y="-100" width="444" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="n7u-af-H0a">
|
||||
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
||||
<rect key="frame" x="-100" y="-100" width="15" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
@ -245,8 +246,25 @@
|
||||
<constraint firstAttribute="trailing" secondItem="m2v-pR-e9v" secondAttribute="trailing" constant="20" symbolic="YES" id="qyi-X9-6B9"/>
|
||||
<constraint firstItem="BOb-Lr-10M" firstAttribute="trailing" secondItem="4Jx-I5-Nkv" secondAttribute="trailing" id="sPx-cY-MeX"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="262.5" y="117.5"/>
|
||||
<point key="canvasLocation" x="262.5" y="121"/>
|
||||
</customView>
|
||||
<menu id="qbK-4f-3fG">
|
||||
<items>
|
||||
<menuItem title="Play Song" id="poo-OI-Kwi">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="menuActionPlaySong:" target="-2" id="ZB9-dq-reF"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Add Song to Queue" id="PdP-4s-xfR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="menuActionAppendSong:" target="-2" id="C0J-2v-bf4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="262" y="-243"/>
|
||||
</menu>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="defaultCoverArt" width="128" height="128"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user