forked from bartvdbraak/blender
Cocoa : add confirmation request before opening a .blend file (dropped on Blender icon or dbl-clicked in Finder)
This commit is contained in:
parent
955f7c9288
commit
c836b0ae18
@ -140,6 +140,24 @@ public:
|
||||
*/
|
||||
GHOST_TUns8 handleQuitRequest();
|
||||
|
||||
/**
|
||||
* Handle Cocoa openFile event
|
||||
* Display confirmation request panel if changes performed since last save
|
||||
*/
|
||||
bool handleOpenDocumentRequest(void *filepathStr);
|
||||
|
||||
/**
|
||||
* Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
|
||||
* @param eventType The type of drag'n'drop event
|
||||
* @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
|
||||
* @param mouseX x mouse coordinate (in cocoa base window coordinates)
|
||||
* @param mouseY y mouse coordinate
|
||||
* @param window The window on which the event occured
|
||||
* @return Indication whether the event was handled.
|
||||
*/
|
||||
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
|
||||
GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data);
|
||||
|
||||
/***************************************************************************************
|
||||
** Cursor management functionality
|
||||
***************************************************************************************/
|
||||
@ -207,18 +225,6 @@ public:
|
||||
GHOST_TSuccess handleApplicationBecomeActiveEvent();
|
||||
|
||||
|
||||
/**
|
||||
* Handles a drag'n'drop destination event. Called by GHOST_WindowCocoa window subclass
|
||||
* @param eventType The type of drag'n'drop event
|
||||
* @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
|
||||
* @param mouseX x mouse coordinate (in cocoa base window coordinates)
|
||||
* @param mouseY y mouse coordinate
|
||||
* @param window The window on which the event occured
|
||||
* @return Indication whether the event was handled.
|
||||
*/
|
||||
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
|
||||
GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Initializes the system.
|
||||
|
@ -436,9 +436,7 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
NSLog(@"\nGet open file event from cocoa : %@",filename);
|
||||
systemCocoa->handleDraggingEvent(GHOST_kEventDraggingDropOnIcon, GHOST_kDragnDropTypeFilenames, nil, 0, 0, [NSArray arrayWithObject:filename]);
|
||||
return YES;
|
||||
return systemCocoa->handleOpenDocumentRequest(filename);
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
@ -1086,6 +1084,33 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
|
||||
return GHOST_kExitCancel;
|
||||
}
|
||||
|
||||
bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
|
||||
{
|
||||
NSString *filepath = (NSString*)filepathStr;
|
||||
int confirmOpen = NSAlertAlternateReturn;
|
||||
NSArray *windowsList;
|
||||
|
||||
//Check open windows if some changes are not saved
|
||||
if (m_windowManager->getAnyModifiedState())
|
||||
{
|
||||
confirmOpen = NSRunAlertPanel([NSString stringWithFormat:@"Opening %@",[filepath lastPathComponent]],
|
||||
@"Current document has not been saved.\nDo you really want to proceed?",
|
||||
@"Cancel", @"Open", nil);
|
||||
}
|
||||
|
||||
//Give back focus to the blender window
|
||||
windowsList = [NSApp orderedWindows];
|
||||
if ([windowsList count]) {
|
||||
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
if (confirmOpen == NSAlertAlternateReturn)
|
||||
{
|
||||
handleDraggingEvent(GHOST_kEventDraggingDropOnIcon,GHOST_kDragnDropTypeFilenames,NULL,0,0, [NSArray arrayWithObject:filepath]);
|
||||
return YES;
|
||||
}
|
||||
else return NO;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user