///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
-// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#ifndef _INC_WINDOWS
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
+#include <ObjIdl.h> // required by QWinMime in QtWinExtras
#endif //_INC_WINDOWS
//Qt
#include <QReadWriteLock>
#include <QLibrary>
#include <QHash>
+#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
+#include <QtWinExtras>
+#endif
+
+//Qt5 support
+#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
+#define PIXMAP2HICON(X) QtWin::toHICON((X))
+#else
+#define PIXMAP2HICON(X) (X).toWinHICON()
+#endif
///////////////////////////////////////////////////////////////////////////////
// QICON TO HICON
///////////////////////////////////////////////////////////////////////////////
-uintptr_t MUtils::Win32Utils::qicon_to_hicon(const QIcon &icon, const int w, const int h)
+uintptr_t MUtils::Win32Utils::qicon_to_hicon(const QIcon *const icon, const int w, const int h)
{
- if(!icon.isNull())
+ if(!icon->isNull())
{
- QPixmap pixmap = icon.pixmap(w, h);
+ QPixmap pixmap = icon->pixmap(w, h);
if(!pixmap.isNull())
{
- return (uintptr_t) pixmap.toWinHICON();
+ return (uintptr_t) PIXMAP2HICON(pixmap);
}
}
return NULL;
static QReadWriteLock g_resolve_lock;
static QHash<QString, LibraryItem> g_resolve_libs;
-uintptr_t MUtils::Win32Utils::resolve_helper(const QString &libraryName, const QString &functionName)
+const uintptr_t &MUtils::Win32Utils::resolve_helper(const QString &libraryName, const QString &functionName)
{
const QString libraryNameFolded = libraryName.toCaseFolded().trimmed();
const QString functionIdTrimmed = functionName.trimmed();
LibraryItem &lib = g_resolve_libs[libraryNameFolded];
if (lib.first.isNull() || (!lib.first->isLoaded()))
{
- return NULL; /*library unavailable*/
+ static const uintptr_t null = NULL;
+ return null; /*library unavailable*/
}
//Lookup the function