3rdparty: Remove framelesshelper and add qwindowkit.
This commit is contained in:
parent
56f21299f0
commit
6e5ad39f4f
|
@ -1,3 +1,3 @@
|
||||||
[submodule "lib_source/3rdparty/framelesshelper"]
|
[submodule "lib_source/3rdparty/qwindowkit"]
|
||||||
path = lib_source/3rdparty/framelesshelper
|
path = lib_source/3rdparty/qwindowkit
|
||||||
url = git@github.com:mentalfl0w/framelesshelper.git
|
url = https://github.com/stdware/qwindowkit.git
|
||||||
|
|
|
@ -7,7 +7,7 @@ set(QT_SDK_DIR ${Qt6_DIR}/../../..)
|
||||||
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
|
cmake_path(SET QT_SDK_DIR NORMALIZE ${QT_SDK_DIR})
|
||||||
|
|
||||||
option(RIBBONUI_BUILD_EXAMPLES "Build RibbonUI APP." ON)
|
option(RIBBONUI_BUILD_EXAMPLES "Build RibbonUI APP." ON)
|
||||||
option(RIBBONUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
option(RIBBONUI_BUILD_QWINDOWKIT "Build QWindowKit." ON)
|
||||||
option(RIBBONUI_BUILD_STATIC_LIB "Build RibbonUI static library." OFF)
|
option(RIBBONUI_BUILD_STATIC_LIB "Build RibbonUI static library." OFF)
|
||||||
|
|
||||||
if(NOT RIBBONUI_QML_PLUGIN_DIRECTORY)
|
if(NOT RIBBONUI_QML_PLUGIN_DIRECTORY)
|
||||||
|
@ -22,5 +22,6 @@ add_subdirectory(lib_source)
|
||||||
message("---------------------------- RibbonUI ----------------------------")
|
message("---------------------------- RibbonUI ----------------------------")
|
||||||
message("Build RibbonUI APP: ${RIBBONUI_BUILD_EXAMPLES}")
|
message("Build RibbonUI APP: ${RIBBONUI_BUILD_EXAMPLES}")
|
||||||
message("Build RibbonUI static library: ${RIBBONUI_BUILD_STATIC_LIB}")
|
message("Build RibbonUI static library: ${RIBBONUI_BUILD_STATIC_LIB}")
|
||||||
|
message("Build QWindowKit: ${RIBBONUI_BUILD_QWINDOWKIT}")
|
||||||
message("RibbonUI QML Plugin Path: ${RIBBONUI_QML_PLUGIN_DIRECTORY}")
|
message("RibbonUI QML Plugin Path: ${RIBBONUI_QML_PLUGIN_DIRECTORY}")
|
||||||
message("------------------------------------------------------------------")
|
message("------------------------------------------------------------------")
|
||||||
|
|
|
@ -12,6 +12,7 @@ RibbonWindow {
|
||||||
title: qsTr("About")
|
title: qsTr("About")
|
||||||
title_bar.show_darkmode_btn: false
|
title_bar.show_darkmode_btn: false
|
||||||
title_bar.show_style_switch: false
|
title_bar.show_style_switch: false
|
||||||
|
windowStatus: RibbonWindow.Status.SingleInstance
|
||||||
|
|
||||||
ColumnLayout{
|
ColumnLayout{
|
||||||
id: content
|
id: content
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 206cd7953eb37618bee14f7c3eae73f0bb863cad
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 15c5605a6a55f9fc08e9b8fa2644b2027e673812
|
|
@ -5,7 +5,6 @@ project(RibbonUI VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
|
@ -21,11 +20,15 @@ if(APPLE)
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FRAMELESSHELPER_BUILD_STATIC ON)
|
if (RIBBONUI_BUILD_QWINDOWKIT)
|
||||||
set(FRAMELESSHELPER_NO_SUMMARY OFF)
|
set(QWINDOWKIT_BUILD_STATIC ON)
|
||||||
set(FRAMELESSHELPER_NO_DEBUG_OUTPUT ON)
|
set(QWINDOWKIT_BUILD_EXAMPLES OFF)
|
||||||
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
set(QWINDOWKIT_BUILD_QUICK ON)
|
||||||
add_subdirectory(3rdparty/framelesshelper)
|
set(QWINDOWKIT_BUILD_WIDGETS OFF)
|
||||||
|
set(QWINDOWKIT_ENABLE_STYLE_AGENT ON)
|
||||||
|
set(QWINDOWKIT_INSTALL OFF)
|
||||||
|
add_subdirectory(3rdparty/qwindowkit)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Qt6 COMPONENTS Core Quick Qml REQUIRED)
|
find_package(Qt6 COMPONENTS Core Quick Qml REQUIRED)
|
||||||
|
|
||||||
|
@ -56,6 +59,15 @@ set(
|
||||||
qml/RibbonMessageListView.qml
|
qml/RibbonMessageListView.qml
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set (
|
||||||
|
source_files ribbonui.cpp ribbonui.h definitions.h ribbontheme.h ribbontheme.cpp
|
||||||
|
platformsupport.h
|
||||||
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
list(APPEND source_files platformsupport.mm)
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(qmlfile ${qml_files})
|
foreach(qmlfile ${qml_files})
|
||||||
string(REPLACE "qml/" "" fixedfile ${qmlfile})
|
string(REPLACE "qml/" "" fixedfile ${qmlfile})
|
||||||
set_source_files_properties(${qmlfile} PROPERTIES QT_RESOURCE_ALIAS ${fixedfile})
|
set_source_files_properties(${qmlfile} PROPERTIES QT_RESOURCE_ALIAS ${fixedfile})
|
||||||
|
@ -68,7 +80,7 @@ qt_add_qml_module(${PROJECT_NAME}
|
||||||
URI ${PROJECT_NAME}
|
URI ${PROJECT_NAME}
|
||||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
SOURCES ribbonui.cpp ribbonui.h definitions.h ribbontheme.h ribbontheme.cpp
|
SOURCES ${source_files}
|
||||||
RESOURCES resources/FluentSystemIcons-Resizable.ttf resources/imgs/icon.png
|
RESOURCES resources/FluentSystemIcons-Resizable.ttf resources/imgs/icon.png
|
||||||
RESOURCE_PREFIX "/qt/qml/"
|
RESOURCE_PREFIX "/qt/qml/"
|
||||||
)
|
)
|
||||||
|
@ -98,12 +110,11 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||||
Qt::QmlPrivate
|
Qt::QmlPrivate
|
||||||
)
|
)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||||
FramelessHelper::Core
|
QWindowKit::Quick
|
||||||
FramelessHelper::Quick
|
|
||||||
)
|
)
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
${PROJECT_SOURCE_DIR}
|
${PROJECT_SOURCE_DIR}
|
||||||
${PROJECT_SOURCE_DIR}/3rdparty/framelesshelper/include
|
${PROJECT_SOURCE_DIR}/3rdparty/qwindowkit/include
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY ${RIBBONUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)
|
install(DIRECTORY ${RIBBONUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef PLATFORMSUPPORT_H
|
||||||
|
#define PLATFORMSUPPORT_H
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
class PlatformSupport : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QML_ELEMENT
|
||||||
|
QML_SINGLETON
|
||||||
|
QML_NAMED_ELEMENT(PlatformSupport)
|
||||||
|
public:
|
||||||
|
static PlatformSupport* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();}
|
||||||
|
static PlatformSupport* instance(){
|
||||||
|
static QMutex mutex;
|
||||||
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
|
static PlatformSupport *singleton = nullptr;
|
||||||
|
if (!singleton) {
|
||||||
|
singleton = new PlatformSupport();
|
||||||
|
}
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
Q_INVOKABLE void showSystemTitleBtns(QWindow *window, bool enable);
|
||||||
|
#endif
|
||||||
|
private:
|
||||||
|
PlatformSupport(QObject *parent = nullptr) : QObject(parent){}
|
||||||
|
Q_DISABLE_COPY_MOVE(PlatformSupport)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PLATFORMSUPPORT_H
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "platformsupport.h"
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
void PlatformSupport::showSystemTitleBtns(QWindow *window, bool enable)
|
||||||
|
{
|
||||||
|
NSWindow* nswindow = [reinterpret_cast<NSView*>(window->winId()) window];
|
||||||
|
[nswindow standardWindowButton:NSWindowCloseButton].hidden = (enable ? NO : YES);
|
||||||
|
[nswindow standardWindowButton:NSWindowMiniaturizeButton].hidden = (enable ? NO : YES);
|
||||||
|
[nswindow standardWindowButton:NSWindowZoomButton].hidden = (enable ? NO : YES);
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import RibbonUI
|
import RibbonUI
|
||||||
import org.wangwenx190.FramelessHelper
|
import QWindowKit
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id:window
|
id:window
|
||||||
|
@ -16,27 +16,42 @@ Window {
|
||||||
property alias title_bar: titleBar
|
property alias title_bar: titleBar
|
||||||
property alias popup: pop
|
property alias popup: pop
|
||||||
property bool comfirmed_quit: false
|
property bool comfirmed_quit: false
|
||||||
|
property bool blurBehindWindow: true
|
||||||
visible: false
|
visible: false
|
||||||
color: {
|
color: {
|
||||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
if (blurBehindWindow) {
|
||||||
return "transparent";
|
return "transparent";
|
||||||
}
|
}
|
||||||
if (FramelessUtils.systemTheme === FramelessHelperConstants.Dark) {
|
if (RibbonTheme.dark_mode) {
|
||||||
return FramelessUtils.defaultSystemDarkColor;
|
return '#2C2B29'
|
||||||
}
|
}
|
||||||
return FramelessUtils.defaultSystemLightColor;
|
return '#FFFFFF'
|
||||||
}
|
}
|
||||||
FramelessHelper.onReady: {
|
onBlurBehindWindowChanged: {
|
||||||
|
if (Qt.platform.os === 'windows')
|
||||||
|
windowAgent.setWindowAttribute("acrylic-material", blurBehindWindow)
|
||||||
|
else if (Qt.platform.os === 'osx')
|
||||||
|
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
windowAgent.setup(window)
|
||||||
if (Qt.platform.os === 'windows')
|
if (Qt.platform.os === 'windows')
|
||||||
{
|
{
|
||||||
FramelessHelper.setSystemButton(titleBar.minimizeBtn, FramelessHelperConstants.Minimize);
|
windowAgent.setWindowAttribute("acrylic-material", blurBehindWindow)
|
||||||
FramelessHelper.setSystemButton(titleBar.maximizeBtn, FramelessHelperConstants.Maximize);
|
windowAgent.setSystemButton(WindowAgent.Minimize, titleBar.minimizeBtn);
|
||||||
FramelessHelper.setSystemButton(titleBar.closeBtn, FramelessHelperConstants.Close);
|
windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn);
|
||||||
|
windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn);
|
||||||
}
|
}
|
||||||
FramelessHelper.setHitTestVisible(titleBar.left_container)
|
if(Qt.platform.os === "osx")
|
||||||
FramelessHelper.setHitTestVisible(titleBar.right_container)
|
{
|
||||||
FramelessHelper.titleBarItem = titleBar;
|
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
|
||||||
FramelessHelper.moveWindowToDesktopCenter();
|
PlatformSupport.showSystemTitleBtns(window, true)
|
||||||
|
}
|
||||||
|
windowAgent.setHitTestVisible(titleBar.left_container)
|
||||||
|
windowAgent.setHitTestVisible(titleBar.right_container)
|
||||||
|
windowAgent.setTitleBar(titleBar);
|
||||||
|
windowAgent.centralize()
|
||||||
window.visible = true;
|
window.visible = true;
|
||||||
}
|
}
|
||||||
Item{
|
Item{
|
||||||
|
@ -65,10 +80,9 @@ Window {
|
||||||
Connections{
|
Connections{
|
||||||
target: RibbonTheme
|
target: RibbonTheme
|
||||||
function onTheme_modeChanged() {
|
function onTheme_modeChanged() {
|
||||||
if (RibbonTheme.dark_mode)
|
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.dark_mode)
|
||||||
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
|
if (Qt.platform.os === 'osx')
|
||||||
else
|
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
|
||||||
FramelessUtils.systemTheme = FramelessHelperConstants.Light
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
@ -82,7 +96,7 @@ Window {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
border.color: RibbonTheme.dark_mode ? "#7A7A7A" : "#2C59B7"
|
border.color: RibbonTheme.dark_mode ? "#7A7A7A" : "#2C59B7"
|
||||||
border.width: RibbonTheme.modern_style ? Qt.platform.os === 'windows' ? 2 : 1 : 0
|
border.width: RibbonTheme.modern_style ? 1 : 0
|
||||||
radius: Qt.platform.os === 'windows' ? 8 : 10
|
radius: Qt.platform.os === 'windows' ? 8 : 10
|
||||||
visible: RibbonTheme.modern_style
|
visible: RibbonTheme.modern_style
|
||||||
}
|
}
|
||||||
|
@ -111,6 +125,10 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WindowAgent {
|
||||||
|
id: windowAgent
|
||||||
|
}
|
||||||
|
|
||||||
onClosing:function(event){
|
onClosing:function(event){
|
||||||
window.raise()
|
window.raise()
|
||||||
event.accepted = !comfirmed_quit
|
event.accepted = !comfirmed_quit
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "ribbonui.h"
|
#include "ribbonui.h"
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QOperatingSystemVersion>
|
#include <QOperatingSystemVersion>
|
||||||
|
#include <QWKQuick/qwkquickglobal.h>
|
||||||
|
#include <QtQuick/QQuickWindow>
|
||||||
#define STR(x) #x
|
#define STR(x) #x
|
||||||
#define JOIN(a,b,c) STR(a.b.c)
|
#define JOIN(a,b,c) STR(a.b.c)
|
||||||
#define VER_JOIN(x) JOIN x
|
#define VER_JOIN(x) JOIN x
|
||||||
|
@ -26,20 +28,15 @@ RibbonUI* RibbonUI::instance(){
|
||||||
|
|
||||||
void RibbonUI::init()
|
void RibbonUI::init()
|
||||||
{
|
{
|
||||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
FramelessHelper::Quick::initialize();
|
qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
|
||||||
#ifdef Q_OS_WINDOWS
|
#else
|
||||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
qputenv("QT_QUICK_CONTROLS_STYLE", "Default");
|
||||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
|
||||||
if(QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 22000))
|
|
||||||
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
|
|
||||||
#endif
|
#endif
|
||||||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
|
||||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RibbonUI::registerTypes(QQmlEngine *qmlEngine)
|
void RibbonUI::registerTypes(QQmlEngine *qmlEngine)
|
||||||
{
|
{
|
||||||
FramelessHelper::Quick::registerTypes(qmlEngine);
|
QWK::registerTypes(qmlEngine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
|
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include "definitions.h"
|
#include "definitions.h"
|
||||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
|
||||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
|
||||||
|
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
|
||||||
class RibbonUI : public QQuickItem
|
class RibbonUI : public QQuickItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in New Issue