Compare commits
2 Commits
56f21299f0
...
02077f837a
Author | SHA1 | Date |
---|---|---|
|
02077f837a | |
|
6e5ad39f4f |
|
@ -1,3 +1,3 @@
|
|||
[submodule "lib_source/3rdparty/framelesshelper"]
|
||||
path = lib_source/3rdparty/framelesshelper
|
||||
url = git@github.com:mentalfl0w/framelesshelper.git
|
||||
[submodule "lib_source/3rdparty/qwindowkit"]
|
||||
path = lib_source/3rdparty/qwindowkit
|
||||
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})
|
||||
|
||||
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)
|
||||
|
||||
if(NOT RIBBONUI_QML_PLUGIN_DIRECTORY)
|
||||
|
@ -22,5 +22,6 @@ add_subdirectory(lib_source)
|
|||
message("---------------------------- RibbonUI ----------------------------")
|
||||
message("Build RibbonUI APP: ${RIBBONUI_BUILD_EXAMPLES}")
|
||||
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("------------------------------------------------------------------")
|
||||
|
|
|
@ -12,6 +12,7 @@ RibbonWindow {
|
|||
title: qsTr("About")
|
||||
title_bar.show_darkmode_btn: false
|
||||
title_bar.show_style_switch: false
|
||||
windowStatus: RibbonWindow.Status.SingleInstance
|
||||
|
||||
ColumnLayout{
|
||||
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)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||
|
@ -21,11 +20,15 @@ if(APPLE)
|
|||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
set(FRAMELESSHELPER_BUILD_STATIC ON)
|
||||
set(FRAMELESSHELPER_NO_SUMMARY OFF)
|
||||
set(FRAMELESSHELPER_NO_DEBUG_OUTPUT ON)
|
||||
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
||||
add_subdirectory(3rdparty/framelesshelper)
|
||||
if (RIBBONUI_BUILD_QWINDOWKIT)
|
||||
set(QWINDOWKIT_BUILD_STATIC ON)
|
||||
set(QWINDOWKIT_BUILD_EXAMPLES OFF)
|
||||
set(QWINDOWKIT_BUILD_QUICK ON)
|
||||
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)
|
||||
|
||||
|
@ -56,6 +59,15 @@ set(
|
|||
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})
|
||||
string(REPLACE "qml/" "" fixedfile ${qmlfile})
|
||||
set_source_files_properties(${qmlfile} PROPERTIES QT_RESOURCE_ALIAS ${fixedfile})
|
||||
|
@ -68,7 +80,7 @@ qt_add_qml_module(${PROJECT_NAME}
|
|||
URI ${PROJECT_NAME}
|
||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
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
|
||||
RESOURCE_PREFIX "/qt/qml/"
|
||||
)
|
||||
|
@ -98,12 +110,11 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
|||
Qt::QmlPrivate
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
QWindowKit::Quick
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
${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)
|
||||
|
|
|
@ -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 RibbonUI
|
||||
import org.wangwenx190.FramelessHelper
|
||||
import QWindowKit
|
||||
|
||||
Window {
|
||||
id:window
|
||||
|
@ -16,27 +16,43 @@ Window {
|
|||
property alias title_bar: titleBar
|
||||
property alias popup: pop
|
||||
property bool comfirmed_quit: false
|
||||
property bool blurBehindWindow: false
|
||||
visible: false
|
||||
color: {
|
||||
if (FramelessHelper.blurBehindWindowEnabled) {
|
||||
if (blurBehindWindow) {
|
||||
return "transparent";
|
||||
}
|
||||
if (FramelessUtils.systemTheme === FramelessHelperConstants.Dark) {
|
||||
return FramelessUtils.defaultSystemDarkColor;
|
||||
if (RibbonTheme.dark_mode) {
|
||||
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')
|
||||
{
|
||||
FramelessHelper.setSystemButton(titleBar.minimizeBtn, FramelessHelperConstants.Minimize);
|
||||
FramelessHelper.setSystemButton(titleBar.maximizeBtn, FramelessHelperConstants.Maximize);
|
||||
FramelessHelper.setSystemButton(titleBar.closeBtn, FramelessHelperConstants.Close);
|
||||
windowAgent.setWindowAttribute("acrylic-material", blurBehindWindow)
|
||||
windowAgent.setSystemButton(WindowAgent.Minimize, titleBar.minimizeBtn);
|
||||
windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn);
|
||||
windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn);
|
||||
}
|
||||
FramelessHelper.setHitTestVisible(titleBar.left_container)
|
||||
FramelessHelper.setHitTestVisible(titleBar.right_container)
|
||||
FramelessHelper.titleBarItem = titleBar;
|
||||
FramelessHelper.moveWindowToDesktopCenter();
|
||||
if(Qt.platform.os === "osx")
|
||||
{
|
||||
blurBehindWindow = true
|
||||
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
|
||||
PlatformSupport.showSystemTitleBtns(window, true)
|
||||
}
|
||||
windowAgent.setHitTestVisible(titleBar.left_container)
|
||||
windowAgent.setHitTestVisible(titleBar.right_container)
|
||||
windowAgent.setTitleBar(titleBar);
|
||||
windowAgent.centralize()
|
||||
window.visible = true;
|
||||
}
|
||||
Item{
|
||||
|
@ -65,10 +81,9 @@ Window {
|
|||
Connections{
|
||||
target: RibbonTheme
|
||||
function onTheme_modeChanged() {
|
||||
if (RibbonTheme.dark_mode)
|
||||
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
|
||||
else
|
||||
FramelessUtils.systemTheme = FramelessHelperConstants.Light
|
||||
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.dark_mode)
|
||||
if (Qt.platform.os === 'osx')
|
||||
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
|
@ -82,7 +97,7 @@ Window {
|
|||
anchors.fill: parent
|
||||
color: 'transparent'
|
||||
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
|
||||
visible: RibbonTheme.modern_style
|
||||
}
|
||||
|
@ -111,6 +126,10 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
WindowAgent {
|
||||
id: windowAgent
|
||||
}
|
||||
|
||||
onClosing:function(event){
|
||||
window.raise()
|
||||
event.accepted = !comfirmed_quit
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "ribbonui.h"
|
||||
#include <QMutex>
|
||||
#include <QOperatingSystemVersion>
|
||||
#include <QWKQuick/qwkquickglobal.h>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#define STR(x) #x
|
||||
#define JOIN(a,b,c) STR(a.b.c)
|
||||
#define VER_JOIN(x) JOIN x
|
||||
|
@ -26,20 +28,15 @@ RibbonUI* RibbonUI::instance(){
|
|||
|
||||
void RibbonUI::init()
|
||||
{
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
FramelessHelper::Quick::initialize();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
|
||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
if(QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 22000))
|
||||
FramelessConfig::instance()->set(Global::Option::WindowUseRoundCorners);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
|
||||
#else
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE", "Default");
|
||||
#endif
|
||||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
}
|
||||
|
||||
void RibbonUI::registerTypes(QQmlEngine *qmlEngine)
|
||||
{
|
||||
FramelessHelper::Quick::registerTypes(qmlEngine);
|
||||
QWK::registerTypes(qmlEngine);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
|
||||
#include <QQuickItem>
|
||||
#include "definitions.h"
|
||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
class RibbonUI : public QQuickItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in New Issue