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)
|
void QWindow::setOpacity(qreal level)
|
||||||
{
|
{
|
||||||
Q_D(QWindow);
|
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);
|
d->platformWindow->setOpacity(level);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -89,6 +89,7 @@ public:
|
|||||||
, receivedExpose(false)
|
, receivedExpose(false)
|
||||||
, positionPolicy(WindowFrameExclusive)
|
, positionPolicy(WindowFrameExclusive)
|
||||||
, contentOrientation(Qt::PrimaryOrientation)
|
, contentOrientation(Qt::PrimaryOrientation)
|
||||||
|
, opacity(qreal(1.0))
|
||||||
, minimumSize(0, 0)
|
, minimumSize(0, 0)
|
||||||
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
|
||||||
, modality(Qt::NonModal)
|
, modality(Qt::NonModal)
|
||||||
@ -135,6 +136,7 @@ public:
|
|||||||
bool receivedExpose;
|
bool receivedExpose;
|
||||||
PositionPolicy positionPolicy;
|
PositionPolicy positionPolicy;
|
||||||
Qt::ScreenOrientation contentOrientation;
|
Qt::ScreenOrientation contentOrientation;
|
||||||
|
qreal opacity;
|
||||||
|
|
||||||
QSize minimumSize;
|
QSize minimumSize;
|
||||||
QSize maximumSize;
|
QSize maximumSize;
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <QtCore/qfileinfo.h>
|
#include <QtCore/qfileinfo.h>
|
||||||
#include <QtCore/private/qcore_mac_p.h>
|
#include <QtCore/private/qcore_mac_p.h>
|
||||||
#include <qwindow.h>
|
#include <qwindow.h>
|
||||||
|
#include <private/qwindow_p.h>
|
||||||
#include <qpa/qwindowsysteminterface.h>
|
#include <qpa/qwindowsysteminterface.h>
|
||||||
#include <qpa/qplatformscreen.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());
|
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
[m_contentView setFrame:frame];
|
[m_contentView setFrame:frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const qreal opacity = qt_window_private(window())->opacity;
|
||||||
|
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||||
|
setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWindow * QCocoaWindow::createNSWindow()
|
NSWindow * QCocoaWindow::createNSWindow()
|
||||||
|
@ -731,6 +731,9 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) :
|
|||||||
if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
|
if (QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)
|
||||||
QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0);
|
QWindowsContext::user32dll.registerTouchWindow(m_data.hwnd, 0);
|
||||||
setWindowState(aWindow->windowState());
|
setWindowState(aWindow->windowState());
|
||||||
|
const qreal opacity = qt_window_private(aWindow)->opacity;
|
||||||
|
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||||
|
setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindowsWindow::~QWindowsWindow()
|
QWindowsWindow::~QWindowsWindow()
|
||||||
|
@ -385,6 +385,10 @@ void QXcbWindow::create()
|
|||||||
#ifndef QT_NO_DRAGANDDROP
|
#ifndef QT_NO_DRAGANDDROP
|
||||||
connection()->drag()->dndEnable(this, true);
|
connection()->drag()->dndEnable(this, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const qreal opacity = qt_window_private(window())->opacity;
|
||||||
|
if (!qFuzzyCompare(opacity, qreal(1.0)))
|
||||||
|
setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
QXcbWindow::~QXcbWindow()
|
QXcbWindow::~QXcbWindow()
|
||||||
|
@ -10266,6 +10266,7 @@ void QWidget::setWindowOpacity(qreal opacity)
|
|||||||
QTLWExtra *extra = d->topData();
|
QTLWExtra *extra = d->topData();
|
||||||
extra->opacity = uint(opacity * 255);
|
extra->opacity = uint(opacity * 255);
|
||||||
setAttribute(Qt::WA_WState_WindowOpacitySet);
|
setAttribute(Qt::WA_WState_WindowOpacitySet);
|
||||||
|
d->setWindowOpacity_sys(opacity);
|
||||||
|
|
||||||
if (!testAttribute(Qt::WA_WState_Created))
|
if (!testAttribute(Qt::WA_WState_Created))
|
||||||
return;
|
return;
|
||||||
@ -10280,8 +10281,6 @@ void QWidget::setWindowOpacity(qreal opacity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
d->setWindowOpacity_sys(opacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user