License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</code></pre>
<h1 id="acknowledgement"><span class="header-section-number">6</span> Acknowledgement</h1>
+<p>The following people have contributed in the development of the MUtilities library:</p>
+<ul>
+<li><strong>John Buonagurio <<script type="text/javascript">
+<!--
+h='exponent.com';a='@';n='jbuonagurio';e=n+a+h;
+document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
+// -->
+</script><noscript>jbuonagurio at exponent dot com</noscript>></strong><br />
+Support for Qt5</li>
+</ul>
<p>The following third-party code is used in the MUtilities library:</p>
<ul>
<li><p><strong>Keccak/SHA-3 Reference Implementation</strong><br />
Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni, Joan Daemen, Michaƫl Peeters, Gilles Van Assche and Ronny Van Keer<br />
No Copyright / Dedicated to the Public Domain</p></li>
<li><p><strong>Natural Order String Comparison</strong><br />
-Copyright (C) 2000, 2004 by Martin Pool <script type="text/javascript">
+Copyright (C) 2000, 2004 by Martin Pool <<script type="text/javascript">
<!--
h='sourcefrog.net';a='@';n='mbp';e=n+a+h;
document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
// -->
-</script><noscript>mbp at sourcefrog dot net</noscript><br />
+</script><noscript>mbp at sourcefrog dot net</noscript>><br />
Released under the zlib License</p></li>
<li><p><strong>Adler-32 Checksum Algorithm (from zlib)</strong><br />
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler<br />
# Acknowledgement
+The following people have contributed in the development of the MUtilities library:
+
+* **John Buonagurio <<jbuonagurio@exponent.com>>**
+ Support for Qt5
+
The following third-party code is used in the MUtilities library:
* **Keccak/SHA-3 Reference Implementation**
No Copyright / Dedicated to the Public Domain
* **Natural Order String Comparison**
- Copyright (C) 2000, 2004 by Martin Pool <mbp@sourcefrog.net>
+ Copyright (C) 2000, 2004 by Martin Pool <<mbp@sourcefrog.net>>
Released under the zlib License
* **Adler-32 Checksum Algorithm (from zlib)**
#include <QString>
#include <QMap>
#include <QDate>
+#include <QWidget>
//Forward declaration
class QFile;
QObject(parent),
m_hIcon(hIcon)
{
- SendMessage(parent->winId(), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
+ SendMessage(reinterpret_cast<HWND>(parent->winId()), WM_SETICON, (bIsBigIcon ? ICON_BIG : ICON_SMALL), LPARAM(hIcon));
}
virtual ~WindowIconHelper(void)
if((!icon.isNull()) && window->winId())
{
const int extend = (bIsBigIcon ? 32 : 16);
- if(const HICON hIcon = (HICON) MUtils::Win32Utils::qicon_to_hicon(icon, extend, extend))
+ if(const HICON hIcon = (HICON) MUtils::Win32Utils::qicon_to_hicon(&icon, extend, extend))
{
new Internal::WindowIconHelper(window, hIcon, bIsBigIcon); /*will be free'd using QObject parent mechanism*/
return true;
{
bool ok = false;
- if(HMENU hMenu = GetSystemMenu(win->winId(), FALSE))
+ if(HMENU hMenu = GetSystemMenu(reinterpret_cast<HWND>(win->winId()), FALSE))
{
ok = (AppendMenuW(hMenu, MF_SEPARATOR, 0, 0) == TRUE);
ok = (AppendMenuW(hMenu, MF_STRING, identifier, MUTILS_WCHR(text)) == TRUE);
{
bool ok = false;
- if(HMENU hMenu = ::GetSystemMenu(win->winId(), FALSE))
+ if(HMENU hMenu = ::GetSystemMenu(reinterpret_cast<HWND>(win->winId()), FALSE))
{
ok = (ModifyMenu(hMenu, identifier, MF_STRING | MF_BYCOMMAND, identifier, MUTILS_WCHR(text)) == TRUE);
}
{
bool ok = false;
- if(HMENU hMenu = GetSystemMenu(win->winId(), FALSE))
+ if(HMENU hMenu = GetSystemMenu(reinterpret_cast<HWND>(win->winId()), FALSE))
{
ok = (EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | (bEnable ? MF_ENABLED : MF_GRAYED)) == TRUE);
}
{
for(int i = 0; (i < 5) && (!ret); i++)
{
- ret = (SetForegroundWindow(window->winId()) != FALSE);
- SwitchToThisWindow(window->winId(), TRUE);
+ ret = (SetForegroundWindow(reinterpret_cast<HWND>(window->winId())) != FALSE);
+ SwitchToThisWindow(reinterpret_cast<HWND>(window->winId()), TRUE);
}
LockSetForegroundWindow(LSFW_LOCK);
}
//Enable the "sheet of glass" effect on this window
MARGINS margins = {-1, -1, -1, -1};
- if(HRESULT hr = dwmExtendFrameIntoClientAreaFun(window->winId(), &margins))
+ if(HRESULT hr = dwmExtendFrameIntoClientAreaFun(reinterpret_cast<HWND>(window->winId()), &margins))
{
qWarning("DwmExtendFrameIntoClientArea function has failed! (error %d)", hr);
return false;
memset(&bb, 0, sizeof(DWM_BLURBEHIND));
bb.fEnable = TRUE;
bb.dwFlags = DWM_BB_ENABLE;
- if(HRESULT hr = dwmEnableBlurBehindWindowFun(window->winId(), &bb))
+ if(HRESULT hr = dwmEnableBlurBehindWindowFun(reinterpret_cast<HWND>(window->winId()), &bb))
{
qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
return false;
memset(&bb, 0, sizeof(DWM_BLURBEHIND));
bb.fEnable = TRUE;
bb.dwFlags = DWM_BB_ENABLE;
- if(HRESULT hr = dwmEnableBlurBehindWindowFun(window->winId(), &bb))
+ if(HRESULT hr = dwmEnableBlurBehindWindowFun(reinterpret_cast<HWND>(window->winId()), &bb))
{
qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
return false;
bool MUtils::OS::shell_open(const QWidget *parent, const QString &url, const QString ¶meters, const QString &directory, const bool explore)
{
- return ((int) ShellExecuteW((parent ? parent->winId() : NULL), (explore ? L"explore" : L"open"), MUTILS_WCHR(url), ((!parameters.isEmpty()) ? MUTILS_WCHR(parameters) : NULL), ((!directory.isEmpty()) ? MUTILS_WCHR(directory) : NULL), SW_SHOW)) > 32;
+ return ((int) ShellExecuteW((parent ? reinterpret_cast<HWND>(parent->winId()) : NULL), (explore ? L"explore" : L"open"), MUTILS_WCHR(url), ((!parameters.isEmpty()) ? MUTILS_WCHR(parameters) : NULL), ((!directory.isEmpty()) ? MUTILS_WCHR(directory) : NULL), SW_SHOW)) > 32;
}
bool MUtils::OS::shell_open(const QWidget *parent, const QString &url, const bool explore)
#include <QFont>
#include <QMessageBox>
#include <QtPlugin>
+#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
+#include <QAbstractNativeEventFilter>
+#endif
//CRT
#include <string.h>
// MESSAGE HANDLER
///////////////////////////////////////////////////////////////////////////////
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
static void qt_message_handler(QtMsgType type, const char *const msg)
{
- if((!msg) || (!(msg[0])))
+ if (msg && msg[0])
{
- return;
+ MUtils::Terminal::write(type, msg);
+ if ((type == QtCriticalMsg) || (type == QtFatalMsg))
+ {
+ MUtils::OS::fatal_exit(MUTILS_WCHR(QString::fromUtf8(msg)));
+ }
}
-
- MUtils::Terminal::write(type, msg);
-
- if((type == QtCriticalMsg) || (type == QtFatalMsg))
+}
+#else
+#define qInstallMsgHandler(X) qInstallMessageHandler((X))
+static void qt_message_handler(QtMsgType type, const QMessageLogContext&, const QString &msg)
+{
+ if (!msg.isEmpty())
{
- MUtils::OS::fatal_exit(MUTILS_WCHR(QString::fromUtf8(msg)));
+ MUtils::Terminal::write(type, msg.toUtf8().constData());
+ if ((type == QtCriticalMsg) || (type == QtFatalMsg))
+ {
+ MUtils::OS::fatal_exit(MUTILS_WCHR(msg));
+ }
}
}
+#endif
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
static bool qt_event_filter(void *message, long *result)
{
return MUtils::OS::handle_os_message(message, result);
}
+#else
+namespace MUtils
+{
+ namespace Startup
+ {
+ namespace Internal
+ {
+ class NativeEventFilter : public QAbstractNativeEventFilter
+ {
+ public:
+ bool nativeEventFilter(const QByteArray&, void *message, long *result) Q_DECL_OVERRIDE
+ {
+ return MUtils::OS::handle_os_message(message, result);
+ };
+ };
+ }
+ }
+}
+static QScopedPointer<MUtils::Startup::Internal::NativeEventFilter> qt_event_filter;
+#endif
///////////////////////////////////////////////////////////////////////////////
// STARTUP FUNCTION
//Check Qt version
#ifdef QT_BUILD_KEY
qDebug("Using Qt v%s [%s], %s, %s", qVersion(), QLibraryInfo::buildDate().toString(Qt::ISODate).toLatin1().constData(), (qSharedBuild() ? "DLL" : "Static"), QLibraryInfo::buildKey().toLatin1().constData());
- qDebug("Compiled with Qt v%s [%s], %s\n", QT_VERSION_STR, QT_PACKAGEDATE_STR, QT_BUILD_KEY);
+ qDebug("Compiled with Qt v%s, %s\n", QT_VERSION_STR, QT_BUILD_KEY);
if(_stricmp(qVersion(), QT_VERSION_STR))
{
qFatal("%s", QApplication::tr("Executable '%1' requires Qt v%2, but found Qt v%3.").arg(executableName, QString::fromLatin1(QT_VERSION_STR), QString::fromLatin1(qVersion())).toLatin1().constData());
}
#else
qDebug("Using Qt v%s [%s], %s", qVersion(), QLibraryInfo::buildDate().toString(Qt::ISODate).toLatin1().constData(), (qSharedBuild() ? "DLL" : "Static"));
- qDebug("Compiled with Qt v%s [%s]\n", QT_VERSION_STR, QT_PACKAGEDATE_STR);
+ qDebug("Compiled with Qt v%s\n", QT_VERSION_STR);
#endif
//Check the Windows version
application->setApplicationName(appName);
application->setOrganizationName("LoRd_MuldeR");
application->setOrganizationDomain("mulder.at.gg");
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
application->setEventFilter(qt_event_filter);
+#else
+ qt_event_filter.reset(new Internal::NativeEventFilter);
+ application->installNativeEventFilter(qt_event_filter.data());
+#endif
//Check for supported image formats
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
+//Internal
+#include "Utils_Win32.h"
+
//Qt
#include <QWidget>
#include <QIcon>
+#if QT_VERSION > QT_VERSION_CHECK(5,0,0)
+#include <QtWinExtras>
+#endif
//Windows includes
#define NOMINMAX
HRESULT result = HRESULT(-1);
if(icon)
{
- if(const HICON hIcon = icon->pixmap(16,16).toWinHICON())
+ if(const HICON hIcon = (HICON)MUtils::Win32Utils::qicon_to_hicon(icon, 16, 16))
{
- result = p->taskbarList->SetOverlayIcon(m_window->winId(), hIcon, MUTILS_WCHR(info));
+ result = p->taskbarList->SetOverlayIcon(reinterpret_cast<HWND>(m_window->winId()), hIcon, MUTILS_WCHR(info));
DestroyIcon(hIcon);
}
}
else
{
- result = p->taskbarList->SetOverlayIcon(m_window->winId(), NULL, MUTILS_WCHR(info));
+ result = p->taskbarList->SetOverlayIcon(reinterpret_cast<HWND>(m_window->winId()), NULL, MUTILS_WCHR(info));
}
return SUCCEEDED(result);
}
if(g_terminal_attached && (!(icon.isNull() || MUtils::OS::running_on_wine())))
{
- if(const HICON hIcon = (HICON) MUtils::Win32Utils::qicon_to_hicon(icon, 16, 16))
+ if(const HICON hIcon = (HICON) MUtils::Win32Utils::qicon_to_hicon(&icon, 16, 16))
{
typedef BOOL(__stdcall *SetConsoleIconFun)(HICON);
bool success = false;
#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;
{
namespace Win32Utils
{
- uintptr_t qicon_to_hicon(const QIcon &icon, const int w, const int h);
+ uintptr_t qicon_to_hicon(const QIcon *const icon, const int w, const int h);
const uintptr_t &resolve_helper(const QString &libraryName, const QString &functionName);
template<class T>