Wired actionbutton. Using properties.

This commit is contained in:
Michael Starke
2019-01-25 18:54:50 +01:00
parent 01d4137fe4
commit 4a0ad506b8
4 changed files with 29 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MPPluginRepositoryBrowserViewController : NSViewController
- (IBAction)refresh:(id)sender;
- (IBAction)closeBrowser:(id)sender;
- (IBAction)executePluginAction:(id)sender;
@end

View File

@@ -45,8 +45,11 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
[self _refreshRepository];
}
- (IBAction)closeBrowser:(id)sender {
[self.presentingViewController dismissViewController:self];
- (void)executePluginAction:(id)sender {
NSInteger tableRow = [self.itemTable rowForView:sender];
if(tableRow < -1 && tableRow < self.repositoryItems.count) {
MPPluginRepositoryItem *actionItem = self.repositoryItems[tableRow];
}
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
@@ -67,14 +70,12 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
}
else if(column == MPPluginTableColumnStatus) {
MPPluginStatusTableCellView *statusView = (MPPluginStatusTableCellView *)view;
statusView.actionButton.hidden = NO;
statusView.actionButton.title = NSLocalizedString(@"PLUGIN_BROWSER_DOWNLOAD_PLUGIN_BUTTON", "Button to download the Plugin");
MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier];
if(plugin) {
switch([MPPluginVersionComparator compareVersion:plugin.shortVersionString toVersion:item.currentVersion]) {
case NSOrderedSame:
view.textField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"PLUGIN_BROWSER_LATEST_VERSION_INSTALLED", "Status for an up-to-date plugin in the plugin browser")];
statusView.actionButton.hidden = YES;
break;
case NSOrderedAscending:
view.textField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"PLUGIN_BROWSER_NEWER_VERSION_%@_AVAILABLE", "Status for an outdated plugin version in the plugin browser"), item.currentVersion];
@@ -85,8 +86,6 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
}
}
else {
MPPluginStatusTableCellView *statusView = (MPPluginStatusTableCellView *)view;
statusView.actionButton.hidden = NO;
view.textField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"PLUGIN_BROWSER_PLUGIN_NOT_INSTALLED", "Status for an uninstalled plugin in the plugin browser")];
}
}
@@ -94,7 +93,19 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
view.textField.stringValue = @"-";
}
return view;
}
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row {
NSLog(@"%@", NSStringFromSelector(_cmd));
return YES;
}
- (void)tableViewSelectionIsChanging:(NSNotification *)notification {
NSLog(@"%@", NSStringFromSelector(_cmd));
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
NSLog(@"%@", NSStringFromSelector(_cmd));
}
- (void)_refreshRepository {
@@ -102,5 +113,8 @@ typedef NS_ENUM(NSUInteger, MPPluginTableColumn) {
[self.itemTable reloadData];
}
- (void)_downloadPluginAtURL:(NSURL *)url {
NSURLSessionDownloadTask *taks = [NSURLSession.sharedSession downloadTaskWithURL:url];
}
@end

View File

@@ -36,7 +36,7 @@ static NSString *allowedCharactersString(MPPasswordCharacterFlags flags) {
[characterString appendString:kMPLowercaseLetterCharacters];
}
if(flags & MPPasswordCharactersUpperCase) {
[characterString appendString:[kMPLowercaseLetterCharacters uppercaseString]];
[characterString appendString:kMPLowercaseLetterCharacters.uppercaseString];
}
if(flags & MPPasswordCharactersNumbers) {
[characterString appendString:kMPNumberCharacters];

View File

@@ -129,6 +129,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<action selector="executePluginAction:" target="-2" id="F6d-ns-ats"/>
</connections>
</button>
</subviews>
<constraints>
@@ -186,7 +189,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="closeBrowser:" target="-2" id="FVU-rJ-Pxm"/>
<action selector="dismissController:" target="-2" id="oAU-cX-l8e"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="d2Q-7O-ilP">
@@ -225,7 +228,7 @@
<constraint firstItem="bGv-Zc-Vrk" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" id="tk3-kF-k22"/>
<constraint firstItem="d2Q-7O-ilP" firstAttribute="leading" secondItem="fjQ-ni-Ayx" secondAttribute="trailing" constant="8" symbolic="YES" id="wHQ-Lk-2fv"/>
</constraints>
<point key="canvasLocation" x="128" y="-118"/>
<point key="canvasLocation" x="-130" y="-66"/>
</customView>
</objects>
</document>