macOS: Only show menu and allow dragging on proxy when a file path is set

If there is no file path set then it should not be possible to see a
menu or to drag from a proxy icon in the titlebar.

Task-number: QTBUG-56082
Change-Id: Ib8305bcab5717bc8cb7ddabbb079f152debbdded
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
bb10
Andy Shaw 2016-09-19 12:13:33 +02:00
parent b38145a11d
commit cd081ca96a
4 changed files with 20 additions and 1 deletions

View File

@ -346,6 +346,7 @@ public: // for QNSView
// This object is tracked by QCocoaWindowPointer,
// preventing the use of dangling pointers.
QObject sentinel;
bool m_hasWindowFilePath;
};
QT_END_NAMESPACE

View File

@ -379,6 +379,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_topContentBorderThickness(0)
, m_bottomContentBorderThickness(0)
, m_normalGeometry(QRect(0,0,-1,-1))
, m_hasWindowFilePath(false)
{
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
@ -941,6 +942,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
QFileInfo fi(filePath);
[m_nsWindow setRepresentedFilename: fi.exists() ? QCFString::toNSString(filePath) : @""];
m_hasWindowFilePath = fi.exists();
}
void QCocoaWindow::setWindowIcon(const QIcon &icon)

View File

@ -51,7 +51,8 @@
- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowDelegate);

View File

@ -109,4 +109,19 @@
return YES;
}
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
{
Q_UNUSED(window);
Q_UNUSED(menu);
return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath;
}
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard
{
Q_UNUSED(window);
Q_UNUSED(event);
Q_UNUSED(dragImageLocation);
Q_UNUSED(pasteboard);
return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath;
}
@end