Skip to content

Commit

Permalink
NSWindow Frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey authored and Jakey committed Mar 22, 2020
1 parent 3a4941e commit 07aefaa
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 49 deletions.
4 changes: 2 additions & 2 deletions ProfilesManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@
INFOPLIST_FILE = ProfilesManager/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = org.skyfox.ProfilesManager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
Expand All @@ -618,7 +618,7 @@
INFOPLIST_FILE = ProfilesManager/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.6;
PRODUCT_BUNDLE_IDENTIFIER = org.skyfox.ProfilesManager;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
Expand Down
13 changes: 7 additions & 6 deletions ProfilesManager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

_window = [[ProfilesManagerWindowController alloc] initWithWindowNibName:@"ProfilesManagerWindowController"];
_window.contentViewController = [[ProfilesManagerViewController alloc] initWithNibName:@"ProfilesManagerViewController" bundle:[NSBundle bundleForClass:[self class]]];
[_window.window orderFront:nil];


NSMenuItem *helpMenu = [_window.window.menu itemWithTag:666];
NSMenuItem *submenuItem = [helpMenu.submenu itemAtIndex:0];;
submenuItem.action = @selector(showHelp:);
submenuItem.target = self;
NSMenuItem *helpMenu = [_window.window.menu itemWithTag:666];
NSMenuItem *submenuItem = [helpMenu.submenu itemAtIndex:0];;
submenuItem.action = @selector(showHelp:);
submenuItem.target = self;
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if (!flag)
{
[_window.window makeKeyAndOrderFront:self];
[_window.window makeKeyAndOrderFront:self];
}
return YES;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="ProfileManager" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="543" y="266" width="1000" height="600"/>
<rect key="contentRect" x="543" y="266" width="1100" height="700"/>
<rect key="screenRect" x="0.0" y="0.0" width="3440" height="1417"/>
<value key="minSize" type="size" width="490" height="600"/>
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="1000" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="1100" height="700"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<toolbar key="toolbar" implicitIdentifier="D0B8F835-261B-492D-B195-DB0C58068081" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="small" id="cZP-oM-lQ5">
Expand Down
34 changes: 17 additions & 17 deletions ProfilesManager/Controller/ProfilesManagerViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@
<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="886" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="1100" height="700"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="22" horizontalPageScroll="10" verticalLineScroll="22" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bQP-D8-T2r">
<rect key="frame" x="0.0" y="20" width="886" height="580"/>
<rect key="frame" x="0.0" y="20" width="1100" height="680"/>
<clipView key="contentView" drawsBackground="NO" id="O7w-RX-5YA">
<rect key="frame" x="1" y="0.0" width="884" height="579"/>
<rect key="frame" x="1" y="0.0" width="1098" height="679"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView appearanceType="vibrantLight" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" headerView="Ygp-i7-VyR" indentationPerLevel="16" outlineTableColumn="FkK-IV-RHo" id="3ki-mw-HE6" customClass="DragOutlineView">
<rect key="frame" x="0.0" y="0.0" width="884" height="556"/>
<rect key="frame" x="0.0" y="0.0" width="1098" height="656"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="5"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="key" width="231" minWidth="40" maxWidth="500" id="FkK-IV-RHo">
<tableColumn identifier="key" width="296" minWidth="40" maxWidth="500" id="FkK-IV-RHo">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="AppID">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -45,9 +45,9 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="type" width="210" minWidth="140" maxWidth="500" id="ggW-Oi-DM3" userLabel="type">
<tableColumn identifier="type" width="265" minWidth="140" maxWidth="500" id="ggW-Oi-DM3" userLabel="type">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Name or Type">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -58,9 +58,9 @@
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="detail" width="100" minWidth="40" maxWidth="100000" id="4N6-rc-Q65" userLabel="detail">
<tableColumn identifier="detail" width="198" minWidth="40" maxWidth="100000" id="4N6-rc-Q65" userLabel="detail">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Status or Detail">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -73,7 +73,7 @@
</tableColumn>
<tableColumn identifier="creationDate" width="135" minWidth="135" maxWidth="135" id="PQW-JJ-FJD" userLabel="creationDate">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="CreateDate">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -86,7 +86,7 @@
</tableColumn>
<tableColumn identifier="expirationDate" width="135" minWidth="135" maxWidth="135" id="Mf9-vb-Si1" userLabel="expirationDate">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="ExpirationDate">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -99,7 +99,7 @@
</tableColumn>
<tableColumn identifier="days" width="50" minWidth="50" maxWidth="50" id="cc0-py-mUm" userLabel="days">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Days">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand All @@ -120,20 +120,20 @@
<nil key="backgroundColor"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="94R-Le-I0r">
<rect key="frame" x="1" y="564" width="1028" height="15"/>
<rect key="frame" x="1" y="664" width="1098" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Rib-nd-9D3">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="Ygp-i7-VyR">
<rect key="frame" x="0.0" y="0.0" width="884" height="23"/>
<rect key="frame" x="0.0" y="0.0" width="1098" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="BLd-8B-ILm">
<rect key="frame" x="-2" y="0.0" width="890" height="20"/>
<rect key="frame" x="-2" y="0.0" width="1104" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="er9-nR-EZ2"/>
</constraints>
Expand All @@ -153,7 +153,7 @@
<constraint firstItem="bQP-D8-T2r" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="vgB-2e-9d7"/>
<constraint firstAttribute="trailing" secondItem="BLd-8B-ILm" secondAttribute="trailing" id="yR6-dQ-hTF"/>
</constraints>
<point key="canvasLocation" x="146" y="308"/>
<point key="canvasLocation" x="-254" y="329"/>
</customView>
</objects>
</document>
15 changes: 14 additions & 1 deletion ProfilesManager/Controller/ProfilesManagerWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import "GitHubUpdater.h"
#import "NSFileManager+Trash.h"
#import "iAlert.h"
@interface ProfilesManagerWindowController ()
@interface ProfilesManagerWindowController ()<GitHubUpdaterDelegate>
@property( atomic, readwrite, strong, nullable ) IBOutlet GitHubUpdater * updater;
@end

Expand All @@ -22,8 +22,14 @@ - (void)windowDidLoad {
self.updater = [[ GitHubUpdater alloc] init];
self.updater.user = @"shaojiankui";
self.updater.repository = @"ProfilesManager";
self.updater.delegate = self;
[self.updater checkForUpdatesInBackground];


// Saving a Window’s Position into the User’s Defaults
[self setShouldCascadeWindows:NO]; // Tell the controller to not cascade its windows.
[self setWindowFrameAutosaveName:@"profile"]; // Specify the autosave name for the window.

// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

Expand Down Expand Up @@ -71,6 +77,13 @@ - (IBAction)refreshButtonTouched:(id)sender {
- (IBAction)resetButtonTouched:(id)sender {
// rm ~/Library/Preferences/myapp.plist; sudo killall cfprefsd
// defaults delete ~/Library/Preferences/myapp.plist
[[NSUserDefaults standardUserDefaults] setObject:@"fuck" forKey:@"fuck"];
// [[NSUserDefaults standardUserDefaults] setObject:@"1215 1057 345 181 0 0 3440 1417" forKey:@"NSWindow Frame NSNavPanelAutosaveName"];
[[NSUserDefaults standardUserDefaults] setObject:@"{1100, 700}" forKey:@"NSNavPanelExpandedSizeForSaveMode"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NSWindow Frame profile"];
// [NSWindow removeFrameUsingName:@"profile"];
[[NSUserDefaults standardUserDefaults] synchronize];

[self.window setFrame:NSMakeRect(0, 0, 1100, 700) display:YES];
[self.window center];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ - ( void )windowDidLoad

- ( IBAction )install: ( nullable id )sender
{
//安装清除首选项
// rm ~/Library/Preferences/myapp.plist; sudo killall cfprefsd
// defaults delete ~/Library/Preferences/myapp.plist
[[NSUserDefaults standardUserDefaults] setObject:@"fuck" forKey:@"fuck"];
// [[NSUserDefaults standardUserDefaults] setObject:@"1215 1057 345 181 0 0 3440 1417" forKey:@"NSWindow Frame NSNavPanelAutosaveName"];
[[NSUserDefaults standardUserDefaults] setObject:@"{1100, 700}" forKey:@"NSNavPanelExpandedSizeForSaveMode"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NSWindow Frame profile"];
// [NSWindow removeFrameUsingName:@"profile"];
[[NSUserDefaults standardUserDefaults] synchronize];

NSString * app;

( void )sender;
Expand Down
Loading

0 comments on commit 07aefaa

Please sign in to comment.