Don't try to initialize ITaskbarList3 on systems prior to Windows 7.
This commit is contained in:
parent
d35ed2eb1b
commit
6fd1b4f721
@ -52,28 +52,27 @@ namespace MUtils
|
|||||||
unsigned int versionMinor;
|
unsigned int versionMinor;
|
||||||
bool overrideFlag;
|
bool overrideFlag;
|
||||||
|
|
||||||
//comparision operators
|
MUTILS_API bool operator== (const _os_info_t &rhs) const;
|
||||||
inline bool operator== (const _os_info_t &rhs) const { return (type == rhs.type) && (versionMajor == rhs.versionMajor) && ((versionMinor == rhs.versionMinor)); }
|
MUTILS_API bool operator!= (const _os_info_t &rhs) const;
|
||||||
inline bool operator!= (const _os_info_t &rhs) const { return (type != rhs.type) || (versionMajor != rhs.versionMajor) || ((versionMinor != rhs.versionMinor)); }
|
MUTILS_API bool operator> (const _os_info_t &rhs) const;
|
||||||
inline bool operator> (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor))); }
|
MUTILS_API bool operator>= (const _os_info_t &rhs) const;
|
||||||
inline bool operator>= (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor))); }
|
MUTILS_API bool operator< (const _os_info_t &rhs) const;
|
||||||
inline bool operator< (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor))); }
|
MUTILS_API bool operator<= (const _os_info_t &rhs) const;
|
||||||
inline bool operator<= (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor))); }
|
|
||||||
}
|
}
|
||||||
os_version_t;
|
os_version_t;
|
||||||
|
|
||||||
//Known Windows NT versions
|
//Known Windows NT versions
|
||||||
static const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5, 0 }; // 2000
|
MUTILS_API extern const os_version_t WINDOWS_WIN2K; // 2000
|
||||||
static const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5, 1 }; // XP
|
MUTILS_API extern const os_version_t WINDOWS_WINXP; // XP
|
||||||
static const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5, 2 }; // XP_x64
|
MUTILS_API extern const os_version_t WINDOWS_XPX64; // XP_x64
|
||||||
static const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6, 0 }; // Vista
|
MUTILS_API extern const os_version_t WINDOWS_VISTA; // Vista
|
||||||
static const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6, 1 }; // 7
|
MUTILS_API extern const os_version_t WINDOWS_WIN70; // 7
|
||||||
static const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6, 2 }; // 8
|
MUTILS_API extern const os_version_t WINDOWS_WIN80; // 8
|
||||||
static const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6, 3 }; // 8.1
|
MUTILS_API extern const os_version_t WINDOWS_WIN81; // 8.1
|
||||||
static const os_version_t WINDOWS_WN100 = { OS_WINDOWS, 6, 4 }; // 10
|
MUTILS_API extern const os_version_t WINDOWS_WN100; // 10
|
||||||
|
|
||||||
//Unknown OS
|
//Unknown OS
|
||||||
static const os_version_t UNKNOWN_OPSYS = { OS_UNKNOWN, 0, 0 }; // N/A
|
MUTILS_API extern const os_version_t UNKNOWN_OPSYS; // N/A
|
||||||
}
|
}
|
||||||
|
|
||||||
//Known Folders IDs
|
//Known Folders IDs
|
||||||
|
@ -140,6 +140,37 @@ g_os_version_lut[] =
|
|||||||
{ MUtils::OS::Version::UNKNOWN_OPSYS, "N/A" }
|
{ MUtils::OS::Version::UNKNOWN_OPSYS, "N/A" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//OS version data dtructures
|
||||||
|
namespace MUtils
|
||||||
|
{
|
||||||
|
namespace OS
|
||||||
|
{
|
||||||
|
namespace Version
|
||||||
|
{
|
||||||
|
//Comparision operators for os_version_t
|
||||||
|
bool os_version_t::operator== (const os_version_t &rhs) const { return (type == rhs.type) && (versionMajor == rhs.versionMajor) && ((versionMinor == rhs.versionMinor)); }
|
||||||
|
bool os_version_t::operator!= (const os_version_t &rhs) const { return (type != rhs.type) || (versionMajor != rhs.versionMajor) || ((versionMinor != rhs.versionMinor)); }
|
||||||
|
bool os_version_t::operator> (const os_version_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor))); }
|
||||||
|
bool os_version_t::operator>= (const os_version_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor))); }
|
||||||
|
bool os_version_t::operator< (const os_version_t &rhs) const { return (type == rhs.type) && ((versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor))); }
|
||||||
|
bool os_version_t::operator<= (const os_version_t &rhs) const { return (type == rhs.type) && ((versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor))); }
|
||||||
|
|
||||||
|
//Known Windows NT versions
|
||||||
|
const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5, 0 }; // 2000
|
||||||
|
const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5, 1 }; // XP
|
||||||
|
const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5, 2 }; // XP_x64
|
||||||
|
const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6, 0 }; // Vista
|
||||||
|
const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6, 1 }; // 7
|
||||||
|
const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6, 2 }; // 8
|
||||||
|
const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6, 3 }; // 8.1
|
||||||
|
const os_version_t WINDOWS_WN100 = { OS_WINDOWS, 6, 4 }; // 10
|
||||||
|
|
||||||
|
//Unknown OS
|
||||||
|
const os_version_t UNKNOWN_OPSYS = { OS_UNKNOWN, 0, 0 }; // N/A
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool verify_os_version(const DWORD major, const DWORD minor)
|
static bool verify_os_version(const DWORD major, const DWORD minor)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEXW osvi;
|
OSVERSIONINFOEXW osvi;
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Internal
|
//MUtils
|
||||||
#include <MUtils/Taskbar7.h>
|
#include <MUtils/Taskbar7.h>
|
||||||
|
#include <MUtils/OSSupport.h>
|
||||||
#include <MUtils/Exception.h>
|
#include <MUtils/Exception.h>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
@ -40,7 +41,11 @@
|
|||||||
|
|
||||||
#define INITIALIZE_TASKBAR() do \
|
#define INITIALIZE_TASKBAR() do \
|
||||||
{ \
|
{ \
|
||||||
if(!initialize()) \
|
if(!p->supported) \
|
||||||
|
{ \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
if(!(p->initialized || initialize())) \
|
||||||
{ \
|
{ \
|
||||||
qWarning("Taskbar initialization failed!"); \
|
qWarning("Taskbar initialization failed!"); \
|
||||||
return false; \
|
return false; \
|
||||||
@ -59,7 +64,15 @@ namespace MUtils
|
|||||||
friend class Taskbar7;
|
friend class Taskbar7;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Taskbar7_Private(void)
|
||||||
|
{
|
||||||
|
taskbarList = NULL;
|
||||||
|
supported = false;
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
ITaskbarList3 *taskbarList;
|
ITaskbarList3 *taskbarList;
|
||||||
|
volatile bool supported;
|
||||||
volatile bool initialized;
|
volatile bool initialized;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -73,13 +86,14 @@ MUtils::Taskbar7::Taskbar7(QWidget *const window)
|
|||||||
p(new Taskbar7_Private()),
|
p(new Taskbar7_Private()),
|
||||||
m_window(window)
|
m_window(window)
|
||||||
{
|
{
|
||||||
p->taskbarList = NULL;
|
|
||||||
p->initialized = false;
|
|
||||||
|
|
||||||
if(!m_window)
|
if(!m_window)
|
||||||
{
|
{
|
||||||
MUTILS_THROW("Taskbar7: Window pointer must not be NULL!");
|
MUTILS_THROW("Taskbar7: Window pointer must not be NULL!");
|
||||||
}
|
}
|
||||||
|
if(!(p->supported = (OS::os_version() >= OS::Version::WINDOWS_WIN70)))
|
||||||
|
{
|
||||||
|
qWarning("Taskbar7: Taskbar progress not supported on this platform.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MUtils::Taskbar7::~Taskbar7(void)
|
MUtils::Taskbar7::~Taskbar7(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user