Sine Striker
2023-12-19 718590bf4dec0e8d9e7a75af98568f5eff5f8f9d
Remove stylesupport
11个文件已修改
1个文件已添加
3个文件已删除
360 ■■■■■ 已修改文件
CMakeLists.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/mainwindow/mainwindow.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
share/install.cmake 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
share/qmake/QWKStyleSupport.pri.in 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/CMakeLists.txt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/CMakeLists.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext.cpp 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/cocoawindowcontext.mm 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/qtwindowcontext.cpp 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/kernel/systemwindow_p.h 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/qwkglobal_p.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/quick/quickwindowagent.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/CMakeLists.txt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/qwkstylesupportglobal.h 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetwindowagent.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
CMakeLists.txt
@@ -8,7 +8,6 @@
option(QWINDOWKIT_BUILD_STATIC "Build static libraries" OFF)
option(QWINDOWKIT_BUILD_WIDGETS "Build widgets module" ON)
option(QWINDOWKIT_BUILD_QUICK "Build quick module" ON)
option(QWINDOWKIT_BUILD_STYLE_SUPPORT "Build style support module" ON)
option(QWINDOWKIT_BUILD_EXAMPLES "Build examples" OFF)
option(QWINDOWKIT_BUILD_DOCUMENTATIONS "Build documentations" OFF)
option(QWINDOWKIT_INSTALL "Install library" ON)
examples/mainwindow/mainwindow.cpp
@@ -107,7 +107,7 @@
void MainWindow::installWindowAgent() {
    // 1. Setup window agent
    QWK::WidgetWindowAgent *agent = QWK::QWK_Initialize(this);
    QWK::WidgetWindowAgent *agent = QWK::setupWidgetWindow(this);
    // 2. Construct your title bar
    auto menuBar = []() {
share/install.cmake
@@ -18,12 +18,10 @@
    set(QMAKE_QWK_CORE_NAME_RELEASE QWKCore)
    set(QMAKE_QWK_WIDGETS_NAME_RELEASE QWKWidgets)
    set(QMAKE_QWK_QUICK_NAME_RELEASE QWKQuick)
    set(QMAKE_QWK_STYLESUPPORT_NAME_RELEASE QWKStyleSupport)
    set(QMAKE_QWK_CORE_NAME_DEBUG QWKCore${CMAKE_DEBUG_POSTFIX})
    set(QMAKE_QWK_WIDGETS_NAME_DEBUG QWKWidgets${CMAKE_DEBUG_POSTFIX})
    set(QMAKE_QWK_QUICK_NAME_DEBUG QWKQuick${CMAKE_DEBUG_POSTFIX})
    set(QMAKE_QWK_STYLESUPPORT_NAME_DEBUG QWKStyleSupport${CMAKE_DEBUG_POSTFIX})
    file(GLOB _qmake_components "${CMAKE_CURRENT_LIST_DIR}/qmake/*.pri.in")
@@ -60,14 +58,12 @@
        QWKCore${CMAKE_DEBUG_POSTFIX}.lib
        QWKWidgets${CMAKE_DEBUG_POSTFIX}.lib
        QWKQuick${CMAKE_DEBUG_POSTFIX}.lib
        QWKStyleSupport${CMAKE_DEBUG_POSTFIX}.lib
    )
    set(MSBUILD_QWK_LIBRARY_LIST_RELEASE
        QWKCore.lib
        QWKWidgets.lib
        QWKQuick.lib
        QWKStyleSupport.lib
    )
    to_dos_separator(MSBUILD_QWK_INSTALL_PREFIX)
share/qmake/QWKStyleSupport.pri.in
File was deleted
src/CMakeLists.txt
@@ -122,10 +122,6 @@
# ----------------------------------
add_subdirectory(core)
if(QWINDOWKIT_BUILD_STYLE_SUPPORT)
    add_subdirectory(stylesupport)
endif()
if(QWINDOWKIT_BUILD_WIDGETS)
    add_subdirectory(widgets)
endif()
src/core/CMakeLists.txt
@@ -13,6 +13,7 @@
    windowitemdelegate.cpp
    kernel/nativeeventfilter_p.h
    kernel/nativeeventfilter.cpp
    kernel/systemwindow_p.h
    contexts/abstractwindowcontext_p.h
    contexts/abstractwindowcontext.cpp
)
src/core/contexts/abstractwindowcontext.cpp
@@ -39,9 +39,8 @@
    bool AbstractWindowContext::setSystemButton(WindowAgentBase::SystemButton button,
                                                QObject *obj) {
        Q_ASSERT(obj);
        Q_ASSERT(button != WindowAgentBase::Unknown);
        if (!obj || (button == WindowAgentBase::Unknown)) {
        if (button == WindowAgentBase::Unknown) {
            return false;
        }
@@ -54,10 +53,6 @@
    bool AbstractWindowContext::setTitleBar(QObject *item) {
        Q_ASSERT(item);
        if (!item) {
            return false;
        }
        if (m_titleBar == item) {
            return false;
        }
src/core/contexts/cocoawindowcontext.mm
@@ -6,7 +6,7 @@
#include <QtGui/QGuiApplication>
#include "qwkglobal_p.h"
#include "systemwindow_p.h"
namespace QWK {
    struct NSWindowProxy {
@@ -259,9 +259,9 @@
        if (type < QEvent::MouseButtonPress || type > QEvent::MouseMove) {
            return false;
        }
        QObject *host = m_context->host();
        QWindow *window = m_context->window();
        WindowItemDelegate *delegate = m_context->delegate();
        auto host = m_context->host();
        auto window = m_context->window();
        auto delegate = m_context->delegate();
        auto me = static_cast<const QMouseEvent *>(event);
        QPoint scenePos = getMouseEventScenePos(me);
@@ -323,7 +323,7 @@
                    }
                    case PreparingMove: {
                        m_windowStatus = Moving;
                        window->startSystemMove();
                        startSystemMove(window);
                        event->accept();
                        return true;
                    }
src/core/contexts/qtwindowcontext.cpp
@@ -3,6 +3,7 @@
#include <QtCore/QDebug>
#include "qwkglobal_p.h"
#include "systemwindow_p.h"
namespace QWK {
@@ -76,125 +77,6 @@
#endif
    }
#ifdef Q_OS_LINUX
    class WindowMoveManipulator : public QObject {
    public:
        explicit WindowMoveManipulator(QWindow *targetWindow)
            : QObject(targetWindow), target(targetWindow), initialMousePosition(QCursor::pos()),
              initialWindowPosition(targetWindow->position()) {
            target->installEventFilter(this);
        }
    protected:
        bool eventFilter(QObject *obj, QEvent *event) override {
            switch (event->type()) {
                case QEvent::MouseMove: {
                    auto mouseEvent = static_cast<QMouseEvent *>(event);
                    QPoint delta = getMouseEventGlobalPos(mouseEvent) - initialMousePosition;
                    target->setPosition(initialWindowPosition + delta);
                    return true;
                }
                case QEvent::MouseButtonRelease: {
                    if (target->y() < 0) {
                        target->setPosition(target->x(), 0);
                    }
                    target->removeEventFilter(this);
                    this->deleteLater();
                }
                default:
                    break;
            }
            return false;
        }
    private:
        QWindow *target;
        QPoint initialMousePosition;
        QPoint initialWindowPosition;
    };
#endif
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
    class WindowResizeManipulator : public QObject {
    public:
        WindowResizeManipulator(QWindow *targetWindow, Qt::Edges edges)
            : QObject(targetWindow), target(targetWindow), resizeEdges(edges),
              initialMousePosition(QCursor::pos()), initialWindowRect(target->geometry()) {
            target->installEventFilter(this);
        }
    protected:
        bool eventFilter(QObject *obj, QEvent *event) override {
            switch (event->type()) {
                case QEvent::MouseMove: {
                    auto mouseEvent = static_cast<QMouseEvent *>(event);
                    QPoint globalMousePos = getMouseEventGlobalPos(mouseEvent);
                    QRect windowRect = initialWindowRect;
                    if (resizeEdges & Qt::LeftEdge) {
                        int delta = globalMousePos.x() - initialMousePosition.x();
                        windowRect.setLeft(initialWindowRect.left() + delta);
                    }
                    if (resizeEdges & Qt::RightEdge) {
                        int delta = globalMousePos.x() - initialMousePosition.x();
                        windowRect.setRight(initialWindowRect.right() + delta);
                    }
                    if (resizeEdges & Qt::TopEdge) {
                        int delta = globalMousePos.y() - initialMousePosition.y();
                        windowRect.setTop(initialWindowRect.top() + delta);
                    }
                    if (resizeEdges & Qt::BottomEdge) {
                        int delta = globalMousePos.y() - initialMousePosition.y();
                        windowRect.setBottom(initialWindowRect.bottom() + delta);
                    }
                    target->setGeometry(windowRect);
                    return true;
                }
                case QEvent::MouseButtonRelease: {
                    target->removeEventFilter(this);
                    this->deleteLater();
                }
                default:
                    break;
            }
            return false;
        }
    private:
        QWindow *target;
        QPoint initialMousePosition;
        QRect initialWindowRect;
        Qt::Edges resizeEdges;
    };
#endif
    static inline void startSystemMove(QWindow *window) {
#ifdef Q_OS_LINUX
        if (window->startSystemMove()) {
            return;
        }
        std::ignore = new WindowMoveManipulator(window);
#else
        window->startSystemMove();
#endif
    }
    static inline void startSystemResize(QWindow *window, Qt::Edges edges) {
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
        if (window->startSystemResize(edges)) {
            return;
        }
        std::ignore = new WindowResizeManipulator(window, edges);
#else
        window->startSystemResize(edges);
#endif
    }
    class QtWindowEventFilter : public QObject {
    public:
        explicit QtWindowEventFilter(AbstractWindowContext *context, QObject *parent = nullptr);
@@ -230,11 +112,11 @@
        if (type < QEvent::MouseButtonPress || type > QEvent::MouseMove) {
            return false;
        }
        QObject *host = m_context->host();
        QWindow *window = m_context->window();
        WindowItemDelegate *delegate = m_context->delegate();
        bool fixedSize = delegate->isHostSizeFixed(host);
        auto host = m_context->host();
        auto window = m_context->window();
        auto delegate = m_context->delegate();
        auto me = static_cast<const QMouseEvent *>(event);
        bool fixedSize = delegate->isHostSizeFixed(host);
        QPoint scenePos = getMouseEventScenePos(me);
        QPoint globalPos = getMouseEventGlobalPos(me);
src/core/kernel/systemwindow_p.h
New file
@@ -0,0 +1,145 @@
#ifndef SYSTEMWINDOW_P_H
#define SYSTEMWINDOW_P_H
#include <QtGui/QWindow>
#include <QtGui/QMouseEvent>
#include <QWKCore/private/qwkglobal_p.h>
// Don't include this header in any header files.
namespace QWK {
    // Anonymous namespace
    namespace {
        class WindowMoveManipulator : public QObject {
        public:
            explicit WindowMoveManipulator(QWindow *targetWindow)
                : QObject(targetWindow), target(targetWindow), initialMousePosition(QCursor::pos()),
                  initialWindowPosition(targetWindow->position()) {
                target->installEventFilter(this);
            }
        protected:
            bool eventFilter(QObject *obj, QEvent *event) override {
                switch (event->type()) {
                    case QEvent::MouseMove: {
                        auto mouseEvent = static_cast<QMouseEvent *>(event);
                        QPoint delta = getMouseEventGlobalPos(mouseEvent) - initialMousePosition;
                        target->setPosition(initialWindowPosition + delta);
                        return true;
                    }
                    case QEvent::MouseButtonRelease: {
                        if (target->y() < 0) {
                            target->setPosition(target->x(), 0);
                        }
                        target->removeEventFilter(this);
                        this->deleteLater();
                    }
                    default:
                        break;
                }
                return false;
            }
        private:
            QWindow *target;
            QPoint initialMousePosition;
            QPoint initialWindowPosition;
        };
        class WindowResizeManipulator : public QObject {
        public:
            WindowResizeManipulator(QWindow *targetWindow, Qt::Edges edges)
                : QObject(targetWindow), target(targetWindow), resizeEdges(edges),
                  initialMousePosition(QCursor::pos()), initialWindowRect(target->geometry()) {
                target->installEventFilter(this);
            }
        protected:
            bool eventFilter(QObject *obj, QEvent *event) override {
                switch (event->type()) {
                    case QEvent::MouseMove: {
                        auto mouseEvent = static_cast<QMouseEvent *>(event);
                        QPoint globalMousePos = getMouseEventGlobalPos(mouseEvent);
                        QRect windowRect = initialWindowRect;
                        if (resizeEdges & Qt::LeftEdge) {
                            int delta = globalMousePos.x() - initialMousePosition.x();
                            windowRect.setLeft(initialWindowRect.left() + delta);
                        }
                        if (resizeEdges & Qt::RightEdge) {
                            int delta = globalMousePos.x() - initialMousePosition.x();
                            windowRect.setRight(initialWindowRect.right() + delta);
                        }
                        if (resizeEdges & Qt::TopEdge) {
                            int delta = globalMousePos.y() - initialMousePosition.y();
                            windowRect.setTop(initialWindowRect.top() + delta);
                        }
                        if (resizeEdges & Qt::BottomEdge) {
                            int delta = globalMousePos.y() - initialMousePosition.y();
                            windowRect.setBottom(initialWindowRect.bottom() + delta);
                        }
                        target->setGeometry(windowRect);
                        return true;
                    }
                    case QEvent::MouseButtonRelease: {
                        target->removeEventFilter(this);
                        this->deleteLater();
                    }
                    default:
                        break;
                }
                return false;
            }
        private:
            QWindow *target;
            QPoint initialMousePosition;
            QRect initialWindowRect;
            Qt::Edges resizeEdges;
        };
    }
    // QWindow::startSystemMove() and QWindow::startSystemResize() is first supported at Qt 5.15
    // QWindow::startSystemResize() returns false on macOS
    // QWindow::startSystemMove() and QWindow::startSystemResize() returns false on Linux Unity DE
    // When the new API fails, we emulate the window actions using the classical API.
    static inline void startSystemMove(QWindow *window) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
        std::ignore = new WindowMoveManipulator(window);
#elif defined(Q_OS_LINUX)
        if (window->startSystemMove()) {
            return;
        }
        std::ignore = new WindowMoveManipulator(window);
#else
        window->startSystemMove();
#endif
    }
    static inline void startSystemResize(QWindow *window, Qt::Edges edges) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
        std::ignore = new WindowResizeManipulator(window, edges);
#elif defined(Q_OS_MAC) || defined(Q_OS_LINUX)
        if (window->startSystemResize(edges)) {
            return;
        }
        std::ignore = new WindowResizeManipulator(window, edges);
#else
        window->startSystemResize(edges);
#endif
    }
}
#endif // SYSTEMWINDOW_P_H
src/core/qwkglobal_p.h
@@ -40,6 +40,7 @@
        return event->windowPos().toPoint();
#endif
    }
    inline QPoint getMouseEventGlobalPos(const QMouseEvent *event) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
        return event->globalPosition().toPoint();
src/quick/quickwindowagent.h
@@ -38,7 +38,7 @@
        QuickWindowAgent(QuickWindowAgentPrivate &d, QObject *parent = nullptr);
    };
    inline QuickWindowAgent *QWK_Initialize(QQuickWindow *window) {
    inline QuickWindowAgent *setupQuickWindow(QQuickWindow *window) {
        auto agent = new QuickWindowAgent(window);
        agent->setup(window);
        return agent;
src/stylesupport/CMakeLists.txt
File was deleted
src/stylesupport/qwkstylesupportglobal.h
File was deleted
src/widgets/widgetwindowagent.h
@@ -42,7 +42,7 @@
        WidgetWindowAgent(WidgetWindowAgentPrivate &d, QObject *parent = nullptr);
    };
    inline WidgetWindowAgent *QWK_Initialize(QWidget *w) {
    inline WidgetWindowAgent *setupWidgetWindow(QWidget *w) {
        auto agent = new WidgetWindowAgent(w);
        agent->setup(w);
        return agent;