Skip to content

Windows Separation Remastered: Preferences Window #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

lolgear
Copy link
Contributor

@lolgear lolgear commented Dec 11, 2019

  • Preferences window controller has been encapsulated.
  • Preferences window controller has been moved to its own xib.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 11, 2019

@lucasderraugh Ready, I guess :) ( except layout, heh. I will add constraints a bit later. )

@lucasderraugh
Copy link
Collaborator

@lucasderraugh Ready, I guess :) ( except layout, heh. I will add constraints a bit later. )

I'll wait until you think it's all done haha. Looks pretty good so far though.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 12, 2019

@lucasderraugh Ok, layout has been added.
It still contains warnings "prior OS X 10.11". Well, maybe it is time to set deployment target to something newer than 10.10? I guess that 10.11 is pretty good.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 14, 2019

@lucasderraugh
If we can raise deployment target, all this layout can be easily done by NSGridView.
It is available since 10.12.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 17, 2019

@lucasderraugh Go-go-go-go-go :)

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Dec 17, 2019

Sorry, I merged the text size changes in first as those were changes made based on a branch many years ago. If you get the chance to look over the conflicts we can merge these in as well. I think we can consider bumping later, but for now constraints will work just fine. We already moved to 10.10 this year from 10.8 to get over some dark mode hurtles with older releases. I think perhaps we can consider moving to 10.12 on the next release of macOS.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 17, 2019

@lucasderraugh
Fixed.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 18, 2019

@lucasderraugh
If everything is fine and you would like to merge it, I guess it could be release candidate.
But, of course, I would like to merge other PRs also, especially #573 ❤️

@lolgear
Copy link
Contributor Author

lolgear commented Dec 18, 2019

@lucasderraugh
Also #583 could enhance UX for most of us...

Copy link
Collaborator

@lucasderraugh lucasderraugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few feedback points, overall seems like it should be ok.

Comment on lines 92 to 100
- (void)showWindow:(id)sender {
// sync NSUserDefaults
NSString* theme = [NSUserDefaults.standardUserDefaults stringForKey:kUserDefaultsKey_Theme];
self.selectedTheme = theme;
NSString* channel = [NSUserDefaults.standardUserDefaults stringForKey:kUserDefaultsKey_ReleaseChannel];
self.selectedChannel = channel;
[self selectPreferencePane:nil];
[super showWindow:sender];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to resync these every time we open the window. They shouldn't be changing other than via the preferences pane. Also, every time you trigger the show preferences window, it is moving it down. Looks like the window frame setup used to be done in awakeFromNib?

Copy link
Contributor Author

@lolgear lolgear Jan 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasderraugh
Heh, weird.

  [self selectPreferencePane:self]; // non-nil sender

fixed it.

Maybe we can remove checks for sender here:

- (IBAction)selectPreferencePane:(id)sender {
  NSWindow *window = self.window;
  [_preferencesTabView selectTabViewItemWithIdentifier:_preferencesToolbar.selectedItemIdentifier];
  NSSize size = NSSizeFromString(_preferencesTabView.selectedTabViewItem.label);
  NSRect rect = [window contentRectForFrameRect:window.frame];
//  if (sender) {
    rect.origin.y += rect.size.height;
//  }
  rect.size.width = size.width;
  rect.size.height = size.height;
//  if (sender) {
    rect.origin.y -= rect.size.height;
//  }
  [window setFrame:[window frameRectForContentRect:rect] display:YES animate:(sender ? YES : NO)];
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure really in what cases there is or isn't a sender? I would assume there always is one. I just want the preference pane to never move itself down haha.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 10 to 12
extern NSString* const GIViewController_DiffTool;
extern NSString* const GIViewController_MergeTool;
extern NSString* const GIViewController_TerminalTool;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why GIViewController?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasderraugh Legacy, I guess.
GIPreferences_ prefix is better?

// Change
extern NSString *const GIPreferences_DiffTool;
extern NSString *const GIPreferences_MergeTool;
extern NSString *const GIPreferences_TerminalTool;

// DiffTool and MergeTool
extern NSString *const GIPreferences_DiffMergeTool_FileMerge;
extern NSString *const GIPreferences_DiffMergeTool_Kaleidoscope;
extern NSString *const GIPreferences_DiffMergeTool_BeyondCompare;
extern NSString *const GIPreferences_DiffMergeTool_P4Merge;
extern NSString *const GIPreferences_DiffMergeTool_GitTool;
extern NSString *const GIPreferences_DiffMergeTool_DiffMerge;

// TerminalTool
extern NSString *const GIPreferences_TerminalTool_Terminal;
extern NSString *const GIPreferences_TerminalTool_iTerm;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I would like to add suffix to distinguish Keys and DisplayNames.

extern NSString *const GIPreferences_DiffTool_Key;
extern NSString *const GIPreferences_DiffMergeTool_FileMerge_DisplayName;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I think GIPreferences works well. I think you can shorten up some of these names. If it's just being used as the localized string value, just GIPreferences_FileMerge would work fine if the string is just going to be "File Merge" anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 55 to 66
+ (NSString *)bundleIdentifierForDisplayName:(NSString *)displayName {
if ([displayName isEqualToString:GIViewController_TerminalTool_iTerm]) {
return GIViewController_TerminalTool_iTerm_BundleIdentifier;
}
return nil;
}
+ (NSString *)standardDefaultsKeyForDisplayName:(NSString *)displayName {
if ([displayName isEqualToString:GIViewController_TerminalTool_iTerm]) {
return GIViewController_TerminalTool_iTerm_Key;
}
return nil;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static analysis warning for returning nil when expecting non-nil return.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@lucasderraugh lucasderraugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always forget to hit the request changes button...

Comment on lines 26 to 27
@property (nonatomic, copy) NSArray <NSString *>*channelTitles;
@property (nonatomic, copy) NSArray <NSString *>*themesTitles;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Generics right next to type: NSArray< (no space)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@property (nonatomic, copy) NSArray<NSString *>*themesTitles;

// or

@property (nonatomic, copy) NSArray<NSString*>*themesTitles;

// or 

@property (nonatomic, copy) NSArray<NSString*> *themesTitles;

Copy link
Collaborator

@lucasderraugh lucasderraugh Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style throughout the rest of the project is to have the type and then the identifier after a space so my vote would be NSArray<NSString*>* propertyName. Not how my personal projects would go, but it's not really my repo 😅.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasderraugh Fixed. :3

@lolgear lolgear requested a review from lucasderraugh January 4, 2020 14:51
@lolgear
Copy link
Contributor Author

lolgear commented Jan 8, 2020

@lucasderraugh Go-go-go

@lolgear
Copy link
Contributor Author

lolgear commented Jan 16, 2020

Ready?

@lucasderraugh lucasderraugh merged commit ec81a92 into git-up:master Jan 20, 2020
simpzan pushed a commit to simpzan/GitUp that referenced this pull request Oct 22, 2020
* kit: launch services locator has been added.

* application: windows preferences window controller has been added.

* application: project has been updated.

* application: app delegate has been cleaned up.

* application: windows xibs main menu preferences window has been removed.

* application: common constants have been cleaned up.

* application: project has been updated.

* application: windows xibs preferences window constraints have been added.

* application: preference text size has been fixed.

* kit: launch services locator preferences keys have been renamed. Bugs have been fixed.

* application: document has been fixed.

* application: windows xibs preferences window layout has been updated.

* application: windows preferences window controller small bugs have been fixed.

* Fix bad merge from master

Co-authored-by: Lucas Derraugh <lucas@derraugh.com>
@lolgear lolgear deleted the window_separation_remastered_preferences_window branch May 17, 2021 09:33
@lolgear lolgear restored the window_separation_remastered_preferences_window branch May 18, 2021 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants