chengxr 1 жил өмнө
parent
commit
fc853dc5d6

+ 17 - 17
QFD/view/MainWindow.h

@@ -85,25 +85,25 @@ private slots:
     void userViewClicked();
 
 private:
-    CustomTitleBar *m_titleBar;
+    CustomTitleBar *m_titleBar = 0;
 
-    QStackedWidget *m_mainStackedWidget;
+    QStackedWidget *m_mainStackedWidget = 0;
 
-    LoginView *m_loginView;
+    LoginView *m_loginView = 0;
 
-    QWidget *m_mainWidget;
-    QHBoxLayout *m_hBoxLayout;
-    QHBoxLayout *m_widgetLayout;
-    StackedWidget *m_stackWidget;
-    NavigationInterface *m_naviInterface;
-
-    HomeView *m_homeView;
-    ProjectView *m_projectView;
-    ExpertManageView *m_expertManageView;
-    EvaluateView *m_evaluateView;
-
-    AboutView *m_aboutView;
-    SettingView *m_settingView;
-    UserView *m_userView;
+    QWidget *m_mainWidget                = 0;
+    QHBoxLayout *m_hBoxLayout            = 0;
+    QHBoxLayout *m_widgetLayout          = 0;
+    StackedWidget *m_stackWidget         = 0;
+    NavigationInterface *m_naviInterface = 0;
+
+    HomeView *m_homeView                 = 0;
+    ProjectView *m_projectView           = 0;
+    ExpertManageView *m_expertManageView = 0;
+    EvaluateView *m_evaluateView         = 0;
+
+    AboutView *m_aboutView     = 0;
+    SettingView *m_settingView = 0;
+    UserView *m_userView       = 0;
 };
 #endif  // MAINWINDOW_H

+ 1 - 0
QFD/widgets/ProjectStateWidget.cpp

@@ -6,6 +6,7 @@
 #include <QHeaderView>
 #include <QBoxLayout>
 #include <QDateTime>
+#include <math.h>
 
 #include <QDebug>
 

+ 2 - 0
QFluentWidgets/Common/SmoothScroll.h

@@ -3,6 +3,8 @@
 
 #include <QQueue>
 #include <QScrollArea>
+#include <QWheelEvent>
+#include <QTimer>
 
 enum SmoothMode
 {

+ 1 - 0
QFluentWidgets/Widgets/Button.h

@@ -1,6 +1,7 @@
 #ifndef BUTTON_H
 #define BUTTON_H
 
+#include "Common/Icon.h"
 #include <QPushButton>
 #include <QRadioButton>
 #include <QToolButton>

+ 1 - 0
QFluentWidgets/Widgets/Menu.h

@@ -1,6 +1,7 @@
 #ifndef MENU_H
 #define MENU_H
 
+#include <Common/SmoothScroll.h>
 #include <QMenu>
 #include <QListWidget>
 #include <QProxyStyle>

+ 1 - 0
QFluentWidgets/Widgets/Slider.h

@@ -4,6 +4,7 @@
 #include <QMap>
 #include <QProxyStyle>
 #include <QSlider>
+#include <QVariant>
 
 class Slider : public QSlider
 {

+ 190 - 187
QFramelessWindow/utils/Win32Utils.cpp

@@ -3,147 +3,150 @@
 #include <QWindow>
 #include <QtWin>
 
-namespace Win32Utils
-{
+namespace Win32Utils {
 
-    bool isMaximized(HWND hWnd)
-    {
-        WINDOWPLACEMENT wPos;
-        BOOL windowPlacement = GetWindowPlacement(hWnd, &wPos);
-        if (!windowPlacement)
-            return false;
-        return wPos.showCmd == SW_MAXIMIZE;
-    }
+bool isMaximized(HWND hWnd)
+{
+    WINDOWPLACEMENT wPos;
+    BOOL windowPlacement = GetWindowPlacement(hWnd, &wPos);
+    if (!windowPlacement)
+        return false;
+    return wPos.showCmd == SW_MAXIMIZE;
+}
 
-    bool isFullScreen(HWND hWnd)
-    {
-        if (!hWnd)
-            return false;
+bool isFullScreen(HWND hWnd)
+{
+    if (!hWnd)
+        return false;
 
-        RECT winRect;
-        if (!GetWindowRect(hWnd, &winRect)) {
-            return false;
-        }
+    RECT winRect;
+    if (!GetWindowRect(hWnd, &winRect)) {
+        return false;
+    }
 
-        MONITORINFO mi = { sizeof(mi) };
-        if (!getMonitorInfo(hWnd, MONITOR_DEFAULTTOPRIMARY, &mi)) {
-            return false;
-        }
+    MONITORINFO mi = { sizeof(mi) };
+    if (!getMonitorInfo(hWnd, MONITOR_DEFAULTTOPRIMARY, &mi)) {
+        return false;
+    }
 
-        return (mi.rcMonitor.left == winRect.left) && (mi.rcMonitor.right == winRect.right)
-                && (mi.rcMonitor.bottom == winRect.bottom) && (mi.rcMonitor.top == winRect.top);
+    return (mi.rcMonitor.left == winRect.left) && (mi.rcMonitor.right == winRect.right)
+            && (mi.rcMonitor.bottom == winRect.bottom) && (mi.rcMonitor.top == winRect.top);
+}
+
+/**
+ * @brief getMonitorInfo
+ * @param hWnd: window handle
+ * @param dwFlags: Determines the return value if the window does not intersect any display monitor
+ * @param lpmi
+ * @return
+ */
+bool getMonitorInfo(HWND hWnd, DWORD dwFlags, LPMONITORINFO lpmi)
+{
+    HMONITOR monitor = MonitorFromWindow(hWnd, dwFlags);
+    if (!monitor) {
+        return false;
     }
 
-    /**
-     * @brief getMonitorInfo
-     * @param hWnd: window handle
-     * @param dwFlags: Determines the return value if the window does not intersect any display monitor
-     * @param lpmi
-     * @return
-     */
-    bool getMonitorInfo(HWND hWnd, DWORD dwFlags, LPMONITORINFO lpmi)
-    {
-        HMONITOR monitor = MonitorFromWindow(hWnd, dwFlags);
-        if (!monitor) {
-            return false;
-        }
+    return GetMonitorInfo(monitor, lpmi);
+}
 
-        return GetMonitorInfo(monitor, lpmi);
+/**
+ * @brief getResizeBorderThickness
+ * @param hWnd: window handle
+ * @param horizontal: (dpiScale) whether to use dpi scale
+ * @return
+ */
+int getResizeBorderThickness(HWND hWnd, bool horizontal)
+{
+    QWindow *window = findWindow(hWnd);
+    if (!window) {
+        return 0;
     }
 
-    /**
-     * @brief getResizeBorderThickness
-     * @param hWnd: window handle
-     * @param horizontal: (dpiScale) whether to use dpi scale
-     * @return
-     */
-    int getResizeBorderThickness(HWND hWnd, bool horizontal)
-    {
-        QWindow *window = findWindow(hWnd);
-        if (!window) {
-            return 0;
-        }
+    int frame = SM_CXSIZEFRAME;
+    if (!horizontal) {
+        frame = SM_CYSIZEFRAME;
+    }
 
-        int frame = SM_CXSIZEFRAME;
-        if (!horizontal) {
-            frame = SM_CYSIZEFRAME;
-        }
+#ifdef Q_CC_MSVC
 
-        UINT dpi = GetDpiForWindow(hWnd);
+    UINT dpi = GetDpiForWindow(hWnd);
 
-        int result = GetSystemMetricsForDpi(frame, dpi) + GetSystemMetricsForDpi(92, dpi);
+    int result = GetSystemMetricsForDpi(frame, dpi) + GetSystemMetricsForDpi(92, dpi);
 
-        if (result > 0)
-            return result;
+    if (result > 0)
+        return result;
 
-        int thickness;
-        if (QtWin::isCompositionEnabled()) {
-            thickness = 8;
-        } else {
-            thickness = 4;
-        }
+#endif
 
-        return qRound(thickness * window->devicePixelRatio());
+    int thickness;
+    if (QtWin::isCompositionEnabled()) {
+        thickness = 8;
+    } else {
+        thickness = 4;
     }
 
-    QWindow *findWindow(HWND hWnd)
-    {
-        if (!hWnd) {
-            return nullptr;
-        }
-
-        QWindowList windows = QGuiApplication::topLevelWindows();
-
-        for (auto win : windows) {
-            if (win && (SIZE_T(win->winId()) == SIZE_T(hWnd))) {
-                return win;
-            }
-        }
+    return qRound(thickness * window->devicePixelRatio());
+}
 
+QWindow *findWindow(HWND hWnd)
+{
+    if (!hWnd) {
         return nullptr;
     }
 
-    bool isGreaterEqualVersion(QOperatingSystemVersion version)
-    {
-        return QOperatingSystemVersion::current() >= version;
-    }
+    QWindowList windows = QGuiApplication::topLevelWindows();
 
-    bool isWin7()
-    {
-        return QOperatingSystemVersion::current().majorVersion() == QOperatingSystemVersion::Windows7.majorVersion();
+    for (auto win : windows) {
+        if (win && (SIZE_T(win->winId()) == SIZE_T(hWnd))) {
+            return win;
+        }
     }
 
-    bool isGreaterEqualWin8_1()
-    {
-        return isGreaterEqualVersion(QOperatingSystemVersion::Windows8_1);
-    }
+    return nullptr;
+}
 
-    bool isGreaterEqualWin10()
-    {
-        return isGreaterEqualVersion(QOperatingSystemVersion::Windows10);
-    }
+bool isGreaterEqualVersion(QOperatingSystemVersion version)
+{
+    return QOperatingSystemVersion::current() >= version;
+}
 
-    /**
-     * @brief Win8以后GetVersionEx废弃,操作不正常,用黑魔法实现版本查询
-     * @param lpVersionInformation
-     * @return
-     */
-    BOOL GetVersionEx2(LPOSVERSIONINFOW lpVersionInformation)
-    {
-        HMODULE hNtDll = GetModuleHandle(L"NTDLL");                          // 获取ntdll.dll的句柄
-        typedef NTSTATUS(NTAPI * tRtlGetVersion)(PRTL_OSVERSIONINFOW povi);  // RtlGetVersion的原型
-        tRtlGetVersion pRtlGetVersion = NULL;
-        if (hNtDll) {
-            pRtlGetVersion = (tRtlGetVersion)GetProcAddress(hNtDll, "RtlGetVersion");  // 获取RtlGetVersion地址
-        }
-        if (pRtlGetVersion) {
-            return pRtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation) >= 0;  // 调用RtlGetVersion
-        }
-        return FALSE;
+bool isWin7()
+{
+    return QOperatingSystemVersion::current().majorVersion() == QOperatingSystemVersion::Windows7.majorVersion();
+}
+
+bool isGreaterEqualWin8_1()
+{
+    return isGreaterEqualVersion(QOperatingSystemVersion::Windows8_1);
+}
+
+bool isGreaterEqualWin10()
+{
+    return isGreaterEqualVersion(QOperatingSystemVersion::Windows10);
+}
+
+/**
+ * @brief Win8以后GetVersionEx废弃,操作不正常,用黑魔法实现版本查询
+ * @param lpVersionInformation
+ * @return
+ */
+BOOL GetVersionEx2(LPOSVERSIONINFOW lpVersionInformation)
+{
+    HMODULE hNtDll = GetModuleHandle(L"NTDLL");                          // 获取ntdll.dll的句柄
+    typedef NTSTATUS(NTAPI * tRtlGetVersion)(PRTL_OSVERSIONINFOW povi);  // RtlGetVersion的原型
+    tRtlGetVersion pRtlGetVersion = NULL;
+    if (hNtDll) {
+        pRtlGetVersion = (tRtlGetVersion)GetProcAddress(hNtDll, "RtlGetVersion");  // 获取RtlGetVersion地址
     }
+    if (pRtlGetVersion) {
+        return pRtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation) >= 0;  // 调用RtlGetVersion
+    }
+    return FALSE;
+}
 
-    bool isGreaterEqualWin11()
-    {
+bool isGreaterEqualWin11()
+{
 #if 0
         OSVERSIONINFOW osi;
         osi.dwOSVersionInfoSize = sizeof(osi);
@@ -160,95 +163,95 @@ namespace Win32Utils
         }
         return false;
 #endif
-        QOperatingSystemVersion os = QOperatingSystemVersion::current();
-        if (os.majorVersion() >= 10 && os.microVersion() >= 22000) {
-            return true;
-        }
-
-        return false;
+    QOperatingSystemVersion os = QOperatingSystemVersion::current();
+    if (os.majorVersion() >= 10 && os.microVersion() >= 22000) {
+        return true;
     }
 
-    /**
-     * @brief detect whether the taskbar is hidden automatically
-     * @return
-     */
-    bool Taskbar::isAutoHide()
-    {
-        APPBARDATA appbarData;
-        appbarData.cbSize           = sizeof(APPBARDATA);
-        appbarData.hWnd             = 0;
-        appbarData.uCallbackMessage = 0;
-        appbarData.uEdge            = 0;
-        appbarData.rc               = { 0, 0, 0, 0 };
-        appbarData.lParam           = 0;
-
-        UINT uState = (UINT)SHAppBarMessage(ABM_GETSTATE, &appbarData);
-
-        return uState == ABS_AUTOHIDE;
-    }
-
-    /**
-     * @brief get the position of auto-hide task bar`
-     * @param hWnd
-     * @return
-     */
-    Taskbar::Position Taskbar::getPosition(HWND hWnd)
-    {
-        APPBARDATA appbarData;
-        if (isGreaterEqualWin8_1()) {
-            MONITORINFO mi = { sizeof(mi) };
-            if (!getMonitorInfo(hWnd, MONITOR_DEFAULTTONEAREST, &mi)) {
-                return NO_POSITION;
-            }
-
-            RECT monitor                      = mi.rcMonitor;
-            appbarData                        = APPBARDATA{ sizeof(APPBARDATA), 0, 0, 0, monitor, 0 };
-            const QVector<Position> positions = { LEFT, TOP, RIGHT, BOTTOM };
-            for (auto positon : positions) {
-                appbarData.uEdge = positon;
-                // ABM_GETAUTOHIDEBAREX = 11
-                if (SHAppBarMessage(11, &appbarData)) {
-                    return positon;
-                }
-            }
+    return false;
+}
 
+/**
+ * @brief detect whether the taskbar is hidden automatically
+ * @return
+ */
+bool Taskbar::isAutoHide()
+{
+    APPBARDATA appbarData;
+    appbarData.cbSize           = sizeof(APPBARDATA);
+    appbarData.hWnd             = 0;
+    appbarData.uCallbackMessage = 0;
+    appbarData.uEdge            = 0;
+    appbarData.rc               = { 0, 0, 0, 0 };
+    appbarData.lParam           = 0;
+
+    UINT uState = (UINT)SHAppBarMessage(ABM_GETSTATE, &appbarData);
+
+    return uState == ABS_AUTOHIDE;
+}
+
+/**
+ * @brief get the position of auto-hide task bar`
+ * @param hWnd
+ * @return
+ */
+Taskbar::Position Taskbar::getPosition(HWND hWnd)
+{
+    APPBARDATA appbarData;
+    if (isGreaterEqualWin8_1()) {
+        MONITORINFO mi = { sizeof(mi) };
+        if (!getMonitorInfo(hWnd, MONITOR_DEFAULTTONEAREST, &mi)) {
             return NO_POSITION;
         }
 
-        appbarData = APPBARDATA{ sizeof(APPBARDATA), FindWindow(L"Shell_TrayWnd", NULL), 0, 0, RECT{ 0, 0, 0, 0 }, 0 };
-        if (appbarData.hWnd) {
-            HMONITOR windowMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
-            if (!windowMonitor) {
-                return NO_POSITION;
-            }
-
-            HMONITOR taskbarMonitor = MonitorFromWindow(appbarData.hWnd, MONITOR_DEFAULTTOPRIMARY);
-            if (!taskbarMonitor) {
-                return NO_POSITION;
-            }
-
-            if (windowMonitor == taskbarMonitor) {
-                SHAppBarMessage(ABM_GETTASKBARPOS, &appbarData);
-                return (Position)appbarData.uEdge;
+        RECT monitor                      = mi.rcMonitor;
+        appbarData                        = APPBARDATA { sizeof(APPBARDATA), 0, 0, 0, monitor, 0 };
+        const QVector<Position> positions = { LEFT, TOP, RIGHT, BOTTOM };
+        for (auto positon : positions) {
+            appbarData.uEdge = positon;
+            // ABM_GETAUTOHIDEBAREX = 11
+            if (SHAppBarMessage(11, &appbarData)) {
+                return positon;
             }
         }
 
         return NO_POSITION;
     }
 
-    void WindowsMoveResize::startSystemMove(QWidget *window, QPoint globalPos)
-    {
-        Q_UNUSED(globalPos)
+    appbarData = APPBARDATA { sizeof(APPBARDATA), FindWindow(L"Shell_TrayWnd", NULL), 0, 0, RECT { 0, 0, 0, 0 }, 0 };
+    if (appbarData.hWnd) {
+        HMONITOR windowMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
+        if (!windowMonitor) {
+            return NO_POSITION;
+        }
 
-        ReleaseCapture();
-        SendMessage((HWND)window->winId(), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
-    }
+        HMONITOR taskbarMonitor = MonitorFromWindow(appbarData.hWnd, MONITOR_DEFAULTTOPRIMARY);
+        if (!taskbarMonitor) {
+            return NO_POSITION;
+        }
 
-    void WindowsMoveResize::starSystemResize(QWidget *window, QPoint globalPos, Qt::Edges edges)
-    {
-        Q_UNUSED(window)
-        Q_UNUSED(globalPos)
-        Q_UNUSED(edges)
+        if (windowMonitor == taskbarMonitor) {
+            SHAppBarMessage(ABM_GETTASKBARPOS, &appbarData);
+            return (Position)appbarData.uEdge;
+        }
     }
 
+    return NO_POSITION;
+}
+
+void WindowsMoveResize::startSystemMove(QWidget *window, QPoint globalPos)
+{
+    Q_UNUSED(globalPos)
+
+    ReleaseCapture();
+    SendMessage((HWND)window->winId(), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
+}
+
+void WindowsMoveResize::starSystemResize(QWidget *window, QPoint globalPos, Qt::Edges edges)
+{
+    Q_UNUSED(window)
+    Q_UNUSED(globalPos)
+    Q_UNUSED(edges)
+}
+
 }  // namespace Win32Utils

+ 296 - 311
QFramelessWindow/windows/WindowsFramelessHelper.cpp

@@ -1,4 +1,4 @@
-#include "WindowsFramelessHelper.h"
+#include "WindowsFramelessHelper.h"
 
 #include <Windows.h>
 #include <windowsx.h>
@@ -17,388 +17,373 @@ QHash<WindowsFramelessHelper *, WId> NativeWindowFilter::s_windows;
 QHash<QWindow *, WId> NativeWindowFilter::s_winIds;
 QHash<WId, WindowsFramelessHelper *> NativeWindowFilter::s_helpers;
 
-void NativeWindowFilter::deliver(QWindow * window, WindowsFramelessHelper * helper)
+void NativeWindowFilter::deliver(QWindow *window, WindowsFramelessHelper *helper)
 {
-	Q_CHECK_PTR(window);
-
-	if (!s_instance) {
-		QCoreApplication *appc = QCoreApplication::instance();
-		if (appc) {
-			auto filter = new NativeWindowFilter();
-			appc->installNativeEventFilter(filter);
-		}
-	}
-
-	if (helper) {
-		WId newId = window->winId();
-		WId oldId = s_windows.value(helper);
-		if (newId != oldId) {
-			s_helpers.insert(newId, helper);
-			s_helpers.remove(oldId);
-			s_windows.insert(helper, newId);
-
-			s_winIds.insert(window, newId);
-		}
-	}
-	else {
-		WId oldId = s_winIds.take(window);
-		WindowsFramelessHelper *helper = s_helpers.take(oldId);
-		s_windows.remove(helper);
-	}
+    Q_CHECK_PTR(window);
+
+    if (!s_instance) {
+        QCoreApplication *appc = QCoreApplication::instance();
+        if (appc) {
+            auto filter = new NativeWindowFilter();
+            appc->installNativeEventFilter(filter);
+        }
+    }
+
+    if (helper) {
+        WId newId = window->winId();
+        WId oldId = s_windows.value(helper);
+        if (newId != oldId) {
+            s_helpers.insert(newId, helper);
+            s_helpers.remove(oldId);
+            s_windows.insert(helper, newId);
+
+            s_winIds.insert(window, newId);
+        }
+    } else {
+        WId oldId                      = s_winIds.take(window);
+        WindowsFramelessHelper *helper = s_helpers.take(oldId);
+        s_windows.remove(helper);
+    }
 }
 
-bool NativeWindowFilter::nativeEventFilter(const QByteArray & eventType, void * message, long * result)
+bool NativeWindowFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
 {
-	LPMSG msg = reinterpret_cast<LPMSG>(message);
-	if (auto h = s_helpers.value(reinterpret_cast<WId>(msg->hwnd)))
-		return h->nativeEventFilter(eventType, msg, result);
-	return false;
+    LPMSG msg = reinterpret_cast<LPMSG>(message);
+    if (auto h = s_helpers.value(reinterpret_cast<WId>(msg->hwnd)))
+        return h->nativeEventFilter(eventType, msg, result);
+    return false;
 }
 
-WindowsFramelessHelper::WindowsFramelessHelper(QWidget *widget)
-	: QObject(widget)
+WindowsFramelessHelper::WindowsFramelessHelper(QWidget *widget) : QObject(widget)
 {
-	Q_CHECK_PTR(widget);
-	m_widget = widget;
-
-	if (QOperatingSystemVersion::current().majorVersion() != QOperatingSystemVersion::Windows7.majorVersion())
-	{
-		m_widget->setWindowFlags(m_widget->windowFlags() | Qt::FramelessWindowHint);
-	}
-	else if (m_widget->parentWidget())
-	{
-		m_widget->setWindowFlags(m_widget->parentWidget()->windowFlags() | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
-	}
-	else
-	{
-		m_widget->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
-	}
-
-	m_widget->installEventFilter(this);
-
-	m_titleBar = new TitleBar(m_widget);
-
-	m_widget->resize(500, 500);
-	m_titleBar->raise();
-	m_titleBarHeight = m_titleBar->height();
+    Q_CHECK_PTR(widget);
+    m_widget = widget;
+
+    if (QOperatingSystemVersion::current().majorVersion() != QOperatingSystemVersion::Windows7.majorVersion()) {
+        m_widget->setWindowFlags(m_widget->windowFlags() | Qt::FramelessWindowHint);
+    } else if (m_widget->parentWidget()) {
+        m_widget->setWindowFlags(m_widget->parentWidget()->windowFlags() | Qt::FramelessWindowHint
+                                 | Qt::WindowMinMaxButtonsHint);
+    } else {
+        m_widget->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint);
+    }
+
+    m_widget->installEventFilter(this);
+
+    m_titleBar = new TitleBar(m_widget);
+
+    m_widget->resize(500, 500);
+    m_titleBar->raise();
+    m_titleBarHeight = m_titleBar->height();
 }
 
 WindowsFramelessHelper::~WindowsFramelessHelper()
 {
-	if (m_window)
-		NativeWindowFilter::deliver(m_window, nullptr);
+    if (m_window)
+        NativeWindowFilter::deliver(m_window, nullptr);
 }
 
 void WindowsFramelessHelper::setMaximizedMargins(int left, int top, int right, int bottom)
 {
-	m_maximizedMargins = QMargins(left, top, right, bottom);
+    m_maximizedMargins = QMargins(left, top, right, bottom);
 }
 
-void WindowsFramelessHelper::setMaximizedMargins(const QMargins & margins)
+void WindowsFramelessHelper::setMaximizedMargins(const QMargins &margins)
 {
-	m_maximizedMargins = margins;
+    m_maximizedMargins = margins;
 }
 
 void WindowsFramelessHelper::setDraggableMargins(int left, int top, int right, int bottom)
 {
-	m_draggableMargins = QMargins(left, top, right, bottom);
+    m_draggableMargins = QMargins(left, top, right, bottom);
 }
 
-void WindowsFramelessHelper::setDraggableMargins(const QMargins & margins)
+void WindowsFramelessHelper::setDraggableMargins(const QMargins &margins)
 {
-	m_draggableMargins = margins;
+    m_draggableMargins = margins;
 }
 
-void WindowsFramelessHelper::setTitleBar(TitleBar * titleBar)
+void WindowsFramelessHelper::setTitleBar(TitleBar *titleBar)
 {
-	if (titleBar != m_titleBar) {
-		m_titleBar->deleteLater();
-		m_titleBar = titleBar;
-		m_titleBar->setParent(m_widget);
-		m_titleBar->raise();
-
-		m_titleBarHeight = m_titleBar->height();
-	}
+    if (titleBar != m_titleBar) {
+        m_titleBar->deleteLater();
+        m_titleBar = titleBar;
+        m_titleBar->setParent(m_widget);
+        m_titleBar->raise();
+
+        m_titleBarHeight = m_titleBar->height();
+    }
 }
 
 void WindowsFramelessHelper::setResizeEnabled(bool isEnabled)
 {
-	m_isResizeEnabled = isEnabled;
+    m_isResizeEnabled = isEnabled;
 }
 
 bool WindowsFramelessHelper::getResizeEnabled() const
 {
-	return m_isResizeEnabled;
+    return m_isResizeEnabled;
 }
 
-bool WindowsFramelessHelper::nativeEventFilter(const QByteArray & eventType, void * msg, long * result)
+bool WindowsFramelessHelper::nativeEventFilter(const QByteArray &eventType, void *msg, long *result)
 {
-	Q_CHECK_PTR(m_window);
-	LPMSG lpMsg = reinterpret_cast<LPMSG>(msg);
-	WPARAM wParam = lpMsg->wParam;
-	LPARAM lParam = lpMsg->lParam;
-
-	if (WM_NCHITTEST == lpMsg->message) {
-		*result = hitTest(GET_X_LPARAM(lParam),
-			GET_Y_LPARAM(lParam));
-		return true;
-	}
-	else if (WM_NCACTIVATE == lpMsg->message) {
-		if (!QtWin::isCompositionEnabled()) {
-			if (result) *result = 1;
-			return true;
-		}
-	}
-	else if (WM_NCCALCSIZE == lpMsg->message) {
-		if (TRUE == wParam) {
-			if (isMaximized()) {
-				NCCALCSIZE_PARAMS &params = *reinterpret_cast<NCCALCSIZE_PARAMS *>(lParam);
-
-				QRect g = availableGeometry();
-				QMargins m = maximizedMargins();
-
-				params.rgrc[0].top = g.top() - m.top();
-				params.rgrc[0].left = g.left() - m.left();
-				params.rgrc[0].right = g.right() + m.right() + 1;
-				params.rgrc[0].bottom = g.bottom() + m.bottom() + 1;
-			}
-
-			if (result) *result = 0;
-			return true;
-		}
-	}
-	else if (WM_GETMINMAXINFO == lpMsg->message) {
-		LPMINMAXINFO lpMinMaxInfo = reinterpret_cast<LPMINMAXINFO>(lParam);
-
-		QRect g = availableGeometry();
-		QMargins m = maximizedMargins();
-
-		lpMinMaxInfo->ptMaxPosition.x = -m.left();
-		lpMinMaxInfo->ptMaxPosition.y = -m.top();
-		lpMinMaxInfo->ptMaxSize.x = g.right() - g.left() + 1 + m.left() + m.right();
-		lpMinMaxInfo->ptMaxSize.y = g.bottom() - g.top() + 1 + m.top() + m.bottom();
-
-		lpMinMaxInfo->ptMinTrackSize.x = m_window->minimumWidth();
-		lpMinMaxInfo->ptMinTrackSize.y = m_window->minimumHeight();
-		lpMinMaxInfo->ptMaxTrackSize.x = m_window->maximumWidth();
-		lpMinMaxInfo->ptMaxTrackSize.y = m_window->maximumHeight();
-
-		if (result) *result = 0;
-		return true;
-	}
-	else if (WM_NCLBUTTONDBLCLK == lpMsg->message) {
-		auto minimumSize = m_window->minimumSize();
-		auto maximumSize = m_window->maximumSize();
-		if ((minimumSize.width() >= maximumSize.width())
-			|| (minimumSize.height() >= maximumSize.height())) {
-			if (result) *result = 0;
-			return true;
-		}
-	}
-	else if (WM_DPICHANGED == lpMsg->message) {
-		qreal old = m_scaleFactor;
-		if (HIWORD(wParam) < 144) {
-			m_scaleFactor = 1.0;
-		}
-		else {
-			m_scaleFactor = 2.0;
-		}
-
-		if (!qFuzzyCompare(old, m_scaleFactor)) {
-			emit scaleFactorChanged(m_scaleFactor);
-		}
-
-		auto hWnd = reinterpret_cast<HWND>(m_window->winId());
-		auto rect = reinterpret_cast<LPRECT>(lParam);
-		SetWindowPos(hWnd,
-			NULL,
-			rect->left,
-			rect->top,
-			rect->right - rect->left,
-			rect->bottom - rect->top,
-			SWP_NOZORDER | SWP_NOACTIVATE);
-	}
-
-	return false;
+    Q_CHECK_PTR(m_window);
+    LPMSG lpMsg   = reinterpret_cast<LPMSG>(msg);
+    WPARAM wParam = lpMsg->wParam;
+    LPARAM lParam = lpMsg->lParam;
+
+    if (WM_NCHITTEST == lpMsg->message) {
+        *result = hitTest(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+        return true;
+    } else if (WM_NCACTIVATE == lpMsg->message) {
+        if (!QtWin::isCompositionEnabled()) {
+            if (result)
+                *result = 1;
+            return true;
+        }
+    } else if (WM_NCCALCSIZE == lpMsg->message) {
+        if (TRUE == wParam) {
+            if (isMaximized()) {
+                NCCALCSIZE_PARAMS &params = *reinterpret_cast<NCCALCSIZE_PARAMS *>(lParam);
+
+                QRect g    = availableGeometry();
+                QMargins m = maximizedMargins();
+
+                params.rgrc[0].top    = g.top() - m.top();
+                params.rgrc[0].left   = g.left() - m.left();
+                params.rgrc[0].right  = g.right() + m.right() + 1;
+                params.rgrc[0].bottom = g.bottom() + m.bottom() + 1;
+            }
+
+            if (result)
+                *result = 0;
+            return true;
+        }
+    } else if (WM_GETMINMAXINFO == lpMsg->message) {
+        LPMINMAXINFO lpMinMaxInfo = reinterpret_cast<LPMINMAXINFO>(lParam);
+
+        QRect g    = availableGeometry();
+        QMargins m = maximizedMargins();
+
+        lpMinMaxInfo->ptMaxPosition.x = -m.left();
+        lpMinMaxInfo->ptMaxPosition.y = -m.top();
+        lpMinMaxInfo->ptMaxSize.x     = g.right() - g.left() + 1 + m.left() + m.right();
+        lpMinMaxInfo->ptMaxSize.y     = g.bottom() - g.top() + 1 + m.top() + m.bottom();
+
+        lpMinMaxInfo->ptMinTrackSize.x = m_window->minimumWidth();
+        lpMinMaxInfo->ptMinTrackSize.y = m_window->minimumHeight();
+        lpMinMaxInfo->ptMaxTrackSize.x = m_window->maximumWidth();
+        lpMinMaxInfo->ptMaxTrackSize.y = m_window->maximumHeight();
+
+        if (result)
+            *result = 0;
+        return true;
+    } else if (WM_NCLBUTTONDBLCLK == lpMsg->message) {
+        auto minimumSize = m_window->minimumSize();
+        auto maximumSize = m_window->maximumSize();
+        if ((minimumSize.width() >= maximumSize.width()) || (minimumSize.height() >= maximumSize.height())) {
+            if (result)
+                *result = 0;
+            return true;
+        }
+    }
+#ifdef Q_CC_MSVC
+    else if (WM_DPICHANGED == lpMsg->message) {
+        qreal old = m_scaleFactor;
+        if (HIWORD(wParam) < 144) {
+            m_scaleFactor = 1.0;
+        } else {
+            m_scaleFactor = 2.0;
+        }
+
+        if (!qFuzzyCompare(old, m_scaleFactor)) {
+            emit scaleFactorChanged(m_scaleFactor);
+        }
+
+        auto hWnd = reinterpret_cast<HWND>(m_window->winId());
+        auto rect = reinterpret_cast<LPRECT>(lParam);
+        SetWindowPos(hWnd, NULL, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top,
+                     SWP_NOZORDER | SWP_NOACTIVATE);
+    }
+#endif
+
+    return false;
 }
 
-bool WindowsFramelessHelper::eventFilter(QObject * obj, QEvent * ev)
+bool WindowsFramelessHelper::eventFilter(QObject *obj, QEvent *ev)
 {
-	if (obj == m_widget && ev->type() == QEvent::WinIdChange)
-	{
-		initWindow();
-	}
-	else if (obj == m_widget && ev->type() == QEvent::Resize)
-	{
-		m_titleBar->resize(m_widget->width(), m_titleBar->height());
-		m_titleBar->raise();
-	}
-
-	if (m_window == obj && ev->type() == QEvent::WinIdChange) {
-		updateWindowStyle();
-	}
-	else if (m_window == obj && ev->type() == QEvent::Show) {
-		updateWindowStyle();
-	}
-
-	return QObject::eventFilter(obj, ev);
+    if (obj == m_widget && ev->type() == QEvent::WinIdChange) {
+        initWindow();
+    } else if (obj == m_widget && ev->type() == QEvent::Resize) {
+        m_titleBar->resize(m_widget->width(), m_titleBar->height());
+        m_titleBar->raise();
+    }
+
+    if (m_window == obj && ev->type() == QEvent::WinIdChange) {
+        updateWindowStyle();
+    } else if (m_window == obj && ev->type() == QEvent::Show) {
+        updateWindowStyle();
+    }
+
+    return QObject::eventFilter(obj, ev);
 }
 
 qreal WindowsFramelessHelper::scaleFactor() const
 {
-	return m_scaleFactor;
+    return m_scaleFactor;
 }
 
 void WindowsFramelessHelper::initWindow()
 {
-	QWindow* window = m_widget->windowHandle();
-
-	Q_CHECK_PTR(window);
-	m_window = window;
+    QWindow *window = m_widget->windowHandle();
 
+    Q_CHECK_PTR(window);
+    m_window = window;
 
-	if (m_window) {
-		m_scaleFactor = m_window->screen()->devicePixelRatio();
+    if (m_window) {
+        m_scaleFactor = m_window->screen()->devicePixelRatio();
 
-		if (m_window->flags() & Qt::FramelessWindowHint) {
-			m_window->installEventFilter(this);
-			updateWindowStyle();
-		}
-	}
+        if (m_window->flags() & Qt::FramelessWindowHint) {
+            m_window->installEventFilter(this);
+            updateWindowStyle();
+        }
+    }
 }
 
 void WindowsFramelessHelper::updateWindowStyle()
 {
-	Q_CHECK_PTR(m_window);
-
-	HWND hWnd = reinterpret_cast<HWND>(m_window->winId());
-	if (NULL == hWnd)
-		return;
-	else if (m_oldWindow == hWnd) {
-		return;
-	}
-	m_oldWindow = hWnd;
-
-	NativeWindowFilter::deliver(m_window, this);
-
-	QOperatingSystemVersion currentVersion = QOperatingSystemVersion::current();
-	if (currentVersion < QOperatingSystemVersion::Windows8) {
-		return;
-	}
-
-	LONG oldStyle = WS_OVERLAPPEDWINDOW | WS_THICKFRAME
-		| WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;;
-	LONG newStyle = WS_POPUP | WS_THICKFRAME;
-
-	if (QtWin::isCompositionEnabled())
-		newStyle |= WS_CAPTION;
-
-	if (m_window->flags() & Qt::CustomizeWindowHint) {
-		if (m_window->flags() & Qt::WindowSystemMenuHint)
-			newStyle |= WS_SYSMENU;
-		if (m_window->flags() & Qt::WindowMinimizeButtonHint)
-			newStyle |= WS_MINIMIZEBOX;
-		if (m_window->flags() & Qt::WindowMaximizeButtonHint)
-			newStyle |= WS_MAXIMIZEBOX;
-	}
-	else {
-		newStyle |= WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
-	}
-
-	LONG currentStyle = GetWindowLong(hWnd, GWL_STYLE);
-	SetWindowLong(hWnd, GWL_STYLE, (currentStyle & ~oldStyle) | newStyle);
-
-	SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
-		SWP_NOOWNERZORDER | SWP_NOZORDER |
-		SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
-
-	if (QtWin::isCompositionEnabled())
-		QtWin::extendFrameIntoClientArea(m_window, 1, 1, 1, 1);
+    Q_CHECK_PTR(m_window);
+
+    HWND hWnd = reinterpret_cast<HWND>(m_window->winId());
+    if (NULL == hWnd)
+        return;
+    else if (m_oldWindow == hWnd) {
+        return;
+    }
+    m_oldWindow = hWnd;
+
+    NativeWindowFilter::deliver(m_window, this);
+
+    QOperatingSystemVersion currentVersion = QOperatingSystemVersion::current();
+    if (currentVersion < QOperatingSystemVersion::Windows8) {
+        return;
+    }
+
+    LONG oldStyle = WS_OVERLAPPEDWINDOW | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
+    ;
+    LONG newStyle = WS_POPUP | WS_THICKFRAME;
+
+    if (QtWin::isCompositionEnabled())
+        newStyle |= WS_CAPTION;
+
+    if (m_window->flags() & Qt::CustomizeWindowHint) {
+        if (m_window->flags() & Qt::WindowSystemMenuHint)
+            newStyle |= WS_SYSMENU;
+        if (m_window->flags() & Qt::WindowMinimizeButtonHint)
+            newStyle |= WS_MINIMIZEBOX;
+        if (m_window->flags() & Qt::WindowMaximizeButtonHint)
+            newStyle |= WS_MAXIMIZEBOX;
+    } else {
+        newStyle |= WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
+    }
+
+    LONG currentStyle = GetWindowLong(hWnd, GWL_STYLE);
+    SetWindowLong(hWnd, GWL_STYLE, (currentStyle & ~oldStyle) | newStyle);
+
+    SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
+
+    if (QtWin::isCompositionEnabled())
+        QtWin::extendFrameIntoClientArea(m_window, 1, 1, 1, 1);
 }
 
 bool WindowsFramelessHelper::isMaximized() const
 {
-	Q_CHECK_PTR(m_window);
+    Q_CHECK_PTR(m_window);
 
-	HWND hWnd = reinterpret_cast<HWND>(m_window->winId());
-	if (NULL == hWnd)
-		return false;
+    HWND hWnd = reinterpret_cast<HWND>(m_window->winId());
+    if (NULL == hWnd)
+        return false;
 
-	WINDOWPLACEMENT windowPlacement;
-	if (!GetWindowPlacement(hWnd, &windowPlacement))
-		return false;
+    WINDOWPLACEMENT windowPlacement;
+    if (!GetWindowPlacement(hWnd, &windowPlacement))
+        return false;
 
-	return (SW_MAXIMIZE == windowPlacement.showCmd);
+    return (SW_MAXIMIZE == windowPlacement.showCmd);
 }
 
 QRect WindowsFramelessHelper::availableGeometry() const
 {
-	MONITORINFO mi{ 0 };
-	mi.cbSize = sizeof(MONITORINFO);
+    MONITORINFO mi { 0 };
+    mi.cbSize = sizeof(MONITORINFO);
 
-	auto hWnd = reinterpret_cast<HWND>(m_window->winId());
-	auto hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
-	if (!hMonitor || !GetMonitorInfoW(hMonitor, &mi)) {
-		Q_ASSERT(NULL != hMonitor);
-		return m_window->screen()->availableGeometry();
-	}
+    auto hWnd     = reinterpret_cast<HWND>(m_window->winId());
+    auto hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
+    if (!hMonitor || !GetMonitorInfoW(hMonitor, &mi)) {
+        Q_ASSERT(NULL != hMonitor);
+        return m_window->screen()->availableGeometry();
+    }
 
-	return QRect(mi.rcWork.left, mi.rcWork.top, mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
+    return QRect(mi.rcWork.left, mi.rcWork.top, mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
 }
 
 int WindowsFramelessHelper::hitTest(int x, int y) const
 {
-	Q_CHECK_PTR(m_window);
-
-	x = x / m_window->devicePixelRatio();
-	y = y / m_window->devicePixelRatio();
-
-	enum RegionMask {
-		Client = 0x0000,
-		Top = 0x0001,
-		Left = 0x0010,
-		Right = 0x0100,
-		Bottom = 0x1000,
-	};
-
-	auto wfg = m_window->frameGeometry();
-	QMargins draggableMargins
-		= this->draggableMargins();
-
-	int top = draggableMargins.top();
-	int left = draggableMargins.left();
-	int right = draggableMargins.right();
-	int bottom = draggableMargins.bottom();
-
-	if (top <= 0)
-		top = GetSystemMetrics(SM_CYFRAME);
-	if (left <= 0)
-		left = GetSystemMetrics(SM_CXFRAME);
-	if (right <= 0)
-		right = GetSystemMetrics(SM_CXFRAME);
-	if (bottom <= 0)
-		bottom = GetSystemMetrics(SM_CYFRAME);
-
-	auto result =
-		(Top *    (y < (wfg.top() + top))) |
-		(Left *   (x < (wfg.left() + left))) |
-		(Right *  (x > (wfg.right() - right))) |
-		(Bottom * (y > (wfg.bottom() - bottom)));
-
-	bool wResizable = m_isResizeEnabled ? m_window->minimumWidth() < m_window->maximumWidth() : false;
-	bool hResizable = m_isResizeEnabled ? m_window->minimumHeight() < m_window->maximumHeight() : false;
-
-	switch (result) {
-		case Top | Left: return wResizable && hResizable ? HTTOPLEFT : HTCLIENT;
-		case Top: return hResizable ? HTTOP : HTCLIENT;
-		case Top | Right: return wResizable && hResizable ? HTTOPRIGHT : HTCLIENT;
-		case Right: return wResizable ? HTRIGHT : HTCLIENT;
-		case Bottom | Right: return wResizable && hResizable ? HTBOTTOMRIGHT : HTCLIENT;
-		case Bottom: return hResizable ? HTBOTTOM : HTCLIENT;
-		case Bottom | Left: return wResizable && hResizable ? HTBOTTOMLEFT : HTCLIENT;
-		case Left: return wResizable ? HTLEFT : HTCLIENT;
-	}
-
-	auto pos = m_window->mapFromGlobal(QPoint(x, y));
-	return HTCLIENT;
+    Q_CHECK_PTR(m_window);
+
+    x = x / m_window->devicePixelRatio();
+    y = y / m_window->devicePixelRatio();
+
+    enum RegionMask
+    {
+        Client = 0x0000,
+        Top    = 0x0001,
+        Left   = 0x0010,
+        Right  = 0x0100,
+        Bottom = 0x1000,
+    };
+
+    auto wfg                  = m_window->frameGeometry();
+    QMargins draggableMargins = this->draggableMargins();
+
+    int top    = draggableMargins.top();
+    int left   = draggableMargins.left();
+    int right  = draggableMargins.right();
+    int bottom = draggableMargins.bottom();
+
+    if (top <= 0)
+        top = GetSystemMetrics(SM_CYFRAME);
+    if (left <= 0)
+        left = GetSystemMetrics(SM_CXFRAME);
+    if (right <= 0)
+        right = GetSystemMetrics(SM_CXFRAME);
+    if (bottom <= 0)
+        bottom = GetSystemMetrics(SM_CYFRAME);
+
+    auto result = (Top * (y < (wfg.top() + top))) | (Left * (x < (wfg.left() + left)))
+            | (Right * (x > (wfg.right() - right))) | (Bottom * (y > (wfg.bottom() - bottom)));
+
+    bool wResizable = m_isResizeEnabled ? m_window->minimumWidth() < m_window->maximumWidth() : false;
+    bool hResizable = m_isResizeEnabled ? m_window->minimumHeight() < m_window->maximumHeight() : false;
+
+    switch (result) {
+    case Top | Left:
+        return wResizable && hResizable ? HTTOPLEFT : HTCLIENT;
+    case Top:
+        return hResizable ? HTTOP : HTCLIENT;
+    case Top | Right:
+        return wResizable && hResizable ? HTTOPRIGHT : HTCLIENT;
+    case Right:
+        return wResizable ? HTRIGHT : HTCLIENT;
+    case Bottom | Right:
+        return wResizable && hResizable ? HTBOTTOMRIGHT : HTCLIENT;
+    case Bottom:
+        return hResizable ? HTBOTTOM : HTCLIENT;
+    case Bottom | Left:
+        return wResizable && hResizable ? HTBOTTOMLEFT : HTCLIENT;
+    case Left:
+        return wResizable ? HTLEFT : HTCLIENT;
+    }
+
+    auto pos = m_window->mapFromGlobal(QPoint(x, y));
+    return HTCLIENT;
 }

BIN
bin/data/qfd.db