some minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
524f65cc9b
commit
2c93d7fe38
|
@ -25,7 +25,7 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(FramelessHelper
|
project(FramelessHelper
|
||||||
VERSION 2.3.3.0
|
VERSION 2.4.0.0
|
||||||
DESCRIPTION "Cross-platform window customization framework for Qt Widgets and Qt Quick."
|
DESCRIPTION "Cross-platform window customization framework for Qt Widgets and Qt Quick."
|
||||||
HOMEPAGE_URL "https://github.com/wangwenx190/framelesshelper/"
|
HOMEPAGE_URL "https://github.com/wangwenx190/framelesshelper/"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
|
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 3;
|
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 4;
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 3;
|
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 0;
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
|
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.3.3.0\0";
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.4.0.0\0";
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN\0";
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN\0";
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN\0";
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN\0";
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ function(setup_compile_params arg_target)
|
||||||
#QT_TYPESAFE_FLAGS # QtQuick private headers prevent us from enabling this flag.
|
#QT_TYPESAFE_FLAGS # QtQuick private headers prevent us from enabling this flag.
|
||||||
QT_USE_QSTRINGBUILDER
|
QT_USE_QSTRINGBUILDER
|
||||||
QT_USE_FAST_OPERATOR_PLUS
|
QT_USE_FAST_OPERATOR_PLUS
|
||||||
|
#QT_STRICT_ITERATORS # Need Qt itself also compile with this flag enabled.
|
||||||
QT_DEPRECATED_WARNINGS # Have no effect since 6.0
|
QT_DEPRECATED_WARNINGS # Have no effect since 6.0
|
||||||
QT_DEPRECATED_WARNINGS_SINCE=0x070000
|
QT_DEPRECATED_WARNINGS_SINCE=0x070000
|
||||||
QT_WARN_DEPRECATED_UP_TO=0x070000 # Since 6.5
|
QT_WARN_DEPRECATED_UP_TO=0x070000 # Since 6.5
|
||||||
|
@ -52,16 +53,22 @@ function(setup_compile_params arg_target)
|
||||||
target_compile_definitions(${arg_target} PRIVATE
|
target_compile_definitions(${arg_target} PRIVATE
|
||||||
_CRT_NON_CONFORMING_SWPRINTFS _CRT_SECURE_NO_WARNINGS
|
_CRT_NON_CONFORMING_SWPRINTFS _CRT_SECURE_NO_WARNINGS
|
||||||
_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
|
_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
|
||||||
_CRT_NONSTDC_NO_DEPRECATE _ENABLE_EXTENDED_ALIGNED_STORAGE
|
_CRT_NONSTDC_NO_DEPRECATE _SCL_SECURE_NO_WARNINGS
|
||||||
NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN
|
_SCL_SECURE_NO_DEPRECATE _ENABLE_EXTENDED_ALIGNED_STORAGE
|
||||||
|
_USE_MATH_DEFINES NOMINMAX UNICODE _UNICODE
|
||||||
|
WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN
|
||||||
)
|
)
|
||||||
target_compile_options(${arg_target} PRIVATE
|
target_compile_options(${arg_target} PRIVATE
|
||||||
/utf-8 /W3 /WX # Can't use /W4 here, Qt's own headers are not warning-clean, especially QtQuick headers. /W4 will trigger too many warnings.
|
/options:strict # Don't allow unknown parameters.
|
||||||
|
/permissive- # Make sure we always write standard code.
|
||||||
|
/utf-8
|
||||||
|
/W3 # Can't use /W4 here, Qt's own headers are not warning-clean, especially QtQuick headers. /W4 will trigger too many warnings.
|
||||||
|
/WX # Make sure we don't ignore any warnings.
|
||||||
$<$<CONFIG:Debug>:/JMC>
|
$<$<CONFIG:Debug>:/JMC>
|
||||||
$<$<NOT:$<CONFIG:Debug>>:/guard:cf /Gw /Gy /QIntel-jcc-erratum /Zc:inline> # /guard:ehcont? /Qspectre-load?
|
$<$<NOT:$<CONFIG:Debug>>:/guard:cf /Gw /Gy /QIntel-jcc-erratum /Zc:inline> # /guard:ehcont? /Qspectre-load?
|
||||||
)
|
)
|
||||||
target_link_options(${arg_target} PRIVATE
|
target_link_options(${arg_target} PRIVATE
|
||||||
/WX # Make sure we don't use wrong parameters.
|
/WX # Don't allow unknown parameters.
|
||||||
$<$<NOT:$<CONFIG:Debug>>:/CETCOMPAT /GUARD:CF /OPT:REF /OPT:ICF> # /GUARD:EHCONT?
|
$<$<NOT:$<CONFIG:Debug>>:/CETCOMPAT /GUARD:CF /OPT:REF /OPT:ICF> # /GUARD:EHCONT?
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -1004,8 +1004,8 @@ static inline void moveWindowToMonitor(const HWND hwnd, const MONITORINFOEXW &ac
|
||||||
WARNING << Utils::getSystemErrorMessage(kGetWindowRect);
|
WARNING << Utils::getSystemErrorMessage(kGetWindowRect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int currentWindowWidth = qAbs(currentWindowRect.right - currentWindowRect.left);
|
const int currentWindowWidth = currentWindowRect.right - currentWindowRect.left;
|
||||||
const int currentWindowHeight = qAbs(currentWindowRect.bottom - currentWindowRect.top);
|
const int currentWindowHeight = currentWindowRect.bottom - currentWindowRect.top;
|
||||||
const int currentWindowOffsetX = (currentWindowRect.left - currentMonitorRect.left);
|
const int currentWindowOffsetX = (currentWindowRect.left - currentMonitorRect.left);
|
||||||
const int currentWindowOffsetY = (currentWindowRect.top - currentMonitorRect.top);
|
const int currentWindowOffsetY = (currentWindowRect.top - currentMonitorRect.top);
|
||||||
const int newWindowX = activeMonitorRect.left + currentWindowOffsetX;
|
const int newWindowX = activeMonitorRect.left + currentWindowOffsetX;
|
||||||
|
@ -2853,7 +2853,7 @@ void Utils::bringWindowToFront(const WId windowId)
|
||||||
const auto hwnd = reinterpret_cast<HWND>(windowId);
|
const auto hwnd = reinterpret_cast<HWND>(windowId);
|
||||||
const HWND oldForegroundWindow = GetForegroundWindow();
|
const HWND oldForegroundWindow = GetForegroundWindow();
|
||||||
if (!oldForegroundWindow) {
|
if (!oldForegroundWindow) {
|
||||||
WARNING << getSystemErrorMessage(kGetForegroundWindow);
|
// The foreground window can be NULL, it's not an API error.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const std::optional<MONITORINFOEXW> activeMonitor = getMonitorForWindow(oldForegroundWindow);
|
const std::optional<MONITORINFOEXW> activeMonitor = getMonitorForWindow(oldForegroundWindow);
|
||||||
|
|
|
@ -391,25 +391,21 @@ void FramelessQuickHelperPrivate::bringWindowToFront()
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto bringWindowToFront_impl = [window]() -> void {
|
|
||||||
if (window->visibility() == QQuickWindow::Hidden) {
|
|
||||||
window->show();
|
|
||||||
}
|
|
||||||
if (window->visibility() == QQuickWindow::Minimized) {
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
|
||||||
window->setWindowStates(window->windowStates() & ~Qt::WindowMinimized);
|
|
||||||
#else
|
|
||||||
window->showNormal();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
window->raise();
|
|
||||||
window->requestActivate();
|
|
||||||
};
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Q_UNUSED(bringWindowToFront_impl);
|
|
||||||
Utils::bringWindowToFront(window->winId());
|
Utils::bringWindowToFront(window->winId());
|
||||||
#else
|
#else
|
||||||
bringWindowToFront_impl();
|
if (window->visibility() == QQuickWindow::Hidden) {
|
||||||
|
window->show();
|
||||||
|
}
|
||||||
|
if (window->visibility() == QQuickWindow::Minimized) {
|
||||||
|
# if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
window->setWindowStates(window->windowStates() & ~Qt::WindowMinimized);
|
||||||
|
# else
|
||||||
|
window->showNormal();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
window->raise();
|
||||||
|
window->requestActivate();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -780,21 +780,17 @@ void FramelessWidgetsHelperPrivate::bringWindowToFront()
|
||||||
if (!m_window) {
|
if (!m_window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto bringWindowToFront_impl = [this]() -> void {
|
|
||||||
if (m_window->isHidden()) {
|
|
||||||
m_window->show();
|
|
||||||
}
|
|
||||||
if (m_window->isMinimized()) {
|
|
||||||
m_window->setWindowState(m_window->windowState() & ~Qt::WindowMinimized);
|
|
||||||
}
|
|
||||||
m_window->raise();
|
|
||||||
m_window->activateWindow();
|
|
||||||
};
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Q_UNUSED(bringWindowToFront_impl);
|
|
||||||
Utils::bringWindowToFront(m_window->winId());
|
Utils::bringWindowToFront(m_window->winId());
|
||||||
#else
|
#else
|
||||||
bringWindowToFront_impl();
|
if (m_window->isHidden()) {
|
||||||
|
m_window->show();
|
||||||
|
}
|
||||||
|
if (m_window->isMinimized()) {
|
||||||
|
m_window->setWindowState(m_window->windowState() & ~Qt::WindowMinimized);
|
||||||
|
}
|
||||||
|
m_window->raise();
|
||||||
|
m_window->activateWindow();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue