mirror of
https://github.com/transmission/transmission
synced 2025-01-30 19:03:04 +00:00
removed redunant code from AddMagnetWindow (#4374)
This commit is contained in:
parent
578099bf1c
commit
078dc8bd08
2 changed files with 12 additions and 88 deletions
|
@ -24,16 +24,6 @@ typedef NS_ENUM(NSUInteger, PopupPriority) {
|
|||
@property(nonatomic) IBOutlet NSPopUpButton* fGroupPopUp;
|
||||
@property(nonatomic) IBOutlet NSPopUpButton* fPriorityPopUp;
|
||||
|
||||
//remove these when switching to auto layout
|
||||
@property(nonatomic) IBOutlet NSTextField* fMagnetLinkLabel;
|
||||
@property(nonatomic) IBOutlet NSTextField* fDownloadToLabel;
|
||||
@property(nonatomic) IBOutlet NSTextField* fGroupLabel;
|
||||
@property(nonatomic) IBOutlet NSTextField* fPriorityLabel;
|
||||
@property(nonatomic) IBOutlet NSButton* fChangeDestinationButton;
|
||||
@property(nonatomic) IBOutlet NSBox* fDownloadToBox;
|
||||
@property(nonatomic) IBOutlet NSButton* fAddButton;
|
||||
@property(nonatomic) IBOutlet NSButton* fCancelButton;
|
||||
|
||||
@property(nonatomic, readonly) Controller* fController;
|
||||
|
||||
@property(nonatomic) NSString* fDestination;
|
||||
|
@ -105,64 +95,6 @@ typedef NS_ENUM(NSUInteger, PopupPriority) {
|
|||
self.fLocationField.stringValue = @"";
|
||||
self.fLocationImageView.image = nil;
|
||||
}
|
||||
|
||||
// TODO: adopt auto layout instead
|
||||
[self.fMagnetLinkLabel sizeToFit];
|
||||
|
||||
CGFloat const downloadToLabelOldWidth = self.fDownloadToLabel.frame.size.width;
|
||||
[self.fDownloadToLabel sizeToFit];
|
||||
CGFloat const changeDestOldWidth = self.fChangeDestinationButton.frame.size.width;
|
||||
[self.fChangeDestinationButton sizeToFit];
|
||||
NSRect changeDestFrame = self.fChangeDestinationButton.frame;
|
||||
changeDestFrame.origin.x -= changeDestFrame.size.width - changeDestOldWidth;
|
||||
self.fChangeDestinationButton.frame = changeDestFrame;
|
||||
|
||||
NSRect downloadToBoxFrame = self.fDownloadToBox.frame;
|
||||
CGFloat const downloadToBoxSizeDiff = (self.fDownloadToLabel.frame.size.width - downloadToLabelOldWidth) +
|
||||
(changeDestFrame.size.width - changeDestOldWidth);
|
||||
downloadToBoxFrame.size.width -= downloadToBoxSizeDiff;
|
||||
downloadToBoxFrame.origin.x -= downloadToLabelOldWidth - self.fDownloadToLabel.frame.size.width;
|
||||
self.fDownloadToBox.frame = downloadToBoxFrame;
|
||||
|
||||
NSRect groupPopUpFrame = self.fGroupPopUp.frame;
|
||||
NSRect priorityPopUpFrame = self.fPriorityPopUp.frame;
|
||||
CGFloat const popUpOffset = groupPopUpFrame.origin.x - NSMaxX(self.fGroupLabel.frame);
|
||||
[self.fGroupLabel sizeToFit];
|
||||
[self.fPriorityLabel sizeToFit];
|
||||
NSRect groupLabelFrame = self.fGroupLabel.frame;
|
||||
NSRect priorityLabelFrame = self.fPriorityLabel.frame;
|
||||
//first bring them both to the left edge
|
||||
groupLabelFrame.origin.x = MIN(groupLabelFrame.origin.x, priorityLabelFrame.origin.x);
|
||||
priorityLabelFrame.origin.x = MIN(groupLabelFrame.origin.x, priorityLabelFrame.origin.x);
|
||||
//then align on the right
|
||||
CGFloat const labelWidth = MAX(groupLabelFrame.size.width, priorityLabelFrame.size.width);
|
||||
groupLabelFrame.origin.x += labelWidth - groupLabelFrame.size.width;
|
||||
priorityLabelFrame.origin.x += labelWidth - priorityLabelFrame.size.width;
|
||||
groupPopUpFrame.origin.x = NSMaxX(groupLabelFrame) + popUpOffset;
|
||||
priorityPopUpFrame.origin.x = NSMaxX(priorityLabelFrame) + popUpOffset;
|
||||
self.fGroupLabel.frame = groupLabelFrame;
|
||||
self.fGroupPopUp.frame = groupPopUpFrame;
|
||||
self.fPriorityLabel.frame = priorityLabelFrame;
|
||||
self.fPriorityPopUp.frame = priorityPopUpFrame;
|
||||
|
||||
CGFloat const minButtonWidth = 82.0;
|
||||
CGFloat const oldAddButtonWidth = self.fAddButton.bounds.size.width;
|
||||
CGFloat const oldCancelButtonWidth = self.fCancelButton.bounds.size.width;
|
||||
[self.fAddButton sizeToFit];
|
||||
[self.fCancelButton sizeToFit];
|
||||
NSRect addButtonFrame = self.fAddButton.frame;
|
||||
NSRect cancelButtonFrame = self.fCancelButton.frame;
|
||||
CGFloat buttonWidth = MAX(addButtonFrame.size.width, cancelButtonFrame.size.width);
|
||||
buttonWidth = MAX(buttonWidth, minButtonWidth);
|
||||
addButtonFrame.size.width = buttonWidth;
|
||||
cancelButtonFrame.size.width = buttonWidth;
|
||||
CGFloat const addButtonWidthIncrease = buttonWidth - oldAddButtonWidth;
|
||||
addButtonFrame.origin.x -= addButtonWidthIncrease;
|
||||
cancelButtonFrame.origin.x -= addButtonWidthIncrease + (buttonWidth - oldCancelButtonWidth);
|
||||
self.fAddButton.frame = addButtonFrame;
|
||||
self.fCancelButton.frame = cancelButtonFrame;
|
||||
|
||||
[self.fStartCheck sizeToFit];
|
||||
}
|
||||
|
||||
- (void)windowDidLoad
|
||||
|
|
|
@ -8,18 +8,10 @@
|
|||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="AddMagnetWindowController">
|
||||
<connections>
|
||||
<outlet property="fAddButton" destination="19" id="111"/>
|
||||
<outlet property="fCancelButton" destination="21" id="110"/>
|
||||
<outlet property="fChangeDestinationButton" destination="9" id="104"/>
|
||||
<outlet property="fDownloadToBox" destination="103" id="105"/>
|
||||
<outlet property="fDownloadToLabel" destination="10" id="106"/>
|
||||
<outlet property="fGroupLabel" destination="40" id="107"/>
|
||||
<outlet property="fGroupPopUp" destination="33" id="39"/>
|
||||
<outlet property="fLocationField" destination="12" id="25"/>
|
||||
<outlet property="fLocationImageView" destination="11" id="28"/>
|
||||
<outlet property="fMagnetLinkLabel" destination="100" id="108"/>
|
||||
<outlet property="fNameField" destination="5" id="23"/>
|
||||
<outlet property="fPriorityLabel" destination="84" id="109"/>
|
||||
<outlet property="fPriorityPopUp" destination="85" id="99"/>
|
||||
<outlet property="fStartCheck" destination="17" id="26"/>
|
||||
<outlet property="window" destination="1" id="29"/>
|
||||
|
@ -31,7 +23,7 @@
|
|||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/>
|
||||
<rect key="contentRect" x="173" y="705" width="414" height="232"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1470" height="919"/>
|
||||
<view key="contentView" verticalHuggingPriority="750" misplaced="YES" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="232"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
|
@ -99,11 +91,11 @@ Gw
|
|||
<box borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="102">
|
||||
<rect key="frame" x="17" y="55" width="380" height="100"/>
|
||||
<view key="contentView" id="xWJ-qu-F1m">
|
||||
<rect key="frame" x="3" y="3" width="374" height="94"/>
|
||||
<rect key="frame" x="4" y="5" width="372" height="92"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="33">
|
||||
<rect key="frame" x="65" y="32" width="99" height="25"/>
|
||||
<rect key="frame" x="64" y="30" width="99" height="25"/>
|
||||
<popUpButtonCell key="cell" type="push" title="None" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="2zq-5y-smI" id="34" customClass="GroupPopUpButtonCell">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
|
@ -117,7 +109,7 @@ Gw
|
|||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="10">
|
||||
<rect key="frame" x="10" y="67" width="84" height="16"/>
|
||||
<rect key="frame" x="9" y="65" width="84" height="16"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Download to:" id="15">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -125,7 +117,7 @@ Gw
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="84">
|
||||
<rect key="frame" x="10" y="13" width="52" height="16"/>
|
||||
<rect key="frame" x="9" y="11" width="52" height="16"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Priority:" id="91">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -133,7 +125,7 @@ Gw
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="85">
|
||||
<rect key="frame" x="65" y="6" width="99" height="25"/>
|
||||
<rect key="frame" x="64" y="4" width="99" height="25"/>
|
||||
<popUpButtonCell key="cell" type="push" title="High" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="90" id="86" customClass="PriorityPopUpButtonCell">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
|
@ -156,7 +148,7 @@ Gw
|
|||
</connections>
|
||||
</popUpButton>
|
||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="40">
|
||||
<rect key="frame" x="10" y="39" width="52" height="16"/>
|
||||
<rect key="frame" x="9" y="37" width="52" height="16"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Group:" id="41">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -164,13 +156,13 @@ Gw
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<box horizontalHuggingPriority="249" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="103">
|
||||
<rect key="frame" x="97" y="58" width="194" height="30"/>
|
||||
<rect key="frame" x="96" y="56" width="194" height="30"/>
|
||||
<view key="contentView" id="29A-0C-qoo">
|
||||
<rect key="frame" x="3" y="3" width="188" height="24"/>
|
||||
<rect key="frame" x="4" y="5" width="186" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="12">
|
||||
<rect key="frame" x="28" y="6" width="154" height="14"/>
|
||||
<rect key="frame" x="27" y="4" width="154" height="14"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="DBq-4X-8Uk"/>
|
||||
</constraints>
|
||||
|
@ -181,7 +173,7 @@ Gw
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="11">
|
||||
<rect key="frame" x="8" y="5" width="16" height="16"/>
|
||||
<rect key="frame" x="7" y="3" width="16" height="16"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="16" id="46x-pe-IRn"/>
|
||||
<constraint firstAttribute="width" constant="16" id="xF7-UN-BfS"/>
|
||||
|
@ -202,7 +194,7 @@ Gw
|
|||
</constraints>
|
||||
</box>
|
||||
<button horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
||||
<rect key="frame" x="290" y="58" width="78" height="27"/>
|
||||
<rect key="frame" x="289" y="57" width="78" height="27"/>
|
||||
<buttonCell key="cell" type="push" title="Change…" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="16">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
|
|
Loading…
Reference in a new issue