main
朱子楚\zhuzi 2023-03-07 00:05:27 +08:00
parent cd86f66358
commit 5f1eb364f8
15 changed files with 279 additions and 16 deletions

View File

@ -55,6 +55,10 @@ FluWindow {
text:"Rectangle"
page:"qrc:/T_Rectangle.qml"
}
ListElement{
text:"TreeView"
page:"qrc:/T_TreeView.qml"
}
ListElement{
text:"Theme"
page:"qrc:/T_Theme.qml"
@ -93,12 +97,6 @@ FluWindow {
FluApp.navigate("/About")
}
}
// FluMenuItem{
// text:""
// onClicked:{
// FluApp.navigate("/Setting")
// }
// }
}
onClicked:{
menu.open()

View File

@ -6,11 +6,29 @@ import QtGraphicalEffects 1.15
import FluentUI 1.0
Item {
FluText{
id:title
text:"Dialog"
text:"Dialog"
fontStyle: FluText.TitleLarge
}
FluContentDialog{
id:dialog
title:"友情提示"
message:"确定要退出程序么?"
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
}
positiveText:"确定"
onPositiveClicked:{
showSuccess("点击确定按钮")
}
}
ScrollView{
clip: true
width: parent.width
@ -25,7 +43,7 @@ Item {
Layout.topMargin: 20
text:"Show Dialog"
onClicked: {
dialog.open()
}
}
}

View File

@ -44,6 +44,7 @@ Item {
progress_bar.progress = value/100
progress_ring.progress = value/100
}
Layout.bottomMargin: 30
}
}
}

View File

@ -23,6 +23,7 @@ Item {
spacing: 5
FluSlider{
Layout.topMargin: 20
Layout.leftMargin: 15
value: 50
}
}

27
example/T_TreeView.qml Normal file
View File

@ -0,0 +1,27 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
import FluentUI 1.0
Item {
FluText{
id:title
text:"TreeView"
fontStyle: FluText.TitleLarge
}
FluTreeView{
id:tree_view
width:100
anchors{
top:title.bottom
left:parent.left
bottom:parent.bottom
}
Component.onCompleted: {
}
}
}

View File

@ -6,7 +6,7 @@ import FluentUI 1.0
Item {
FluText{
id:title
text:"Theme"
text:"Typography"
fontStyle: FluText.TitleLarge
}
ScrollView{
@ -21,6 +21,7 @@ Item {
spacing: 5
FluText{
text:"Display"
Layout.topMargin: 20
fontStyle: FluText.Display
}
FluText{

View File

@ -28,5 +28,6 @@
<file>T_TextBox.qml</file>
<file>T_Theme.qml</file>
<file>T_Dialog.qml</file>
<file>T_TreeView.qml</file>
</qresource>
</RCC>

View File

@ -33,6 +33,7 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluContentDialog.qml"),uri,major,minor,"FluContentDialog");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluMenu.qml"),uri,major,minor,"FluMenu");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluMenuItem.qml"),uri,major,minor,"FluMenuItem");

View File

@ -4,6 +4,27 @@
#include <QScreen>
#include <QWindow>
#include <VersionHelpers.h>
#include <WinUser.h>
#include <dwmapi.h>
#include <objidl.h> // Fixes error C2504: 'IUnknown' : base class undefined
#include <windows.h>
#include <windowsx.h>
#include <wtypes.h>
#pragma comment(lib, "Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "Gdi32.lib")
static bool isMaxWin(QWindow* win)
{
return win->windowState() == Qt::WindowMaximized;
}
static bool isFullWin(QQuickView* win)
{
return win->windowState() == Qt::WindowFullScreen;
}
class FramelessViewPrivate
{
public:
@ -100,6 +121,44 @@ bool FramelessView::nativeEvent(const QByteArray &eventType, void *message, qint
bool FramelessView::nativeEvent(const QByteArray &eventType, void *message, long *result)
#endif
{
#if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1))
// Work-around a bug caused by typo which only exists in Qt 5.11.1
const auto msg = *reinterpret_cast<MSG**>(message);
#else
const auto msg = static_cast<LPMSG>(message);
#endif
if (!msg || !msg->hwnd)
{
return false;
}
switch (msg->message)
{
case WM_NCCALCSIZE: {
const auto mode = static_cast<BOOL>(msg->wParam);
const auto clientRect = mode ? &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(msg->lParam)->rgrc[0]) : reinterpret_cast<LPRECT>(msg->lParam);
if (mode == TRUE)
{
*result = WVR_REDRAW;
//规避 拖动border进行resize时界面闪烁
if (!isMaxWin(this) && !isFullWin(this))
{
if (clientRect->top != 0)
{
clientRect->top -= 0.1;
}
}
else
{
if (clientRect->top != 0)
{
clientRect->top += 0.1;
}
}
return true;
}
break;
}
}
return Super::nativeEvent(eventType, message, result);
}

View File

@ -11,7 +11,7 @@ Rectangle{
color: {
if(Window.window == null)
return borerlessColor
return Window.window.active ? borerlessColor : Qt.lighter(FluTheme.primaryColor.lightest,1.1)
return Window.window.active ? borerlessColor : Qt.lighter(borerlessColor,1.1)
}
height: 50
width: {

View File

@ -1,19 +1,115 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
Popup {
id: popup
default property alias content: container.data
property string title: "Title"
property string message: "Messaeg"
property string negativeText: "Negative"
property string positiveText: "Positive"
signal negativeClicked
signal positiveClicked
property var minWidth: {
if(Window.window==null)
return 400
return Math.min(Window.window.width,400)
}
modal:true
anchors.centerIn: Overlay.overlay
closePolicy: Popup.CloseOnEscape
background: Rectangle {
implicitWidth: 140
implicitHeight: container.height
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(237/255,237/255,237/255,1)
radius: 5
implicitWidth:minWidth
implicitHeight: text_title.height + text_message.height + layout_actions.height
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
radius:5
FluShadow{
radius: 5
}
FluText{
id:text_title
fontStyle: FluText.TitleLarge
text:title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
anchors{
top:parent.top
left: parent.left
right: parent.right
}
}
FluText{
id:text_message
fontStyle: FluText.Body
wrapMode: Text.WrapAnywhere
text:message
topPadding: 14
leftPadding: 20
rightPadding: 20
bottomPadding: 14
anchors{
top:text_title.bottom
left: parent.left
right: parent.right
}
}
Rectangle{
id:layout_actions
height: 68
radius: 5
color: FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
anchors{
top:text_message.bottom
left: parent.left
right: parent.right
}
Item {
id:divider
width: 1
height: parent.height
anchors.centerIn: parent
}
FluButton{
anchors{
left: parent.left
leftMargin: 20
rightMargin: 10
right: divider.left
verticalCenter: parent.verticalCenter
}
text: negativeText
onClicked: {
popup.close()
negativeClicked()
}
}
FluFilledButton{
anchors{
right: parent.right
left: divider.right
rightMargin: 20
leftMargin: 10
verticalCenter: parent.verticalCenter
}
text: positiveText
onClicked: {
popup.close()
positiveClicked()
}
}
}
}
}

View File

@ -0,0 +1,6 @@
import QtQuick 2.15
QtObject {
property string text;
property list<FluTreeItem> items;
}

View File

@ -0,0 +1,52 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
import QtGraphicalEffects 1.15
Rectangle {
id:root
color:"#eeeeee"
ListModel{
id:list_model
}
ListView {
id: list_root
anchors.fill: parent
delegate: Rectangle{
width: list_root.width
height: 40
FluText{
anchors.centerIn: parent
text:model.text
}
}
model:list_model
clip: true
}
function addItems(items:list<FluTreeItem>){
items.map(item=>{
list_model.append({"text":item.text})
console.debug(item.text)
})
}
function createItem(text){
var com = Qt.createComponent("FluTreeItem.qml")
return com.createObject(root,{text:text})
}
Component.onCompleted: {
addItems([createItem("item1"),createItem("item2")])
// var data=[{"text":"item1"},{"text":"item1"}]
// list_model.append(data)
}
}

View File

@ -46,7 +46,7 @@ Item {
color: {
if(window === null)
return borerlessColor
return window.active ? borerlessColor : Qt.lighter(FluTheme.primaryColor.lightest,1.1)
return window.active ? borerlessColor : Qt.lighter(borerlessColor,1.1)
}
border.width: 1
anchors.fill: parent

View File

@ -33,5 +33,7 @@
<file>controls/FluShadow.qml</file>
<file>controls/FluTextButton.qml</file>
<file>controls/FluContentDialog.qml</file>
<file>controls/FluTreeView.qml</file>
<file>controls/FluTreeItem.qml</file>
</qresource>
</RCC>