mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
removed redunant code from AddMagnetWindow (#4374)
This commit is contained in:
@@ -24,16 +24,6 @@ typedef NS_ENUM(NSUInteger, PopupPriority) {
|
|||||||
@property(nonatomic) IBOutlet NSPopUpButton* fGroupPopUp;
|
@property(nonatomic) IBOutlet NSPopUpButton* fGroupPopUp;
|
||||||
@property(nonatomic) IBOutlet NSPopUpButton* fPriorityPopUp;
|
@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, readonly) Controller* fController;
|
||||||
|
|
||||||
@property(nonatomic) NSString* fDestination;
|
@property(nonatomic) NSString* fDestination;
|
||||||
@@ -105,64 +95,6 @@ typedef NS_ENUM(NSUInteger, PopupPriority) {
|
|||||||
self.fLocationField.stringValue = @"";
|
self.fLocationField.stringValue = @"";
|
||||||
self.fLocationImageView.image = nil;
|
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
|
- (void)windowDidLoad
|
||||||
|
|||||||
@@ -8,18 +8,10 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="AddMagnetWindowController">
|
<customObject id="-2" userLabel="File's Owner" customClass="AddMagnetWindowController">
|
||||||
<connections>
|
<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="fGroupPopUp" destination="33" id="39"/>
|
||||||
<outlet property="fLocationField" destination="12" id="25"/>
|
<outlet property="fLocationField" destination="12" id="25"/>
|
||||||
<outlet property="fLocationImageView" destination="11" id="28"/>
|
<outlet property="fLocationImageView" destination="11" id="28"/>
|
||||||
<outlet property="fMagnetLinkLabel" destination="100" id="108"/>
|
|
||||||
<outlet property="fNameField" destination="5" id="23"/>
|
<outlet property="fNameField" destination="5" id="23"/>
|
||||||
<outlet property="fPriorityLabel" destination="84" id="109"/>
|
|
||||||
<outlet property="fPriorityPopUp" destination="85" id="99"/>
|
<outlet property="fPriorityPopUp" destination="85" id="99"/>
|
||||||
<outlet property="fStartCheck" destination="17" id="26"/>
|
<outlet property="fStartCheck" destination="17" id="26"/>
|
||||||
<outlet property="window" destination="1" id="29"/>
|
<outlet property="window" destination="1" id="29"/>
|
||||||
@@ -31,7 +23,7 @@
|
|||||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/>
|
||||||
<rect key="contentRect" x="173" y="705" width="414" height="232"/>
|
<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">
|
<view key="contentView" verticalHuggingPriority="750" misplaced="YES" id="2">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="232"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="232"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
@@ -99,11 +91,11 @@ Gw
|
|||||||
<box borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="102">
|
<box borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="102">
|
||||||
<rect key="frame" x="17" y="55" width="380" height="100"/>
|
<rect key="frame" x="17" y="55" width="380" height="100"/>
|
||||||
<view key="contentView" id="xWJ-qu-F1m">
|
<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"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="33">
|
<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">
|
<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"/>
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="menu"/>
|
<font key="font" metaFont="menu"/>
|
||||||
@@ -117,7 +109,7 @@ Gw
|
|||||||
</popUpButtonCell>
|
</popUpButtonCell>
|
||||||
</popUpButton>
|
</popUpButton>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="10">
|
<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">
|
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Download to:" id="15">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
@@ -125,7 +117,7 @@ Gw
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="84">
|
<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">
|
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Priority:" id="91">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
@@ -133,7 +125,7 @@ Gw
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="85">
|
<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">
|
<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"/>
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="menu"/>
|
<font key="font" metaFont="menu"/>
|
||||||
@@ -156,7 +148,7 @@ Gw
|
|||||||
</connections>
|
</connections>
|
||||||
</popUpButton>
|
</popUpButton>
|
||||||
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="40">
|
<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">
|
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Group:" id="41">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
@@ -164,13 +156,13 @@ Gw
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<box horizontalHuggingPriority="249" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="103">
|
<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">
|
<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"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="12">
|
<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>
|
<constraints>
|
||||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="DBq-4X-8Uk"/>
|
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="DBq-4X-8Uk"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -181,7 +173,7 @@ Gw
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="11">
|
<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>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="16" id="46x-pe-IRn"/>
|
<constraint firstAttribute="height" constant="16" id="46x-pe-IRn"/>
|
||||||
<constraint firstAttribute="width" constant="16" id="xF7-UN-BfS"/>
|
<constraint firstAttribute="width" constant="16" id="xF7-UN-BfS"/>
|
||||||
@@ -202,7 +194,7 @@ Gw
|
|||||||
</constraints>
|
</constraints>
|
||||||
</box>
|
</box>
|
||||||
<button horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9">
|
<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">
|
<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"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user