Minor improvements

1. QScopedPointer's get() function was introduced in Qt 5.11, too new, don't use it, use data() instead. They are the same.
2. Fixed a typo.
3. Use QGuiApplication::isRightToLeft() to simplify the code.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-03-20 11:19:10 +08:00
parent b62dabcc68
commit 42ee3f8a91
3 changed files with 8 additions and 8 deletions

View File

@ -106,7 +106,7 @@ static inline void setup()
{
if (g_instance.isNull()) {
g_instance.reset(new FramelessHelperWin);
qApp->installNativeEventFilter(g_instance.get());
qApp->installNativeEventFilter(g_instance.data());
}
}
@ -127,7 +127,7 @@ FramelessHelperWin::FramelessHelperWin() = default;
FramelessHelperWin::~FramelessHelperWin()
{
if (!g_instance.isNull()) {
qApp->removeNativeEventFilter(g_instance.get());
qApp->removeNativeEventFilter(g_instance.data());
}
}

View File

@ -65,14 +65,14 @@ void QtAcrylicWinEventFilter::setup()
{
if (g_instance.isNull()) {
g_instance.reset(new QtAcrylicWinEventFilter);
qApp->installNativeEventFilter(g_instance.get());
qApp->installNativeEventFilter(g_instance.data());
}
}
void QtAcrylicWinEventFilter::unsetup()
{
if (!g_instance.isNull()) {
qApp->removeNativeEventFilter(g_instance.get());
qApp->removeNativeEventFilter(g_instance.data());
g_instance.reset();
}
}
@ -118,8 +118,8 @@ bool QtAcrylicWinEventFilter::nativeEventFilter(const QByteArray &eventType, voi
if (shouldUpdate) {
const QWindow *window = Utilities::findWindow(reinterpret_cast<WId>(msg->hwnd));
if (window) {
const QScopedPointer<QEvent> updateEvent(new QtAcrylicWinUpdateEvent(shouldClearWallpaper));
QCoreApplication::sendEvent(const_cast<QWindow *>(window), updateEvent.get());
QtAcrylicWinUpdateEvent event(shouldClearWallpaper);
QCoreApplication::sendEvent(const_cast<QWindow *>(window), &event);
}
}
return false;

View File

@ -390,7 +390,7 @@ bool Utilities::isDarkThemeEnabled()
// We can't use ShouldAppsUseDarkMode due to the following reason:
// it's not exported publicly so we can only load it dynamically through its ordinal name,
// however, its ordinal name has changed in some unknown system versions so we can't find
// the actually function now. But ShouldSystemUseDarkMode is not affected, we can still
// the actual function now. But ShouldSystemUseDarkMode is not affected, we can still
// use it in the latest version of Windows.
if (win32Data()->ShouldSystemUseDarkModePFN) {
return win32Data()->ShouldSystemUseDarkModePFN();
@ -771,7 +771,7 @@ void Utilities::displaySystemMenu(const QWindow *window, const QPoint &pos)
if (isMin) {
SetMenuItemInfoW(hMenu, SC_MINIMIZE, FALSE, &mii);
}
const bool isRtl = QGuiApplication::layoutDirection() == Qt::RightToLeft;
const bool isRtl = QGuiApplication::isRightToLeft();
const QPoint point = pos.isNull() ? QCursor::pos(window->screen()) : window->mapToGlobal(pos);
const LPARAM cmd = TrackPopupMenu(hMenu,
(TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_TOPALIGN |