Compare commits

..

39 Commits
1.0.5 ... 1.1.1

Author SHA1 Message Date
b83e70ba24 update 2023-03-20 21:28:12 +08:00
e29cb7433e update 2023-03-20 18:22:32 +08:00
9545175445 update 2023-03-18 22:52:24 +08:00
a447b260e7 update 2023-03-18 20:41:21 +08:00
8eb7e1df4a update 2023-03-18 20:20:59 +08:00
c622f80659 update 2023-03-18 01:25:49 +08:00
c0ed9cb41c update 2023-03-18 01:18:13 +08:00
e5a24ec642 update 2023-03-18 00:53:06 +08:00
6553584c3d update 2023-03-18 00:50:09 +08:00
1ea043ee13 update 2023-03-18 00:39:08 +08:00
0d6b0d9d25 update 2023-03-17 23:33:02 +08:00
5f71ad57d0 update 2023-03-17 23:03:46 +08:00
c789d53d6a update 2023-03-17 23:01:48 +08:00
f2bbbd5250 update 2023-03-17 22:59:21 +08:00
4e95923847 update 2023-03-17 17:56:50 +08:00
5fadb582c9 update 2023-03-17 14:33:46 +08:00
6b54401371 update 2023-03-17 14:29:13 +08:00
28b65e2f33 update 2023-03-17 14:09:16 +08:00
0689c3b9d9 Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2023-03-17 14:05:42 +08:00
9c121c6ba9 update 2023-03-17 14:05:27 +08:00
f2a66221e6 updaet 2023-03-16 22:06:08 +08:00
2de9d78f41 update 2023-03-16 18:11:03 +08:00
96355b0a97 update 2023-03-16 14:34:20 +08:00
47597471dd Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2023-03-15 20:40:30 +08:00
184f52c896 update 2023-03-15 20:40:09 +08:00
31b2b0b004 update 2023-03-15 18:45:14 +08:00
1e4f939de7 update 2023-03-15 14:49:33 +08:00
926132a285 update 2023-03-15 14:48:48 +08:00
9e245fb533 update 2023-03-15 00:36:49 +08:00
8bfbfd63fb update 2023-03-15 00:33:38 +08:00
51a206e583 update 2023-03-14 18:23:12 +08:00
ee3ddf7732 update 2023-03-13 21:32:29 +08:00
6d238871ee update 2023-03-13 21:28:35 +08:00
9d3de073c0 update 2023-03-13 21:18:51 +08:00
7282a6f8d1 update 2023-03-13 18:23:46 +08:00
2b9e9b2159 update 2023-03-12 22:43:13 +08:00
23bc5cdf68 update 2023-03-12 22:36:31 +08:00
f75da5e3ce update 2023-03-12 22:02:12 +08:00
8cc828a56b update 2023-03-12 21:49:11 +08:00
82 changed files with 1720 additions and 422 deletions

11
.gitignore vendored
View File

@ -1,14 +1,3 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug

View File

@ -57,12 +57,21 @@
|FluTooltip|tooltip提示框||
|FluTreeView|树控件||
|FluTheme|主题设置|支持主题颜色切换,夜间模式|
|FluCarousel|轮播图组件|支持无限轮播|
|FluTimePicker|时间选择器||
|FluDatePicker|日期选择器||
|FluMenu|菜单Popup||
|FluNavigationView|响应式导航布局||
# 部分效果预览
## 主页
## 一个聊天Demo调用了ChatGPT的接口
![](doc/preview/main.png)
![](doc/preview/chatgpt.png)
## 各种Button按钮
![](doc/preview/buttons.png)
## 主题颜色切换、夜间模式
@ -72,10 +81,14 @@
![](doc/preview/treeview.png)
## Toast组件
## 轮播图组件
![](doc/preview/carousel.png)
## InfoBar提示框组件
![](doc/preview/infobar.png)
## Rectangle组件
## 多窗口路由跳转
![](doc/preview/rectangle.png)
![](doc/preview/multiwindow.png)

BIN
doc/preview/buttons.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
doc/preview/carousel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB

BIN
doc/preview/chatgpt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

BIN
doc/preview/multiwindow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -12,9 +12,10 @@ Window {
FluApp.init(app,properties)
FluTheme.isDark = false
FluApp.routes = {
"/":"qrc:/MainPage.qml",
"/Setting":"qrc:/SettingPage.qml",
"/About":"qrc:/AboutPage.qml",
"/":"qrc:/page/MainPage.qml",
"/about":"qrc:/page/AboutPage.qml",
"/login":"qrc:/page/LoginPage.qml",
"/chat":"qrc:/page/ChatPage.qml",
}
FluApp.initialRoute = "/"
FluApp.run()

View File

@ -0,0 +1,56 @@
#include "ChatController.h"
ChatController::ChatController(QObject *parent)
: QObject{parent}
{
isLoading(false);
networkManager = new QNetworkAccessManager(this);
}
void ChatController::sendMessage(const QString& text){
isLoading(true);
QUrl apiUrl("https://api.openai.com/v1/chat/completions");
QNetworkRequest request(apiUrl);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setRawHeader("Authorization", QString::fromStdString("Bearer %1").arg(QString::fromUtf8(QByteArray::fromBase64(baseKey.toUtf8()))).toUtf8());
QJsonObject requestData;
requestData.insert("model", "gpt-3.5-turbo");
messages.append(createMessage("user",text));
requestData.insert("messages", messages);
QJsonDocument requestDoc(requestData);
QByteArray requestDataBytes = requestDoc.toJson();
QNetworkReply* reply = networkManager->post(request, requestDataBytes);
connect(reply, &QNetworkReply::finished,this, [=]() {
if (reply->error() == QNetworkReply::NoError) {
QString responseString = QString::fromUtf8(reply->readAll());
qDebug() << responseString;
QJsonDocument doc = QJsonDocument::fromJson(responseString.toUtf8());
QJsonObject jsonObj = doc.object();
QString text = jsonObj.value("choices").toArray().at(0).toObject().value("message").toObject().value("content").toString();
if(text.isEmpty()){
text = "响应错误content为空数据";
}else{
messages.append(createMessage("assistant",text));
}
responseData(text.trimmed());
} else {
responseData("网络错误:"+reply->errorString());
}
isLoading(false);
reply->deleteLater();
});
}
QJsonObject ChatController::createMessage(const QString& role,const QString& content){
QJsonObject message;
message.insert("role",role);
message.insert("content",content);
return message;
}
void ChatController::clipText(const QString& text){
qDebug()<<text;
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(text);
}

35
example/ChatController.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef CHATCONTROLLER_H
#define CHATCONTROLLER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QGuiApplication>
#include <QClipboard>
#include <QByteArray>
#include <QFile>
#include "stdafx.h"
class ChatController : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(bool,isLoading)
Q_PROPERTY_AUTO(QString,responseData);
public:
explicit ChatController(QObject *parent = nullptr);
Q_INVOKABLE void sendMessage(const QString& text);
Q_INVOKABLE void clipText(const QString& text);
private:
QJsonObject createMessage(const QString& role,const QString& content);
private:
QNetworkAccessManager* networkManager;
QJsonArray messages;
QString baseKey = "c2stbXgxWm5MQkZ5TzhNYzNmRWl6eDZUM0JsYmtGSnNBWjNiakJjSXB6WGN3QW9KSk11";
};
#endif // CHATCONTROLLER_H

View File

@ -1,29 +0,0 @@
import QtQuick 2.15
import FluentUI 1.0
FluWindow {
width: 500
height: 600
title:"设置"
FluAppBar{
id:appbar
title:"设置"
}
FluText{
text:"设置"
fontStyle: FluText.Display
anchors.centerIn: parent
MouseArea{
anchors.fill: parent
onClicked: {
FluApp.navigate("/About")
}
}
}
}

View File

@ -47,7 +47,7 @@ FluContentPage {
height: 80
FluIconButton{
id:item_icon
icon:modelData.icon
iconSource:modelData.icon
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
var text ="FluentIcons."+modelData.name;

101
example/T_Badge.qml Normal file
View File

@ -0,0 +1,101 @@
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
FluScrollablePage{
title:"Badge"
FluArea{
width: parent.width
Layout.topMargin: 20
height: 106
paddings: 10
Column{
spacing: 15
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"一般出现在通知图标或头像的右上角,用于显示需要处理的消息条数"
}
Row{
spacing: 20
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:0
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:5
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:50
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:100
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
isDot:true
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:99
color: Qt.rgba(250/255,173/255,20/255,1)
}
}
Rectangle{
width: 40
height: 40
radius: 8
color: Qt.rgba(191/255,191/255,191/255,1)
FluBadge{
count:99
color: Qt.rgba(82/255,196/255,26/255,1)
}
}
}
}
}
}

View File

@ -10,8 +10,8 @@ FluScrollablePage{
spacing: 20
FluText{
Layout.topMargin: 20
text:"支持Tab键切换焦点Enter键执行点击事件"
Layout.topMargin: 20
text:"支持Tab键切换焦点空格键执行点击事件"
}
FluArea{
@ -20,7 +20,8 @@ FluScrollablePage{
paddings: 10
FluButton{
disabled:button_switch.checked
disabled:button_switch.selected
text:"Standard Button"
onClicked: {
showInfo("点击StandardButton")
}
@ -39,8 +40,6 @@ FluScrollablePage{
FluToggleSwitch{
id:button_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
@ -52,9 +51,10 @@ FluScrollablePage{
paddings: 10
FluFilledButton{
disabled:filled_button_switch.checked
disabled:filled_button_switch.selected
text:"Filled Button"
onClicked: {
showWarning("点击FilledButton")
showWarning("点击FilledButton")
}
anchors{
verticalCenter: parent.verticalCenter
@ -71,8 +71,6 @@ FluScrollablePage{
FluToggleSwitch{
id:filled_button_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
@ -85,8 +83,8 @@ FluScrollablePage{
paddings: 10
FluIconButton{
icon:FluentIcons.ChromeCloseContrast
disabled:icon_button_switch.checked
iconSource:FluentIcons.ChromeCloseContrast
disabled:icon_button_switch.selected
iconSize: 15
anchors{
verticalCenter: parent.verticalCenter
@ -106,8 +104,47 @@ FluScrollablePage{
FluToggleSwitch{
id:icon_button_switch
Layout.alignment: Qt.AlignRight
text:"Disabled"
}
FluText{
}
}
FluArea{
width: parent.width
height: 68
paddings: 10
FluDropDownButton{
disabled:drop_down_button_switch.selected
text:"DropDownButton"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
items:[
FluMenuItem{
text:"Menu_1"
},
FluMenuItem{
text:"Menu_2"
},
FluMenuItem{
text:"Menu_3"
},
FluMenuItem{
text:"Menu_4"
}
]
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:drop_down_button_switch
Layout.alignment: Qt.AlignRight
text:"Disabled"
}
}
@ -129,8 +166,8 @@ FluScrollablePage{
property int selecIndex : 0
model: 3
delegate: FluRadioButton{
checked : repeater.selecIndex===index
disabled:radio_button_switch.checked
selected : repeater.selecIndex===index
disabled:radio_button_switch.selected
text:"Radio Button_"+index
onClicked:{
repeater.selecIndex = index
@ -149,8 +186,6 @@ FluScrollablePage{
FluToggleSwitch{
id:radio_button_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
@ -163,7 +198,8 @@ FluScrollablePage{
paddings: 10
FluCheckBox{
disabled:icon_button_check.checked
disabled:check_box_switch.selected
text:"Check Box"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
@ -178,12 +214,12 @@ FluScrollablePage{
right: parent.right
}
FluToggleSwitch{
id:icon_button_check
id:check_box_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
}
}

36
example/T_Carousel.qml Normal file
View File

@ -0,0 +1,36 @@
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
FluScrollablePage{
title:"Carousel"
FluArea{
width: parent.width
height: 370
paddings: 10
Layout.topMargin: 20
Column{
spacing: 15
anchors{
verticalCenter: parent.verticalCenter
left:parent.left
}
FluText{
text:"轮播图支持无限轮播无限滑动用ListView实现的组件"
}
FluCarousel{
id:carousel
Layout.topMargin: 20
Layout.leftMargin: 5
Component.onCompleted: {
carousel.setData([{url:"qrc:/res/image/banner_1.jpg"},{url:"qrc:/res/image/banner_2.jpg"},{url:"qrc:/res/image/banner_3.jpg"}])
}
}
}
}
}

View File

@ -26,7 +26,7 @@ FluScrollablePage{
property int selecIndex : 0
model: 3
delegate: FluRadioButton{
checked : repeater.selecIndex===index
selected : repeater.selecIndex===index
text:"Radio Button_"+index
onClicked:{
repeater.selecIndex = index

54
example/T_Menu.qml Normal file
View File

@ -0,0 +1,54 @@
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
FluScrollablePage{
title:"Menu"
FluButton{
text:"左击菜单"
Layout.topMargin: 20
Layout.leftMargin: 15
onClicked:{
menu.popup()
}
}
FluButton{
text:"右击菜单"
Layout.topMargin: 20
Layout.leftMargin: 15
onClicked: {
showSuccess("请按鼠标右击")
}
MouseArea{
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
menu.popup()
}
}
}
FluMenu{
id:menu
FluMenuItem{
text:"删除"
onClicked: {
showError("删除")
}
}
FluMenuItem{
text:"修改"
onClicked: {
showError("修改")
}
}
}
}

77
example/T_MultiWindow.qml Normal file
View File

@ -0,0 +1,77 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
FluScrollablePage{
title:"MultiWindow"
property string password: ""
property var loginPageRegister: registerForPageResult("/login")
Connections{
target: loginPageRegister
function onResult(data)
{
password = data.password
}
}
FluArea{
width: parent.width
height: 100
paddings: 10
Layout.topMargin: 20
Column{
spacing: 15
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"页面跳转,不携带任何参数"
}
FluButton{
text:"点击跳转"
onClicked: {
FluApp.navigate("/about")
}
}
}
}
FluArea{
width: parent.width
height: 130
paddings: 10
Layout.topMargin: 20
Column{
spacing: 15
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"页面跳转并携带参数用户名zhuzichu"
}
FluButton{
text:"点击跳转到登录"
onClicked: {
loginPageRegister.launch({username:"zhuzichu"})
}
}
FluText{
text:"登录窗口返回过来的密码->"+password
}
}
}
}

View File

@ -13,17 +13,26 @@ FluScrollablePage{
Layout.topMargin: 20
placeholderText: "单行输入框"
Layout.preferredWidth: 300
disabled:toggle_switch.selected
}
FluMultiLineTextBox{
Layout.topMargin: 20
Layout.preferredWidth: 300
placeholderText: "多行输入框"
disabled:toggle_switch.selected
}
FluAutoSuggestBox{
Layout.topMargin: 20
values:generateRandomNames(100)
placeholderText: "AutoSuggestBox"
Layout.preferredWidth: 300
disabled:toggle_switch.selected
}
FluToggleSwitch{
id:toggle_switch
text:"Disabled"
Layout.topMargin: 20
}
function generateRandomNames(numNames) {

View File

@ -20,7 +20,7 @@ FluScrollablePage{
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
FluIcon {
anchors.centerIn: parent
icon: FluentIcons.AcceptMedium
iconSource: FluentIcons.AcceptMedium
iconSize: 15
visible: modelData === FluTheme.primaryColor
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
@ -41,8 +41,8 @@ FluScrollablePage{
Layout.topMargin: 20
}
FluToggleSwitch{
checked: FluTheme.isDark
onClickFunc:function(){
selected: FluTheme.isDark
clickFunc:function(){
FluTheme.isDark = !FluTheme.isDark
}
}
@ -51,8 +51,8 @@ FluScrollablePage{
Layout.topMargin: 20
}
FluToggleSwitch{
checked: FluTheme.isFrameless
onClickFunc:function(){
selected: FluTheme.isFrameless
clickFunc:function(){
FluTheme.isFrameless = !FluTheme.isFrameless
}
}
@ -61,8 +61,8 @@ FluScrollablePage{
Layout.topMargin: 20
}
FluToggleSwitch{
checked: FluTheme.isNativeText
onClickFunc:function(){
selected: FluTheme.isNativeText
clickFunc:function(){
FluTheme.isNativeText = !FluTheme.isNativeText
}
}

View File

@ -12,4 +12,8 @@ FluScrollablePage{
FluToggleSwitch{
Layout.topMargin: 20
}
FluToggleSwitch{
Layout.topMargin: 20
text:"Disabled"
}
}

75
example/T_Tooltip.qml Normal file
View File

@ -0,0 +1,75 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtGraphicalEffects 1.15
import FluentUI 1.0
FluScrollablePage{
title:"Tooltip"
FluText{
Layout.topMargin: 20
text:"鼠标悬停不动弹出Tooltip"
}
FluArea{
width: parent.width
Layout.topMargin: 20
height: 68
paddings: 10
Column{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"FluIconButton的text属性自带Tooltip效果"
}
FluIconButton{
iconSource:FluentIcons.ChromeCloseContrast
iconSize: 15
text:"删除"
onClicked:{
showSuccess("点击IconButton")
}
}
}
}
FluArea{
width: parent.width
Layout.topMargin: 20
height: 68
paddings: 10
Column{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluText{
text:"给一个Button添加Tooltip效果"
}
FluButton{
id:button_1
text:"删除"
onClicked:{
showSuccess("点击一个Button")
}
FluTooltip{
visible: button_1.hovered
text:button_1.text
delay: 1000
}
}
}
}
}

View File

@ -1,13 +1,16 @@
QT += quick concurrent
QT += quick concurrent network
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
SOURCES += \
ChatController.cpp \
main.cpp
RESOURCES += qml.qrc
RC_ICONS = favicon.ico
#qnx: target.path = /tmp/$${TARGET}/bin
#else: unix:!android: target.path = /opt/$${TARGET}/bin
#!isEmpty(target.path): INSTALLS += target
@ -22,3 +25,27 @@ CONFIG(debug,debug|release) {
} else {
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/release)
}
win32 {
contains(QT_ARCH, i386) {
COPYDLL = $$absolute_path($${_PRO_FILE_PWD_}/../third/Win_x86/*.dll) $$DESTDIR
contains(QMAKE_CC, cl) {
QMAKE_PRE_LINK += $$QMAKE_COPY $$replace(COPYDLL, /, \\)
} else {
QMAKE_PRE_LINK += $$QMAKE_COPY $$COPYDLL
}
} else {
COPYDLL = $$absolute_path($${_PRO_FILE_PWD_}/../third/Win_x64/*.dll) $$DESTDIR
contains(QMAKE_CC, cl) {
QMAKE_PRE_LINK += $$QMAKE_COPY $$replace(COPYDLL, /, \\)
} else {
QMAKE_PRE_LINK += $$QMAKE_COPY $$COPYDLL
}
}
}
HEADERS += \
ChatController.h

BIN
example/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

View File

@ -4,6 +4,7 @@
#include <QDir>
#include <QQuickWindow>
#include <QProcess>
#include "ChatController.h"
QMap<QString, QVariant> properties(){
QMap<QString, QVariant> map;
@ -20,6 +21,9 @@ int main(int argc, char *argv[])
// QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
qmlRegisterType<ChatController>("Controller",1,0,"ChatController");
QMapIterator<QString, QVariant> iterator(properties());
while (iterator.hasNext()) {
iterator.next();

View File

@ -34,7 +34,7 @@ FluWindow {
fontStyle: FluText.Title
}
FluText{
text:"v1.0.5"
text:"v1.1.1"
fontStyle: FluText.Body
Layout.alignment: Qt.AlignBottom
}
@ -70,6 +70,28 @@ FluWindow {
}
}
RowLayout{
spacing: 14
Layout.topMargin: 20
Layout.leftMargin: 15
FluText{
id:text_info
text:"如果该项目对你有作用就请点击上方链接给一个免费的star吧"
ColorAnimation {
id: animation
target: text_info
property: "color"
from: "red"
to: "blue"
duration: 1000
running: true
loops: Animation.Infinite
easing.type: Easing.InOutQuad
}
}
}
}

261
example/page/ChatPage.qml Normal file
View File

@ -0,0 +1,261 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import FluentUI 1.0
import Controller 1.0
import QtQuick.Dialogs 1.3
FluWindow {
width: 680
height: 600
minimumWidth: 500
minimumHeight: 600
title:"ChatGPT"
onInitArgument:
(argument)=>{
scrollview.focus = true
}
ChatController{
id:controller
onResponseDataChanged: {
appendMessage(false,responseData)
}
}
ListModel{
id:model_message
ListElement{
isMy:false
text:"欢迎使用ChatGPT"
}
ListElement{
isMy:true
text:"好的3Q"
}
}
FluAppBar{
id:appbar
title:"ChatGPT"
}
Component{
id:com_text
TextEdit {
id:item_text
text: message
wrapMode: Text.WrapAnywhere
readOnly: true
selectByMouse: true
selectByKeyboard: true
selectedTextColor: Qt.rgba(51,153,255,1)
color:FluColors.Black
selectionColor: {
if(FluTheme.isDark){
return FluTheme.primaryColor.lighter
}else{
return FluTheme.primaryColor.dark
}
}
width: Math.min(list_message.width-200,600,implicitWidth)
TapHandler{
acceptedButtons: Qt.RightButton
onTapped: {
menu_item.showMenu(item_text.selectedText)
}
}
}
}
FluArea{
id:layout_content
anchors{
top: appbar.bottom
left: parent.left
right: parent.right
bottom: layout_bottom.top
margins: 10
}
color: FluTheme.isDark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(245/255,245/255,245/255,1)
ListView{
id:list_message
anchors.fill: parent
model:model_message
clip: true
ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
header:Item{
width: list_message.width
height:20
}
footer:Item{
width: list_message.width
height:20
}
delegate: Item{
width: ListView.view.width
height: childrenRect.height
FluRectangle{
id:item_avatar
width: 30
height: 30
radius:[15,15,15,15]
anchors{
right: isMy ? parent.right : undefined
rightMargin: isMy ? 20 : undefined
left: isMy ? undefined : parent.left
leftMargin: isMy ? undefined : 20
top:parent.top
}
Image {
asynchronous: true
anchors.fill: parent
sourceSize: Qt.size(100,100)
source: isMy ? "qrc:/res/svg/avatar_2.svg" : "qrc:/res/image/logo_openai.png"
}
}
Rectangle{
id:item_layout_content
color: isMy ? "#FF95EC69" : "#FFFFFF"
width: item_msg_loader.width+10
height: item_msg_loader.height+10
radius: 3
anchors{
top: item_avatar.top
right: isMy ? item_avatar.left : undefined
rightMargin: isMy ? 10 : undefined
left: isMy ? undefined : item_avatar.right
leftMargin: isMy ? undefined : 10
}
Loader{
id:item_msg_loader
property var message: model.text
anchors.centerIn: parent
sourceComponent: com_text
}
}
Item{
id:item_layout_bottom
width: parent.width
anchors.top: item_layout_content.bottom
height: 20
}
}
}
}
FluArea{
id:layout_bottom
height: 90
anchors{
bottom: parent.bottom
bottomMargin: 10
left: parent.left
right: parent.right
leftMargin: 10
rightMargin: 10
}
ScrollView{
id:scrollview
anchors{
bottom: parent.bottom
left: parent.left
right: button_send.left
bottomMargin: 10
leftMargin: 10
rightMargin: 10
}
height: Math.min(textbox.implicitHeight,64)
FluMultiLineTextBox{
id:textbox
focus:true
placeholderText: "请输入消息"
}
}
FluFilledButton{
id:button_send
text:controller.isLoading ? timer_loading.loadingText :"发送"
anchors{
bottom: parent.bottom
right: parent.right
bottomMargin: 10
rightMargin: 10
}
width: 60
disabled: controller.isLoading
onClicked:{
var text = textbox.text
appendMessage(true,text)
controller.sendMessage(text)
textbox.clear()
}
Timer{
id:timer_loading
property int count : 0
property string loadingText : ""
interval: 500
running: controller.isLoading
repeat: true
onTriggered: {
switch(count%3){
case 0:
loadingText = "."
break
case 1:
loadingText = ".."
break
case 2:
loadingText = "..."
break
default:
loadingText = ""
break
}
count++
}
}
}
}
FluMenu{
id:menu_item
focus: false
property string selectedText: ""
FluMenuItem{
text:"复制"
onClicked: {
controller.clipText(menu_item.selectedText)
showSuccess("复制成功")
}
}
function showMenu(text){
menu_item.selectedText = text
menu_item.popup()
}
}
function appendMessage(isMy,text){
model_message.append({isMy:isMy,text:text})
list_message.positionViewAtEnd()
}
}

View File

@ -0,0 +1,72 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
FluWindow {
id:window
width: 400
height: 400
minimumWidth: 400
minimumHeight: 400
maximumWidth: 400
maximumHeight: 400
modality:2
title:"登录"
onInitArgument:
(argument)=>{
textbox_uesrname.text = argument.username
textbox_password.focus = true
}
FluAppBar{
id:appbar
title:"登录"
}
ColumnLayout{
anchors{
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
}
FluAutoSuggestBox{
id:textbox_uesrname
values:["Admin","User"]
placeholderText: "请输入账号"
Layout.preferredWidth: 260
Layout.alignment: Qt.AlignHCenter
}
FluTextBox{
id:textbox_password
Layout.topMargin: 20
Layout.preferredWidth: 260
placeholderText: "请输入密码"
echoMode:TextInput.Password
Layout.alignment: Qt.AlignHCenter
}
FluFilledButton{
text:"登录"
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 20
onClicked:{
if(textbox_password.text === ""){
showError("请随便输入一个密码")
return
}
onResult({password:textbox_password.text})
window.close()
}
}
}
}

View File

@ -9,7 +9,7 @@ import FluentUI 1.0
FluWindow {
id:rootwindow
width: 860
height: 680
height: 600
title: "FluentUI"
minimumWidth: 500
minimumHeight: 400
@ -19,7 +19,6 @@ FluWindow {
title: "FluentUI"
}
FluObject{
id:original_items
@ -90,12 +89,28 @@ FluWindow {
nav_view.push("qrc:/T_Progress.qml")
}
}
FluPaneItem{
title:"Badge"
onTap:{
nav_view.push("qrc:/T_Badge.qml")
}
}
FluPaneItem{
title:"Rectangle"
onTap:{
nav_view.push("qrc:/T_Rectangle.qml")
}
}
FluPaneItem{
title:"Carousel"
onTap:{
nav_view.push("qrc:/T_Carousel.qml")
}
}
FluPaneItem{
title:"Expander"
onTap:{
@ -107,7 +122,6 @@ FluWindow {
title:"Popus"
}
FluPaneItem{
title:"Dialog"
onTap:{
@ -115,6 +129,20 @@ FluWindow {
}
}
FluPaneItem{
title:"Tooltip"
onTap:{
nav_view.push("qrc:/T_Tooltip.qml")
}
}
FluPaneItem{
title:"Menu"
onTap:{
nav_view.push("qrc:/T_Menu.qml")
}
}
FluPaneItemHeader{
title:"Navigation"
}
@ -126,6 +154,14 @@ FluWindow {
}
}
FluPaneItem{
title:"MultiWindow"
onTap:{
nav_view.push("qrc:/T_MultiWindow.qml")
}
}
FluPaneItemHeader{
title:"Theming"
}
@ -164,7 +200,7 @@ FluWindow {
FluPaneItem{
title:"关于"
onTap:{
FluApp.navigate("/About")
FluApp.navigate("/about")
}
}
}
@ -181,6 +217,35 @@ FluWindow {
items:original_items
footerItems:footer_items
actions:[
Image {
width: 30
height: 30
Layout.preferredWidth: 30
Layout.preferredHeight: 30
sourceSize: Qt.size(60,60)
source: "qrc:/res/image/logo_openai.png"
Layout.rightMargin: 5
MouseArea{
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
FluApp.navigate("/chat")
}
}
},
FluText{
text:"夜间模式"
fontStyle: FluText.Body
},
FluToggleSwitch{
selected: FluTheme.isDark
clickFunc:function(){
FluTheme.isDark = !FluTheme.isDark
}
}
]
Component.onCompleted: {
nav_view.setCurrentIndex(1)
nav_view.push("qrc:/T_Buttons.qml")

View File

@ -1,15 +1,6 @@
<RCC>
<qresource prefix="/">
<file>T_ToggleSwitch.qml</file>
<file>T_Typography.qml</file>
<file>App.qml</file>
<file>SettingPage.qml</file>
<file>AboutPage.qml</file>
<file>T_Buttons.qml</file>
<file>T_Rectangle.qml</file>
<file>T_InfoBar.qml</file>
<file>T_Progress.qml</file>
<file>T_Slider.qml</file>
<file>res/image/image_huoyin.webp</file>
<file>res/svg/avatar_1.svg</file>
<file>res/svg/avatar_2.svg</file>
@ -23,14 +14,33 @@
<file>res/svg/avatar_10.svg</file>
<file>res/svg/avatar_11.svg</file>
<file>res/svg/avatar_12.svg</file>
<file>page/AboutPage.qml</file>
<file>page/MainPage.qml</file>
<file>page/LoginPage.qml</file>
<file>T_ToggleSwitch.qml</file>
<file>T_Typography.qml</file>
<file>T_Awesome.qml</file>
<file>T_Buttons.qml</file>
<file>T_Rectangle.qml</file>
<file>T_InfoBar.qml</file>
<file>T_Progress.qml</file>
<file>T_Slider.qml</file>
<file>T_TextBox.qml</file>
<file>T_Theme.qml</file>
<file>T_Dialog.qml</file>
<file>T_TreeView.qml</file>
<file>T_Expander.qml</file>
<file>MainPage.qml</file>
<file>T_TimePicker.qml</file>
<file>T_DatePicker.qml</file>
<file>T_MultiWindow.qml</file>
<file>T_Menu.qml</file>
<file>T_Carousel.qml</file>
<file>res/image/banner_1.jpg</file>
<file>res/image/banner_2.jpg</file>
<file>res/image/banner_3.jpg</file>
<file>res/image/logo_openai.png</file>
<file>page/ChatPage.qml</file>
<file>T_Tooltip.qml</file>
<file>T_Badge.qml</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -17,7 +17,7 @@ function Main() {
New-Item -ItemType Directory $archiveName
# 拷贝exe
Copy-Item bin\release\$targetName $archiveName\
Copy-Item bin\release\* $archiveName\
# 拷贝依赖
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
# 删除不必要的文件

View File

@ -27,7 +27,7 @@ function Main() {
New-Item -ItemType Directory $archiveName
# 拷贝exe
Copy-Item bin\release\$targetName $archiveName\
Copy-Item bin\release\* $archiveName\
# 拷贝依赖
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
# 删除不必要的文件

View File

@ -33,14 +33,18 @@ void FluApp::run(){
navigate(initialRoute());
}
void FluApp::navigate(const QString& route){
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
if(!routes().contains(route)){
qErrnoWarning("没有找到当前路由");
return;
}
bool isAppWindow = route == initialRoute();
FramelessView *view = new FramelessView();
if(fluRegister){
fluRegister->to(view);
view->setProperty("pageRegister",QVariant::fromValue(fluRegister));
}
view->setProperty("argument",argument);
QMapIterator<QString, QVariant> iterator(properties);
while (iterator.hasNext()) {
iterator.next();
@ -59,7 +63,6 @@ void FluApp::navigate(const QString& route){
view->setSource((routes().value(route).toString()));
if(isAppWindow){
QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit);
// QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [&view](){view->setSource({});});
}else{
view->closeDeleteLater();
}

View File

@ -7,6 +7,7 @@
#include <QQmlContext>
#include <QJsonObject>
#include <QQmlEngine>
#include "FluRegister.h"
#include "FramelessView.h"
#include "stdafx.h"
@ -24,7 +25,7 @@ public:
Q_INVOKABLE void run();
Q_INVOKABLE void navigate(const QString& route);
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
Q_INVOKABLE void init(QWindow *window,QMap<QString, QVariant> properties);
@ -37,9 +38,8 @@ public:
Q_INVOKABLE void clipText(const QString& text);
private:
static FluApp* m_instance;
QMap<QString, QVariant> properties;
static FluApp* m_instance;
QWindow *appWindow;
};

20
src/FluRegister.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "FluRegister.h"
#include "FluApp.h"
#include <QCoreApplication>
FluRegister::FluRegister(QObject *parent)
: QObject{parent}
{
from(nullptr);
to(nullptr);
path("");
}
void FluRegister::launch(const QJsonObject& argument){
FluApp::getInstance()->navigate(path(),argument,this);
}
void FluRegister::onResult(const QJsonObject& data){
Q_EMIT result(data);
}

24
src/FluRegister.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef FLUREGISTER_H
#define FLUREGISTER_H
#include <QObject>
#include <FramelessView.h>
#include <QJsonObject>
#include "stdafx.h"
class FluRegister : public QObject
{
Q_OBJECT
Q_PROPERTY_AUTO(FramelessView*,from)
Q_PROPERTY_AUTO(FramelessView*,to)
Q_PROPERTY_AUTO(QString,path);
public:
explicit FluRegister(QObject *parent = nullptr);
Q_INVOKABLE void launch(const QJsonObject& argument = {});
Q_INVOKABLE void onResult(const QJsonObject& data = {});
Q_SIGNAL void result(const QJsonObject& data);
};
#endif // FLUREGISTER_H

View File

@ -35,6 +35,7 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluArea.qml"),uri,major,minor,"FluArea");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluBadge.qml"),uri,major,minor,"FluBadge");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
@ -47,6 +48,7 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluDatePicker.qml"),uri,major,minor,"FluDatePicker");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluCarousel.qml"),uri,major,minor,"FluCarousel");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluAutoSuggestBox.qml"),uri,major,minor,"FluAutoSuggestBox");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluExpander.qml"),uri,major,minor,"FluExpander");
@ -91,7 +93,7 @@ void Fluent::initializeEngine(QQmlEngine *engine, const char *uri)
QFont font;
font.setFamily("Microsoft YaHei");
QGuiApplication::setFont(font);
// QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
// QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
#endif
QFontDatabase::addApplicationFont(":/com.zhuzichu/res/font/Segoe_Fluent_Icons.ttf");
FluApp* app = FluApp::getInstance();

View File

@ -15,6 +15,7 @@ HEADERS += \
FluApp.h \
FluColorSet.h \
FluColors.h \
FluRegister.h \
FluTheme.h \
Fluent.h \
FluentUI.h \
@ -28,6 +29,7 @@ SOURCES += \
FluApp.cpp \
FluColorSet.cpp \
FluColors.cpp \
FluRegister.cpp \
FluTheme.cpp \
Fluent.cpp \
FluentUI.cpp \

View File

@ -4,9 +4,6 @@
#include <QQuickView>
#include <QRegion>
//无边框窗口,主要用来实现自定义标题栏。
//Windows平台支持拖动和改变大小支持Aero效果
//非Windows平台去掉边框不做其它处理。由Qml模拟resize和拖动。
class FramelessViewPrivate;
class FramelessView : public QQuickView
{

View File

@ -1,5 +1,7 @@
#include "WindowHelper.h"
#include "FluRegister.h"
WindowHelper::WindowHelper(QObject *parent)
: QObject{parent}
{
@ -10,11 +12,18 @@ void WindowHelper::setTitle(const QString& text){
window->setTitle(text);
}
void WindowHelper::initWindow(FramelessView* window){
this->window = window;
}
QJsonObject WindowHelper::getArgument(){
return window->property("argument").toJsonObject();
}
QVariant WindowHelper::getPageRegister(){
return window->property("pageRegister");
}
void WindowHelper::setMinimumWidth(int width){
this->window->setMinimumWidth(width);
}
@ -27,3 +36,25 @@ void WindowHelper::setMinimumHeight(int height){
void WindowHelper::setMaximumHeight(int height){
this->window->setMaximumHeight(height);
}
void WindowHelper::updateWindow(){
this->window->setFlag(Qt::Window,false);
this->window->setFlag(Qt::Window,true);
}
void WindowHelper::setModality(int type){
if(type == 0){
this->window->setModality(Qt::NonModal);
}else if(type == 1){
this->window->setModality(Qt::WindowModal);
}else if(type == 2){
this->window->setModality(Qt::ApplicationModal);
}else{
this->window->setModality(Qt::NonModal);
}
}
QVariant WindowHelper::createRegister(const QString& path){
FluRegister *p = new FluRegister(this->window);
p->from(this->window);
p->path(path);
return QVariant::fromValue(p);
}

View File

@ -5,6 +5,7 @@
#include <QQuickWindow>
#include <QQuickItem>
#include <QWindow>
#include <QJsonObject>
#include "FramelessView.h"
class WindowHelper : public QObject
@ -20,6 +21,11 @@ public:
Q_INVOKABLE void setMaximumWidth(int width);
Q_INVOKABLE void setMinimumHeight(int height);
Q_INVOKABLE void setMaximumHeight(int height);
Q_INVOKABLE QJsonObject getArgument();
Q_INVOKABLE QVariant getPageRegister();
Q_INVOKABLE void updateWindow();
Q_INVOKABLE void setModality(int type);
Q_INVOKABLE QVariant createRegister(const QString& path);
private:
FramelessView* window;

View File

@ -93,15 +93,15 @@ Rectangle{
fontStyle: FluText.Body
}
FluToggleSwitch{
checked: FluTheme.isDark
onClickFunc:function(){
selected: FluTheme.isDark
clickFunc:function(){
FluTheme.isDark = !FluTheme.isDark
}
}
}
FluIconButton{
icon : FluentIcons.ChromeMinimizeContrast
iconSource : FluentIcons.ChromeMinimizeContrast
Layout.alignment: Qt.AlignVCenter
iconSize: 15
text:"最小化"
@ -117,7 +117,7 @@ Rectangle{
return false
return Window.Maximized === window.visibility
}
icon : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast
iconSource : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast
color:hovered ? "#20000000" : "#00000000"
Layout.alignment: Qt.AlignVCenter
visible: resizable
@ -129,7 +129,7 @@ Rectangle{
}
}
FluIconButton{
icon : FluentIcons.ChromeCloseContrast
iconSource : FluentIcons.ChromeCloseContrast
Layout.alignment: Qt.AlignVCenter
text:"关闭"
iconSize: 13

View File

@ -7,12 +7,19 @@ TextField{
property var values:[]
property int fontStyle: FluText.Body
property int pixelSize : FluTheme.textSize
property int icon: -1
property int iconSource: 0
property bool disabled: false
signal itemClicked(string data)
id:input
width: 300
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
enabled: !disabled
color: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
}
selectionColor: {
if(FluTheme.isDark){
return FluTheme.primaryColor.lighter
@ -22,6 +29,9 @@ TextField{
}
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
placeholderTextColor: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
if(focus){
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
}
@ -91,7 +101,7 @@ TextField{
inputItem: input
FluIconButton{
icon:FluentIcons.ChromeClose
iconSource:FluentIcons.ChromeClose
iconSize: 10
width: 20
height: 20
@ -109,10 +119,10 @@ TextField{
FluIcon{
id:icon_right
icon: input.icon
iconSource: input.iconSource
iconSize: 15
opacity: 0.5
visible: input.icon != -1
visible: input.iconSource != 0
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
@ -152,6 +162,7 @@ TextField{
boundsBehavior: ListView.StopAtBounds
clip: true
currentIndex: -1
ScrollBar.vertical: FluScrollBar {}
header: Item{
width: input.width
height: visible ? 38 : 0
@ -165,7 +176,6 @@ TextField{
}
}
}
ScrollBar.vertical: ScrollBar { }
delegate:Control{
width: input.width
padding:10

77
src/controls/FluBadge.qml Normal file
View File

@ -0,0 +1,77 @@
import QtQuick 2.15
Rectangle{
property bool isDot: false
property bool showZero: true
property int count: 0
id:control
color:Qt.rgba(255/255,77/255,79/255,1)
width: {
if(isDot)
return 10
if(count<10){
return 20
}else if(count<100){
return 30
}
return 40
}
height: {
if(isDot)
return 10
return 20
}
radius: {
if(isDot)
return 5
return 10
}
border.width: 1
border.color: Qt.rgba(1,1,1,1)
visible: {
if(showZero)
return true
return count!==0
}
anchors{
right: {
if(parent)
return parent.right
return undefined
}
top: {
if(parent)
return parent.top
return undefined
}
rightMargin: {
if(isDot){
return -2.5
}
return -(control.width/2)
}
topMargin: {
if(isDot){
return -2.5
}
return -10
}
}
Text{
anchors.centerIn: parent
color: Qt.rgba(1,1,1,1)
visible: !isDot
text:{
if(count<100)
return count
return count+"+"
}
}
}

View File

@ -2,39 +2,22 @@
import QtQuick.Controls 2.15
import FluentUI 1.0
Control {
id: control
Button {
property string text: "Standard Button"
property bool disabled: false
property color normalColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
signal clicked
id: control
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:15
enabled: !disabled
focusPolicy:Qt.TabFocus
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
MouseArea {
anchors.fill: parent
onClicked: handleClick()
}
function handleClick(){
if(disabled){
return
}
control.clicked()
}
Keys.onSpacePressed: control.visualFocus&&clicked()
background: Rectangle{
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
@ -51,10 +34,8 @@ Control {
return hovered ? hoverColor :normalColor
}
}
contentItem: FluText {
text: control.text
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: {
@ -71,5 +52,4 @@ Control {
}
}
}
}

View File

@ -0,0 +1,136 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
Item {
property bool flagXChanged: true
property int radius : 5
property int loopTime: 2000
property bool showIndicator: true
id:control
width: 400
height: 300
ListModel{
id:content_model
}
FluRectangle{
anchors.fill: parent
radius: [control.radius,control.radius,control.radius,control.radius]
FluShadow{
radius:control.radius
}
ListView{
id:list_view
anchors.fill: parent
snapMode: ListView.SnapOneItem
clip: true
boundsBehavior: ListView.StopAtBounds
model:content_model
maximumFlickVelocity: 4 * (list_view.orientation === Qt.Horizontal ? width : height)
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
orientation : ListView.Horizontal
delegate: Item{
width: ListView.view.width
height: ListView.view.height
property int displayIndex: {
if(index === 0)
return content_model.count-3
if(index === content_model.count-1)
return 0
return index-1
}
Image {
anchors.fill: parent
source: model.url
fillMode:Image.PreserveAspectCrop
}
}
onMovementEnded:{
currentIndex = list_view.contentX/list_view.width
if(currentIndex === 0){
currentIndex = list_view.count-2
}else if(currentIndex === list_view.count-1){
currentIndex = 1
}
flagXChanged = false
timer_run.start()
}
onMovementStarted: {
flagXChanged = true
timer_run.stop()
}
onContentXChanged: {
if(flagXChanged){
var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
var minY = Math.max(0,(list_view.width*(currentIndex-1)))
if(contentX>=maxX){
contentX = maxX
}
if(contentX<=minY){
contentX = minY
}
}
}
}
}
function setData(data){
content_model.clear()
content_model.append(data[data.length-1])
content_model.append(data)
content_model.append(data[0])
list_view.currentIndex = 1
timer_run.restart()
}
Row{
spacing: 10
anchors{
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 20
}
visible: showIndicator
Repeater{
model: list_view.count
Rectangle{
width: 8
height: 8
radius: 4
visible: {
if(index===0 || index===list_view.count-1)
return false
return true
}
layer.samples: 4
layer.enabled: true
layer.smooth: true
border.width: 1
border.color: FluColors.Grey100
color: list_view.currentIndex === index ? FluTheme.primaryColor.dark : Qt.rgba(1,1,1,0.5)
}
}
}
Timer{
id:timer_anim
interval: 250
onTriggered: {
list_view.highlightMoveDuration = 0
if(list_view.currentIndex === list_view.count-1){
list_view.currentIndex = 1
}
}
}
Timer{
id:timer_run
interval: control.loopTime
repeat: true
onTriggered: {
list_view.highlightMoveDuration = 250
list_view.currentIndex = list_view.currentIndex+1
timer_anim.start()
}
}
}

View File

@ -3,55 +3,42 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
Control {
id:control
property bool checked: false
property string text: "Check Box"
property var checkClicked
Button {
property bool selected: false
property var clickFunc
property bool disabled: false
property color borderNormalColor: FluTheme.isDark ? Qt.rgba(160/255,160/255,160/255,1) : Qt.rgba(136/255,136/255,136/255,1)
property color borderCheckedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color borderSelectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color borderHoverColor: FluTheme.isDark ? Qt.rgba(167/255,167/255,167/255,1) : Qt.rgba(135/255,135/255,135/255,1)
property color borderDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property color normalColor: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(247/255,247/255,247/255,1)
property color checkedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color selectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(244/255,244/255,244/255,1)
property color checkedHoverColor: FluTheme.isDark ? Qt.darker(checkedColor,1.1) : Qt.lighter(checkedColor,1.1)
property color checkedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property color selectedHoverColor: FluTheme.isDark ? Qt.darker(selectedColor,1.1) : Qt.lighter(selectedColor,1.1)
property color selectedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property color disableColor: FluTheme.isDark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1)
id:control
enabled: !disabled
focusPolicy:Qt.TabFocus
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
MouseArea {
anchors.fill: parent
onClicked: handleClick()
}
function handleClick(){
Keys.onSpacePressed: control.visualFocus&&clicked()
padding:0
onClicked: {
if(disabled){
return
}
if(checkClicked){
checkClicked()
if(clickFunc){
clickFunc()
return
}
checked = !checked
selected = !selected
}
background: Item{
FluFocusRectangle{
visible: control.visualFocus
}
}
contentItem: RowLayout{
spacing: 4
Rectangle{
@ -62,8 +49,8 @@ Control {
if(disabled){
return borderDisableColor
}
if(checked){
return borderCheckedColor
if(selected){
return borderSelectedColor
}
if(hovered){
return borderHoverColor
@ -72,26 +59,25 @@ Control {
}
border.width: 1
color: {
if(checked){
if(selected){
if(disabled){
return checkedDisableColor
return selectedDisableColor
}
if(hovered){
return checkedHoverColor
return selectedHoverColor
}
return checkedColor
return selectedColor
}
if(hovered){
return hoverColor
}
return normalColor
}
FluIcon {
anchors.centerIn: parent
icon: FluentIcons.AcceptMedium
iconSource: FluentIcons.AcceptMedium
iconSize: 15
visible: checked
visible: selected
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
}
}
@ -99,5 +85,4 @@ Control {
text:control.text
}
}
}

View File

@ -202,9 +202,12 @@ Rectangle {
width: 100
height: parent.height
boundsBehavior:Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar { }
ScrollBar.vertical: FluScrollBar {}
model: generateYearArray(1924,2048)
clip: true
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
visible: showYear
delegate: Loader{
property var model: modelData
@ -212,11 +215,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
if(currentIndex!==-1){
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
}
Rectangle{
width: 1
@ -228,7 +226,10 @@ Rectangle {
width: showYear ? 100 : 150
height: parent.height
clip: true
ScrollBar.vertical: ScrollBar { }
ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
boundsBehavior:Flickable.StopAtBounds
delegate: Loader{
property var model: modelData
@ -236,11 +237,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
if(currentIndex!==-1){
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
}
Rectangle{
width: 1
@ -252,7 +248,10 @@ Rectangle {
width: showYear ? 100 : 150
height: parent.height
clip: true
ScrollBar.vertical: ScrollBar { }
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {}
Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds
delegate: Loader{
@ -261,9 +260,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
}
@ -348,10 +344,12 @@ Rectangle {
text_day.text = day
var pos = root.mapToItem(null, 0, 0)
if(window.height>pos.y+35+340){
popup.y = 35
}else{
popup.y = window.height-(pos.y+340)
if(window.height>pos.y+root.height+popup.height){
popup.y = root.height
} else if(pos.y>popup.height){
popup.y = -popup.height
} else {
popup.y = window.height-(pos.y+popup.height)
}
popup.open()
}

View File

@ -1,6 +1,89 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import FluentUI 1.0
Item {
Button {
property bool disabled: false
property color normalColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
property color hoverColor: FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
id: control
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:35
enabled: !disabled
focusPolicy:Qt.TabFocus
property var window : Window.window
property alias items: menu.content
Keys.onSpacePressed: control.visualFocus&&clicked()
background: Rectangle{
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
border.width: 1
radius: 4
FluFocusRectangle{
visible: control.visualFocus
radius:8
}
color:{
if(disabled){
return disableColor
}
return hovered ? hoverColor :normalColor
}
FluIcon{
iconSource:FluentIcons.ChevronDown
iconSize: 15
anchors{
right: parent.right
rightMargin: 10
verticalCenter: parent.verticalCenter
}
color:title.color
}
}
contentItem: FluText {
id:title
text: control.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: {
if(FluTheme.isDark){
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
}
onClicked: {
var pos = control.mapToItem(null, 0, 0)
if(window.height>pos.y+control.height+menu.height){
menu.y = control.height
}else if(pos.y>menu.height){
menu.y = -menu.height
}else{
popup.y = window.height-(pos.y+menu.height)
}
menu.open()
}
FluMenu{
id:menu
width: control.width
}
}

View File

@ -56,7 +56,7 @@ Item {
return FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
}
iconSize: 15
icon: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown
iconSource: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown
onClicked: {
expand = !expand
}

View File

@ -2,35 +2,21 @@
import QtQuick.Controls 2.15
import FluentUI 1.0
Control {
Button {
id: control
property string text: "Filled Button"
property bool disabled: false
property color normalColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
property color hoverColor: FluTheme.isDark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
property color disableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
signal clicked
enabled: !disabled
topPadding:5
bottomPadding:5
leftPadding:15
rightPadding:15
Keys.onSpacePressed: control.visualFocus&&clicked()
focusPolicy:Qt.TabFocus
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
MouseArea {
anchors.fill: parent
onClicked: handleClick()
}
function handleClick(){
if(disabled)
return
control.clicked()
}
background: Rectangle{
radius: 4
FluFocusRectangle{
@ -44,7 +30,6 @@ Control {
return hovered ? hoverColor :normalColor
}
}
contentItem: FluText {
text: control.text
horizontalAlignment: Text.AlignHCenter
@ -61,6 +46,4 @@ Control {
}
font.pixelSize: 14
}
}

View File

@ -2,7 +2,7 @@
Text {
property int icon
property int iconSource
property int iconSize: 20
property color iconColor: FluTheme.isDark ? "#FFFFFF" : "#000000"
@ -12,5 +12,5 @@ Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
color: iconColor
text: (String.fromCharCode(icon).toString(16));
text: (String.fromCharCode(iconSource).toString(16));
}

View File

@ -2,29 +2,20 @@
import QtQuick.Controls 2.15
import FluentUI 1.0
Control {
id:control
width: 30
height: 30
Button {
property int iconSize: 20
property int icon
property alias text: tool_tip.text
signal clicked
property int iconSource
property bool disabled: false
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03)
property color normalColor: FluTheme.isDark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(0,0,0,0)
property color color: {
if(disabled){
return disableColor
}
return hovered ? hoverColor : normalColor
}
property color textColor: {
if(FluTheme.isDark){
if(disabled){
@ -39,22 +30,15 @@ Control {
}
}
id:control
width: 30
height: 30
implicitWidth: width
implicitHeight: height
padding: 0
enabled: !disabled
focusPolicy:Qt.TabFocus
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
MouseArea {
anchors.fill: parent
onClicked: handleClick()
}
function handleClick(){
if(disabled){
return
}
control.clicked()
}
Keys.onSpacePressed: control.visualFocus&&clicked()
background: Rectangle{
radius: 4
color:control.color
@ -62,19 +46,19 @@ Control {
visible: control.visualFocus
}
}
contentItem: Item{
Text {
id:text_icon
font.family: "Segoe Fluent Icons"
font.pixelSize: iconSize
width: iconSize
height: iconSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.centerIn: parent
color:control.textColor
text: (String.fromCharCode(icon).toString(16));
text: (String.fromCharCode(iconSource).toString(16));
}
FluTooltip{
id:tool_tip
visible: {
@ -83,11 +67,8 @@ Control {
}
return hovered
}
text:control.text
delay: 1000
}
}
}

View File

@ -190,7 +190,7 @@ FluObject {
spacing: 10
FluIcon{
icon:{
iconSource:{
switch(_super.type){
case mcontrol.const_success: return FluentIcons.CompletedSolid;
case mcontrol.const_warning: return FluentIcons.InfoSolid;

View File

@ -1,16 +1,27 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
Popup {
Menu {
id: popup
default property alias content: container.children
default property alias content: container.data
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
width: 140
height: container.height
background: Item {
Rectangle{
anchors.fill: parent
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97)
radius: 5
layer.enabled: true
layer.effect: GaussianBlur {
radius: 8
samples: 16
}
}
FluShadow{
radius: 5
@ -19,6 +30,7 @@ Popup {
spacing: 5
topPadding: 5
bottomPadding: 5
width: popup.width
id:container
function closePopup(){
popup.close()

View File

@ -4,7 +4,12 @@ import QtQuick.Controls 2.15
Item {
id:root
width: 140
width: {
if(root.parent){
return root.parent.width
}
return 140
}
height: 32
property string text: "MenuItem"
@ -12,14 +17,21 @@ Item {
Rectangle{
anchors.centerIn: parent
width: 100
width: root.width-40
height: 32
radius: 4
color:{
if(mouse_area.containsMouse){
return FluTheme.isDark ? Qt.rgba(56/255,56/255,56/255,1) : Qt.rgba(230/255,230/255,230/255,1)
if(FluTheme.isDark){
if(mouse_area.containsMouse){
return Qt.rgba(1,1,1,0.05)
}
return Qt.rgba(0,0,0,0)
}else{
if(mouse_area.containsMouse){
return Qt.rgba(0,0,0,0.05)
}
return Qt.rgba(0,0,0,0)
}
return FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(237/255,237/255,237/255,1)
}
FluText{

View File

@ -6,10 +6,17 @@ TextArea{
property int fontStyle: FluText.Body
property int pixelSize : FluTheme.textSize
property bool disabled: false
id:input
width: 300
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
color: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
}
enabled: !disabled
wrapMode: Text.WrapAnywhere
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
selectByMouse: true
@ -24,6 +31,9 @@ TextArea{
inputItem: input
}
placeholderTextColor: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
if(focus){
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
}

View File

@ -16,6 +16,8 @@ Item {
property bool displaMinimalNav : false
property alias actions: layout_actions.data
onDisplayModeChanged: {
if(displayMode === FluNavigationView.Minimal){
anim_navi.enabled = false
@ -135,17 +137,16 @@ Item {
}
}
Item {
id:nav_app_bar
width: parent.width
height: 38
z:999
RowLayout{
height:parent.height
spacing: 0
FluIconButton{
icon: FluentIcons.ChromeBack
iconSource: FluentIcons.ChromeBack
Layout.leftMargin: 5
Layout.alignment: Qt.AlignVCenter
disabled: nav_swipe.depth === 1
@ -160,7 +161,7 @@ Item {
}
}
FluIconButton{
icon: FluentIcons.GlobalNavButton
iconSource: FluentIcons.GlobalNavButton
Layout.leftMargin: 5
iconSize: 15
visible: displayMode === FluNavigationView.Minimal
@ -173,22 +174,13 @@ Item {
RowLayout{
id:layout_actions
anchors{
right: parent.right
rightMargin: 14
verticalCenter: parent.verticalCenter
}
spacing: 5
FluText{
text:"夜间模式"
fontStyle: FluText.Body
}
FluToggleSwitch{
checked: FluTheme.isDark
onClickFunc:function(){
FluTheme.isDark = !FluTheme.isDark
}
}
}
}
@ -232,7 +224,7 @@ Item {
id:layout_list
width: 300
anchors{
top: nav_app_bar.bottom
top: parent.top
bottom: parent.bottom
}
x: {
@ -264,12 +256,13 @@ Item {
Item{
id:layout_header
width: layout_list.width
y:nav_app_bar.height
height: 50
FluAutoSuggestBox{
width: 280
anchors.centerIn: parent
icon: FluentIcons.Zoom
iconSource: FluentIcons.Zoom
values: {
var arr = []
if(items==null)
@ -322,6 +315,8 @@ Item {
stackIndex.push(currentIndex)
}
}
ScrollBar.vertical: FluScrollBar {}
model:{
if(items){
return items.children
@ -375,11 +370,8 @@ Item {
}
}
}
}
function push(url){
nav_swipe.push(url)
}

View File

@ -4,38 +4,21 @@ import QtQuick.Layouts 1.15
import FluentUI 1.0
Control {
Button {
id:control
property bool checked: false
property string text: "RodioButton"
signal clicked
property bool selected: false
property bool disabled: false
id:control
enabled: !disabled
focusPolicy:Qt.TabFocus
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
MouseArea {
anchors.fill: parent
onClicked: handleClick()
}
function handleClick(){
if(disabled){
return
}
control.clicked()
}
padding:0
background: Item{
FluFocusRectangle{
visible: control.visualFocus
}
}
Keys.onSpacePressed: control.visualFocus&&clicked()
contentItem: RowLayout{
Rectangle{
id:rect_check
@ -46,26 +29,26 @@ Control {
layer.enabled: true
layer.smooth: true
border.width: {
if(checked&&disabled){
if(selected&&disabled){
return 3
}
if(hovered){
if(checked){
if(pressed){
if(selected){
return 5
}
return 1
}
if(hovered){
if(checked){
if(selected){
return 3
}
return 1
}
return checked ? 5 : 1
return selected ? 5 : 1
}
Behavior on border.width {
NumberAnimation{
duration: 100
duration: 150
}
}
border.color: {
@ -76,7 +59,7 @@ Control {
return Qt.rgba(198/255,198/255,198/255,1)
}
}
if(checked){
if(selected){
if(FluTheme.isDark){
return FluTheme.primaryColor.lighter
}else{
@ -93,7 +76,7 @@ Control {
}
}
color:{
if(disabled&&checked){
if(disabled&&selected){
return Qt.rgba(159/255,159/255,159/255,1)
}
if(FluTheme.isDark){
@ -103,7 +86,7 @@ Control {
return Qt.rgba(50/255,50/255,50/255,1)
}else{
if(hovered){
if(checked){
if(selected){
return Qt.rgba(1,1,1,1)
}
return Qt.rgba(222/255,222/255,222/255,1)
@ -112,14 +95,10 @@ Control {
}
}
}
FluText{
text: control.text
Layout.alignment: Qt.AlignVCenter
}
}
}

View File

@ -6,10 +6,8 @@ Item{
id:root
property var radius:[0,0,0,0]
property color color : "#FFFFFF"
property color borderColor:"red"
property int borderWidth: 1
property bool shadow: true
default property alias contentItem: container.children
default property alias contentItem: container.data
Rectangle{
id:container

View File

@ -17,10 +17,13 @@ Item {
fontStyle: FluText.TitleLarge
}
ScrollView{
Flickable{
clip: true
width: parent.width
contentWidth: parent.width
contentHeight: container.height
boundsBehavior: Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar { }
anchors{
top: text_title.bottom
bottom: parent.bottom

View File

@ -4,9 +4,9 @@ Item {
id:root
anchors.fill: parent
anchors.margins: -4
property color color: FluTheme.isDark ? "#FFFFFF" : "#000000"
property color color: FluTheme.isDark ? "#FFFFFF" : "#999999"
property var radius: 4
property int radius: 4
Rectangle{
width: root.width

View File

@ -6,10 +6,17 @@ TextField{
property int fontStyle: FluText.Body
property int pixelSize : FluTheme.textSize
property bool disabled: false
id:input
width: 300
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
enabled: !disabled
color: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
}
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
selectionColor: {
if(FluTheme.isDark){
@ -19,6 +26,9 @@ TextField{
}
}
placeholderTextColor: {
if(disabled){
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
}
if(focus){
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
}

View File

@ -9,10 +9,13 @@ Rectangle{
radius: 4
layer.enabled: true
color: {
if(input.focus){
if(inputItem.disabled){
return FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
}
if(inputItem.focus){
return FluTheme.isDark ? Qt.rgba(36/255,36/255,36/255,1) : Qt.rgba(1,1,1,1)
}
if(input.hovered){
if(inputItem.hovered){
return FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
}
return FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1)
@ -25,16 +28,22 @@ Rectangle{
}
}
border.width: 1
border.color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
border.color: {
if(inputItem.disabled){
return FluTheme.isDark ? Qt.rgba(73/255,73/255,73/255,1) : Qt.rgba(237/255,237/255,237/255,1)
}
return FluTheme.isDark ? Qt.rgba(76/255,76/255,76/255,1) : Qt.rgba(240/255,240/255,240/255,1)
}
Rectangle{
width: parent.width
height: input.focus ? 3 : 1
height: inputItem.focus ? 3 : 1
anchors.bottom: parent.bottom
visible: !inputItem.disabled
color: {
if(FluTheme.isDark){
input.focus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
inputItem.focus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
}else{
return input.focus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
return inputItem.focus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
}
}
Behavior on height{

View File

@ -201,7 +201,10 @@ Rectangle {
width: isH ? 100 : 150
height: parent.height
boundsBehavior:Flickable.StopAtBounds
ScrollBar.vertical: ScrollBar { }
ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
model: isH ? generateArray(1,12) : generateArray(0,23)
clip: true
delegate: Loader{
@ -210,9 +213,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
Rectangle{
width: 1
@ -225,7 +225,10 @@ Rectangle {
height: parent.height
model: generateArray(0,59)
clip: true
ScrollBar.vertical: ScrollBar { }
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {}
boundsBehavior:Flickable.StopAtBounds
delegate: Loader{
property var model: modelData
@ -233,9 +236,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
Rectangle{
width: 1
@ -250,7 +250,10 @@ Rectangle {
model: ["上午","下午"]
clip: true
visible: isH
ScrollBar.vertical: ScrollBar { }
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {}
Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds
delegate: Loader{
@ -259,9 +262,6 @@ Rectangle {
property int position:index
sourceComponent: list_delegate
}
onCurrentIndexChanged: {
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
}
@ -358,10 +358,12 @@ Rectangle {
}
var pos = root.mapToItem(null, 0, 0)
if(window.height>pos.y+35+340){
popup.y = 35
}else{
popup.y = window.height-(pos.y+340)
if(window.height>pos.y+root.height+popup.height){
popup.y = root.height
} else if(pos.y>popup.height){
popup.y = -popup.height
} else {
popup.y = window.height-(pos.y+popup.height)
}
popup.open()
}

View File

@ -1,77 +1,87 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import FluentUI 1.0
import QtQuick.Layouts 1.15
Switch {
id: root
property var onClickFunc
width: 40
implicitWidth: 40
Button {
property bool selected: false
property var clickFunc
id: control
height: 20
implicitHeight: 20
checkable: false
background:FluFocusRectangle{
visible: root.visualFocus
radius: 20
implicitHeight: height
focusPolicy:Qt.TabFocus
Keys.onSpacePressed: control.visualFocus&&clicked()
onClicked: {
if(clickFunc){
clickFunc()
return
}
selected = !selected
}
Keys.onEnterPressed:(visualFocus&&handleClick())
Keys.onReturnPressed:(visualFocus&&handleClick())
indicator: Rectangle {
width: root.width
height: root.height
radius: height / 2
color: {
if(FluTheme.isDark){
if(root.checked){
return FluTheme.primaryColor.dark
}
if(switch_mouse.containsMouse){
return "#3E3E3C"
}
return "#323232"
}else{
if(root.checked){
return FluTheme.primaryColor.dark
}
if(switch_mouse.containsMouse){
return "#F4F4F4"
}
return "#FFFFFF"
}
}
border.width: 1
border.color: root.checked ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
contentItem: Item{}
background : RowLayout{
spacing: 0
Rectangle {
x: root.checked ? root.implicitWidth - width - 4 : 4
width: root.height - 8
height: root.height - 8
radius: width / 2
scale: switch_mouse.containsMouse ? 1.2 : 1.0
anchors.verticalCenter: parent.verticalCenter
color: root.checked ? "#FFFFFF" : "#666666"
// border.color: "#D5D5D5"
Behavior on x {
NumberAnimation { duration: 200 }
id:control_backgound
width: 40
height: control.height
radius: height / 2
smooth: true
antialiasing: true
FluFocusRectangle{
visible: control.visualFocus
radius: 20
}
color: {
if(FluTheme.isDark){
if(selected){
return FluTheme.primaryColor.dark
}
if(hovered){
return "#3E3E3C"
}
return "#323232"
}else{
if(selected){
return FluTheme.primaryColor.dark
}
if(hovered){
return "#F4F4F4"
}
return "#FFFFFF"
}
}
border.width: 1
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
Rectangle {
x: selected ? control_backgound.width - width - 4 : 4
width: control.height - 8
height: control.height - 8
radius: width / 2
antialiasing: true
scale: hovered ? 1.2 : 1.0
smooth: true
anchors.verticalCenter: parent.verticalCenter
color: selected ? "#FFFFFF" : "#666666"
Behavior on x {
NumberAnimation { duration: 200 }
}
Behavior on scale {
NumberAnimation { duration: 150 }
}
}
}
}
MouseArea{
id:switch_mouse
anchors.fill: parent
hoverEnabled: true
onClicked: handleClick()
}
function handleClick(){
if(root.onClickFunc){
root.onClickFunc()
}else{
root.checked = !root.checked
FluText{
text: control.text
Layout.leftMargin: 5
visible: text !== ""
}
}
}

View File

@ -163,7 +163,7 @@ Item {
FluCheckBox{
id:item_layout_checkbox
text:""
checked: itemModel.multipSelected
selected: itemModel.multipSelected
visible: selectionMode === FluTreeView.Multiple
Layout.leftMargin: 5
@ -199,7 +199,7 @@ Item {
}
}
checkClicked:function(){
clickFunc:function(){
if(hasChild){
const stack = [itemModel];
while (stack.length > 0) {
@ -222,7 +222,7 @@ Item {
FluIconButton{
id:item_layout_expanded
color:"#00000000"
icon:item_layout.expanded?FluentIcons.ChevronDown:FluentIcons.ChevronRight
iconSource:item_layout.expanded?FluentIcons.ChevronDown:FluentIcons.ChevronRight
opacity: item_layout.hasChild
iconSize: 15
onClicked: {
@ -276,8 +276,8 @@ Item {
model: tree_model
flickableDirection: Flickable.HorizontalAndVerticalFlick
clip: true
ScrollBar.vertical: ScrollBar { }
ScrollBar.horizontal: ScrollBar { }
ScrollBar.vertical: FluScrollBar {}
ScrollBar.horizontal: FluScrollBar { }
}
function updateData(items){

View File

@ -26,6 +26,11 @@ Item {
property int maximumWidth
property int minimumHeight
property int maximumHeight
property int modality:0
signal initArgument(var argument)
property var pageRegister
property int borderless:{
if(!FluTheme.isFrameless){
@ -76,8 +81,10 @@ Item {
target: FluApp
function onWindowReady(view){
if(FluApp.equalsWindow(view,window)){
helper.initWindow(view);
helper.setTitle(title);
helper.initWindow(view)
initArgument(helper.getArgument())
pageRegister = helper.getPageRegister()
helper.setTitle(title)
if(minimumWidth){
helper.setMinimumWidth(minimumWidth)
}
@ -90,6 +97,8 @@ Item {
if(maximumHeight){
helper.setMaximumHeight(maximumHeight)
}
helper.setModality(root.modality);
helper.updateWindow()
}
}
}
@ -106,17 +115,31 @@ Item {
function showSuccess(text,duration,moremsg){
infoBar.showSuccess(text,duration,moremsg);
}
function showInfo(text,duration,moremsg){
infoBar.showInfo(text,duration,moremsg);
}
function showWarning(text,duration,moremsg){
infoBar.showWarning(text,duration,moremsg);
}
function showError(text,duration,moremsg){
infoBar.showError(text,duration,moremsg);
}
function close(){
window.close()
}
function registerForPageResult(path){
return helper.createRegister(path)
}
function onResult(data){
if(pageRegister){
pageRegister.onResult(data)
}
}
}

0
src/macos_install.sh Executable file → Normal file
View File

View File

@ -47,5 +47,7 @@
<file>controls/FluCalenderView.qml</file>
<file>controls/FluCalendarDatePicker.qml</file>
<file>controls/FluFocusRectangle.qml</file>
<file>controls/FluCarousel.qml</file>
<file>controls/FluBadge.qml</file>
</qresource>
</RCC>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.