1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Merge pull request #706 from srazi/master

[Qt5][Windows] Added support for compiling QupZilla with Qt5 on Windows (msvc).
This commit is contained in:
David Rosca 2013-01-20 02:25:56 -08:00
commit 489b5bcc2f
13 changed files with 99 additions and 17 deletions

2
.gitignore vendored
View File

@ -28,3 +28,5 @@ tests/modeltest
*.ilk *.ilk
*.kdev4 *.kdev4
*.swp *.swp
*_manifest.*
*.embed.manifest

View File

@ -32,7 +32,7 @@ EcWin7::EcWin7()
} }
// Init taskbar communication // Init taskbar communication
void EcWin7::init(WId wid) void EcWin7::init(HWND wid)
{ {
mWindowId = wid; mWindowId = wid;
mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated"); mTaskbarMessageId = RegisterWindowMessage(L"TaskbarButtonCreated");

View File

@ -27,7 +27,7 @@
// Windows only data definitions // Windows only data definitions
#ifdef W7TASKBAR #ifdef W7TASKBAR
#define NOMINMAX
#include <windows.h> #include <windows.h>
#include <initguid.h> #include <initguid.h>
#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK #define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
@ -45,7 +45,7 @@ public:
// Initialization methods // Initialization methods
EcWin7(); EcWin7();
void init(WId wid); void init(HWND wid);
bool winEvent(MSG* message, long* result); bool winEvent(MSG* message, long* result);
// Overlay icon handling // Overlay icon handling
@ -63,7 +63,7 @@ public:
void setProgressState(ToolBarProgressState state); void setProgressState(ToolBarProgressState state);
private: private:
WId mWindowId; HWND mWindowId;
UINT mTaskbarMessageId; UINT mTaskbarMessageId;
ITaskbarList3* mTaskbar; ITaskbarList3* mTaskbar;
HICON mOverlayIcon; HICON mOverlayIcon;

View File

@ -66,16 +66,24 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
Qt::HANDLE mutex; Qt::HANDLE mutex;
if (doCreate) { if (doCreate) {
#if (QT_VERSION < 0x050000)
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); }); { 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) { if (!mutex) {
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
return 0; return 0;
} }
} }
else { else {
#if (QT_VERSION < 0x050000)
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); }); { 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 (!mutex) {
if (GetLastError() != ERROR_FILE_NOT_FOUND) { if (GetLastError() != ERROR_FILE_NOT_FOUND) {
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");

View File

@ -84,7 +84,11 @@ public:
void removeWidget(QWidget* widget) { void removeWidget(QWidget* widget) {
widgets.removeAll(widget); widgets.removeAll(widget);
} }
#if (QT_VERSION < 0x050000)
bool winEvent(MSG* message, long* result); bool winEvent(MSG* message, long* result);
#else
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
private: private:
QWidgetList widgets; QWidgetList widgets;
@ -93,7 +97,7 @@ private:
static bool resolveLibs() static bool resolveLibs()
{ {
if (!pDwmIsCompositionEnabled) { if (!pDwmIsCompositionEnabled) {
QLibrary dwmLib(QString::fromAscii("dwmapi")); QLibrary dwmLib(QString::fromLatin1("dwmapi"));
pDwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); pDwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow");
@ -164,9 +168,13 @@ bool QtWin::enableBlurBehindWindow(QWidget* widget, bool enable)
bb.fEnable = enable; bb.fEnable = enable;
bb.dwFlags = DWM_BB_ENABLE; bb.dwFlags = DWM_BB_ENABLE;
bb.hRgnBlur = NULL; bb.hRgnBlur = NULL;
widget->setAttribute(Qt::WA_TranslucentBackground, enable); widget->setAttribute(Qt::WA_TranslucentBackground, enable);
widget->setAttribute(Qt::WA_NoSystemBackground, 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)) { if (SUCCEEDED(hr)) {
result = true; result = true;
windowNotifier()->addWidget(widget); windowNotifier()->addWidget(widget);
@ -202,16 +210,18 @@ bool QtWin::extendFrameIntoClientArea(QWidget* widget, int left, int top, int ri
bool result = false; bool result = false;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (resolveLibs()) { if (resolveLibs()) {
QLibrary dwmLib(QString::fromAscii("dwmapi")); QLibrary dwmLib(QString::fromLatin1("dwmapi"));
HRESULT hr = S_OK; HRESULT hr = S_OK;
MARGINS m = {left, right, top, bottom}; MARGINS m = {left, right, top, bottom};
hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m); hr = pDwmExtendFrameIntoClientArea(hwndOfWidget(widget), &m);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
result = true; result = true;
windowNotifier()->addWidget(widget); windowNotifier()->addWidget(widget);
widgetsBlurState.insert(widget, true); widgetsBlurState.insert(widget, true);
} }
widget->setAttribute(Qt::WA_TranslucentBackground, result); widget->setAttribute(Qt::WA_TranslucentBackground, result);
// Qt5: setting WA_TranslucentBackground without the following line hides the widget!!
widget->setWindowOpacity(1);
} }
#endif #endif
return result; return result;
@ -230,7 +240,7 @@ QColor QtWin::colorizationColor()
if (resolveLibs()) { if (resolveLibs()) {
DWORD color = 0; DWORD color = 0;
BOOL opaque = FALSE; BOOL opaque = FALSE;
QLibrary dwmLib(QString::fromAscii("dwmapi")); QLibrary dwmLib(QString::fromLatin1("dwmapi"));
HRESULT hr = S_OK; HRESULT hr = S_OK;
hr = pDwmGetColorizationColor(&color, &opaque); hr = pDwmGetColorizationColor(&color, &opaque);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
@ -242,6 +252,16 @@ QColor QtWin::colorizationColor()
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
HWND QtWin::hwndOfWidget(const QWidget* widget)
{
if (widget) {
return reinterpret_cast<HWND>(widget->winId());
}
else {
return 0;
}
}
WindowNotifier* QtWin::windowNotifier() WindowNotifier* QtWin::windowNotifier()
{ {
static WindowNotifier* windowNotifierInstance = 0; static WindowNotifier* windowNotifierInstance = 0;
@ -253,8 +273,15 @@ WindowNotifier* QtWin::windowNotifier()
/* Notify all enabled windows that the DWM state changed */ /* Notify all enabled windows that the DWM state changed */
#if (QT_VERSION < 0x050000)
bool WindowNotifier::winEvent(MSG* message, long* result) 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) { if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
bool compositionEnabled = QtWin::isCompositionEnabled(); bool compositionEnabled = QtWin::isCompositionEnabled();
foreach(QWidget * widget, widgets) { foreach(QWidget * widget, widgets) {
@ -270,7 +297,11 @@ bool WindowNotifier::winEvent(MSG* message, long* result)
} }
} }
} }
#if (QT_VERSION < 0x050000)
return QWidget::winEvent(message, result); return QWidget::winEvent(message, result);
#else
return QWidget::nativeEvent(eventType, _message, result);
#endif
} }
#ifdef W7API #ifdef W7API

View File

@ -38,6 +38,8 @@
* these functions will simply not do anything. * these functions will simply not do anything.
*/ */
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Qt5 compile issue: http://comments.gmane.org/gmane.comp.lib.qt.user/4711
#define NOMINMAX
#ifdef W7API #ifdef W7API
#include <ShlObj.h> #include <ShlObj.h>
#include <shlwapi.h> #include <shlwapi.h>
@ -62,6 +64,9 @@ public:
static QColor colorizationColor(); static QColor colorizationColor();
static void setupJumpList(); static void setupJumpList();
#ifdef Q_OS_WIN
static HWND hwndOfWidget(const QWidget* widget);
#endif
private: private:
static WindowNotifier* windowNotifier(); static WindowNotifier* windowNotifier();

View File

@ -25,6 +25,8 @@
#include "locationbar.h" #include "locationbar.h"
#include "searchtoolbar.h" #include "searchtoolbar.h"
#include "websearchbar.h" #include "websearchbar.h"
#include "pluginproxy.h"
#include "sidebar.h"
#include "downloadmanager.h" #include "downloadmanager.h"
#include "cookiejar.h" #include "cookiejar.h"
#include "cookiemanager.h" #include "cookiemanager.h"
@ -40,12 +42,10 @@
#include "rssmanager.h" #include "rssmanager.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "aboutdialog.h" #include "aboutdialog.h"
#include "pluginproxy.h"
#include "checkboxdialog.h" #include "checkboxdialog.h"
#include "adblockmanager.h" #include "adblockmanager.h"
#include "clickablelabel.h" #include "clickablelabel.h"
#include "docktitlebarwidget.h" #include "docktitlebarwidget.h"
#include "sidebar.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "progressbar.h" #include "progressbar.h"
#include "adblockicon.h" #include "adblockicon.h"
@ -661,6 +661,8 @@ void QupZilla::loadSettings()
m_usingTransparentBackground = true; m_usingTransparentBackground = true;
applyBlurToMainWindow(); applyBlurToMainWindow();
update();
//install event filter //install event filter
menuBar()->installEventFilter(this); menuBar()->installEventFilter(this);
m_navigationBar->installEventFilter(this); m_navigationBar->installEventFilter(this);
@ -1998,8 +2000,15 @@ void QupZilla::moveToVirtualDesktop(int desktopId)
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#if (QT_VERSION < 0x050000)
bool QupZilla::winEvent(MSG* message, long* result) 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) { if (message && message->message == WM_DWMCOMPOSITIONCHANGED) {
Settings settings; Settings settings;
settings.beginGroup("Browser-View-Settings"); settings.beginGroup("Browser-View-Settings");
@ -2039,7 +2048,11 @@ bool QupZilla::winEvent(MSG* message, long* result)
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
} }
#if (QT_VERSION < 0x050000)
return QMainWindow::winEvent(message, result); return QMainWindow::winEvent(message, result);
#else
return QMainWindow::nativeEvent(eventType, _message, result);
#endif
} }
void QupZilla::applyBlurToMainWindow(bool force) void QupZilla::applyBlurToMainWindow(bool force)

View File

@ -208,7 +208,11 @@ private:
void disconnectObjects(); void disconnectObjects();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#if (QT_VERSION < 0x050000)
bool winEvent(MSG* message, long* result); bool winEvent(MSG* message, long* result);
#else
bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
bool eventFilter(QObject* object, QEvent* event); bool eventFilter(QObject* object, QEvent* event);
#endif #endif

View File

@ -367,9 +367,16 @@ void DownloadItem::openFile()
void DownloadItem::openFolder() void DownloadItem::openFolder()
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QString winFileName = m_path + m_fileName; if (m_fileName.endsWith(" ")) {
winFileName.replace(QLatin1Char('/'), "\\"); // explorer.exe don't support filenames that end with SPACE
QProcess::startDetached("explorer.exe /e,/select,\"" + winFileName + "\""); QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
}
else {
QString winFileName = m_path + m_fileName;
winFileName.replace(QLatin1Char('/'), "\\");
QString shExArg = "/e,/select,\""+winFileName+"\"";
ShellExecute(NULL, NULL, TEXT("explorer.exe"), shExArg.toStdWString().c_str(), NULL, SW_SHOW);
}
#else #else
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path)); QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
#endif #endif

View File

@ -58,7 +58,7 @@ DownloadManager::DownloadManager(QWidget* parent)
#ifdef W7TASKBAR #ifdef W7TASKBAR
if (QtWin::isRunningWindows7()) { if (QtWin::isRunningWindows7()) {
win7.init(this->winId()); win7.init(QtWin::hwndOfWidget(this));
} }
#endif #endif
} }
@ -116,8 +116,15 @@ void DownloadManager::startExternalManager(const QUrl &url)
} }
#ifdef W7TASKBAR #ifdef W7TASKBAR
#if (QT_VERSION < 0x050000)
bool DownloadManager::winEvent(MSG* message, long* result) 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); return win7.winEvent(message, result);
} }
#endif #endif

View File

@ -80,7 +80,11 @@ public slots:
#ifdef W7TASKBAR #ifdef W7TASKBAR
protected: protected:
#if (QT_VERSION < 0x050000)
virtual bool winEvent(MSG* message, long* result); virtual bool winEvent(MSG* message, long* result);
#else
virtual bool nativeEvent(const QByteArray &eventType, void* _message, long* result);
#endif
#endif #endif
private slots: private slots:

View File

@ -19,13 +19,13 @@
#include "tabbedwebview.h" #include "tabbedwebview.h"
#include "tabwidget.h" #include "tabwidget.h"
#include "qupzilla.h" #include "qupzilla.h"
#include "pluginproxy.h"
#include "downloadmanager.h" #include "downloadmanager.h"
#include "webpluginfactory.h" #include "webpluginfactory.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "checkboxdialog.h" #include "checkboxdialog.h"
#include "widget.h" #include "widget.h"
#include "globalfunctions.h" #include "globalfunctions.h"
#include "pluginproxy.h"
#include "speeddial.h" #include "speeddial.h"
#include "popupwebpage.h" #include "popupwebpage.h"
#include "popupwebview.h" #include "popupwebview.h"

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */ * ============================================================ */
#include "webview.h" #include "webview.h"
#include "webpage.h" #include "webpage.h"
#include "mainapplication.h" #include "mainapplication.h"
@ -22,6 +23,7 @@
#include "iconprovider.h" #include "iconprovider.h"
#include "history.h" #include "history.h"
#include "autofillmodel.h" #include "autofillmodel.h"
#include "pluginproxy.h"
#include "downloadmanager.h" #include "downloadmanager.h"
#include "sourceviewer.h" #include "sourceviewer.h"
#include "siteinfo.h" #include "siteinfo.h"
@ -31,7 +33,6 @@
#include "settings.h" #include "settings.h"
#include "qzsettings.h" #include "qzsettings.h"
#include "enhancedmenu.h" #include "enhancedmenu.h"
#include "pluginproxy.h"
#include <QDir> #include <QDir>
#include <QTimer> #include <QTimer>