Compare commits

..

No commits in common. "02077f837a8bad216e14f25dcd07d09c2f39a119" and "56f21299f0c7dc8f49460d864a61d98160feb60a" have entirely different histories.

11 changed files with 47 additions and 116 deletions

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "lib_source/3rdparty/qwindowkit"]
path = lib_source/3rdparty/qwindowkit
url = https://github.com/stdware/qwindowkit.git
[submodule "lib_source/3rdparty/framelesshelper"]
path = lib_source/3rdparty/framelesshelper
url = git@github.com:mentalfl0w/framelesshelper.git

View File

@ -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_QWINDOWKIT "Build QWindowKit." ON)
option(RIBBONUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
option(RIBBONUI_BUILD_STATIC_LIB "Build RibbonUI static library." OFF)
if(NOT RIBBONUI_QML_PLUGIN_DIRECTORY)
@ -22,6 +22,5 @@ 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("------------------------------------------------------------------")

View File

@ -12,7 +12,6 @@ RibbonWindow {
title: qsTr("About")
title_bar.show_darkmode_btn: false
title_bar.show_style_switch: false
windowStatus: RibbonWindow.Status.SingleInstance
ColumnLayout{
id: content

@ -0,0 +1 @@
Subproject commit 206cd7953eb37618bee14f7c3eae73f0bb863cad

@ -1 +0,0 @@
Subproject commit 15c5605a6a55f9fc08e9b8fa2644b2027e673812

View File

@ -5,6 +5,7 @@ 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")
@ -20,15 +21,11 @@ if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
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()
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)
find_package(Qt6 COMPONENTS Core Quick Qml REQUIRED)
@ -59,15 +56,6 @@ 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})
@ -80,7 +68,7 @@ qt_add_qml_module(${PROJECT_NAME}
URI ${PROJECT_NAME}
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
QML_FILES ${qml_files}
SOURCES ${source_files}
SOURCES ribbonui.cpp ribbonui.h definitions.h ribbontheme.h ribbontheme.cpp
RESOURCES resources/FluentSystemIcons-Resizable.ttf resources/imgs/icon.png
RESOURCE_PREFIX "/qt/qml/"
)
@ -110,11 +98,12 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
Qt::QmlPrivate
)
target_link_libraries(${PROJECT_NAME} PUBLIC
QWindowKit::Quick
FramelessHelper::Core
FramelessHelper::Quick
)
target_include_directories(${PROJECT_NAME} PUBLIC
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/3rdparty/qwindowkit/include
${PROJECT_SOURCE_DIR}/3rdparty/framelesshelper/include
)
install(DIRECTORY ${RIBBONUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)

View File

@ -1,33 +0,0 @@
#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

View File

@ -1,10 +0,0 @@
#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);
}

View File

@ -1,6 +1,6 @@
import QtQuick
import RibbonUI
import QWindowKit
import org.wangwenx190.FramelessHelper
Window {
id:window
@ -16,43 +16,27 @@ Window {
property alias title_bar: titleBar
property alias popup: pop
property bool comfirmed_quit: false
property bool blurBehindWindow: false
visible: false
color: {
if (blurBehindWindow) {
if (FramelessHelper.blurBehindWindowEnabled) {
return "transparent";
}
if (RibbonTheme.dark_mode) {
return '#2C2B29'
if (FramelessUtils.systemTheme === FramelessHelperConstants.Dark) {
return FramelessUtils.defaultSystemDarkColor;
}
return '#FFFFFF'
return FramelessUtils.defaultSystemLightColor;
}
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)
FramelessHelper.onReady: {
if (Qt.platform.os === 'windows')
{
windowAgent.setWindowAttribute("acrylic-material", blurBehindWindow)
windowAgent.setSystemButton(WindowAgent.Minimize, titleBar.minimizeBtn);
windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn);
windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn);
FramelessHelper.setSystemButton(titleBar.minimizeBtn, FramelessHelperConstants.Minimize);
FramelessHelper.setSystemButton(titleBar.maximizeBtn, FramelessHelperConstants.Maximize);
FramelessHelper.setSystemButton(titleBar.closeBtn, FramelessHelperConstants.Close);
}
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()
FramelessHelper.setHitTestVisible(titleBar.left_container)
FramelessHelper.setHitTestVisible(titleBar.right_container)
FramelessHelper.titleBarItem = titleBar;
FramelessHelper.moveWindowToDesktopCenter();
window.visible = true;
}
Item{
@ -81,9 +65,10 @@ Window {
Connections{
target: RibbonTheme
function onTheme_modeChanged() {
windowAgent.setWindowAttribute("dark-mode", RibbonTheme.dark_mode)
if (Qt.platform.os === 'osx')
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.dark_mode ? "dark" : "light" : "none")
if (RibbonTheme.dark_mode)
FramelessUtils.systemTheme = FramelessHelperConstants.Dark
else
FramelessUtils.systemTheme = FramelessHelperConstants.Light
}
}
Rectangle{
@ -97,7 +82,7 @@ Window {
anchors.fill: parent
color: 'transparent'
border.color: RibbonTheme.dark_mode ? "#7A7A7A" : "#2C59B7"
border.width: RibbonTheme.modern_style ? 1 : 0
border.width: RibbonTheme.modern_style ? Qt.platform.os === 'windows' ? 2 : 1 : 0
radius: Qt.platform.os === 'windows' ? 8 : 10
visible: RibbonTheme.modern_style
}
@ -126,10 +111,6 @@ Window {
}
}
WindowAgent {
id: windowAgent
}
onClosing:function(event){
window.raise()
event.accepted = !comfirmed_quit

View File

@ -1,8 +1,6 @@
#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
@ -28,15 +26,20 @@ RibbonUI* RibbonUI::instance(){
void RibbonUI::init()
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
#else
qputenv("QT_QUICK_CONTROLS_STYLE", "Default");
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);
#endif
QQuickWindow::setDefaultAlphaBuffer(true);
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
}
void RibbonUI::registerTypes(QQmlEngine *qmlEngine)
{
QWK::registerTypes(qmlEngine);
FramelessHelper::Quick::registerTypes(qmlEngine);
}

View File

@ -3,7 +3,10 @@
#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