Fix QWidget::setWindowOpacity() when called before show().
Pass opacity from the QWidget to QWindow and to the platform windows. Task-number: QTBUG-28477 Change-Id: If5a85d9183bd1ca33dac2052936ecd1e6c0b5f6c Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
parent
bf178c77dd
commit
76ce3e6419
@ -654,9 +654,11 @@ void QWindow::lower()
|
||||
void QWindow::setOpacity(qreal level)
|
||||
{
|
||||
Q_D(QWindow);
|
||||
if (d->platformWindow) {
|
||||
if (level == d->opacity) // #fixme: Add property for 5.1
|
||||
return;
|
||||
d->opacity = level;
|
||||
if (d->platformWindow)
|
||||
d->platformWindow->setOpacity(level);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -89,6 +89,7 @@ public:
|
||||
, receivedExpose(false)
|
||||
, positionPolicy(WindowFrameExclusive)
|
||||
, contentOrientation(Qt::PrimaryOrientation)
|
||||
, opacity(qreal(1.0))
|
||||
, minimumSize(0, 0)
|
||||
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
||||
, modality(Qt::NonModal)
|
||||
@ -135,6 +136,7 @@ public:
|
||||
bool receivedExpose;
|
||||
PositionPolicy positionPolicy;
|
||||
Qt::ScreenOrientation contentOrientation;
|
||||
qreal opacity;
|
||||
|
||||
QSize minimumSize;
|
||||
QSize maximumSize;
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
#include <qwindow.h>
|
||||
#include <private/qwindow_p.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
|
||||
@ -649,6 +650,10 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
|
||||
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
|
||||
[m_contentView setFrame:frame];
|
||||
}
|
||||
|
||||
const qreal opacity = qt_window_private(window())->opacity;
|
||||
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
NSWindow * QCocoaWindow::createNSWindow()
|
||||
|
@ -731,6 +731,9 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
|
||||
if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
|
||||
QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0);
|
||||
setWindowState(aWindow->windowState());
|
||||
const qreal opacity = qt_window_private(aWindow)->opacity;
|
||||
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
QWindowsWindow::~QWindowsWindow()
|
||||
|
@ -385,6 +385,10 @@ void QXcbWindow::create()
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
connection()->drag()->dndEnable(this, true);
|
||||
#endif
|
||||
|
||||
const qreal opacity = qt_window_private(window())->opacity;
|
||||
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
QXcbWindow::~QXcbWindow()
|
||||
|
@ -10266,6 +10266,7 @@ void QWidget::setWindowOpacity(qreal opacity)
|
||||
QTLWExtra *extra = d->topData();
|
||||
extra->opacity = uint(opacity * 255);
|
||||
setAttribute(Qt::WA_WState_WindowOpacitySet);
|
||||
d->setWindowOpacity_sys(opacity);
|
||||
|
||||
if (!testAttribute(Qt::WA_WState_Created))
|
||||
return;
|
||||
@ -10280,8 +10281,6 @@ void QWidget::setWindowOpacity(qreal opacity)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
d->setWindowOpacity_sys(opacity);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user