mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
feat(macos): added last known location (#6610)
* feat(macos): added last known location * fix data file label and reveal data button positions * code review: code style --------- Co-authored-by: BogdanArdelean <bogdan.ardelean@ymail.com>
This commit is contained in:
parent
fb79a2d399
commit
cdbc8574a7
4 changed files with 89 additions and 33 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
@ -13,6 +13,8 @@
|
|||
<outlet property="fDataLocationField" destination="14" id="48"/>
|
||||
<outlet property="fDateCreatedField" destination="8" id="47"/>
|
||||
<outlet property="fHashField" destination="5" id="43"/>
|
||||
<outlet property="fLastDataLabel" destination="52" id="53"/>
|
||||
<outlet property="fLastDataLocationField" destination="54" id="55"/>
|
||||
<outlet property="fPiecesField" destination="19" id="42"/>
|
||||
<outlet property="fRevealDataButton" destination="12" id="49"/>
|
||||
<outlet property="fSecureField" destination="16" id="44"/>
|
||||
|
@ -111,36 +113,6 @@
|
|||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="12">
|
||||
<rect key="frame" x="111" y="12" width="14" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="14" id="50q-rm-IPl"/>
|
||||
<constraint firstAttribute="width" constant="14" id="Zd6-df-Ynq"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="RevealOff" imagePosition="only" alignment="center" alternateImage="RevealOn" imageScaling="proportionallyDown" inset="2" id="29">
|
||||
<behavior key="behavior" lightByContents="YES"/>
|
||||
<font key="font" metaFont="label"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="revealDataFile:" target="-2" id="50"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="14" customClass="InfoTextField">
|
||||
<rect key="frame" x="82" y="12" width="23" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" sendsActionOnEndEditing="YES" placeholderString="N/A" id="27">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="15">
|
||||
<rect key="frame" x="10" y="12" width="68" height="14"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Data File:" id="26">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="16" customClass="InfoTextField">
|
||||
<rect key="frame" x="82" y="154" width="264" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" placeholderString="N/A" id="25">
|
||||
|
@ -189,6 +161,52 @@
|
|||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="15">
|
||||
<rect key="frame" x="10" y="12" width="68" height="14"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Data File:" id="26">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="14" customClass="InfoTextField">
|
||||
<rect key="frame" x="82" y="12" width="23" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" sendsActionOnEndEditing="YES" placeholderString="N/A" id="27">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="52">
|
||||
<rect key="frame" x="109" y="12" width="30" height="14"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Was:" id="uaW-NM-PTU">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="54" customClass="InfoTextField">
|
||||
<rect key="frame" x="143" y="12" width="23" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" sendsActionOnEndEditing="YES" placeholderString="N/A" id="7YU-bS-UkI">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="12">
|
||||
<rect key="frame" x="111" y="12" width="14" height="14"/>
|
||||
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="RevealOff" imagePosition="only" alignment="center" alternateImage="RevealOn" imageScaling="proportionallyDown" inset="2" id="29">
|
||||
<behavior key="behavior" lightByContents="YES"/>
|
||||
<font key="font" metaFont="label"/>
|
||||
</buttonCell>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="14" id="50q-rm-IPl"/>
|
||||
<constraint firstAttribute="width" constant="14" id="Zd6-df-Ynq"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<action selector="revealDataFile:" target="-2" id="50"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="5" firstAttribute="leading" secondItem="6" secondAttribute="trailing" constant="8" symbolic="YES" id="5Ne-pq-sRS"/>
|
||||
|
@ -201,9 +219,12 @@
|
|||
<constraint firstItem="5" firstAttribute="baseline" secondItem="6" secondAttribute="baseline" id="ECi-VE-QMb"/>
|
||||
<constraint firstAttribute="trailing" secondItem="19" secondAttribute="trailing" constant="12" id="Gz7-KD-B5M"/>
|
||||
<constraint firstItem="6" firstAttribute="leading" secondItem="20" secondAttribute="leading" id="HYF-CL-zWb"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="54" secondAttribute="trailing" priority="249" constant="12" id="HoE-d3-pZC"/>
|
||||
<constraint firstItem="54" firstAttribute="centerY" secondItem="12" secondAttribute="centerY" id="HuR-fz-Sgm"/>
|
||||
<constraint firstItem="15" firstAttribute="top" secondItem="13" secondAttribute="bottom" constant="2" id="ISV-i7-Dw4"/>
|
||||
<constraint firstItem="11" firstAttribute="width" secondItem="17" secondAttribute="width" id="IvL-6F-3c5"/>
|
||||
<constraint firstItem="8" firstAttribute="leading" secondItem="9" secondAttribute="trailing" constant="8" symbolic="YES" id="JVu-ov-gM4"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="13" secondAttribute="trailing" constant="12" id="K5p-t1-MGg"/>
|
||||
<constraint firstItem="8" firstAttribute="baseline" secondItem="9" secondAttribute="baseline" id="MtY-dy-1hK"/>
|
||||
<constraint firstItem="13" firstAttribute="leading" secondItem="3" secondAttribute="leading" id="Mzp-Ok-3pG"/>
|
||||
<constraint firstItem="10" firstAttribute="leading" secondItem="11" secondAttribute="trailing" constant="8" symbolic="YES" id="Nn5-Qe-jAB"/>
|
||||
|
@ -226,9 +247,12 @@
|
|||
<constraint firstAttribute="bottom" secondItem="15" secondAttribute="bottom" constant="12" id="gv8-oj-Jkx"/>
|
||||
<constraint firstItem="14" firstAttribute="leading" secondItem="15" secondAttribute="trailing" constant="8" symbolic="YES" id="iqM-1Z-Swp"/>
|
||||
<constraint firstItem="17" firstAttribute="leading" secondItem="6" secondAttribute="leading" id="jYk-4k-PC2"/>
|
||||
<constraint firstItem="52" firstAttribute="leading" secondItem="14" secondAttribute="trailing" constant="8" symbolic="YES" id="jc0-0Z-u36"/>
|
||||
<constraint firstItem="9" firstAttribute="width" secondItem="11" secondAttribute="width" id="jrd-BL-IQN"/>
|
||||
<constraint firstItem="54" firstAttribute="baseline" secondItem="52" secondAttribute="baseline" id="lhn-fM-eSh"/>
|
||||
<constraint firstItem="12" firstAttribute="leading" secondItem="14" secondAttribute="trailing" constant="8" symbolic="YES" id="m7k-6t-cbD"/>
|
||||
<constraint firstItem="11" firstAttribute="leading" secondItem="17" secondAttribute="leading" id="mMq-1j-8xZ"/>
|
||||
<constraint firstItem="54" firstAttribute="leading" secondItem="52" secondAttribute="trailing" constant="8" symbolic="YES" id="nOT-Fw-u31"/>
|
||||
<constraint firstItem="13" firstAttribute="top" secondItem="4" secondAttribute="bottom" constant="20" id="pL5-Vg-kGN"/>
|
||||
<constraint firstItem="7" firstAttribute="leading" secondItem="9" secondAttribute="leading" id="rBJ-74-Kzj"/>
|
||||
<constraint firstItem="20" firstAttribute="top" secondItem="3" secondAttribute="bottom" constant="2" id="rl9-wM-6CX"/>
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
@property(nonatomic) IBOutlet NSTextField* fHashField;
|
||||
@property(nonatomic) IBOutlet NSTextField* fSecureField;
|
||||
@property(nonatomic) IBOutlet NSTextField* fDataLocationField;
|
||||
@property(nonatomic) IBOutlet NSTextField* fLastDataLocationField;
|
||||
@property(nonatomic) IBOutlet NSTextField* fLastDataLabel;
|
||||
@property(nonatomic) IBOutlet NSTextField* fCreatorField;
|
||||
@property(nonatomic) IBOutlet NSTextField* fDateCreatedField;
|
||||
|
||||
|
@ -60,10 +62,17 @@
|
|||
Torrent* torrent = self.fTorrents[0];
|
||||
|
||||
NSString* location = torrent.dataLocation;
|
||||
NSString* lastKnownDataLocation = torrent.lastKnownDataLocation;
|
||||
|
||||
self.fDataLocationField.stringValue = location ? location.stringByAbbreviatingWithTildeInPath : @"";
|
||||
self.fDataLocationField.toolTip = location ? location : @"";
|
||||
|
||||
self.fRevealDataButton.hidden = !location;
|
||||
self.fLastDataLabel.hidden = location ? YES : NO;
|
||||
self.fLastDataLocationField.hidden = location ? YES : NO;
|
||||
self.fLastDataLocationField.stringValue = location ? @"" : lastKnownDataLocation.stringByAbbreviatingWithTildeInPath;
|
||||
self.fLastDataLocationField.toolTip = location ? @"" : lastKnownDataLocation;
|
||||
|
||||
self.fRevealDataButton.hidden = location ? NO : YES;
|
||||
}
|
||||
|
||||
- (void)revealDataFile:(id)sender
|
||||
|
@ -83,6 +92,9 @@
|
|||
|
||||
- (void)setupInfo
|
||||
{
|
||||
self.fLastDataLabel.hidden = YES;
|
||||
self.fLastDataLocationField.hidden = YES;
|
||||
|
||||
if (self.fTorrents.count == 1)
|
||||
{
|
||||
Torrent* torrent = self.fTorrents[0];
|
||||
|
|
|
@ -111,6 +111,7 @@ extern NSString* const kTorrentDidChangeGroupNotification;
|
|||
|
||||
@property(nonatomic, readonly) NSString* torrentLocation;
|
||||
@property(nonatomic, readonly) NSString* dataLocation;
|
||||
@property(nonatomic, readonly) NSString* lastKnownDataLocation;
|
||||
- (NSString*)fileLocation:(FileListNode*)node;
|
||||
|
||||
- (void)renameTorrent:(NSString*)newName completionHandler:(void (^)(BOOL didRename))completionHandler;
|
||||
|
|
|
@ -773,6 +773,25 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
|
|||
}
|
||||
}
|
||||
|
||||
- (NSString*)lastKnownDataLocation
|
||||
{
|
||||
if (self.magnet)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (self.folder)
|
||||
{
|
||||
NSString* lastDataLocation = [self.currentDirectory stringByAppendingPathComponent:self.name];
|
||||
return lastDataLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const lastFileName = @(tr_torrentFile(self.fHandle, 0).name);
|
||||
return [self.currentDirectory stringByAppendingPathComponent:lastFileName];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*)fileLocation:(FileListNode*)node
|
||||
{
|
||||
if (node.isFolder)
|
||||
|
|
Loading…
Reference in a new issue