Skip to content

Commit

Permalink
improved alert (for long URLs)
Browse files Browse the repository at this point in the history
fix for: #407
  • Loading branch information
Patrick Wardle committed Oct 24, 2021
1 parent f8a1b13 commit 4eebfe3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions LuLu/App/AlertWindow.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -40,7 +40,7 @@
<rect key="contentRect" x="949" y="509" width="745" height="404"/>
<rect key="screenRect" x="0.0" y="0.0" width="3440" height="1415"/>
<value key="minSize" type="size" width="745" height="404"/>
<value key="maxSize" type="size" width="1000" height="404"/>
<value key="maxSize" type="size" width="1337" height="404"/>

This comment has been minimized.

Copy link
@greveritt

greveritt Jun 15, 2022

olol, I see what you did there

<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="745" height="404"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -235,7 +235,7 @@
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="251" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="i43-b2-cU0">
<rect key="frame" x="155" y="256" width="374" height="72"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" id="hoJ-mx-qEO">
<textFieldCell key="cell" lineBreakMode="charWrapping" truncatesLastVisibleLine="YES" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" id="hoJ-mx-qEO">
<font key="font" size="14" name="Menlo-Bold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
Expand Down
16 changes: 15 additions & 1 deletion LuLu/App/AlertWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ -(void)windowDidLoad
//title attributes (for temporary label)
NSMutableDictionary* titleAttributes = nil;

//width
NSUInteger width = 0;

//init paragraph style
paragraphStyle = [[NSMutableParagraphStyle alloc] init];

Expand Down Expand Up @@ -107,11 +110,15 @@ -(void)windowDidLoad
//alert message
self.alertMessage.stringValue = [NSString stringWithFormat:@"is trying to connect to %@", remoteAddress];

//and set a tool tip
// as super long URLs can be truncated
self.alertMessage.toolTip = [NSString stringWithFormat:@"remote address: %@", remoteAddress];

/* BOTTOM */

//process pid
self.processID.stringValue = [self.alert[KEY_PROCESS_ID] stringValue];

//process args
// none? means error
if(0 == [self.alert[KEY_PROCESS_ARGS] count])
Expand Down Expand Up @@ -192,6 +199,13 @@ -(void)windowDidLoad
//show touch bar
[self initTouchBar];

//width of alert
// max of standard window size, or size of alert msg + padding for addition items
width = MAX(self.window.frame.size.width, self.alertMessage.intrinsicContentSize.width+400);

//resize to handle size of alert
[self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, width, NSHeight(self.window.frame)) display:YES];

bail:

return;
Expand Down

0 comments on commit 4eebfe3

Please sign in to comment.