Compare commits
3 Commits
3515eb178d
...
ac52c2710c
Author | SHA1 | Date |
---|---|---|
|
ac52c2710c | |
|
10e32d12a9 | |
|
d120c67d79 |
|
@ -1,3 +1,3 @@
|
|||
[submodule "3rdparty/framelesshelper"]
|
||||
path = 3rdparty/framelesshelper
|
||||
[submodule "lib_source/3rdparty/framelesshelper"]
|
||||
path = lib_source/3rdparty/framelesshelper
|
||||
url = git@github.com:mentalfl0w/framelesshelper.git
|
||||
|
|
|
@ -10,27 +10,18 @@ option(RIBBONUI_BUILD_EXAMPLES "Build RibbonUI APP." ON)
|
|||
option(RIBBONUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
||||
option(RIBBONUI_BUILD_STATIC_LIB "Build RibbonUI static library." OFF)
|
||||
|
||||
add_subdirectory(lib_source)
|
||||
|
||||
if (RIBBONUI_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if (RIBBONUI_BUILD_FRAMELESSHEPLER)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(NOT RIBBONUI_QML_PLUGIN_DIRECTORY)
|
||||
set(RIBBONUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/RibbonUI CACHE PATH "RibbonUI Plugin Path")
|
||||
endif()
|
||||
|
||||
add_subdirectory(lib_source)
|
||||
|
||||
message("---------------------------- RibbonUI ----------------------------")
|
||||
message("Build RibbonUI APP: ${RIBBONUI_BUILD_EXAMPLES}")
|
||||
message("Build FramelessHelper: ${RIBBONUI_BUILD_FRAMELESSHEPLER}")
|
||||
message("Build RibbonUI static library: ${RIBBONUI_BUILD_STATIC_LIB}")
|
||||
message("RibbonUI QML Plugin Path: ${RIBBONUI_QML_PLUGIN_DIRECTORY}")
|
||||
message("------------------------------------------------------------------")
|
||||
|
|
|
@ -85,7 +85,7 @@ qt_add_qml_module(${PROJECT_NAME}
|
|||
URI ${PROJECT_NAME}
|
||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||
RESOURCE_PREFIX "/qt/qml/"
|
||||
QML_FILES example.qml components/RibbonWindow.qml
|
||||
QML_FILES example.qml
|
||||
RESOURCES resources/imgs/heart.png resources/imgs/search.png
|
||||
)
|
||||
|
||||
|
@ -97,22 +97,19 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
|||
)
|
||||
|
||||
if(RIBBONUI_BUILD_STATIC_LIB)
|
||||
add_definitions(-DRIBBONUI_BUILD_STATIC_LIB)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt::Quick
|
||||
RibbonUIplugin
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
|
||||
else()
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt::Quick
|
||||
RibbonUI
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
RIBBONUI_BUILD_STATIC_LIB
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt::Quick
|
||||
RibbonUI
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR})
|
||||
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QtQml/qqmlextensionplugin.h>
|
||||
#include <FramelessHelper/Quick/framelessquickmodule.h>
|
||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||
#include "ribbonui.h"
|
||||
|
||||
FRAMELESSHELPER_USE_NAMESPACE
|
||||
#ifdef RIBBONUI_BUILD_STATIC_LIB
|
||||
Q_IMPORT_QML_PLUGIN(RibbonUIPlugin)
|
||||
#endif
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
FramelessHelper::Quick::initialize();
|
||||
RibbonUI::init(); // Must set before QGuiApplication
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
||||
#endif
|
||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
FramelessHelper::Quick::registerTypes(&engine);
|
||||
RibbonUI::registerTypes(&engine);
|
||||
const QUrl url(u"qrc:/qt/qml/RibbonUIAPP/example.qml"_qs);
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import QtQuick.Controls.Material
|
|||
import QtQuick.Window
|
||||
import RibbonUI
|
||||
import org.wangwenx190.FramelessHelper
|
||||
import "components"
|
||||
|
||||
RibbonWindow {
|
||||
id:root
|
||||
|
|
|
@ -6,6 +6,8 @@ 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")
|
||||
qt_standard_project_setup()
|
||||
qt_policy(SET QTP0001 NEW)
|
||||
|
@ -19,6 +21,12 @@ 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)
|
||||
|
||||
find_package(Qt6 COMPONENTS Core Quick Qml REQUIRED)
|
||||
|
||||
set(version_str "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH}")
|
||||
|
@ -44,14 +52,14 @@ set(
|
|||
qml/RibbonText.qml qml/RibbonTextBoxMenu.qml qml/RibbonPopup.qml
|
||||
qml/RibbonPopupDialog.qml qml/RibbonLineEdit.qml qml/RibbonTextEdit.qml
|
||||
qml/RibbonComboBox.qml qml/RibbonSpinBox.qml qml/RibbonScrollIndicator.qml
|
||||
qml/RibbonScrollBar.qml
|
||||
qml/RibbonScrollBar.qml qml/RibbonWindow.qml
|
||||
)
|
||||
|
||||
foreach(qmlfile ${qml_files})
|
||||
string(REPLACE "qml/" "" fixedfile ${qmlfile})
|
||||
set_source_files_properties(${qmlfile} PROPERTIES QT_RESOURCE_ALIAS ${fixedfile})
|
||||
endforeach(qmlfile)
|
||||
message(${RIBBONUI_QML_PLUGIN_DIRECTORY})
|
||||
|
||||
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||
qt_add_qml_module(${PROJECT_NAME}
|
||||
PLUGIN_TARGET ${PLUGIN_TARGET_NAME}
|
||||
|
@ -64,13 +72,38 @@ qt_add_qml_module(${PROJECT_NAME}
|
|||
RESOURCE_PREFIX "/qt/qml/"
|
||||
)
|
||||
|
||||
if (MINGW)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
|
||||
endif()
|
||||
|
||||
if (RIBBONUI_BUILD_STATIC_LIB)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
RIBBONUI_BUILD_STATIC_LIB
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
||||
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
|
||||
RIBBONUI_LIBRARY
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt::Quick
|
||||
Qt::CorePrivate
|
||||
Qt::QuickPrivate
|
||||
Qt::QmlPrivate
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
${PROJECT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/framelesshelper/include
|
||||
)
|
||||
|
||||
install(DIRECTORY ${RIBBONUI_QML_PLUGIN_DIRECTORY} DESTINATION ${CMAKE_INSTALL_PREFIX}/imports)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
|
|
@ -5,6 +5,18 @@
|
|||
#include <QtQml/qqml.h>
|
||||
#include <QtQml/qqmlregistration.h>
|
||||
|
||||
#ifndef RIBBONUI_API
|
||||
# ifdef RIBBONUI_BUILD_STATIC_LIB
|
||||
# define RIBBONUI_API
|
||||
# else // RIBBONUI_BUILD_STATIC_LIB
|
||||
# ifdef RIBBONUI_LIBRARY
|
||||
# define RIBBONUI_API Q_DECL_EXPORT
|
||||
# else // RIBBONUI_LIBRARY
|
||||
# define RIBBONUI_API Q_DECL_IMPORT
|
||||
# endif // RIBBONUI_LIBRARY
|
||||
# endif // RIBBONUI_BUILD_STATIC_LIB
|
||||
#endif // RIBBONUI_API
|
||||
|
||||
namespace RibbonIconsFilledEnum {
|
||||
Q_NAMESPACE
|
||||
enum class RibbonIcons_Filled{
|
||||
|
|
|
@ -10,18 +10,18 @@ ScrollBar {
|
|||
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
|
||||
implicitContentHeight + topPadding + bottomPadding)
|
||||
|
||||
verticalPadding: (control.vertical ? 8 + 5 : 0) + (18 - 8) / 2
|
||||
horizontalPadding: (control.vertical ? 0 : 8 + 5) + (18 - 8) / 2
|
||||
verticalPadding: control.hovered || control.pressed ? (control.vertical ? 8 + 5 : 0) + (18 - 8) / 2 : 2
|
||||
horizontalPadding: control.hovered || control.pressed ? (control.vertical ? 0 : 8 + 5) + (18 - 8) / 2 : 2
|
||||
visible: control.policy !== ScrollBar.AlwaysOff
|
||||
minimumSize: orientation === Qt.Horizontal ? height / width : width / height
|
||||
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: 8
|
||||
implicitHeight: 8
|
||||
implicitWidth: control.hovered || control.pressed ? 8 : 4
|
||||
implicitHeight: control.hovered || control.pressed ? 8 : 4
|
||||
visible: control.size < 1.0
|
||||
radius: width / 2
|
||||
color: RibbonTheme.dark_mode ? hover_handler.hovered ? '#D6D6D6' : hover_handler.hovered && control.pressed ? '#E5E5E5' : '#999999'
|
||||
: hover_handler.hovered ? '#424242' : hover_handler.hovered && control.pressed ? '#333333' : '#707070'
|
||||
: hover_handler.hovered ? '#424242' : hover_handler.hovered && control.pressed ? '#333333' : '#707070'
|
||||
opacity: 0.0
|
||||
|
||||
states: State {
|
||||
|
@ -38,21 +38,41 @@ ScrollBar {
|
|||
}
|
||||
}
|
||||
|
||||
Behavior on implicitWidth {
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: hover_handler.hovered ? 0 : 300 }
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: hover_handler.hovered ? 0 : 300 }
|
||||
NumberAnimation {
|
||||
duration: 200
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler{
|
||||
id:hover_handler
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle{
|
||||
implicitWidth: 18
|
||||
implicitHeight: 18
|
||||
implicitWidth: control.hovered || control.pressed ? 18 : 0
|
||||
implicitHeight: control.hovered || control.pressed ? 18 : 0
|
||||
color: RibbonTheme.dark_mode ? '#141414' : '#F5F5F5'
|
||||
opacity: 0.0
|
||||
radius: implicitWidth / 2
|
||||
visible: control.contentItem.visible
|
||||
states: State {
|
||||
name: "active"
|
||||
when: control.active
|
||||
when: control.active && control.hovered
|
||||
PropertyChanges { control.background.opacity: 0.75 }
|
||||
}
|
||||
|
||||
|
@ -60,9 +80,14 @@ ScrollBar {
|
|||
Transition {
|
||||
from: "active"
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 450 }
|
||||
NumberAnimation { target: control.background; duration: 200; property: "opacity"; to: 0.0 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "active"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { target: control.background; duration: 200; property: "opacity";}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -76,7 +101,7 @@ ScrollBar {
|
|||
onClicked: control.decrease()
|
||||
Component.onCompleted: setup()
|
||||
ribbon_icon.filled: true
|
||||
ribbon_icon.icon_size: 14
|
||||
ribbon_icon.icon_size: 15
|
||||
ribbon_icon.color: RibbonTheme.dark_mode ? hovered ? '#D6D6D6' : pressed ? '#E5E5E5' : '#999999'
|
||||
: hovered ? '#424242' : pressed ? '#333333' : '#707070'
|
||||
Connections{
|
||||
|
@ -116,7 +141,7 @@ ScrollBar {
|
|||
onClicked: control.increase()
|
||||
Component.onCompleted: setup()
|
||||
ribbon_icon.filled: true
|
||||
ribbon_icon.icon_size: 14
|
||||
ribbon_icon.icon_size: 15
|
||||
ribbon_icon.color: RibbonTheme.dark_mode ? hovered ? '#D6D6D6' : pressed ? '#E5E5E5' : '#999999'
|
||||
: hovered ? '#424242' : pressed ? '#333333' : '#707070'
|
||||
Connections{
|
||||
|
@ -146,4 +171,20 @@ ScrollBar {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on verticalPadding {
|
||||
enabled: control.hovered
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on horizontalPadding {
|
||||
enabled: control.hovered
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ ScrollIndicator {
|
|||
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
|
||||
implicitContentHeight + topPadding + bottomPadding)
|
||||
|
||||
padding: (control.background.implicitWidth - control.contentItem.implicitWidth)/2
|
||||
padding: control.hovered ? (control.background.implicitWidth - control.contentItem.implicitWidth)/2 : 2
|
||||
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: 8
|
||||
implicitHeight: 8
|
||||
implicitWidth: control.hovered ? 8 : 4
|
||||
implicitHeight: control.hovered ? 8 : 4
|
||||
|
||||
color: RibbonTheme.dark_mode ? '#999999' : '#707070'
|
||||
visible: control.size < 1.0
|
||||
|
@ -31,16 +31,35 @@ ScrollIndicator {
|
|||
Transition {
|
||||
from: "active"
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 450 }
|
||||
NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 }
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Behavior on implicitWidth {
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: control.hovered ? 0 : 300 }
|
||||
NumberAnimation {
|
||||
duration: 50
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: control.hovered ? 0 : 300 }
|
||||
NumberAnimation {
|
||||
duration: 100
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle{
|
||||
implicitWidth: 18
|
||||
implicitHeight: 18
|
||||
implicitWidth: control.hovered ? 18 : 0
|
||||
implicitHeight: control.hovered ? 18 : 0
|
||||
color: RibbonTheme.dark_mode ? '#141414' : '#F5F5F5'
|
||||
opacity: 0.0
|
||||
radius: implicitWidth / 2
|
||||
|
@ -48,7 +67,7 @@ ScrollIndicator {
|
|||
|
||||
states: State {
|
||||
name: "active"
|
||||
when: control.active
|
||||
when: control.active && control.hovered
|
||||
PropertyChanges { control.background.opacity: 0.75 }
|
||||
}
|
||||
|
||||
|
@ -56,9 +75,14 @@ ScrollIndicator {
|
|||
Transition {
|
||||
from: "active"
|
||||
SequentialAnimation {
|
||||
PauseAnimation { duration: 450 }
|
||||
NumberAnimation { target: control.background; duration: 200; property: "opacity"; to: 0.0 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
to: "active"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { target: control.background; duration: 200; property: "opacity";}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -21,3 +21,20 @@ RibbonUI* RibbonUI::instance(){
|
|||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
void RibbonUI::init()
|
||||
{
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
FramelessHelper::Quick::initialize();
|
||||
#ifdef Q_OS_WIN
|
||||
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
|
||||
#endif
|
||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
}
|
||||
|
||||
void RibbonUI::registerTypes(QQmlEngine *qmlEngine)
|
||||
{
|
||||
FramelessHelper::Quick::registerTypes(qmlEngine);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -15,6 +18,8 @@ class RibbonUI : public QQuickItem
|
|||
public:
|
||||
static RibbonUI* instance();
|
||||
static RibbonUI* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();}
|
||||
RIBBONUI_API static void init();
|
||||
RIBBONUI_API static void registerTypes(QQmlEngine *qmlEngine);
|
||||
private:
|
||||
explicit RibbonUI(QQuickItem *parent = nullptr);
|
||||
Q_DISABLE_COPY_MOVE(RibbonUI)
|
||||
|
|
Loading…
Reference in New Issue