mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[Qt5][Windows] Now QupZilla compiles with Qt5 on Windows (msvc).
-There are some issues when enabling blur effect!
This commit is contained in:
parent
6072b7c4be
commit
6c3d210544
2
src/lib/3rdparty/ecwin7.cpp
vendored
2
src/lib/3rdparty/ecwin7.cpp
vendored
|
@ -32,7 +32,7 @@ EcWin7::EcWin7()
|
|||
}
|
||||
|
||||
// Init taskbar communication
|
||||
void EcWin7::init(WId wid)
|
||||
void EcWin7::init(HWND wid)
|
||||
{
|
||||
mWindowId = wid;
|
||||
mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
||||
|
|
6
src/lib/3rdparty/ecwin7.h
vendored
6
src/lib/3rdparty/ecwin7.h
vendored
|
@ -27,7 +27,7 @@
|
|||
|
||||
// Windows only data definitions
|
||||
#ifdef W7TASKBAR
|
||||
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
// Initialization methods
|
||||
EcWin7();
|
||||
void init(WId wid);
|
||||
void init(HWND wid);
|
||||
bool winEvent(MSG* message, long* result);
|
||||
|
||||
// Overlay icon handling
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
void setProgressState(ToolBarProgressState state);
|
||||
|
||||
private:
|
||||
WId mWindowId;
|
||||
HWND mWindowId;
|
||||
UINT mTaskbarMessageId;
|
||||
ITaskbarList3* mTaskbar;
|
||||
HICON mOverlayIcon;
|
||||
|
|
8
src/lib/3rdparty/qtlockedfile_win.cpp
vendored
8
src/lib/3rdparty/qtlockedfile_win.cpp
vendored
|
@ -66,16 +66,24 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
|
|||
|
||||
Qt::HANDLE mutex;
|
||||
if (doCreate) {
|
||||
#if (QT_VERSION < 0x050000)
|
||||
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
|
||||
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); });
|
||||
#else // QT_WA removed from Qt5: http://qt-project.org/forums/viewthread/22994/#107379
|
||||
mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16());
|
||||
#endif
|
||||
if (!mutex) {
|
||||
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if (QT_VERSION < 0x050000)
|
||||
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
|
||||
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); });
|
||||
#else // QT_WA removed from Qt5: http://qt-project.org/forums/viewthread/22994/#107379
|
||||
mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16());
|
||||
#endif
|
||||
if (!mutex) {
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND) {
|
||||
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
|
||||
|
|
41
src/lib/3rdparty/qtwin.cpp
vendored
41
src/lib/3rdparty/qtwin.cpp
vendored
|
@ -84,7 +84,11 @@ public:
|
|||
void removeWidget(QWidget* widget) {
|
||||
widgets.removeAll(widget);
|
||||
}
|
||||
#if (QT_VERSION < 0x050000)
|
||||
bool winEvent(MSG* message, long* result);
|
||||
#else
|
||||
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QWidgetList widgets;
|
||||
|
@ -93,7 +97,7 @@ private:
|
|||
static bool resolveLibs()
|
||||
{
|
||||
if (!pDwmIsCompositionEnabled) {
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
||||
pDwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
|
||||
pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
|
||||
pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow");
|
||||
|
@ -164,9 +168,13 @@ bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable)
|
|||
bb.fEnable = enable;
|
||||
bb.dwFlags = DWM_BB_ENABLE;
|
||||
bb.hRgnBlur = NULL;
|
||||
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground, enable);
|
||||
widget->setAttribute(Qt::WA_NoSystemBackground, enable);
|
||||
hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb);
|
||||
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
||||
widget->setWindowOpacity(1);
|
||||
|
||||
hr = pDwmEnableBlurBehindWindow(hwndOfWidget(widget) , &bb);
|
||||
if (SUCCEEDED(hr)) {
|
||||
result = true;
|
||||
windowNotifier()->addWidget(widget);
|
||||
|
@ -202,16 +210,18 @@ bool QtWin::extendFrameIntoClientArea(QWidget* widget, int left, int top, int ri
|
|||
bool result = false;
|
||||
#ifdef Q_OS_WIN
|
||||
if (resolveLibs()) {
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
||||
HRESULT hr = S_OK;
|
||||
MARGINS m = {left, right, top, bottom};
|
||||
hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m);
|
||||
hr = pDwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m);
|
||||
if (SUCCEEDED(hr)) {
|
||||
result = true;
|
||||
windowNotifier()->addWidget(widget);
|
||||
widgetsBlurState.insert(widget, true);
|
||||
}
|
||||
widget->setAttribute(Qt::WA_TranslucentBackground, result);
|
||||
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
|
||||
widget->setWindowOpacity(1);
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
|
@ -230,7 +240,7 @@ QColor QtWin::colorizationColor()
|
|||
if (resolveLibs()) {
|
||||
DWORD color = 0;
|
||||
BOOL opaque = FALSE;
|
||||
QLibrary dwmLib(QString::fromAscii("dwmapi"));
|
||||
QLibrary dwmLib(QString::fromLatin1("dwmapi"));
|
||||
HRESULT hr = S_OK;
|
||||
hr = pDwmGetColorizationColor(&color, &opaque);
|
||||
if (SUCCEEDED(hr)) {
|
||||
|
@ -242,6 +252,16 @@ QColor QtWin::colorizationColor()
|
|||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
HWND QtWin::hwndOfWidget(const QWidget* widget)
|
||||
{
|
||||
if (widget) {
|
||||
return reinterpret_cast<HWND>(widget->winId());
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
WindowNotifier* QtWin::windowNotifier()
|
||||
{
|
||||
static WindowNotifier* windowNotifierInstance = 0;
|
||||
|
@ -253,8 +273,15 @@ WindowNotifier* QtWin::windowNotifier()
|
|||
|
||||
|
||||
/* Notify all enabled windows that the DWM state changed */
|
||||
#if (QT_VERSION < 0x050000)
|
||||
bool WindowNotifier::winEvent(MSG* message, long* result)
|
||||
{
|
||||
#else
|
||||
bool WindowNotifier::nativeEvent(const QByteArray &eventType, void* _message, long* result)
|
||||
{
|
||||
Q_UNUSED(eventType)
|
||||
MSG* message = static_cast<MSG*>(_message);
|
||||
#endif
|
||||
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
|
||||
bool compositionEnabled = QtWin::isCompositionEnabled();
|
||||
foreach(QWidget * widget, widgets) {
|
||||
|
@ -270,7 +297,11 @@ bool WindowNotifier::winEvent(MSG* message, long* result)
|
|||
}
|
||||
}
|
||||
}
|
||||
#if (QT_VERSION < 0x050000)
|
||||
return QWidget::winEvent(message, result);
|
||||
#else
|
||||
return QWidget::nativeEvent(eventType, _message, result);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef W7API
|
||||
|
|
5
src/lib/3rdparty/qtwin.h
vendored
5
src/lib/3rdparty/qtwin.h
vendored
|
@ -38,6 +38,8 @@
|
|||
* these functions will simply not do anything.
|
||||
*/
|
||||
#ifdef Q_OS_WIN
|
||||
// Qt5 compile issue: http://comments.gmane.org/gmane.comp.lib.qt.user/4711
|
||||
#define NOMINMAX
|
||||
#ifdef W7API
|
||||
#include <ShlObj.h>
|
||||
#include <shlwapi.h>
|
||||
|
@ -62,6 +64,9 @@ public:
|
|||
static QColor colorizationColor();
|
||||
|
||||
static void setupJumpList();
|
||||
#ifdef Q_OS_WIN
|
||||
static HWND hwndOfWidget(const QWidget* widget);
|
||||
#endif
|
||||
|
||||
private:
|
||||
static WindowNotifier* windowNotifier();
|
||||
|
|
|
@ -661,6 +661,8 @@ void QupZilla::loadSettings()
|
|||
m_usingTransparentBackground = true;
|
||||
|
||||
applyBlurToMainWindow();
|
||||
update();
|
||||
|
||||
//install event filter
|
||||
menuBar()->installEventFilter(this);
|
||||
m_navigationBar->installEventFilter(this);
|
||||
|
@ -1998,8 +2000,15 @@ void QupZilla::moveToVirtualDesktop(int desktopId)
|
|||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if (QT_VERSION < 0x050000)
|
||||
bool QupZilla::winEvent(MSG* message, long* result)
|
||||
{
|
||||
#else
|
||||
bool QupZilla::nativeEvent(const QByteArray &eventType, void* _message, long* result)
|
||||
{
|
||||
Q_UNUSED(eventType)
|
||||
MSG* message = static_cast<MSG*>(_message);
|
||||
#endif
|
||||
if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
|
||||
Settings settings;
|
||||
settings.beginGroup("Browser-View-Settings");
|
||||
|
@ -2039,7 +2048,11 @@ bool QupZilla::winEvent(MSG* message, long* result)
|
|||
setUpdatesEnabled(true);
|
||||
}
|
||||
}
|
||||
#if (QT_VERSION < 0x050000)
|
||||
return QMainWindow::winEvent(message, result);
|
||||
#else
|
||||
return QMainWindow::nativeEvent(eventType, _message, result);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QupZilla::applyBlurToMainWindow(bool force)
|
||||
|
|
|
@ -208,7 +208,11 @@ private:
|
|||
void disconnectObjects();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if (QT_VERSION < 0x050000)
|
||||
bool winEvent(MSG* message, long* result);
|
||||
#else
|
||||
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
|
||||
#endif
|
||||
bool eventFilter(QObject* object, QEvent* event);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ DownloadManager::DownloadManager(QWidget* parent)
|
|||
|
||||
#ifdef W7TASKBAR
|
||||
if (QtWin::isRunningWindows7()) {
|
||||
win7.init(this->winId());
|
||||
win7.init(QtWin::hwndOfWidget(this));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -116,8 +116,15 @@ void DownloadManager::startExternalManager(const QUrl &url)
|
|||
}
|
||||
|
||||
#ifdef W7TASKBAR
|
||||
#if (QT_VERSION < 0x050000)
|
||||
bool DownloadManager::winEvent(MSG* message, long* result)
|
||||
{
|
||||
#else
|
||||
bool DownloadManager::nativeEvent(const QByteArray &eventType, void* _message, long* result)
|
||||
{
|
||||
Q_UNUSED(eventType)
|
||||
MSG* message = static_cast<MSG*>(_message);
|
||||
#endif
|
||||
return win7.winEvent(message, result);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,11 @@ public slots:
|
|||
|
||||
#ifdef W7TASKBAR
|
||||
protected:
|
||||
#if (QT_VERSION < 0x050000)
|
||||
virtual bool winEvent(MSG* message, long* result);
|
||||
#else
|
||||
virtual bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
|
|
Loading…
Reference in New Issue
Block a user