Skip to content

Commit

Permalink
Merge pull request #7 from autodesk-forks/autodesk/vfx/5.6.1/maya/201…
Browse files Browse the repository at this point in the history
…8/update3

Autodesk/vfx/5.6.1/maya/2018/update3
  • Loading branch information
BadSingleton authored Apr 30, 2018
2 parents 38eba4f + b48948c commit cf41d17
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
5 changes: 4 additions & 1 deletion src/corelib/io/qfilesystemengine_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
clearWinStatData(data);
WIN32_FIND_DATA findData;
// The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA
// for all members used by fillFindData().
// for all members used by fillFindData(), except for dwReserved0. So we zero the
// whole struct to be extra safe. This also clears all internal FILETIME which for
// umounted drives has shown to be wrong.
ZeroMemory(&findData, sizeof(findData));
bool ok = ::GetFileAttributesEx((wchar_t*)fname.nativeFilePath().utf16(), GetFileExInfoStandard,
reinterpret_cast<WIN32_FILE_ATTRIBUTE_DATA *>(&findData));
if (ok) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/cocoa/qcocoahelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ QColor qt_mac_toQColor(CGColorRef color);
// Creates a mutable shape, it's the caller's responsibility to release.
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region);

OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);
void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage);

NSDragOperation qt_mac_mapDropAction(Qt::DropAction action);
NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions);
Expand Down
13 changes: 1 addition & 12 deletions src/plugins/platforms/cocoa/qcocoahelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -507,26 +507,15 @@ NSRect qt_mac_flipRect(const QRect &rect)
return NSMakeRect(rect.x(), flippedY, rect.width(), rect.height());
}

OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
{
// Verbatim copy if HIViewDrawCGImage (as shown on Carbon-Dev)
OSStatus err = noErr;

require_action(inContext != NULL, InvalidContext, err = paramErr);
require_action(inBounds != NULL, InvalidBounds, err = paramErr);
require_action(inImage != NULL, InvalidImage, err = paramErr);

CGContextSaveGState( inContext );
CGContextTranslateCTM (inContext, 0, inBounds->origin.y + CGRectGetMaxY(*inBounds));
CGContextScaleCTM(inContext, 1, -1);

CGContextDrawImage(inContext, *inBounds, inImage);

CGContextRestoreGState(inContext);
InvalidImage:
InvalidBounds:
InvalidContext:
return err;
}

Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/platforms/cocoa/qnsview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1574,10 +1574,16 @@ - (void)handleKeyEvent:(NSEvent *)nsevent eventType:(int)eventType

QChar ch = QChar::ReplacementCharacter;
int keyCode = Qt::Key_unknown;
if ([characters length] != 0) {

// If a dead key occurs as a result of pressing a key combination then
// characters will have 0 length, but charactersIgnoringModifiers will
// have a valid character in it. This enables key combinations such as
// ALT+E to be used as a shortcut with an English keyboard even though
// pressing ALT+E will give a dead key while doing normal text input.
if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) {
if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
else
else if ([characters length] != 0)
ch = QChar([characters characterAtIndex:0]);
keyCode = [self convertKeyCode:ch];
}
Expand Down
24 changes: 12 additions & 12 deletions src/widgets/widgets/qmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ class QTornOffMenu : public QMenu
void setMenuSize(const QRect &screen) {
Q_Q(QTornOffMenu);
QSize size = q->sizeHint();
if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) {
const int frameAddedHeight = q->frameGeometry().height() - q->geometry().height();
if (scroll && (size.height() + frameAddedHeight > screen.height() || size.width() > screen.width())) {
const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q);
const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, 0, q);
scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
size.setWidth(qMin(actionRects.at(getLastVisibleAction()).right() + fw + hmargin + rightmargin + 1, screen.width()));
size.setHeight(screen.height() - desktopFrame * 2 - titleBarHeight);
size.setHeight(screen.height() - desktopFrame * 2 - frameAddedHeight);
}
q->setFixedSize(size);
}
Expand All @@ -106,7 +107,6 @@ class QTornOffMenu : public QMenu
QPointer<QMenu> causedMenu;
QVector<QPointer<QWidget> > causedStack;
bool initialized;
int titleBarHeight;
};

public:
Expand All @@ -126,10 +126,6 @@ class QTornOffMenu : public QMenu
if (style() != p->style())
setStyle(p->style());

QStyleOption opt;
opt.init(this);
d->titleBarHeight = style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt, this);

int leftMargin, topMargin, rightMargin, bottomMargin;
p->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
Expand Down Expand Up @@ -292,7 +288,8 @@ int QMenuPrivate::scrollerHeight() const
//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
{
if (QGuiApplicationPrivate::platformTheme() &&
if ((widget->windowFlags() & Qt::Tool) != Qt::Tool && // Torn-off menus are different
QGuiApplicationPrivate::platformTheme() &&
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
return QApplication::desktop()->screenGeometry(widget);
} else {
Expand Down Expand Up @@ -359,11 +356,11 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const

// Torn off menu windows should be adjusted by their frame height, otherwise some
// window managers may behave unexpectedly if the window is taller than the screen.
int frameHeight = 0;
int frameAddedHeight = 0;
if (!tearoff && (q->windowFlags() & Qt::WindowType_Mask) == Qt::Tool)
frameHeight = q->geometry().top() - q->frameGeometry().top();
frameAddedHeight = q->frameGeometry().height() - q->geometry().height();

const int column_max_y = screen.height() - 2 * deskFw - (vmargin + bottommargin + fw + frameHeight);
const int column_max_y = screen.height() - 2 * deskFw - (vmargin + bottommargin + fw + frameAddedHeight);
int max_column_width = 0;
int y = base_y;

Expand Down Expand Up @@ -1289,7 +1286,10 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
if (e->type() == QEvent::MouseButtonRelease) {
if (!tornPopup)
tornPopup = new QTornOffMenu(q);
tornPopup->setGeometry(q->geometry());

// The torn-off menu should be of the right size. Make sure its titlebar is within the screen's bounds.
const auto frameOffset = tornPopup->geometry().topLeft() - tornPopup->frameGeometry().topLeft();
tornPopup->setGeometry(q->geometry().translated(frameOffset));
tornPopup->show();
hideUpToMenuBar();
}
Expand Down

0 comments on commit cf41d17

Please sign in to comment.