diff --git a/include/MUtils/OSSupport.h b/include/MUtils/OSSupport.h index 7db9988..9dbb359 100644 --- a/include/MUtils/OSSupport.h +++ b/include/MUtils/OSSupport.h @@ -52,28 +52,27 @@ namespace MUtils unsigned int versionMinor; bool overrideFlag; - //comparision operators - inline bool operator== (const _os_info_t &rhs) const { return (type == rhs.type) && (versionMajor == rhs.versionMajor) && ((versionMinor == rhs.versionMinor)); } - inline bool operator!= (const _os_info_t &rhs) const { return (type != rhs.type) || (versionMajor != rhs.versionMajor) || ((versionMinor != rhs.versionMinor)); } - inline bool operator> (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor))); } - inline bool operator>= (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor))); } - inline bool operator< (const _os_info_t &rhs) const { return (type == rhs.type) && ((versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor))); } - 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; + MUTILS_API bool operator!= (const _os_info_t &rhs) const; + MUTILS_API bool operator> (const _os_info_t &rhs) const; + MUTILS_API bool operator>= (const _os_info_t &rhs) const; + MUTILS_API bool operator< (const _os_info_t &rhs) const; + MUTILS_API bool operator<= (const _os_info_t &rhs) const; } os_version_t; //Known Windows NT versions - static const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5, 0 }; // 2000 - static const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5, 1 }; // XP - static const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5, 2 }; // XP_x64 - static const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6, 0 }; // Vista - static const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6, 1 }; // 7 - static const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6, 2 }; // 8 - static const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6, 3 }; // 8.1 - static const os_version_t WINDOWS_WN100 = { OS_WINDOWS, 6, 4 }; // 10 + MUTILS_API extern const os_version_t WINDOWS_WIN2K; // 2000 + MUTILS_API extern const os_version_t WINDOWS_WINXP; // XP + MUTILS_API extern const os_version_t WINDOWS_XPX64; // XP_x64 + MUTILS_API extern const os_version_t WINDOWS_VISTA; // Vista + MUTILS_API extern const os_version_t WINDOWS_WIN70; // 7 + MUTILS_API extern const os_version_t WINDOWS_WIN80; // 8 + MUTILS_API extern const os_version_t WINDOWS_WIN81; // 8.1 + MUTILS_API extern const os_version_t WINDOWS_WN100; // 10 //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 diff --git a/src/OSSupport_Win32.cpp b/src/OSSupport_Win32.cpp index f47590d..d67ba16 100644 --- a/src/OSSupport_Win32.cpp +++ b/src/OSSupport_Win32.cpp @@ -140,6 +140,37 @@ g_os_version_lut[] = { 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) { OSVERSIONINFOEXW osvi; diff --git a/src/Taskbar7_Win32.cpp b/src/Taskbar7_Win32.cpp index d86bd53..9b8501d 100644 --- a/src/Taskbar7_Win32.cpp +++ b/src/Taskbar7_Win32.cpp @@ -20,8 +20,9 @@ // http://www.gnu.org/licenses/gpl-2.0.txt /////////////////////////////////////////////////////////////////////////////// -//Internal +//MUtils #include +#include #include //Qt @@ -40,7 +41,11 @@ #define INITIALIZE_TASKBAR() do \ { \ - if(!initialize()) \ + if(!p->supported) \ + { \ + return false; \ + } \ + if(!(p->initialized || initialize())) \ { \ qWarning("Taskbar initialization failed!"); \ return false; \ @@ -59,7 +64,15 @@ namespace MUtils friend class Taskbar7; protected: + Taskbar7_Private(void) + { + taskbarList = NULL; + supported = false; + initialized = false; + } + ITaskbarList3 *taskbarList; + volatile bool supported; volatile bool initialized; }; } @@ -73,13 +86,14 @@ MUtils::Taskbar7::Taskbar7(QWidget *const window) p(new Taskbar7_Private()), m_window(window) { - p->taskbarList = NULL; - p->initialized = false; - if(!m_window) { 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)