Skip to content

Commit 694e84e

Browse files
committed
Disable File -> Load Media Menu item when is loading
1 parent 30e2238 commit 694e84e

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

uPlayer/AppDelegate.mm

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ @interface AppDelegate ()
4040

4141
@property (nonatomic,strong) NSMenu *dockMenu;
4242

43+
@property bool isLoadItunesMedia;
44+
4345
@end
4446

4547

@@ -161,12 +163,14 @@ - (IBAction)cmdOpenDirectory:(id)sender
161163

162164
dojobInBkgnd(
163165
^{
166+
self.isLoadItunesMedia = true;
164167
postEvent(EventID_importing_tracks_begin, nil);
165168
[list addTrackInfoItems: enumAudioFiles(fileName)];
166169
} ,
167170
^{
168171
postEvent(EventID_importing_tracks_end, nil);
169172
postEvent(EventID_to_reload_tracklist, list);
173+
self.isLoadItunesMedia = false;
170174
});
171175

172176
}
@@ -185,6 +189,7 @@ -(void)reloadiTunesMedia
185189

186190
- (IBAction)cmdReloadiTunesMedia:(id)sender
187191
{
192+
188193
NSString *alertSuppressionKey = @"ReloadiTunesMedia";
189194
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
190195

@@ -202,14 +207,21 @@ - (IBAction)cmdReloadiTunesMedia:(id)sender
202207
[alert addButtonWithTitle:NSLocalizedString(@"Cancel",nil)];
203208
alert.showsSuppressionButton = YES;
204209

205-
if( [alert runModal] == NSAlertFirstButtonReturn)
210+
NSModalResponse resp = [alert runModal];
211+
212+
if( resp == NSAlertFirstButtonReturn)
206213
[self reloadiTunesMedia];
207214

215+
216+
208217
if (alert.suppressionButton.state == NSOnState)
209218
[defaults setBool: YES forKey: alertSuppressionKey];
219+
210220
}
221+
211222
}
212223

224+
213225
- (IBAction)cmdFind:(id)sender
214226
{
215227
WindowController *vc = [NSApplication sharedApplication].mainWindow.windowController;
@@ -394,12 +406,14 @@ -(void)loadiTunesMedia
394406

395407
dojobInBkgnd(
396408
^{
409+
self.isLoadItunesMedia = true;
397410
postEvent(EventID_importing_tracks_begin, nil);
398411
[list addTrackInfoItems: enumAudioFiles( userMusic )];
399412
} ,
400413
^{
401414
postEvent(EventID_importing_tracks_end, nil);
402415
postEvent(EventID_to_reload_tracklist, list);
416+
self.isLoadItunesMedia = false;
403417
});
404418
}
405419

@@ -510,13 +524,15 @@ -(void)playerErrorHandler:(NSNotification*)n
510524
[[NSAlert alertWithError:error] runModal];
511525
}
512526

513-
514-
-(BOOL)importDirectoryEnabled
527+
-(bool)isMediaItemReloadItunesEnabled
515528
{
516-
return [player().document.playerlList getSelectedItem].type != type_temporary ;
529+
// only enabled when not temp playlist, nor not loading itunes media.
530+
return [player().document.playerlList getSelectedItem].type != type_temporary && self.isLoadItunesMedia == false;
517531
}
518532

519533

534+
535+
520536
- (IBAction)cmdLastFm_Love:(id)sender
521537
{
522538
postEvent(EventID_to_love_item, nil);

uPlayer/Base.lproj/Main.storyboard

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
55
</dependencies>
66
<scenes>
77
<!--Application-->
@@ -84,14 +84,13 @@
8484
<modifierMask key="keyEquivalentModifierMask"/>
8585
<connections>
8686
<action selector="cmdOpenDirectory:" target="Voe-Tx-rLC" id="J9f-kD-myF"/>
87-
<binding destination="Voe-Tx-rLC" name="enabled" keyPath="importDirectoryEnabled" id="1kU-cW-faQ"/>
8887
</connections>
8988
</menuItem>
9089
<menuItem title="Reload iTunes Media" id="GuR-yr-pUc" userLabel="Open Directory...">
9190
<modifierMask key="keyEquivalentModifierMask"/>
9291
<connections>
9392
<action selector="cmdReloadiTunesMedia:" target="Voe-Tx-rLC" id="cOd-ZG-HOB"/>
94-
<binding destination="Voe-Tx-rLC" name="enabled" keyPath="importDirectoryEnabled" id="fbZ-7m-3gZ"/>
93+
<binding destination="Voe-Tx-rLC" name="enabled" keyPath="isMediaItemReloadItunesEnabled" id="Yst-ha-zZ4"/>
9594
</connections>
9695
</menuItem>
9796
<menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>

0 commit comments

Comments
 (0)