Compare commits
101 Commits
Author | SHA1 | Date | |
---|---|---|---|
f0f58ca2dd | |||
3a32d66d6a | |||
a2c23231f2 | |||
dae49a5bfc | |||
5e61af99ba | |||
e2d72d4510 | |||
fcdb05b7d1 | |||
a59010ec72 | |||
36d7c714a5 | |||
2f95bdf649 | |||
faa6c625cb | |||
0176f14469 | |||
128869f46e | |||
14ceb3a4c6 | |||
a1d8581768 | |||
e7146bf2ca | |||
432023aee3 | |||
a1959641c2 | |||
0f7c5f4ff5 | |||
b6befc4416 | |||
901c83e499 | |||
7e60bfd37f | |||
d2e1a6fef9 | |||
ffd7d3bce5 | |||
424a6137c5 | |||
57d453d574 | |||
697c379ee1 | |||
f5adefb0f1 | |||
00f08eaf99 | |||
795fc26777 | |||
603bab5d93 | |||
d570acf5a7 | |||
758f8ccb9c | |||
dfd8ef875c | |||
8b156699fb | |||
183f105776 | |||
162c4851ea | |||
6f38bb9985 | |||
30b8c19f52 | |||
64d636d391 | |||
4ba19a5bf2 | |||
3c978f1655 | |||
592abd3cab | |||
8b0a0c7c98 | |||
09bf3cf0ab | |||
753d1cdd30 | |||
11cd46ba18 | |||
587b422275 | |||
fb68455ded | |||
d2d2e97d28 | |||
6d809efd4b | |||
d8d95399cd | |||
1f1e8b0ed0 | |||
a3fb672cc7 | |||
f20dc1edcb | |||
bfaffd3dab | |||
2c63eb21f0 | |||
f4e5316987 | |||
d3d6e64af1 | |||
82a7aa167a | |||
83f97159e9 | |||
5fcd95611f | |||
b83e70ba24 | |||
e29cb7433e | |||
9545175445 | |||
a447b260e7 | |||
8eb7e1df4a | |||
c622f80659 | |||
c0ed9cb41c | |||
e5a24ec642 | |||
6553584c3d | |||
1ea043ee13 | |||
0d6b0d9d25 | |||
5f71ad57d0 | |||
c789d53d6a | |||
f2bbbd5250 | |||
4e95923847 | |||
5fadb582c9 | |||
6b54401371 | |||
28b65e2f33 | |||
0689c3b9d9 | |||
9c121c6ba9 | |||
f2a66221e6 | |||
2de9d78f41 | |||
96355b0a97 | |||
47597471dd | |||
184f52c896 | |||
31b2b0b004 | |||
1e4f939de7 | |||
926132a285 | |||
9e245fb533 | |||
8bfbfd63fb | |||
51a206e583 | |||
ee3ddf7732 | |||
6d238871ee | |||
9d3de073c0 | |||
7282a6f8d1 | |||
2b9e9b2159 | |||
23bc5cdf68 | |||
f75da5e3ce | |||
8cc828a56b |
2
.github/workflows/windows-mingw.yml
vendored
@ -66,7 +66,7 @@ jobs:
|
|||||||
- name: package
|
- name: package
|
||||||
id: package
|
id: package
|
||||||
env:
|
env:
|
||||||
archiveName: ${{ env.fileName }}-${{ matrix.qt_ver }}-${{ matrix.qt_arch }}
|
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
& scripts\windows-mingw-publish.ps1 ${env:archiveName} ${env:targetName}
|
& scripts\windows-mingw-publish.ps1 ${env:archiveName} ${env:targetName}
|
||||||
|
2
.github/workflows/windows.yml
vendored
@ -67,7 +67,7 @@ jobs:
|
|||||||
- name: package
|
- name: package
|
||||||
id: package
|
id: package
|
||||||
env:
|
env:
|
||||||
archiveName: ${{ env.fileName }}-${{ matrix.qt_ver }}-${{ matrix.qt_arch }}
|
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }}
|
||||||
msvcArch: ${{ matrix.msvc_arch }}
|
msvcArch: ${{ matrix.msvc_arch }}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
|
11
.gitignore
vendored
@ -1,14 +1,3 @@
|
|||||||
# C++ objects and libs
|
|
||||||
*.slo
|
|
||||||
*.lo
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
*.la
|
|
||||||
*.lai
|
|
||||||
*.so
|
|
||||||
*.dll
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Qt-es
|
# Qt-es
|
||||||
object_script.*.Release
|
object_script.*.Release
|
||||||
object_script.*.Debug
|
object_script.*.Debug
|
||||||
|
26
README.md
@ -57,12 +57,21 @@
|
|||||||
|FluTooltip|tooltip提示框||
|
|FluTooltip|tooltip提示框||
|
||||||
|FluTreeView|树控件||
|
|FluTreeView|树控件||
|
||||||
|FluTheme|主题设置|支持主题颜色切换,夜间模式|
|
|FluTheme|主题设置|支持主题颜色切换,夜间模式|
|
||||||
|
|FluCarousel|轮播图组件|支持无限轮播|
|
||||||
|
|FluTimePicker|时间选择器||
|
||||||
|
|FluDatePicker|日期选择器||
|
||||||
|
|FluMenu|菜单Popup||
|
||||||
|
|FluNavigationView|响应式导航布局||
|
||||||
|
|
||||||
# 部分效果预览
|
# 部分效果预览
|
||||||
|
|
||||||
## 主页
|
## 一个聊天Demo,调用了ChatGPT的接口
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## 各种Button按钮
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## 主题颜色切换、夜间模式
|
## 主题颜色切换、夜间模式
|
||||||
|
|
||||||
@ -72,10 +81,17 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Toast组件
|
## 轮播图组件
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## InfoBar提示框组件
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Rectangle组件
|
## 多窗口路由跳转
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
### ⚡ Visitor count
|
||||||
|

|
BIN
doc/preview/buttons.png
Normal file
After Width: | Height: | Size: 103 KiB |
BIN
doc/preview/carousel.png
Normal file
After Width: | Height: | Size: 383 KiB |
BIN
doc/preview/chatgpt.png
Normal file
After Width: | Height: | Size: 382 KiB |
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 119 KiB |
BIN
doc/preview/multiwindow.png
Normal file
After Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 703 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 101 KiB |
@ -12,9 +12,10 @@ Window {
|
|||||||
FluApp.init(app,properties)
|
FluApp.init(app,properties)
|
||||||
FluTheme.isDark = false
|
FluTheme.isDark = false
|
||||||
FluApp.routes = {
|
FluApp.routes = {
|
||||||
"/":"qrc:/MainPage.qml",
|
"/":"qrc:/page/MainPage.qml",
|
||||||
"/Setting":"qrc:/SettingPage.qml",
|
"/about":"qrc:/page/AboutPage.qml",
|
||||||
"/About":"qrc:/AboutPage.qml",
|
"/login":"qrc:/page/LoginPage.qml",
|
||||||
|
"/chat":"qrc:/page/ChatPage.qml",
|
||||||
}
|
}
|
||||||
FluApp.initialRoute = "/"
|
FluApp.initialRoute = "/"
|
||||||
FluApp.run()
|
FluApp.run()
|
||||||
|
56
example/ChatController.cpp
Normal 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
@ -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
|
11
example/Info.plist
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -47,7 +47,7 @@ FluContentPage {
|
|||||||
height: 80
|
height: 80
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
id:item_icon
|
id:item_icon
|
||||||
icon:modelData.icon
|
iconSource:modelData.icon
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var text ="FluentIcons."+modelData.name;
|
var text ="FluentIcons."+modelData.name;
|
||||||
|
101
example/T_Badge.qml
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,38 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
text:"支持Tab键切换焦点,Enter键执行点击事件"
|
text:"支持Tab键切换焦点,空格键执行点击事件"
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
height: 68
|
||||||
|
paddings: 10
|
||||||
|
|
||||||
|
FluTextButton{
|
||||||
|
disabled:text_button_switch.selected
|
||||||
|
text:"Text Button"
|
||||||
|
onClicked: {
|
||||||
|
showInfo("点击Text Button")
|
||||||
|
}
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row{
|
||||||
|
spacing: 5
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:text_button_switch
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
text:"Disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
@ -20,7 +51,8 @@ FluScrollablePage{
|
|||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
FluButton{
|
FluButton{
|
||||||
disabled:button_switch.checked
|
disabled:button_switch.selected
|
||||||
|
text:"Standard Button"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
showInfo("点击StandardButton")
|
showInfo("点击StandardButton")
|
||||||
}
|
}
|
||||||
@ -39,8 +71,6 @@ FluScrollablePage{
|
|||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:button_switch
|
id:button_switch
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
|
||||||
FluText{
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +82,8 @@ FluScrollablePage{
|
|||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
FluFilledButton{
|
FluFilledButton{
|
||||||
disabled:filled_button_switch.checked
|
disabled:filled_button_switch.selected
|
||||||
|
text:"Filled Button"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
showWarning("点击FilledButton")
|
showWarning("点击FilledButton")
|
||||||
}
|
}
|
||||||
@ -71,8 +102,6 @@ FluScrollablePage{
|
|||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:filled_button_switch
|
id:filled_button_switch
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
|
||||||
FluText{
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +114,8 @@ FluScrollablePage{
|
|||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon:FluentIcons.ChromeCloseContrast
|
iconSource:FluentIcons.ChromeCloseContrast
|
||||||
disabled:icon_button_switch.checked
|
disabled:icon_button_switch.selected
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
@ -106,8 +135,47 @@ FluScrollablePage{
|
|||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:icon_button_switch
|
id:icon_button_switch
|
||||||
Layout.alignment: Qt.AlignRight
|
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"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,8 +197,8 @@ FluScrollablePage{
|
|||||||
property int selecIndex : 0
|
property int selecIndex : 0
|
||||||
model: 3
|
model: 3
|
||||||
delegate: FluRadioButton{
|
delegate: FluRadioButton{
|
||||||
checked : repeater.selecIndex===index
|
selected : repeater.selecIndex===index
|
||||||
disabled:radio_button_switch.checked
|
disabled:radio_button_switch.selected
|
||||||
text:"Radio Button_"+index
|
text:"Radio Button_"+index
|
||||||
onClicked:{
|
onClicked:{
|
||||||
repeater.selecIndex = index
|
repeater.selecIndex = index
|
||||||
@ -149,8 +217,6 @@ FluScrollablePage{
|
|||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:radio_button_switch
|
id:radio_button_switch
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
|
||||||
FluText{
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +229,8 @@ FluScrollablePage{
|
|||||||
paddings: 10
|
paddings: 10
|
||||||
|
|
||||||
FluCheckBox{
|
FluCheckBox{
|
||||||
disabled:icon_button_check.checked
|
disabled:check_box_switch.selected
|
||||||
|
text:"Check Box"
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@ -178,12 +245,12 @@ FluScrollablePage{
|
|||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
id:icon_button_check
|
id:check_box_switch
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
|
||||||
FluText{
|
|
||||||
text:"Disabled"
|
text:"Disabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
35
example/T_CalendarPicker.qml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import QtQuick.Window 2.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"CalendarPicker"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
Layout.topMargin: 20
|
||||||
|
height: 350
|
||||||
|
paddings: 10
|
||||||
|
FluCalendarView{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
Layout.topMargin: 20
|
||||||
|
height: 80
|
||||||
|
paddings: 10
|
||||||
|
ColumnLayout{
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
FluCalendarPicker{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
example/T_Carousel.qml
Normal 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"}])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
example/T_ColorPicker.qml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
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:"ColorPicker"
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
height: 280
|
||||||
|
Layout.topMargin: 20
|
||||||
|
paddings: 10
|
||||||
|
ColumnLayout{
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left:parent.left
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:"此颜色组件是Github上的开源项目"
|
||||||
|
}
|
||||||
|
FluTextButton{
|
||||||
|
leftPadding: 0
|
||||||
|
rightPadding: 0
|
||||||
|
text:"https://github.com/rshest/qml-colorpicker"
|
||||||
|
onClicked: {
|
||||||
|
Qt.openUrlExternally(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluColorView{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
Layout.topMargin: 20
|
||||||
|
height: 60
|
||||||
|
paddings: 10
|
||||||
|
|
||||||
|
RowLayout{
|
||||||
|
FluText{
|
||||||
|
text:"点击选择颜色->"
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
}
|
||||||
|
FluColorPicker{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ FluScrollablePage{
|
|||||||
property int selecIndex : 0
|
property int selecIndex : 0
|
||||||
model: 3
|
model: 3
|
||||||
delegate: FluRadioButton{
|
delegate: FluRadioButton{
|
||||||
checked : repeater.selecIndex===index
|
selected : repeater.selecIndex===index
|
||||||
text:"Radio Button_"+index
|
text:"Radio Button_"+index
|
||||||
onClicked:{
|
onClicked:{
|
||||||
repeater.selecIndex = index
|
repeater.selecIndex = index
|
||||||
|
43
example/T_MediaPlayer.qml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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:"MediaPlayer"
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if(visible){
|
||||||
|
player.play()
|
||||||
|
}else{
|
||||||
|
player.pause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
height: 320
|
||||||
|
Layout.topMargin: 20
|
||||||
|
paddings: 10
|
||||||
|
ColumnLayout{
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left:parent.left
|
||||||
|
}
|
||||||
|
|
||||||
|
FluMediaPlayer{
|
||||||
|
id:player
|
||||||
|
// source:"http://mirror.aarnet.edu.au/pub/TED-talks/911Mothers_2010W-480p.mp4"
|
||||||
|
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
|
||||||
|
// source:"http://video.chinanews.com/flv/2019/04/23/400/111773_web.mp4"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
54
example/T_Menu.qml
Normal 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
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
41
example/T_TabView.qml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import QtQuick.Window 2.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
FluScrollablePage{
|
||||||
|
|
||||||
|
title:"TabView"
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_page
|
||||||
|
Rectangle{
|
||||||
|
anchors.fill: parent
|
||||||
|
color: argument
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
var colors = [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
|
||||||
|
for(var i =0;i<colors.length;i++){
|
||||||
|
tab_view.appendTab("","Document "+i,com_page,colors[i].dark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
width: parent.width
|
||||||
|
Layout.topMargin: 20
|
||||||
|
height: 400
|
||||||
|
paddings: 10
|
||||||
|
|
||||||
|
|
||||||
|
FluTabView{
|
||||||
|
id:tab_view
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -13,17 +13,26 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
placeholderText: "单行输入框"
|
placeholderText: "单行输入框"
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
|
disabled:toggle_switch.selected
|
||||||
}
|
}
|
||||||
FluMultiLineTextBox{
|
FluMultiLineTextBox{
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
placeholderText: "多行输入框"
|
placeholderText: "多行输入框"
|
||||||
|
disabled:toggle_switch.selected
|
||||||
}
|
}
|
||||||
FluAutoSuggestBox{
|
FluAutoSuggestBox{
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
values:generateRandomNames(100)
|
values:generateRandomNames(100)
|
||||||
placeholderText: "AutoSuggestBox"
|
placeholderText: "AutoSuggestBox"
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
|
disabled:toggle_switch.selected
|
||||||
|
}
|
||||||
|
|
||||||
|
FluToggleSwitch{
|
||||||
|
id:toggle_switch
|
||||||
|
text:"Disabled"
|
||||||
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateRandomNames(numNames) {
|
function generateRandomNames(numNames) {
|
||||||
|
@ -13,14 +13,14 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Repeater{
|
Repeater{
|
||||||
model: [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
|
model: [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
|
||||||
delegate: Rectangle{
|
delegate: FluRectangle{
|
||||||
width: 42
|
width: 42
|
||||||
height: 42
|
height: 42
|
||||||
radius: 4
|
radius: [4,4,4,4]
|
||||||
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
|
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
|
||||||
FluIcon {
|
FluIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
icon: FluentIcons.AcceptMedium
|
iconSource: FluentIcons.AcceptMedium
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
visible: modelData === FluTheme.primaryColor
|
visible: modelData === FluTheme.primaryColor
|
||||||
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
||||||
@ -41,8 +41,8 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
checked: FluTheme.isDark
|
selected: FluTheme.isDark
|
||||||
onClickFunc:function(){
|
clickFunc:function(){
|
||||||
FluTheme.isDark = !FluTheme.isDark
|
FluTheme.isDark = !FluTheme.isDark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,8 +51,8 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
checked: FluTheme.isFrameless
|
selected: FluTheme.isFrameless
|
||||||
onClickFunc:function(){
|
clickFunc:function(){
|
||||||
FluTheme.isFrameless = !FluTheme.isFrameless
|
FluTheme.isFrameless = !FluTheme.isFrameless
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,8 +61,8 @@ FluScrollablePage{
|
|||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
checked: FluTheme.isNativeText
|
selected: FluTheme.isNativeText
|
||||||
onClickFunc:function(){
|
clickFunc:function(){
|
||||||
FluTheme.isNativeText = !FluTheme.isNativeText
|
FluTheme.isNativeText = !FluTheme.isNativeText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,8 @@ FluScrollablePage{
|
|||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
}
|
}
|
||||||
|
FluToggleSwitch{
|
||||||
|
Layout.topMargin: 20
|
||||||
|
text:"Disabled"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
75
example/T_Tooltip.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,10 @@ FluContentPage {
|
|||||||
title: "Typography"
|
title: "Typography"
|
||||||
property int textSize: 13
|
property int textSize: 13
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
slider.seek(31)
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView{
|
ScrollView{
|
||||||
clip: true
|
clip: true
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -68,17 +72,17 @@ FluContentPage {
|
|||||||
|
|
||||||
|
|
||||||
FluSlider{
|
FluSlider{
|
||||||
|
id:slider
|
||||||
orientation:FluSlider.Vertical
|
orientation:FluSlider.Vertical
|
||||||
anchors{
|
anchors{
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 30
|
rightMargin: 45
|
||||||
top: parent.top
|
top: parent.top
|
||||||
topMargin: 30
|
topMargin: 30
|
||||||
}
|
}
|
||||||
onValueChanged:{
|
onValueChanged:{
|
||||||
textSize = value/100*16+8
|
textSize = value/100*16+8
|
||||||
}
|
}
|
||||||
value: 31
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,49 @@
|
|||||||
QT += quick concurrent
|
QT += quick concurrent network multimedia
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
|
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
ChatController.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
ChatController.cpp \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc
|
||||||
|
|
||||||
#qnx: target.path = /tmp/$${TARGET}/bin
|
RC_ICONS = favicon.ico
|
||||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|
||||||
#!isEmpty(target.path): INSTALLS += target
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
|
||||||
QML_IMPORT_PATH =
|
QML_IMPORT_PATH =
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
|
||||||
QML_DESIGNER_IMPORT_PATH =
|
QML_DESIGNER_IMPORT_PATH =
|
||||||
|
|
||||||
CONFIG(debug,debug|release) {
|
CONFIG(debug,debug|release) {
|
||||||
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/debug)
|
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/debug)
|
||||||
} else {
|
} else {
|
||||||
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/release)
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
mac: {
|
||||||
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
|
}
|
||||||
|
BIN
example/favicon.ico
Normal file
After Width: | Height: | Size: 272 KiB |
@ -4,6 +4,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include "ChatController.h"
|
||||||
|
|
||||||
QMap<QString, QVariant> properties(){
|
QMap<QString, QVariant> properties(){
|
||||||
QMap<QString, QVariant> map;
|
QMap<QString, QVariant> map;
|
||||||
@ -20,6 +21,9 @@ int main(int argc, char *argv[])
|
|||||||
// QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
|
// QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
qmlRegisterType<ChatController>("Controller",1,0,"ChatController");
|
||||||
|
|
||||||
QMapIterator<QString, QVariant> iterator(properties());
|
QMapIterator<QString, QVariant> iterator(properties());
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
iterator.next();
|
iterator.next();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ FluWindow {
|
|||||||
fontStyle: FluText.Title
|
fontStyle: FluText.Title
|
||||||
}
|
}
|
||||||
FluText{
|
FluText{
|
||||||
text:"v1.0.5"
|
text:"v1.1.4"
|
||||||
fontStyle: FluText.Body
|
fontStyle: FluText.Body
|
||||||
Layout.alignment: Qt.AlignBottom
|
Layout.alignment: Qt.AlignBottom
|
||||||
}
|
}
|
||||||
@ -69,9 +70,25 @@ 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
@ -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()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
example/page/LoginPage.qml
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -9,9 +9,9 @@ import FluentUI 1.0
|
|||||||
FluWindow {
|
FluWindow {
|
||||||
id:rootwindow
|
id:rootwindow
|
||||||
width: 860
|
width: 860
|
||||||
height: 680
|
height: 600
|
||||||
title: "FluentUI"
|
title: "FluentUI"
|
||||||
minimumWidth: 500
|
minimumWidth: 520
|
||||||
minimumHeight: 400
|
minimumHeight: 400
|
||||||
|
|
||||||
FluAppBar{
|
FluAppBar{
|
||||||
@ -19,7 +19,6 @@ FluWindow {
|
|||||||
title: "FluentUI"
|
title: "FluentUI"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FluObject{
|
FluObject{
|
||||||
id:original_items
|
id:original_items
|
||||||
|
|
||||||
@ -73,6 +72,20 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"CalendarPicker"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_CalendarPicker.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"ColorPicker"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_ColorPicker.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItemHeader{
|
FluPaneItemHeader{
|
||||||
title:"Surface"
|
title:"Surface"
|
||||||
}
|
}
|
||||||
@ -90,12 +103,28 @@ FluWindow {
|
|||||||
nav_view.push("qrc:/T_Progress.qml")
|
nav_view.push("qrc:/T_Progress.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Badge"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_Badge.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"Rectangle"
|
title:"Rectangle"
|
||||||
onTap:{
|
onTap:{
|
||||||
nav_view.push("qrc:/T_Rectangle.qml")
|
nav_view.push("qrc:/T_Rectangle.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Carousel"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_Carousel.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"Expander"
|
title:"Expander"
|
||||||
onTap:{
|
onTap:{
|
||||||
@ -107,7 +136,6 @@ FluWindow {
|
|||||||
title:"Popus"
|
title:"Popus"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"Dialog"
|
title:"Dialog"
|
||||||
onTap:{
|
onTap:{
|
||||||
@ -115,10 +143,31 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Tooltip"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_Tooltip.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"Menu"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_Menu.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItemHeader{
|
FluPaneItemHeader{
|
||||||
title:"Navigation"
|
title:"Navigation"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"TabView"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_TabView.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"TreeView"
|
title:"TreeView"
|
||||||
onTap:{
|
onTap:{
|
||||||
@ -126,6 +175,14 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"MultiWindow"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_MultiWindow.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FluPaneItemHeader{
|
FluPaneItemHeader{
|
||||||
title:"Theming"
|
title:"Theming"
|
||||||
}
|
}
|
||||||
@ -150,6 +207,17 @@ FluWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluPaneItemHeader{
|
||||||
|
title:"Media"
|
||||||
|
}
|
||||||
|
|
||||||
|
FluPaneItem{
|
||||||
|
title:"MediaPlayer"
|
||||||
|
onTap:{
|
||||||
|
nav_view.push("qrc:/T_MediaPlayer.qml")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FluObject{
|
FluObject{
|
||||||
@ -164,7 +232,7 @@ FluWindow {
|
|||||||
FluPaneItem{
|
FluPaneItem{
|
||||||
title:"关于"
|
title:"关于"
|
||||||
onTap:{
|
onTap:{
|
||||||
FluApp.navigate("/About")
|
FluApp.navigate("/about")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,6 +249,35 @@ FluWindow {
|
|||||||
items:original_items
|
items:original_items
|
||||||
footerItems:footer_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: {
|
Component.onCompleted: {
|
||||||
nav_view.setCurrentIndex(1)
|
nav_view.setCurrentIndex(1)
|
||||||
nav_view.push("qrc:/T_Buttons.qml")
|
nav_view.push("qrc:/T_Buttons.qml")
|
@ -1,15 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>T_ToggleSwitch.qml</file>
|
|
||||||
<file>T_Typography.qml</file>
|
|
||||||
<file>App.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/image/image_huoyin.webp</file>
|
||||||
<file>res/svg/avatar_1.svg</file>
|
<file>res/svg/avatar_1.svg</file>
|
||||||
<file>res/svg/avatar_2.svg</file>
|
<file>res/svg/avatar_2.svg</file>
|
||||||
@ -23,14 +14,37 @@
|
|||||||
<file>res/svg/avatar_10.svg</file>
|
<file>res/svg/avatar_10.svg</file>
|
||||||
<file>res/svg/avatar_11.svg</file>
|
<file>res/svg/avatar_11.svg</file>
|
||||||
<file>res/svg/avatar_12.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_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_TextBox.qml</file>
|
||||||
<file>T_Theme.qml</file>
|
<file>T_Theme.qml</file>
|
||||||
<file>T_Dialog.qml</file>
|
<file>T_Dialog.qml</file>
|
||||||
<file>T_TreeView.qml</file>
|
<file>T_TreeView.qml</file>
|
||||||
<file>T_Expander.qml</file>
|
<file>T_Expander.qml</file>
|
||||||
<file>MainPage.qml</file>
|
|
||||||
<file>T_TimePicker.qml</file>
|
<file>T_TimePicker.qml</file>
|
||||||
<file>T_DatePicker.qml</file>
|
<file>T_DatePicker.qml</file>
|
||||||
|
<file>T_MultiWindow.qml</file>
|
||||||
|
<file>T_Menu.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>
|
||||||
|
<file>T_CalendarPicker.qml</file>
|
||||||
|
<file>T_ColorPicker.qml</file>
|
||||||
|
<file>T_Carousel.qml</file>
|
||||||
|
<file>T_MediaPlayer.qml</file>
|
||||||
|
<file>T_TabView.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
example/res/image/banner_1.jpg
Normal file
After Width: | Height: | Size: 300 KiB |
BIN
example/res/image/banner_2.jpg
Normal file
After Width: | Height: | Size: 298 KiB |
BIN
example/res/image/banner_3.jpg
Normal file
After Width: | Height: | Size: 130 KiB |
BIN
example/res/image/logo_openai.png
Normal file
After Width: | Height: | Size: 22 KiB |
@ -17,7 +17,7 @@ function Main() {
|
|||||||
|
|
||||||
New-Item -ItemType Directory $archiveName
|
New-Item -ItemType Directory $archiveName
|
||||||
# 拷贝exe
|
# 拷贝exe
|
||||||
Copy-Item bin\release\$targetName $archiveName\
|
Copy-Item bin\release\* $archiveName\
|
||||||
# 拷贝依赖
|
# 拷贝依赖
|
||||||
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
||||||
# 删除不必要的文件
|
# 删除不必要的文件
|
||||||
|
@ -27,7 +27,7 @@ function Main() {
|
|||||||
|
|
||||||
New-Item -ItemType Directory $archiveName
|
New-Item -ItemType Directory $archiveName
|
||||||
# 拷贝exe
|
# 拷贝exe
|
||||||
Copy-Item bin\release\$targetName $archiveName\
|
Copy-Item bin\release\* $archiveName\
|
||||||
# 拷贝依赖
|
# 拷贝依赖
|
||||||
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
||||||
# 删除不必要的文件
|
# 删除不必要的文件
|
||||||
|
@ -33,14 +33,18 @@ void FluApp::run(){
|
|||||||
navigate(initialRoute());
|
navigate(initialRoute());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluApp::navigate(const QString& route){
|
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
||||||
if(!routes().contains(route)){
|
if(!routes().contains(route)){
|
||||||
qErrnoWarning("没有找到当前路由");
|
qErrnoWarning("没有找到当前路由");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool isAppWindow = route == initialRoute();
|
bool isAppWindow = route == initialRoute();
|
||||||
FramelessView *view = new FramelessView();
|
FramelessView *view = new FramelessView();
|
||||||
|
if(fluRegister){
|
||||||
|
fluRegister->to(view);
|
||||||
|
view->setProperty("pageRegister",QVariant::fromValue(fluRegister));
|
||||||
|
}
|
||||||
|
view->setProperty("argument",argument);
|
||||||
QMapIterator<QString, QVariant> iterator(properties);
|
QMapIterator<QString, QVariant> iterator(properties);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
iterator.next();
|
iterator.next();
|
||||||
@ -59,7 +63,6 @@ void FluApp::navigate(const QString& route){
|
|||||||
view->setSource((routes().value(route).toString()));
|
view->setSource((routes().value(route).toString()));
|
||||||
if(isAppWindow){
|
if(isAppWindow){
|
||||||
QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit);
|
QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit);
|
||||||
// QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [&view](){view->setSource({});});
|
|
||||||
}else{
|
}else{
|
||||||
view->closeDeleteLater();
|
view->closeDeleteLater();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
#include "FluRegister.h"
|
||||||
#include "FramelessView.h"
|
#include "FramelessView.h"
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void run();
|
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);
|
Q_INVOKABLE void init(QWindow *window,QMap<QString, QVariant> properties);
|
||||||
|
|
||||||
@ -37,9 +38,8 @@ public:
|
|||||||
Q_INVOKABLE void clipText(const QString& text);
|
Q_INVOKABLE void clipText(const QString& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static FluApp* m_instance;
|
|
||||||
QMap<QString, QVariant> properties;
|
QMap<QString, QVariant> properties;
|
||||||
|
static FluApp* m_instance;
|
||||||
QWindow *appWindow;
|
QWindow *appWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
20
src/FluRegister.cpp
Normal 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
@ -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
|
@ -32,22 +32,23 @@ void Fluent::registerTypes(const char *uri){
|
|||||||
|
|
||||||
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
|
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
|
||||||
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
|
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
|
||||||
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTabView.qml"),uri,major,minor,"FluTabView");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluArea.qml"),uri,major,minor,"FluArea");
|
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/FluMediaPlayer.qml"),uri,major,minor,"FluMediaPlayer");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
|
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/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItem.qml"),uri,major,minor,"FluPaneItem");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItem.qml"),uri,major,minor,"FluPaneItem");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemSeparator.qml"),uri,major,minor,"FluPaneItemSeparator");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemSeparator.qml"),uri,major,minor,"FluPaneItemSeparator");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluNavigationView.qml"),uri,major,minor,"FluNavigationView");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluNavigationView.qml"),uri,major,minor,"FluNavigationView");
|
||||||
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluCalendarPicker.qml"),uri,major,minor,"FluCalendarPicker");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluCalendarDatePicker.qml"),uri,major,minor,"FluCalendarDatePicker");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluCalendarView.qml"),uri,major,minor,"FluCalendarView");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluCalenderView.qml"),uri,major,minor,"FluCalenderView");
|
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluDatePicker.qml"),uri,major,minor,"FluDatePicker");
|
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/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
|
||||||
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluColorView.qml"),uri,major,minor,"FluColorView");
|
||||||
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluColorPicker.qml"),uri,major,minor,"FluColorPicker");
|
||||||
|
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/FluAutoSuggestBox.qml"),uri,major,minor,"FluAutoSuggestBox");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluExpander.qml"),uri,major,minor,"FluExpander");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluExpander.qml"),uri,major,minor,"FluExpander");
|
||||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
|
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
|
||||||
@ -91,7 +92,7 @@ void Fluent::initializeEngine(QQmlEngine *engine, const char *uri)
|
|||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily("Microsoft YaHei");
|
font.setFamily("Microsoft YaHei");
|
||||||
QGuiApplication::setFont(font);
|
QGuiApplication::setFont(font);
|
||||||
// QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
|
// QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
|
||||||
#endif
|
#endif
|
||||||
QFontDatabase::addApplicationFont(":/com.zhuzichu/res/font/Segoe_Fluent_Icons.ttf");
|
QFontDatabase::addApplicationFont(":/com.zhuzichu/res/font/Segoe_Fluent_Icons.ttf");
|
||||||
FluApp* app = FluApp::getInstance();
|
FluApp* app = FluApp::getInstance();
|
||||||
|
@ -15,6 +15,7 @@ HEADERS += \
|
|||||||
FluApp.h \
|
FluApp.h \
|
||||||
FluColorSet.h \
|
FluColorSet.h \
|
||||||
FluColors.h \
|
FluColors.h \
|
||||||
|
FluRegister.h \
|
||||||
FluTheme.h \
|
FluTheme.h \
|
||||||
Fluent.h \
|
Fluent.h \
|
||||||
FluentUI.h \
|
FluentUI.h \
|
||||||
@ -28,6 +29,7 @@ SOURCES += \
|
|||||||
FluApp.cpp \
|
FluApp.cpp \
|
||||||
FluColorSet.cpp \
|
FluColorSet.cpp \
|
||||||
FluColors.cpp \
|
FluColors.cpp \
|
||||||
|
FluRegister.cpp \
|
||||||
FluTheme.cpp \
|
FluTheme.cpp \
|
||||||
Fluent.cpp \
|
Fluent.cpp \
|
||||||
FluentUI.cpp \
|
FluentUI.cpp \
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
#include <QRegion>
|
#include <QRegion>
|
||||||
|
|
||||||
//无边框窗口,主要用来实现自定义标题栏。
|
|
||||||
//Windows平台支持拖动和改变大小,支持Aero效果
|
|
||||||
//非Windows平台,去掉边框,不做其它处理。由Qml模拟resize和拖动。
|
|
||||||
class FramelessViewPrivate;
|
class FramelessViewPrivate;
|
||||||
class FramelessView : public QQuickView
|
class FramelessView : public QQuickView
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "WindowHelper.h"
|
#include "WindowHelper.h"
|
||||||
|
|
||||||
|
#include "FluRegister.h"
|
||||||
|
|
||||||
WindowHelper::WindowHelper(QObject *parent)
|
WindowHelper::WindowHelper(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
@ -10,11 +12,18 @@ void WindowHelper::setTitle(const QString& text){
|
|||||||
window->setTitle(text);
|
window->setTitle(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WindowHelper::initWindow(FramelessView* window){
|
void WindowHelper::initWindow(FramelessView* window){
|
||||||
this->window = window;
|
this->window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject WindowHelper::getArgument(){
|
||||||
|
return window->property("argument").toJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant WindowHelper::getPageRegister(){
|
||||||
|
return window->property("pageRegister");
|
||||||
|
}
|
||||||
|
|
||||||
void WindowHelper::setMinimumWidth(int width){
|
void WindowHelper::setMinimumWidth(int width){
|
||||||
this->window->setMinimumWidth(width);
|
this->window->setMinimumWidth(width);
|
||||||
}
|
}
|
||||||
@ -27,3 +36,25 @@ void WindowHelper::setMinimumHeight(int height){
|
|||||||
void WindowHelper::setMaximumHeight(int height){
|
void WindowHelper::setMaximumHeight(int height){
|
||||||
this->window->setMaximumHeight(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);
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
#include <QJsonObject>
|
||||||
#include "FramelessView.h"
|
#include "FramelessView.h"
|
||||||
|
|
||||||
class WindowHelper : public QObject
|
class WindowHelper : public QObject
|
||||||
@ -20,6 +21,11 @@ public:
|
|||||||
Q_INVOKABLE void setMaximumWidth(int width);
|
Q_INVOKABLE void setMaximumWidth(int width);
|
||||||
Q_INVOKABLE void setMinimumHeight(int height);
|
Q_INVOKABLE void setMinimumHeight(int height);
|
||||||
Q_INVOKABLE void setMaximumHeight(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:
|
private:
|
||||||
FramelessView* window;
|
FramelessView* window;
|
||||||
|
234
src/colorpicker/ColorPicker.qml
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import "content"
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: colorPicker
|
||||||
|
property color colorValue: "transparent"
|
||||||
|
property bool enableAlphaChannel: true
|
||||||
|
property bool enableDetails: true
|
||||||
|
property int colorHandleRadius : 8
|
||||||
|
property color _changingColorValue : _hsla(hueSlider.value, sbPicker.saturation,sbPicker.brightness, alphaSlider.value)
|
||||||
|
on_ChangingColorValueChanged: {
|
||||||
|
colorValue = _changingColorValue
|
||||||
|
}
|
||||||
|
|
||||||
|
signal colorChanged(color changedColor)
|
||||||
|
|
||||||
|
implicitWidth: picker.implicitWidth
|
||||||
|
implicitHeight: picker.implicitHeight
|
||||||
|
color: "#00000000"
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: picker
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: colorHandleRadius
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
|
||||||
|
SBPicker {
|
||||||
|
id: sbPicker
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.minimumWidth: 200
|
||||||
|
Layout.minimumHeight: 200
|
||||||
|
hueColor: {
|
||||||
|
var v = 1.0-hueSlider.value
|
||||||
|
if(0.0 <= v && v < 0.16) {
|
||||||
|
return Qt.rgba(1.0, 0.0, v/0.16, 1.0)
|
||||||
|
} else if(0.16 <= v && v < 0.33) {
|
||||||
|
return Qt.rgba(1.0 - (v-0.16)/0.17, 0.0, 1.0, 1.0)
|
||||||
|
} else if(0.33 <= v && v < 0.5) {
|
||||||
|
return Qt.rgba(0.0, ((v-0.33)/0.17), 1.0, 1.0)
|
||||||
|
} else if(0.5 <= v && v < 0.76) {
|
||||||
|
return Qt.rgba(0.0, 1.0, 1.0 - (v-0.5)/0.26, 1.0)
|
||||||
|
} else if(0.76 <= v && v < 0.85) {
|
||||||
|
return Qt.rgba((v-0.76)/0.09, 1.0, 0.0, 1.0)
|
||||||
|
} else if(0.85 <= v && v <= 1.0) {
|
||||||
|
return Qt.rgba(1.0, 1.0 - (v-0.85)/0.15, 0.0, 1.0)
|
||||||
|
} else {
|
||||||
|
return "red"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: huePicker
|
||||||
|
width: 12
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.topMargin: colorHandleRadius
|
||||||
|
Layout.bottomMargin: colorHandleRadius
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
id: colorBar
|
||||||
|
gradient: Gradient {
|
||||||
|
GradientStop { position: 1.0; color: "#FF0000" }
|
||||||
|
GradientStop { position: 0.85; color: "#FFFF00" }
|
||||||
|
GradientStop { position: 0.76; color: "#00FF00" }
|
||||||
|
GradientStop { position: 0.5; color: "#00FFFF" }
|
||||||
|
GradientStop { position: 0.33; color: "#0000FF" }
|
||||||
|
GradientStop { position: 0.16; color: "#FF00FF" }
|
||||||
|
GradientStop { position: 0.0; color: "#FF0000" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColorSlider {
|
||||||
|
id: hueSlider; anchors.fill: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: alphaPicker
|
||||||
|
visible: enableAlphaChannel
|
||||||
|
width: 12
|
||||||
|
Layout.leftMargin: 4
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.topMargin: colorHandleRadius
|
||||||
|
Layout.bottomMargin: colorHandleRadius
|
||||||
|
Checkerboard { cellSide: 4 }
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
gradient: Gradient {
|
||||||
|
GradientStop { position: 0.0; color: "#FF000000" }
|
||||||
|
GradientStop { position: 1.0; color: "#00000000" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ColorSlider {
|
||||||
|
id: alphaSlider; anchors.fill: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: detailColumn
|
||||||
|
Layout.leftMargin: 4
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.topMargin: colorHandleRadius
|
||||||
|
Layout.bottomMargin: colorHandleRadius
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
visible: enableDetails
|
||||||
|
|
||||||
|
PanelBorder {
|
||||||
|
width: parent.width
|
||||||
|
height: 30
|
||||||
|
visible: enableAlphaChannel
|
||||||
|
Checkerboard { cellSide: 5 }
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width; height: 30
|
||||||
|
border.width: 1; border.color: "black"
|
||||||
|
color: colorPicker.colorValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PanelBorder {
|
||||||
|
id: colorEditBox
|
||||||
|
height: 15; width: parent.width
|
||||||
|
TextInput {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "#AAAAAA"
|
||||||
|
selectionColor: "#FF7777AA"
|
||||||
|
font.pixelSize: 11
|
||||||
|
maximumLength: 9
|
||||||
|
focus: false
|
||||||
|
text: _fullColorString(colorPicker.colorValue, alphaSlider.value)
|
||||||
|
selectByMouse: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 1
|
||||||
|
NumberBox { caption: "H:"; value: hueSlider.value.toFixed(2) }
|
||||||
|
NumberBox { caption: "S:"; value: sbPicker.saturation.toFixed(2) }
|
||||||
|
NumberBox { caption: "B:"; value: sbPicker.brightness.toFixed(2) }
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 1
|
||||||
|
NumberBox {
|
||||||
|
caption: "R:"
|
||||||
|
value: _getChannelStr(colorPicker.colorValue, 0)
|
||||||
|
min: 0; max: 255
|
||||||
|
}
|
||||||
|
NumberBox {
|
||||||
|
caption: "G:"
|
||||||
|
value: _getChannelStr(colorPicker.colorValue, 1)
|
||||||
|
min: 0; max: 255
|
||||||
|
}
|
||||||
|
NumberBox {
|
||||||
|
caption: "B:"
|
||||||
|
value: _getChannelStr(colorPicker.colorValue, 2)
|
||||||
|
min: 0; max: 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item{
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberBox {
|
||||||
|
visible: enableAlphaChannel
|
||||||
|
caption: "A:"; value: Math.ceil(alphaSlider.value*255)
|
||||||
|
min: 0; max: 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _hsla(h, s, b, a) {
|
||||||
|
var lightness = (2 - s)*b
|
||||||
|
var satHSL = s*b/((lightness <= 1) ? lightness : 2 - lightness)
|
||||||
|
lightness /= 2
|
||||||
|
|
||||||
|
var c = Qt.hsla(h, satHSL, lightness, a)
|
||||||
|
|
||||||
|
colorChanged(c)
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
function _rgb(rgb, a) {
|
||||||
|
|
||||||
|
var c = Qt.rgba(rgb.r, rgb.g, rgb.b, a)
|
||||||
|
|
||||||
|
colorChanged(c)
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
function _fullColorString(clr, a) {
|
||||||
|
return "#" + ((Math.ceil(a*255) + 256).toString(16).substr(1, 2) + clr.toString().substr(1, 6)).toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getChannelStr(clr, channelIdx) {
|
||||||
|
return parseInt(clr.toString().substr(channelIdx*2 + 1, 2), 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setColor(color) {
|
||||||
|
var c = Qt.tint(color, "transparent")
|
||||||
|
alphaSlider.setValue(c.a)
|
||||||
|
colorPicker.colorValue = c
|
||||||
|
}
|
||||||
|
}
|
16
src/colorpicker/content/Checkerboard.qml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
Grid {
|
||||||
|
id: root
|
||||||
|
property int cellSide: 5
|
||||||
|
anchors.fill: parent
|
||||||
|
rows: height/cellSide; columns: width/cellSide
|
||||||
|
clip: true
|
||||||
|
Repeater {
|
||||||
|
model: root.columns*root.rows
|
||||||
|
Rectangle {
|
||||||
|
width: root.cellSide; height: root.cellSide
|
||||||
|
color: (index%2 == 0) ? "gray" : "white"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
43
src/colorpicker/content/ColorSlider.qml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property int cursorHeight: 7
|
||||||
|
property real value: (1 - pickerCursor.y/height)
|
||||||
|
width: 15
|
||||||
|
height: 300
|
||||||
|
Item {
|
||||||
|
id: pickerCursor
|
||||||
|
width: parent.width
|
||||||
|
Rectangle {
|
||||||
|
x: -3; y: -height*0.5
|
||||||
|
width: parent.width + 4; height: cursorHeight
|
||||||
|
border.color: "black"; border.width: 1
|
||||||
|
color: "transparent"
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent; anchors.margins: 2
|
||||||
|
border.color: "white"; border.width: 1
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
y: -Math.round(cursorHeight/2)
|
||||||
|
height: parent.height+cursorHeight
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
function handleMouse(mouse) {
|
||||||
|
if (mouse.buttons & Qt.LeftButton) {
|
||||||
|
pickerCursor.y = Math.max(0, Math.min(height, mouse.y)-cursorHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
handleMouse(mouse)
|
||||||
|
}
|
||||||
|
onPressed: handleMouse(mouse)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue(val) {
|
||||||
|
pickerCursor.y = height * (1 - val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
39
src/colorpicker/content/NumberBox.qml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Row {
|
||||||
|
property alias caption: captionBox.text
|
||||||
|
property alias value: inputBox.text
|
||||||
|
property alias min: numValidator.bottom
|
||||||
|
property alias max: numValidator.top
|
||||||
|
property alias decimals: numValidator.decimals
|
||||||
|
|
||||||
|
width: 80;
|
||||||
|
height: 15
|
||||||
|
spacing: 4
|
||||||
|
//anchors.margins: 2
|
||||||
|
Text {
|
||||||
|
id: captionBox
|
||||||
|
width: 18; height: parent.height
|
||||||
|
color: "#AAAAAA"
|
||||||
|
font.pixelSize: 11; font.bold: true
|
||||||
|
}
|
||||||
|
PanelBorder {
|
||||||
|
height: parent.height
|
||||||
|
TextInput {
|
||||||
|
id: inputBox
|
||||||
|
color: "#AAAAAA"; selectionColor: "#FF7777AA"
|
||||||
|
font.pixelSize: 11
|
||||||
|
maximumLength: 10
|
||||||
|
focus: false
|
||||||
|
readOnly: true
|
||||||
|
selectByMouse: true
|
||||||
|
validator: DoubleValidator {
|
||||||
|
id: numValidator
|
||||||
|
bottom: 0; top: 1; decimals: 2
|
||||||
|
notation: DoubleValidator.StandardNotation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
18
src/colorpicker/content/PanelBorder.qml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width : 40; height : 15; radius: 2
|
||||||
|
border.width: 1; border.color: "#FF101010"
|
||||||
|
color: "transparent"
|
||||||
|
anchors.leftMargin: 1; anchors.topMargin: 3
|
||||||
|
clip: true
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent; radius: 2
|
||||||
|
anchors.leftMargin: -1; anchors.topMargin: -1
|
||||||
|
anchors.rightMargin: 0; anchors.bottomMargin: 0
|
||||||
|
border.width: 1; border.color: "#FF525255"
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
69
src/colorpicker/content/SBPicker.qml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
property color hueColor : "blue"
|
||||||
|
property real saturation : pickerCursor.x/(width-2*r)
|
||||||
|
property real brightness : 1 - pickerCursor.y/(height-2*r)
|
||||||
|
property int r : colorHandleRadius
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
x : r
|
||||||
|
y : r + parent.height - 2 * r
|
||||||
|
rotation: -90
|
||||||
|
transformOrigin: Item.TopLeft
|
||||||
|
width: parent.height - 2 * r
|
||||||
|
height: parent.width - 2 * r
|
||||||
|
gradient: Gradient {
|
||||||
|
GradientStop { position: 0.0; color: "#FFFFFF" }
|
||||||
|
GradientStop { position: 1.0; color: root.hueColor }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: r
|
||||||
|
y: r
|
||||||
|
width: parent.width - 2 * r
|
||||||
|
height: parent.height - 2 * r
|
||||||
|
gradient: Gradient {
|
||||||
|
GradientStop { position: 1.0; color: "#FF000000" }
|
||||||
|
GradientStop { position: 0.0; color: "#00000000" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
id: pickerCursor
|
||||||
|
Rectangle {
|
||||||
|
width: r*2; height: r*2
|
||||||
|
radius: r
|
||||||
|
border.color: "black"; border.width: 2
|
||||||
|
color: "transparent"
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent; anchors.margins: 2;
|
||||||
|
border.color: "white"; border.width: 2
|
||||||
|
radius: width/2
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
x: r
|
||||||
|
y: r
|
||||||
|
function handleMouse(mouse) {
|
||||||
|
if (mouse.buttons & Qt.LeftButton) {
|
||||||
|
|
||||||
|
pickerCursor.x = Math.max(0,Math.min(mouse.x - r,width-2*r));
|
||||||
|
pickerCursor.y = Math.max(0,Math.min(mouse.y - r,height-2*r));
|
||||||
|
|
||||||
|
|
||||||
|
// pickerCursor.x = Math.max(-r,Math.min(mouse.x - r,width+r));
|
||||||
|
// pickerCursor.y = Math.max(-r,Math.min(mouse.y - r,height+r));
|
||||||
|
|
||||||
|
// pickerCursor.x = Math.max(0, Math.min(width, mouse.x) - 2 * r);
|
||||||
|
// pickerCursor.y = Math.max(0, Math.min(height, mouse.y) - 2 * r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onPositionChanged: handleMouse(mouse)
|
||||||
|
onPressed: handleMouse(mouse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,25 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Window 2.15
|
import QtQuick.Window 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
|
|
||||||
id:root
|
property string title: "标题"
|
||||||
|
property color textColor: FluTheme.isDark ? "#000000" : "#FFFFFF"
|
||||||
|
property bool showDark: false
|
||||||
|
property bool showFps: false
|
||||||
|
property var window: Window.window
|
||||||
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
property color borerlessColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||||
|
property bool resizable: {
|
||||||
|
if(window == null){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return !(window.minimumHeight === window.maximumHeight && window.maximumWidth === window.minimumWidth)
|
||||||
|
}
|
||||||
|
|
||||||
|
id:root
|
||||||
color: {
|
color: {
|
||||||
if(Window.window == null)
|
if(Window.window == null)
|
||||||
return borerlessColor
|
return borerlessColor
|
||||||
@ -15,7 +27,6 @@ Rectangle{
|
|||||||
}
|
}
|
||||||
visible: FluTheme.isFrameless
|
visible: FluTheme.isFrameless
|
||||||
height: visible ? 34 : 0
|
height: visible ? 34 : 0
|
||||||
|
|
||||||
width: {
|
width: {
|
||||||
if(parent==null)
|
if(parent==null)
|
||||||
return 200
|
return 200
|
||||||
@ -23,19 +34,7 @@ Rectangle{
|
|||||||
}
|
}
|
||||||
z: 65535
|
z: 65535
|
||||||
clip: true
|
clip: true
|
||||||
property string title: "标题"
|
|
||||||
property color textColor: FluTheme.isDark ? "#000000" : "#FFFFFF"
|
|
||||||
property bool showDark: false
|
|
||||||
property bool showFps: false
|
|
||||||
|
|
||||||
property var window: Window.window
|
|
||||||
|
|
||||||
property bool resizable: {
|
|
||||||
if(window == null){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return !(window.minimumHeight === window.maximumHeight && window.maximumWidth === window.minimumWidth)
|
|
||||||
}
|
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onTapped: if (tapCount === 2) toggleMaximized()
|
onTapped: if (tapCount === 2) toggleMaximized()
|
||||||
@ -48,14 +47,6 @@ Rectangle{
|
|||||||
onActiveChanged: if (active) { window.startSystemMove(); }
|
onActiveChanged: if (active) { window.startSystemMove(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMaximized() {
|
|
||||||
if (window.visibility === Window.Maximized) {
|
|
||||||
window.showNormal();
|
|
||||||
} else {
|
|
||||||
window.showMaximized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FluText {
|
FluText {
|
||||||
text: title
|
text: title
|
||||||
anchors{
|
anchors{
|
||||||
@ -93,15 +84,15 @@ Rectangle{
|
|||||||
fontStyle: FluText.Body
|
fontStyle: FluText.Body
|
||||||
}
|
}
|
||||||
FluToggleSwitch{
|
FluToggleSwitch{
|
||||||
checked: FluTheme.isDark
|
selected: FluTheme.isDark
|
||||||
onClickFunc:function(){
|
clickFunc:function(){
|
||||||
FluTheme.isDark = !FluTheme.isDark
|
FluTheme.isDark = !FluTheme.isDark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon : FluentIcons.ChromeMinimizeContrast
|
iconSource : FluentIcons.ChromeMinimizeContrast
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
text:"最小化"
|
text:"最小化"
|
||||||
@ -117,7 +108,7 @@ Rectangle{
|
|||||||
return false
|
return false
|
||||||
return Window.Maximized === window.visibility
|
return Window.Maximized === window.visibility
|
||||||
}
|
}
|
||||||
icon : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast
|
iconSource : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast
|
||||||
color:hovered ? "#20000000" : "#00000000"
|
color:hovered ? "#20000000" : "#00000000"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
visible: resizable
|
visible: resizable
|
||||||
@ -129,7 +120,7 @@ Rectangle{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon : FluentIcons.ChromeCloseContrast
|
iconSource : FluentIcons.ChromeCloseContrast
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
text:"关闭"
|
text:"关闭"
|
||||||
iconSize: 13
|
iconSize: 13
|
||||||
@ -147,4 +138,14 @@ Rectangle{
|
|||||||
anchors.bottom: parent.bottom;
|
anchors.bottom: parent.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleMaximized() {
|
||||||
|
if(!resizable)
|
||||||
|
return
|
||||||
|
if (window.visibility === Window.Maximized) {
|
||||||
|
window.showNormal();
|
||||||
|
} else {
|
||||||
|
window.showMaximized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
radius: 4
|
|
||||||
color: FluTheme.isDark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
|
|
||||||
border.color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
|
||||||
border.width: 1
|
|
||||||
implicitHeight: height
|
|
||||||
implicitWidth: width
|
|
||||||
|
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
property int paddings : 0
|
property int paddings : 0
|
||||||
@ -16,6 +10,13 @@ Rectangle {
|
|||||||
property int topPadding : 0
|
property int topPadding : 0
|
||||||
property int bottomPadding : 0
|
property int bottomPadding : 0
|
||||||
|
|
||||||
|
radius: 4
|
||||||
|
color: FluTheme.isDark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
|
||||||
|
border.color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
||||||
|
border.width: 1
|
||||||
|
implicitHeight: height
|
||||||
|
implicitWidth: width
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: container
|
id: container
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -7,12 +7,19 @@ TextField{
|
|||||||
property var values:[]
|
property var values:[]
|
||||||
property int fontStyle: FluText.Body
|
property int fontStyle: FluText.Body
|
||||||
property int pixelSize : FluTheme.textSize
|
property int pixelSize : FluTheme.textSize
|
||||||
property int icon: -1
|
property int iconSource: 0
|
||||||
|
property bool disabled: false
|
||||||
signal itemClicked(string data)
|
signal itemClicked(string data)
|
||||||
|
|
||||||
id:input
|
id:input
|
||||||
width: 300
|
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: {
|
selectionColor: {
|
||||||
if(FluTheme.isDark){
|
if(FluTheme.isDark){
|
||||||
return FluTheme.primaryColor.lighter
|
return FluTheme.primaryColor.lighter
|
||||||
@ -22,6 +29,9 @@ TextField{
|
|||||||
}
|
}
|
||||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||||
placeholderTextColor: {
|
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){
|
if(focus){
|
||||||
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
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
|
inputItem: input
|
||||||
|
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon:FluentIcons.ChromeClose
|
iconSource:FluentIcons.ChromeClose
|
||||||
iconSize: 10
|
iconSize: 10
|
||||||
width: 20
|
width: 20
|
||||||
height: 20
|
height: 20
|
||||||
@ -109,10 +119,10 @@ TextField{
|
|||||||
|
|
||||||
FluIcon{
|
FluIcon{
|
||||||
id:icon_right
|
id:icon_right
|
||||||
icon: input.icon
|
iconSource: input.iconSource
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
visible: input.icon != -1
|
visible: input.iconSource != 0
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
right: parent.right
|
right: parent.right
|
||||||
@ -152,6 +162,7 @@ TextField{
|
|||||||
boundsBehavior: ListView.StopAtBounds
|
boundsBehavior: ListView.StopAtBounds
|
||||||
clip: true
|
clip: true
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
header: Item{
|
header: Item{
|
||||||
width: input.width
|
width: input.width
|
||||||
height: visible ? 38 : 0
|
height: visible ? 38 : 0
|
||||||
@ -165,7 +176,6 @@ TextField{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScrollBar.vertical: ScrollBar { }
|
|
||||||
delegate:Control{
|
delegate:Control{
|
||||||
width: input.width
|
width: input.width
|
||||||
padding:10
|
padding:10
|
||||||
|
76
src/controls/FluBadge.qml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
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+"+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,39 +2,22 @@
|
|||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Control {
|
Button {
|
||||||
id: control
|
|
||||||
|
|
||||||
property string text: "Standard Button"
|
|
||||||
property bool disabled: false
|
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 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 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)
|
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
|
topPadding:5
|
||||||
bottomPadding:5
|
bottomPadding:5
|
||||||
leftPadding:15
|
leftPadding:15
|
||||||
rightPadding:15
|
rightPadding:15
|
||||||
|
enabled: !disabled
|
||||||
focusPolicy:Qt.TabFocus
|
focusPolicy:Qt.TabFocus
|
||||||
Keys.onEnterPressed:(visualFocus&&handleClick())
|
|
||||||
Keys.onReturnPressed:(visualFocus&&handleClick())
|
|
||||||
|
|
||||||
MouseArea {
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: handleClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClick(){
|
|
||||||
if(disabled){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
control.clicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
|
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
|
||||||
@ -51,10 +34,8 @@ Control {
|
|||||||
return hovered ? hoverColor :normalColor
|
return hovered ? hoverColor :normalColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: FluText {
|
contentItem: FluText {
|
||||||
text: control.text
|
text: control.text
|
||||||
anchors.centerIn: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: {
|
color: {
|
||||||
@ -71,5 +52,4 @@ Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import QtQuick 2.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
|
|
||||||
}
|
|
91
src/controls/FluCalendarPicker.qml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import QtQuick.Window 2.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
|
||||||
|
property color dividerColor: FluTheme.isDark ? Qt.rgba(77/255,77/255,77/255,1) : Qt.rgba(239/255,239/255,239/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 normalColor: FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||||
|
property var window : Window.window
|
||||||
|
|
||||||
|
id:root
|
||||||
|
color: {
|
||||||
|
if(mouse_area.containsMouse){
|
||||||
|
return hoverColor
|
||||||
|
}
|
||||||
|
return normalColor
|
||||||
|
}
|
||||||
|
height: 30
|
||||||
|
width: 120
|
||||||
|
radius: 4
|
||||||
|
border.width: 1
|
||||||
|
border.color: dividerColor
|
||||||
|
|
||||||
|
MouseArea{
|
||||||
|
id:mouse_area
|
||||||
|
hoverEnabled: true
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
popup.showPopup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
id:text_date
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: 30
|
||||||
|
top: parent.top
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text:"请选择日期"
|
||||||
|
}
|
||||||
|
|
||||||
|
FluIcon{
|
||||||
|
iconSource: FluentIcons.Calendar
|
||||||
|
iconSize: 14
|
||||||
|
color: text_date.color
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Popup{
|
||||||
|
id:popup
|
||||||
|
height: container.height
|
||||||
|
width: container.width
|
||||||
|
background: FluCalendarView{
|
||||||
|
id:container
|
||||||
|
onDateClicked:
|
||||||
|
(date)=>{
|
||||||
|
popup.close()
|
||||||
|
var year = date.getFullYear()
|
||||||
|
var month = date.getMonth()
|
||||||
|
var day = date.getDate()
|
||||||
|
text_date.text = year+"-"+(month+1)+"-"+day
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
function showPopup() {
|
||||||
|
var pos = root.mapToItem(null, 0, 0)
|
||||||
|
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.x = -(popup.width-root.width)/2
|
||||||
|
popup.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
473
src/controls/FluCalendarView.qml
Normal file
@ -0,0 +1,473 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
|
||||||
|
enum DisplayMode {
|
||||||
|
Month,
|
||||||
|
Year,
|
||||||
|
Decade
|
||||||
|
}
|
||||||
|
|
||||||
|
property int displayMode: FluCalendarView.Month
|
||||||
|
property var date: new Date()
|
||||||
|
property var currentDate : new Date()
|
||||||
|
property var toDay: new Date()
|
||||||
|
signal dateClicked(var date)
|
||||||
|
|
||||||
|
id:control
|
||||||
|
width: 280
|
||||||
|
height: 325
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
updateMouth(date)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_week
|
||||||
|
Item{
|
||||||
|
height: 40
|
||||||
|
width: 40
|
||||||
|
FluText{
|
||||||
|
text:name
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_year
|
||||||
|
Button{
|
||||||
|
id:item_control
|
||||||
|
property bool isYear: control.toDay.getFullYear() === date.getFullYear()
|
||||||
|
height: 70
|
||||||
|
width: 70
|
||||||
|
onClicked:{
|
||||||
|
control.date = date
|
||||||
|
displayMode = FluCalendarView.Year
|
||||||
|
updateYear(date)
|
||||||
|
}
|
||||||
|
background: Item{
|
||||||
|
Rectangle{
|
||||||
|
width: 60
|
||||||
|
height: 60
|
||||||
|
radius: 4
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color:{
|
||||||
|
if(FluTheme.isDark){
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(1,1,1,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}else{
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(0,0,0,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
id:backgound_selected
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 50
|
||||||
|
height: 50
|
||||||
|
radius: 25
|
||||||
|
visible: isYear
|
||||||
|
color: FluTheme.primaryColor.dark
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:date.getFullYear()
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: {
|
||||||
|
if(isYear){
|
||||||
|
return "#FFFFFF"
|
||||||
|
}
|
||||||
|
if(isDecade){
|
||||||
|
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||||
|
}
|
||||||
|
return Qt.rgba(150/255,150/255,150/255,1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_month
|
||||||
|
Button{
|
||||||
|
id:item_control
|
||||||
|
property bool isYear: control.date.getFullYear() === date.getFullYear()
|
||||||
|
property bool isMonth: control.toDay.getFullYear() === date.getFullYear() && control.toDay.getMonth() === date.getMonth()
|
||||||
|
height: 70
|
||||||
|
width: 70
|
||||||
|
onClicked:{
|
||||||
|
control.date = date
|
||||||
|
displayMode = FluCalendarView.Month
|
||||||
|
updateMouth(date)
|
||||||
|
}
|
||||||
|
background: Item{
|
||||||
|
Rectangle{
|
||||||
|
width: 60
|
||||||
|
height: 60
|
||||||
|
radius: 4
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color:{
|
||||||
|
if(FluTheme.isDark){
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(1,1,1,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}else{
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(0,0,0,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle{
|
||||||
|
id:backgound_selected
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 50
|
||||||
|
height: 50
|
||||||
|
radius: 25
|
||||||
|
visible: isMonth
|
||||||
|
color: FluTheme.primaryColor.dark
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:(date.getMonth()+1)+"月"
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: {
|
||||||
|
if(isMonth){
|
||||||
|
return "#FFFFFF"
|
||||||
|
}
|
||||||
|
if(isYear){
|
||||||
|
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||||
|
}
|
||||||
|
return Qt.rgba(150/255,150/255,150/255,1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_day
|
||||||
|
Button{
|
||||||
|
id:item_control
|
||||||
|
property bool isMonth: control.date.getMonth() === date.getMonth()
|
||||||
|
property bool isDay: control.currentDate.getFullYear() === date.getFullYear() && control.currentDate.getMonth() === date.getMonth() && control.currentDate.getDate() === date.getDate()
|
||||||
|
property bool isToDay: control.toDay.getFullYear() === date.getFullYear() && control.toDay.getMonth() === date.getMonth() && control.toDay.getDate() === date.getDate()
|
||||||
|
height: 40
|
||||||
|
width: 40
|
||||||
|
onClicked: {
|
||||||
|
currentDate = date
|
||||||
|
control.dateClicked(date)
|
||||||
|
}
|
||||||
|
background: Item{
|
||||||
|
Rectangle{
|
||||||
|
width: 36
|
||||||
|
height: 36
|
||||||
|
radius: 4
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color:{
|
||||||
|
if(FluTheme.isDark){
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(1,1,1,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}else{
|
||||||
|
if(item_control.hovered){
|
||||||
|
return Qt.rgba(0,0,0,0.05)
|
||||||
|
}
|
||||||
|
return Qt.rgba(0,0,0,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id:backgound_today
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 36
|
||||||
|
height: 36
|
||||||
|
radius: 18
|
||||||
|
color:"#00000000"
|
||||||
|
visible: isDay
|
||||||
|
border.color: FluTheme.primaryColor.dark
|
||||||
|
border.width: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id:backgound_selected
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
radius: 15
|
||||||
|
visible: isToDay
|
||||||
|
color: FluTheme.primaryColor.dark
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
text:date.getDate()
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: {
|
||||||
|
if(isToDay){
|
||||||
|
return "#FFFFFF"
|
||||||
|
}
|
||||||
|
if(isMonth){
|
||||||
|
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||||
|
}
|
||||||
|
return Qt.rgba(150/255,150/255,150/255,1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: 5
|
||||||
|
|
||||||
|
FluShadow{
|
||||||
|
radius: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id:layout_divider
|
||||||
|
height: 1
|
||||||
|
width: parent.width
|
||||||
|
color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
||||||
|
anchors{
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 44
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item{
|
||||||
|
id:layout_top
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: parent.top
|
||||||
|
bottom: layout_divider.top
|
||||||
|
}
|
||||||
|
|
||||||
|
FluTextButton{
|
||||||
|
id:title
|
||||||
|
leftPadding: 0
|
||||||
|
rightPadding: 0
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 14
|
||||||
|
}
|
||||||
|
disabled: displayMode === FluCalendarView.Decade
|
||||||
|
onClicked:{
|
||||||
|
if(displayMode === FluCalendarView.Month){
|
||||||
|
displayMode = FluCalendarView.Year
|
||||||
|
updateYear(date)
|
||||||
|
}else if(displayMode === FluCalendarView.Year){
|
||||||
|
displayMode = FluCalendarView.Decade
|
||||||
|
updateDecade(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluIconButton{
|
||||||
|
id:icon_up
|
||||||
|
iconSource: FluentIcons.CaretUpSolid8
|
||||||
|
iconSize: 10
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: icon_down.left
|
||||||
|
rightMargin: 14
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
var year = date.getFullYear()
|
||||||
|
var month = date.getMonth()
|
||||||
|
if(displayMode === FluCalendarView.Month){
|
||||||
|
var lastMonthYear = year;
|
||||||
|
var lastMonthMonth = month - 1
|
||||||
|
if (month === 0) {
|
||||||
|
lastMonthYear = year - 1
|
||||||
|
lastMonthMonth = 11
|
||||||
|
}
|
||||||
|
date = new Date(lastMonthYear,lastMonthMonth,1)
|
||||||
|
updateMouth(date)
|
||||||
|
}else if(displayMode === FluCalendarView.Year){
|
||||||
|
date = new Date(year-1,month,1)
|
||||||
|
updateYear(date)
|
||||||
|
}else if(displayMode === FluCalendarView.Decade){
|
||||||
|
date = new Date(Math.floor(year / 10) * 10-10,month,1)
|
||||||
|
updateDecade(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluIconButton{
|
||||||
|
id:icon_down
|
||||||
|
iconSource: FluentIcons.CaretDownSolid8
|
||||||
|
iconSize: 10
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
rightMargin: 8
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
var year = date.getFullYear()
|
||||||
|
var month = date.getMonth()
|
||||||
|
if(displayMode === FluCalendarView.Month){
|
||||||
|
var nextMonthYear = year
|
||||||
|
var nextMonth = month + 1
|
||||||
|
if (month === 11) {
|
||||||
|
nextMonthYear = year + 1
|
||||||
|
nextMonth = 0
|
||||||
|
}
|
||||||
|
date = new Date(nextMonthYear,nextMonth,1)
|
||||||
|
updateMouth(date)
|
||||||
|
}else if(displayMode === FluCalendarView.Year){
|
||||||
|
date = new Date(year+1,month,1)
|
||||||
|
updateYear(date)
|
||||||
|
}else if(displayMode === FluCalendarView.Decade){
|
||||||
|
date = new Date(Math.floor(year / 10) * 10+10,month,1)
|
||||||
|
updateDecade(date)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ListModel {
|
||||||
|
id:list_model
|
||||||
|
}
|
||||||
|
|
||||||
|
Item{
|
||||||
|
id:layout_bottom
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
top: layout_divider.bottom
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
|
||||||
|
GridView{
|
||||||
|
model: list_model
|
||||||
|
anchors.fill: parent
|
||||||
|
cellHeight: displayMode === FluCalendarView.Month ? 40 : 70
|
||||||
|
cellWidth: displayMode === FluCalendarView.Month ? 40 : 70
|
||||||
|
clip: true
|
||||||
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
|
delegate: Loader{
|
||||||
|
property var modelData : model
|
||||||
|
property var name : model.name
|
||||||
|
property var date : model.date
|
||||||
|
property var isDecade: {
|
||||||
|
return model.isDecade
|
||||||
|
}
|
||||||
|
sourceComponent: {
|
||||||
|
if(model.type === 0){
|
||||||
|
return com_week
|
||||||
|
}
|
||||||
|
if(model.type === 1){
|
||||||
|
return com_day
|
||||||
|
}
|
||||||
|
if(model.type === 2){
|
||||||
|
return com_month
|
||||||
|
}
|
||||||
|
if(model.type === 3){
|
||||||
|
return com_year
|
||||||
|
}
|
||||||
|
return com_day
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createItemWeek(name){
|
||||||
|
return {type:0,date:new Date(),name:name,isDecade:false}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createItemDay(date){
|
||||||
|
return {type:1,date:date,name:"",isDecade:false}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createItemMonth(date){
|
||||||
|
return {type:2,date:date,name:"",isDecade:false}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createItemYear(date,isDecade){
|
||||||
|
return {type:3,date:date,name:"",isDecade:isDecade}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateDecade(date){
|
||||||
|
list_model.clear()
|
||||||
|
var year = date.getFullYear()
|
||||||
|
const decadeStart = Math.floor(year / 10) * 10;
|
||||||
|
for(var i = decadeStart ; i< decadeStart+10 ; i++){
|
||||||
|
list_model.append(createItemYear(new Date(i,0,1),true));
|
||||||
|
}
|
||||||
|
for(var j = decadeStart+10 ; j< decadeStart+16 ; j++){
|
||||||
|
list_model.append(createItemYear(new Date(j,0,1),false));
|
||||||
|
}
|
||||||
|
title.text = decadeStart+"-"+(decadeStart+10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateYear(date){
|
||||||
|
list_model.clear()
|
||||||
|
var year = date.getFullYear()
|
||||||
|
for(var i = 0 ; i< 12 ; i++){
|
||||||
|
list_model.append(createItemMonth(new Date(year,i)));
|
||||||
|
}
|
||||||
|
for(var j = 0 ; j< 4 ; j++){
|
||||||
|
list_model.append(createItemMonth(new Date(year+1,j)));
|
||||||
|
}
|
||||||
|
title.text = year+"年"
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateMouth(date){
|
||||||
|
list_model.clear()
|
||||||
|
list_model.append([createItemWeek("一"),createItemWeek("二"),createItemWeek("三"),createItemWeek("四"),createItemWeek("五"),createItemWeek("六"),createItemWeek("日")])
|
||||||
|
var year = date.getFullYear()
|
||||||
|
var month = date.getMonth()
|
||||||
|
var day = date.getDate()
|
||||||
|
var firstDayOfMonth = new Date(year, month, 1)
|
||||||
|
var dayOfWeek = firstDayOfMonth.getDay()
|
||||||
|
var headerSize = (dayOfWeek===0?7:dayOfWeek)-1
|
||||||
|
if(headerSize!==0){
|
||||||
|
var lastMonthYear = year;
|
||||||
|
var lastMonthMonth = month - 1
|
||||||
|
if (month === 0) {
|
||||||
|
lastMonthYear = year - 1
|
||||||
|
lastMonthMonth = 11
|
||||||
|
}
|
||||||
|
var lastMonthDays = new Date(lastMonthYear, lastMonthMonth+1, 0).getDate()
|
||||||
|
for (var i = headerSize-1; i >= 0; i--) {
|
||||||
|
list_model.append(createItemDay(new Date(lastMonthYear, lastMonthMonth,lastMonthDays-i)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const lastDayOfMonth = new Date(year, month+1, 0).getDate()
|
||||||
|
for (let day = 1; day <= lastDayOfMonth; day++) {
|
||||||
|
list_model.append(createItemDay(new Date(year, month,day)))
|
||||||
|
}
|
||||||
|
var footerSize = 49-list_model.count
|
||||||
|
var nextMonthYear = year
|
||||||
|
var nextMonth = month + 1
|
||||||
|
if (month === 11) {
|
||||||
|
nextMonthYear = year + 1
|
||||||
|
nextMonth = 0
|
||||||
|
}
|
||||||
|
const nextDayOfMonth = new Date(nextMonthYear, nextMonth+1, 0).getDate()
|
||||||
|
for (let j = 1; j <= footerSize; j++) {
|
||||||
|
list_model.append(createItemDay(new Date(nextMonthYear, nextMonth,j)))
|
||||||
|
}
|
||||||
|
title.text = year+"年"+(month+1)+"月"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
import QtQuick 2.15
|
|
||||||
|
|
||||||
Item {
|
|
||||||
|
|
||||||
}
|
|
137
src/controls/FluCarousel.qml
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
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
|
||||||
|
asynchronous: true
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,55 +3,42 @@ import QtQuick.Controls 2.15
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Control {
|
Button {
|
||||||
|
|
||||||
id:control
|
|
||||||
property bool checked: false
|
|
||||||
property string text: "Check Box"
|
|
||||||
property var checkClicked
|
|
||||||
|
|
||||||
|
property bool selected: false
|
||||||
|
property var clickFunc
|
||||||
property bool disabled: false
|
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 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 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 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 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 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 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 checkedDisableColor: 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)
|
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
|
focusPolicy:Qt.TabFocus
|
||||||
Keys.onEnterPressed:(visualFocus&&handleClick())
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||||
Keys.onReturnPressed:(visualFocus&&handleClick())
|
padding:0
|
||||||
|
onClicked: {
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: handleClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClick(){
|
|
||||||
if(disabled){
|
if(disabled){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(checkClicked){
|
if(clickFunc){
|
||||||
checkClicked()
|
clickFunc()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checked = !checked
|
selected = !selected
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Item{
|
background: Item{
|
||||||
FluFocusRectangle{
|
FluFocusRectangle{
|
||||||
visible: control.visualFocus
|
visible: control.visualFocus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: RowLayout{
|
contentItem: RowLayout{
|
||||||
spacing: 4
|
spacing: 4
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -62,8 +49,8 @@ Control {
|
|||||||
if(disabled){
|
if(disabled){
|
||||||
return borderDisableColor
|
return borderDisableColor
|
||||||
}
|
}
|
||||||
if(checked){
|
if(selected){
|
||||||
return borderCheckedColor
|
return borderSelectedColor
|
||||||
}
|
}
|
||||||
if(hovered){
|
if(hovered){
|
||||||
return borderHoverColor
|
return borderHoverColor
|
||||||
@ -72,26 +59,25 @@ Control {
|
|||||||
}
|
}
|
||||||
border.width: 1
|
border.width: 1
|
||||||
color: {
|
color: {
|
||||||
if(checked){
|
if(selected){
|
||||||
if(disabled){
|
if(disabled){
|
||||||
return checkedDisableColor
|
return selectedDisableColor
|
||||||
}
|
}
|
||||||
if(hovered){
|
if(hovered){
|
||||||
return checkedHoverColor
|
return selectedHoverColor
|
||||||
}
|
}
|
||||||
return checkedColor
|
return selectedColor
|
||||||
}
|
}
|
||||||
if(hovered){
|
if(hovered){
|
||||||
return hoverColor
|
return hoverColor
|
||||||
}
|
}
|
||||||
return normalColor
|
return normalColor
|
||||||
}
|
}
|
||||||
|
|
||||||
FluIcon {
|
FluIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
icon: FluentIcons.AcceptMedium
|
iconSource: FluentIcons.AcceptMedium
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
visible: checked
|
visible: selected
|
||||||
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,5 +85,4 @@ Control {
|
|||||||
text:control.text
|
text:control.text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
52
src/controls/FluColorPicker.qml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import QtQuick.Window 2.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
|
||||||
|
Button{
|
||||||
|
id:control
|
||||||
|
width: 36
|
||||||
|
height: 36
|
||||||
|
implicitWidth: width
|
||||||
|
implicitHeight: height
|
||||||
|
background:
|
||||||
|
Rectangle{
|
||||||
|
id:layout_color
|
||||||
|
radius: 5
|
||||||
|
color: container.colorValue
|
||||||
|
border.color: {
|
||||||
|
if(hovered)
|
||||||
|
return FluTheme.primaryColor.light
|
||||||
|
return FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
||||||
|
}
|
||||||
|
border.width: 1
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
onClicked: {
|
||||||
|
popup.showPopup()
|
||||||
|
}
|
||||||
|
Popup{
|
||||||
|
id:popup
|
||||||
|
height: container.height
|
||||||
|
width: container.width
|
||||||
|
background: FluColorView{
|
||||||
|
id:container
|
||||||
|
}
|
||||||
|
contentItem: Item{}
|
||||||
|
function showPopup() {
|
||||||
|
var pos = control.mapToItem(null, 0, 0)
|
||||||
|
if(window.height>pos.y+control.height+popup.height){
|
||||||
|
popup.y = control.height
|
||||||
|
} else if(pos.y>popup.height){
|
||||||
|
popup.y = -popup.height
|
||||||
|
} else {
|
||||||
|
popup.y = window.height-(pos.y+popup.height)
|
||||||
|
}
|
||||||
|
popup.x = -(popup.width-control.width)/2
|
||||||
|
popup.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
src/controls/FluColorView.qml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import "../colorpicker"
|
||||||
|
|
||||||
|
Item {
|
||||||
|
|
||||||
|
property alias colorValue: color_picker.colorValue
|
||||||
|
|
||||||
|
width: color_picker.width+10
|
||||||
|
height: color_picker.height
|
||||||
|
|
||||||
|
FluArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: 5
|
||||||
|
|
||||||
|
FluShadow{
|
||||||
|
radius: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorPicker{
|
||||||
|
id:color_picker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setColor(color) {
|
||||||
|
color_picker.setColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,6 @@ Popup {
|
|||||||
property string positiveText: "Positive"
|
property string positiveText: "Positive"
|
||||||
signal negativeClicked
|
signal negativeClicked
|
||||||
signal positiveClicked
|
signal positiveClicked
|
||||||
|
|
||||||
property var minWidth: {
|
property var minWidth: {
|
||||||
if(Window.window==null)
|
if(Window.window==null)
|
||||||
return 400
|
return 400
|
||||||
@ -111,7 +110,6 @@ Popup {
|
|||||||
positiveClicked()
|
positiveClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ import FluentUI 1.0
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
id:root
|
|
||||||
|
|
||||||
property alias title: text_title.text
|
property alias title: text_title.text
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
|
|
||||||
|
id:root
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
id:text_title
|
id:text_title
|
||||||
fontStyle: FluText.TitleLarge
|
fontStyle: FluText.TitleLarge
|
||||||
|
@ -6,15 +6,16 @@ import FluentUI 1.0
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
||||||
id:root
|
|
||||||
|
|
||||||
property color dividerColor: FluTheme.isDark ? Qt.rgba(77/255,77/255,77/255,1) : Qt.rgba(239/255,239/255,239/255,1)
|
property color dividerColor: FluTheme.isDark ? Qt.rgba(77/255,77/255,77/255,1) : Qt.rgba(239/255,239/255,239/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 hoverColor: FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
||||||
property color normalColor: FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
property color normalColor: FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||||
property var window : Window.window
|
property var window : Window.window
|
||||||
|
|
||||||
property bool showYear: true
|
property bool showYear: true
|
||||||
|
property bool changeFlag: true
|
||||||
|
readonly property var rowData: ["","",""]
|
||||||
|
|
||||||
|
|
||||||
|
id:root
|
||||||
color: {
|
color: {
|
||||||
if(mouse_area.containsMouse){
|
if(mouse_area.containsMouse){
|
||||||
return hoverColor
|
return hoverColor
|
||||||
@ -98,7 +99,11 @@ Rectangle {
|
|||||||
|
|
||||||
Popup{
|
Popup{
|
||||||
id:popup
|
id:popup
|
||||||
|
width: container.width
|
||||||
|
height: container.height
|
||||||
|
contentItem: Item{}
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
|
id:container
|
||||||
width: 300
|
width: 300
|
||||||
radius: 4
|
radius: 4
|
||||||
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
||||||
@ -202,9 +207,12 @@ Rectangle {
|
|||||||
width: 100
|
width: 100
|
||||||
height: parent.height
|
height: parent.height
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
ScrollBar.vertical: ScrollBar { }
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
model: generateYearArray(1924,2048)
|
model: generateYearArray(1924,2048)
|
||||||
clip: true
|
clip: true
|
||||||
|
preferredHighlightBegin: 0
|
||||||
|
preferredHighlightEnd: 0
|
||||||
|
highlightMoveDuration: 0
|
||||||
visible: showYear
|
visible: showYear
|
||||||
delegate: Loader{
|
delegate: Loader{
|
||||||
property var model: modelData
|
property var model: modelData
|
||||||
@ -212,11 +220,6 @@ Rectangle {
|
|||||||
property int position:index
|
property int position:index
|
||||||
sourceComponent: list_delegate
|
sourceComponent: list_delegate
|
||||||
}
|
}
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if(currentIndex!==-1){
|
|
||||||
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: 1
|
width: 1
|
||||||
@ -228,7 +231,10 @@ Rectangle {
|
|||||||
width: showYear ? 100 : 150
|
width: showYear ? 100 : 150
|
||||||
height: parent.height
|
height: parent.height
|
||||||
clip: true
|
clip: true
|
||||||
ScrollBar.vertical: ScrollBar { }
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
|
preferredHighlightBegin: 0
|
||||||
|
preferredHighlightEnd: 0
|
||||||
|
highlightMoveDuration: 0
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
delegate: Loader{
|
delegate: Loader{
|
||||||
property var model: modelData
|
property var model: modelData
|
||||||
@ -236,11 +242,6 @@ Rectangle {
|
|||||||
property int position:index
|
property int position:index
|
||||||
sourceComponent: list_delegate
|
sourceComponent: list_delegate
|
||||||
}
|
}
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if(currentIndex!==-1){
|
|
||||||
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: 1
|
width: 1
|
||||||
@ -252,7 +253,10 @@ Rectangle {
|
|||||||
width: showYear ? 100 : 150
|
width: showYear ? 100 : 150
|
||||||
height: parent.height
|
height: parent.height
|
||||||
clip: true
|
clip: true
|
||||||
ScrollBar.vertical: ScrollBar { }
|
preferredHighlightBegin: 0
|
||||||
|
preferredHighlightEnd: 0
|
||||||
|
highlightMoveDuration: 0
|
||||||
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
boundsBehavior:Flickable.StopAtBounds
|
boundsBehavior:Flickable.StopAtBounds
|
||||||
delegate: Loader{
|
delegate: Loader{
|
||||||
@ -261,9 +265,6 @@ Rectangle {
|
|||||||
property int position:index
|
property int position:index
|
||||||
sourceComponent: list_delegate
|
sourceComponent: list_delegate
|
||||||
}
|
}
|
||||||
onCurrentIndexChanged: {
|
|
||||||
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,10 +349,12 @@ Rectangle {
|
|||||||
text_day.text = day
|
text_day.text = day
|
||||||
|
|
||||||
var pos = root.mapToItem(null, 0, 0)
|
var pos = root.mapToItem(null, 0, 0)
|
||||||
if(window.height>pos.y+35+340){
|
if(window.height>pos.y+root.height+popup.height){
|
||||||
popup.y = 35
|
popup.y = root.height
|
||||||
}else{
|
} else if(pos.y>popup.height){
|
||||||
popup.y = window.height-(pos.y+340)
|
popup.y = -popup.height
|
||||||
|
} else {
|
||||||
|
popup.y = window.height-(pos.y+popup.height)
|
||||||
}
|
}
|
||||||
popup.open()
|
popup.open()
|
||||||
}
|
}
|
||||||
@ -365,9 +368,6 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool changeFlag: true
|
|
||||||
readonly property var rowData: ["","",""]
|
|
||||||
|
|
||||||
function generateYearArray(startYear, endYear) {
|
function generateYearArray(startYear, endYear) {
|
||||||
const yearArray = [];
|
const yearArray = [];
|
||||||
for (let year = startYear; year <= endYear; year++) {
|
for (let year = startYear; year <= endYear; year++) {
|
||||||
|
@ -1,6 +1,88 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Window 2.15
|
||||||
import FluentUI 1.0
|
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)
|
||||||
|
property var window : Window.window
|
||||||
|
property alias items: menu.content
|
||||||
|
|
||||||
|
id: control
|
||||||
|
topPadding:5
|
||||||
|
bottomPadding:5
|
||||||
|
leftPadding:15
|
||||||
|
rightPadding:35
|
||||||
|
enabled: !disabled
|
||||||
|
focusPolicy:Qt.TabFocus
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
|
|
||||||
property string headerText: "Titlte"
|
property string headerText: "Titlte"
|
||||||
property bool expand: false
|
property bool expand: false
|
||||||
|
property int contentHeight : 300
|
||||||
|
default property alias content: container.data
|
||||||
|
|
||||||
id:root
|
id:root
|
||||||
height: layout_header.height + container.height
|
height: layout_header.height + container.height
|
||||||
@ -13,10 +15,6 @@ Item {
|
|||||||
implicitWidth: width
|
implicitWidth: width
|
||||||
implicitHeight: height
|
implicitHeight: height
|
||||||
|
|
||||||
property int contentHeight : 300
|
|
||||||
|
|
||||||
default property alias content: container.data
|
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:layout_header
|
id:layout_header
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -56,7 +54,7 @@ Item {
|
|||||||
return FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
return FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||||
}
|
}
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
icon: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown
|
iconSource: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown
|
||||||
onClicked: {
|
onClicked: {
|
||||||
expand = !expand
|
expand = !expand
|
||||||
}
|
}
|
||||||
|
@ -2,35 +2,21 @@
|
|||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Control {
|
Button {
|
||||||
id: control
|
|
||||||
|
|
||||||
property string text: "Filled Button"
|
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property color normalColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
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 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)
|
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
|
|
||||||
|
|
||||||
|
id: control
|
||||||
|
enabled: !disabled
|
||||||
topPadding:5
|
topPadding:5
|
||||||
bottomPadding:5
|
bottomPadding:5
|
||||||
leftPadding:15
|
leftPadding:15
|
||||||
rightPadding:15
|
rightPadding:15
|
||||||
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||||
focusPolicy:Qt.TabFocus
|
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{
|
background: Rectangle{
|
||||||
radius: 4
|
radius: 4
|
||||||
FluFocusRectangle{
|
FluFocusRectangle{
|
||||||
@ -44,7 +30,6 @@ Control {
|
|||||||
return hovered ? hoverColor :normalColor
|
return hovered ? hoverColor :normalColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: FluText {
|
contentItem: FluText {
|
||||||
text: control.text
|
text: control.text
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
@ -61,6 +46,4 @@ Control {
|
|||||||
}
|
}
|
||||||
font.pixelSize: 14
|
font.pixelSize: 14
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
|
property int radius: 4
|
||||||
|
|
||||||
id:root
|
id:root
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: -3
|
anchors.margins: -3
|
||||||
|
|
||||||
property var radius: 4
|
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: root.width
|
width: root.width
|
||||||
height: root.height
|
height: root.height
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|
||||||
property int icon
|
property int iconSource
|
||||||
property int iconSize: 20
|
property int iconSize: 20
|
||||||
property color iconColor: FluTheme.isDark ? "#FFFFFF" : "#000000"
|
property color iconColor: FluTheme.isDark ? "#FFFFFF" : "#000000"
|
||||||
|
|
||||||
@ -12,5 +12,5 @@ Text {
|
|||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: iconColor
|
color: iconColor
|
||||||
text: (String.fromCharCode(icon).toString(16));
|
text: (String.fromCharCode(iconSource).toString(16));
|
||||||
}
|
}
|
||||||
|
@ -2,29 +2,20 @@
|
|||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
Control {
|
Button {
|
||||||
|
|
||||||
id:control
|
|
||||||
width: 30
|
|
||||||
height: 30
|
|
||||||
|
|
||||||
property int iconSize: 20
|
property int iconSize: 20
|
||||||
property int icon
|
property int iconSource
|
||||||
property alias text: tool_tip.text
|
|
||||||
signal clicked
|
|
||||||
property bool disabled: false
|
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 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 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 disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(0,0,0,0)
|
||||||
|
|
||||||
property color color: {
|
property color color: {
|
||||||
if(disabled){
|
if(disabled){
|
||||||
return disableColor
|
return disableColor
|
||||||
}
|
}
|
||||||
return hovered ? hoverColor : normalColor
|
return hovered ? hoverColor : normalColor
|
||||||
}
|
}
|
||||||
|
|
||||||
property color textColor: {
|
property color textColor: {
|
||||||
if(FluTheme.isDark){
|
if(FluTheme.isDark){
|
||||||
if(disabled){
|
if(disabled){
|
||||||
@ -39,22 +30,15 @@ Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id:control
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
implicitWidth: width
|
||||||
|
implicitHeight: height
|
||||||
|
padding: 0
|
||||||
|
enabled: !disabled
|
||||||
focusPolicy:Qt.TabFocus
|
focusPolicy:Qt.TabFocus
|
||||||
Keys.onEnterPressed:(visualFocus&&handleClick())
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||||
Keys.onReturnPressed:(visualFocus&&handleClick())
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: handleClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClick(){
|
|
||||||
if(disabled){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
control.clicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
radius: 4
|
radius: 4
|
||||||
color:control.color
|
color:control.color
|
||||||
@ -62,19 +46,19 @@ Control {
|
|||||||
visible: control.visualFocus
|
visible: control.visualFocus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: Item{
|
contentItem: Item{
|
||||||
Text {
|
Text {
|
||||||
id:text_icon
|
id:text_icon
|
||||||
font.family: "Segoe Fluent Icons"
|
font.family: "Segoe Fluent Icons"
|
||||||
font.pixelSize: iconSize
|
font.pixelSize: iconSize
|
||||||
|
width: iconSize
|
||||||
|
height: iconSize
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color:control.textColor
|
color:control.textColor
|
||||||
text: (String.fromCharCode(icon).toString(16));
|
text: (String.fromCharCode(iconSource).toString(16));
|
||||||
}
|
}
|
||||||
|
|
||||||
FluTooltip{
|
FluTooltip{
|
||||||
id:tool_tip
|
id:tool_tip
|
||||||
visible: {
|
visible: {
|
||||||
@ -83,11 +67,8 @@ Control {
|
|||||||
}
|
}
|
||||||
return hovered
|
return hovered
|
||||||
}
|
}
|
||||||
|
text:control.text
|
||||||
delay: 1000
|
delay: 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,26 +7,6 @@ FluObject {
|
|||||||
property var root;
|
property var root;
|
||||||
property int layoutY: 75;
|
property int layoutY: 75;
|
||||||
|
|
||||||
function showSuccess(text,duration,moremsg){
|
|
||||||
mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function showInfo(text,duration,moremsg){
|
|
||||||
mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function showWarning(text,duration,moremsg){
|
|
||||||
mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function showError(text,duration,moremsg){
|
|
||||||
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function showCustom(itemcomponent,duration){
|
|
||||||
mcontrol.createCustom(itemcomponent,duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
FluObject{
|
FluObject{
|
||||||
id:mcontrol
|
id:mcontrol
|
||||||
|
|
||||||
@ -34,9 +14,7 @@ FluObject {
|
|||||||
property string const_info: "info";
|
property string const_info: "info";
|
||||||
property string const_warning: "warning";
|
property string const_warning: "warning";
|
||||||
property string const_error: "error";
|
property string const_error: "error";
|
||||||
|
|
||||||
property int maxWidth: 300;
|
property int maxWidth: 300;
|
||||||
|
|
||||||
property var screenLayout: null;
|
property var screenLayout: null;
|
||||||
|
|
||||||
function create(type,text,duration,moremsg){
|
function create(type,text,duration,moremsg){
|
||||||
@ -190,7 +168,7 @@ FluObject {
|
|||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
FluIcon{
|
FluIcon{
|
||||||
icon:{
|
iconSource:{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return FluentIcons.CompletedSolid;
|
case mcontrol.const_success: return FluentIcons.CompletedSolid;
|
||||||
case mcontrol.const_warning: return FluentIcons.InfoSolid;
|
case mcontrol.const_warning: return FluentIcons.InfoSolid;
|
||||||
@ -230,4 +208,25 @@ FluObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showSuccess(text,duration,moremsg){
|
||||||
|
mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showInfo(text,duration,moremsg){
|
||||||
|
mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showWarning(text,duration,moremsg){
|
||||||
|
mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError(text,duration,moremsg){
|
||||||
|
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCustom(itemcomponent,duration){
|
||||||
|
mcontrol.createCustom(itemcomponent,duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
53
src/controls/FluItem.qml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtGraphicalEffects 1.15
|
||||||
|
|
||||||
|
Item{
|
||||||
|
id:control
|
||||||
|
property var radius:[0,0,0,0]
|
||||||
|
default property alias contentItem: container.data
|
||||||
|
|
||||||
|
Item{
|
||||||
|
id:container
|
||||||
|
width: control.width
|
||||||
|
height: control.height
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Canvas {
|
||||||
|
id: canvas
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: false
|
||||||
|
onPaint: {
|
||||||
|
var ctx = getContext("2d");
|
||||||
|
var x = 0;
|
||||||
|
var y = 0;
|
||||||
|
var w = control.width;
|
||||||
|
var h = control.height;
|
||||||
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x + radius[0], y);
|
||||||
|
ctx.lineTo(x + w - radius[1], y);
|
||||||
|
ctx.arcTo(x + w, y, x + w, y + radius[1], radius[1]);
|
||||||
|
ctx.lineTo(x + w, y + h - radius[2]);
|
||||||
|
ctx.arcTo(x + w, y + h, x + w - radius[2], y + h, radius[2]);
|
||||||
|
ctx.lineTo(x + radius[3], y + h);
|
||||||
|
ctx.arcTo(x, y + h, x, y + h - radius[3], radius[3]);
|
||||||
|
ctx.lineTo(x, y + radius[0]);
|
||||||
|
ctx.arcTo(x, y, x + radius[0], y, radius[0]);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fillStyle = control.color;
|
||||||
|
ctx.fill();
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpacityMask {
|
||||||
|
anchors.fill: container
|
||||||
|
source: container
|
||||||
|
maskSource: canvas
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
217
src/controls/FluMediaPlayer.qml
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtMultimedia 5.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
|
||||||
|
property url source
|
||||||
|
property bool showControl: false
|
||||||
|
property real volume: 30
|
||||||
|
|
||||||
|
id:control
|
||||||
|
width: 480
|
||||||
|
height: 270
|
||||||
|
color: FluColors.Black
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
showControl = !showControl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaPlayer {
|
||||||
|
id: mediaplayer
|
||||||
|
property bool autoSeek:true
|
||||||
|
autoPlay: true
|
||||||
|
source: control.source
|
||||||
|
onError: {
|
||||||
|
console.debug(error)
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
if(autoSeek){
|
||||||
|
slider.seek(mediaplayer.position*slider.maxValue/mediaplayer.duration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onStatusChanged: {
|
||||||
|
if(status===6){
|
||||||
|
slider.maxValue = mediaplayer.duration
|
||||||
|
showControl = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onSourceChanged: {
|
||||||
|
slider.seek(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoOutput {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: mediaplayer
|
||||||
|
}
|
||||||
|
|
||||||
|
Item{
|
||||||
|
height: 100
|
||||||
|
y:showControl ? control.height - 110 : control.height
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
leftMargin: 10
|
||||||
|
rightMargin: 10
|
||||||
|
}
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on y{
|
||||||
|
NumberAnimation{
|
||||||
|
duration: 150
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
FluSlider{
|
||||||
|
id:slider
|
||||||
|
size:parent.width-20
|
||||||
|
y:20
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
enableTip:false
|
||||||
|
onPressed: {
|
||||||
|
mediaplayer.autoSeek = false
|
||||||
|
mediaplayer.pause()
|
||||||
|
}
|
||||||
|
value:0
|
||||||
|
onReleased: {
|
||||||
|
mediaplayer.autoSeek = true
|
||||||
|
mediaplayer.play()
|
||||||
|
}
|
||||||
|
|
||||||
|
onValueChanged: {
|
||||||
|
if(mediaplayer.autoSeek == false){
|
||||||
|
mediaplayer.seek(value*mediaplayer.duration/slider.maxValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLineClickFunc:function(val){
|
||||||
|
mediaplayer.seek(val*mediaplayer.duration/slider.maxValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
id:start_time
|
||||||
|
anchors{
|
||||||
|
top: slider.bottom
|
||||||
|
topMargin: 10
|
||||||
|
left: slider.left
|
||||||
|
}
|
||||||
|
text: formatDuration(slider.value*mediaplayer.duration/slider.maxValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
id:end_time
|
||||||
|
anchors{
|
||||||
|
top: slider.bottom
|
||||||
|
right: slider.right
|
||||||
|
topMargin: 10
|
||||||
|
}
|
||||||
|
text: formatDuration(mediaplayer.duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Row{
|
||||||
|
spacing: 10
|
||||||
|
anchors{
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: 10
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSize: 17
|
||||||
|
iconSource: FluentIcons.SkipBack10
|
||||||
|
onClicked: {
|
||||||
|
mediaplayer.seek(Math.max(mediaplayer.position-10*1000,0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSize: 15
|
||||||
|
iconSource: mediaplayer.playbackState === Audio.PlayingState ? FluentIcons.Pause : FluentIcons.Play
|
||||||
|
onClicked: {
|
||||||
|
if(mediaplayer.playbackState === Audio.PlayingState){
|
||||||
|
mediaplayer.pause()
|
||||||
|
}else{
|
||||||
|
mediaplayer.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSize: 17
|
||||||
|
iconSource: FluentIcons.SkipForward30
|
||||||
|
onClicked: {
|
||||||
|
mediaplayer.seek(Math.min(mediaplayer.position+30*1000,mediaplayer.duration))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FluIconButton{
|
||||||
|
id:btn_volume
|
||||||
|
iconSize: 17
|
||||||
|
iconSource: mediaplayer.volume ? FluentIcons.Volume : FluentIcons.Mute
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 5
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: 10
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
mediaplayer.volume = !mediaplayer.volume
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FluSlider{
|
||||||
|
id:slider_volume
|
||||||
|
size: 80
|
||||||
|
dotSize: 20
|
||||||
|
value:30
|
||||||
|
anchors{
|
||||||
|
left:btn_volume.right
|
||||||
|
verticalCenter: btn_volume.verticalCenter
|
||||||
|
leftMargin: 10
|
||||||
|
}
|
||||||
|
onValueChanged:{
|
||||||
|
mediaplayer.volume = value/100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDuration(duration) {
|
||||||
|
const seconds = Math.floor(duration / 1000);
|
||||||
|
const hours = Math.floor(seconds / 3600);
|
||||||
|
const minutes = Math.floor((seconds % 3600) / 60);
|
||||||
|
const remainingSeconds = seconds % 60;
|
||||||
|
return `${pad(hours)}:${pad(minutes)}:${pad(remainingSeconds)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pad(value) {
|
||||||
|
return value.toString().padStart(2, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause(){
|
||||||
|
mediaplayer.pause()
|
||||||
|
}
|
||||||
|
|
||||||
|
function play(){
|
||||||
|
mediaplayer.play()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,16 +2,20 @@
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
|
||||||
Popup {
|
Menu {
|
||||||
|
|
||||||
|
default property alias content: container.data
|
||||||
|
|
||||||
id: popup
|
id: popup
|
||||||
default property alias content: container.children
|
width: 140
|
||||||
|
height: container.height
|
||||||
|
|
||||||
background: Rectangle {
|
background: Item {
|
||||||
implicitWidth: 140
|
Rectangle{
|
||||||
implicitHeight: container.height
|
anchors.fill: parent
|
||||||
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(237/255,237/255,237/255,1)
|
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
|
radius: 5
|
||||||
|
}
|
||||||
FluShadow{
|
FluShadow{
|
||||||
radius: 5
|
radius: 5
|
||||||
}
|
}
|
||||||
@ -19,6 +23,7 @@ Popup {
|
|||||||
spacing: 5
|
spacing: 5
|
||||||
topPadding: 5
|
topPadding: 5
|
||||||
bottomPadding: 5
|
bottomPadding: 5
|
||||||
|
width: popup.width
|
||||||
id:container
|
id:container
|
||||||
function closePopup(){
|
function closePopup(){
|
||||||
popup.close()
|
popup.close()
|
||||||
|
@ -3,23 +3,36 @@ import QtQuick.Controls 2.15
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
id:root
|
|
||||||
width: 140
|
|
||||||
height: 32
|
|
||||||
|
|
||||||
property string text: "MenuItem"
|
property string text: "MenuItem"
|
||||||
signal clicked
|
signal clicked
|
||||||
|
|
||||||
|
id:root
|
||||||
|
width: {
|
||||||
|
if(root.parent){
|
||||||
|
return root.parent.width
|
||||||
|
}
|
||||||
|
return 140
|
||||||
|
}
|
||||||
|
height: 32
|
||||||
|
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: 100
|
width: root.width-40
|
||||||
height: 32
|
height: 32
|
||||||
radius: 4
|
radius: 4
|
||||||
color:{
|
color:{
|
||||||
|
if(FluTheme.isDark){
|
||||||
if(mouse_area.containsMouse){
|
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)
|
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{
|
FluText{
|
||||||
|
@ -6,10 +6,17 @@ TextArea{
|
|||||||
|
|
||||||
property int fontStyle: FluText.Body
|
property int fontStyle: FluText.Body
|
||||||
property int pixelSize : FluTheme.textSize
|
property int pixelSize : FluTheme.textSize
|
||||||
|
property bool disabled: false
|
||||||
|
|
||||||
id:input
|
id:input
|
||||||
width: 300
|
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
|
wrapMode: Text.WrapAnywhere
|
||||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
@ -24,6 +31,9 @@ TextArea{
|
|||||||
inputItem: input
|
inputItem: input
|
||||||
}
|
}
|
||||||
placeholderTextColor: {
|
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){
|
if(focus){
|
||||||
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,13 @@ import FluentUI 1.0
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
id:root
|
|
||||||
|
|
||||||
property FluObject items
|
property FluObject items
|
||||||
property FluObject footerItems
|
property FluObject footerItems
|
||||||
|
|
||||||
property int displayMode: width<=700 ? FluNavigationView.Minimal : FluNavigationView.Open
|
property int displayMode: width<=700 ? FluNavigationView.Minimal : FluNavigationView.Open
|
||||||
|
|
||||||
property bool displaMinimalNav : false
|
property bool displaMinimalNav : false
|
||||||
|
property alias actions: layout_actions.data
|
||||||
|
|
||||||
|
id:root
|
||||||
|
|
||||||
onDisplayModeChanged: {
|
onDisplayModeChanged: {
|
||||||
if(displayMode === FluNavigationView.Minimal){
|
if(displayMode === FluNavigationView.Minimal){
|
||||||
@ -135,17 +134,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id:nav_app_bar
|
id:nav_app_bar
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 38
|
height: 38
|
||||||
|
z:999
|
||||||
RowLayout{
|
RowLayout{
|
||||||
height:parent.height
|
height:parent.height
|
||||||
spacing: 0
|
spacing: 0
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon: FluentIcons.ChromeBack
|
iconSource: FluentIcons.ChromeBack
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 5
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
disabled: nav_swipe.depth === 1
|
disabled: nav_swipe.depth === 1
|
||||||
@ -160,7 +158,7 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
icon: FluentIcons.GlobalNavButton
|
iconSource: FluentIcons.GlobalNavButton
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 5
|
||||||
iconSize: 15
|
iconSize: 15
|
||||||
visible: displayMode === FluNavigationView.Minimal
|
visible: displayMode === FluNavigationView.Minimal
|
||||||
@ -173,22 +171,13 @@ Item {
|
|||||||
|
|
||||||
|
|
||||||
RowLayout{
|
RowLayout{
|
||||||
|
id:layout_actions
|
||||||
anchors{
|
anchors{
|
||||||
right: parent.right
|
right: parent.right
|
||||||
rightMargin: 14
|
rightMargin: 14
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
spacing: 5
|
spacing: 5
|
||||||
FluText{
|
|
||||||
text:"夜间模式"
|
|
||||||
fontStyle: FluText.Body
|
|
||||||
}
|
|
||||||
FluToggleSwitch{
|
|
||||||
checked: FluTheme.isDark
|
|
||||||
onClickFunc:function(){
|
|
||||||
FluTheme.isDark = !FluTheme.isDark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +221,7 @@ Item {
|
|||||||
id:layout_list
|
id:layout_list
|
||||||
width: 300
|
width: 300
|
||||||
anchors{
|
anchors{
|
||||||
top: nav_app_bar.bottom
|
top: parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
x: {
|
x: {
|
||||||
@ -264,12 +253,13 @@ Item {
|
|||||||
Item{
|
Item{
|
||||||
id:layout_header
|
id:layout_header
|
||||||
width: layout_list.width
|
width: layout_list.width
|
||||||
|
y:nav_app_bar.height
|
||||||
height: 50
|
height: 50
|
||||||
|
|
||||||
FluAutoSuggestBox{
|
FluAutoSuggestBox{
|
||||||
width: 280
|
width: 280
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
icon: FluentIcons.Zoom
|
iconSource: FluentIcons.Zoom
|
||||||
values: {
|
values: {
|
||||||
var arr = []
|
var arr = []
|
||||||
if(items==null)
|
if(items==null)
|
||||||
@ -322,6 +312,8 @@ Item {
|
|||||||
stackIndex.push(currentIndex)
|
stackIndex.push(currentIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ScrollBar.vertical: FluScrollBar {}
|
||||||
|
|
||||||
model:{
|
model:{
|
||||||
if(items){
|
if(items){
|
||||||
return items.children
|
return items.children
|
||||||
@ -375,11 +367,8 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function push(url){
|
function push(url){
|
||||||
nav_swipe.push(url)
|
nav_swipe.push(url)
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
FluRectangle {
|
FluRectangle {
|
||||||
id: control
|
|
||||||
|
|
||||||
|
property real progress: 0.5
|
||||||
|
property bool indeterminate: true
|
||||||
|
|
||||||
|
id: control
|
||||||
width: 150
|
width: 150
|
||||||
height: 5
|
height: 5
|
||||||
radius: [3,3,3,3]
|
radius: [3,3,3,3]
|
||||||
clip: true
|
clip: true
|
||||||
color: FluTheme.isDark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
|
color: FluTheme.isDark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
|
||||||
property real progress: 0.5
|
|
||||||
property bool indeterminate: true
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if(indeterminate){
|
if(indeterminate){
|
||||||
|
@ -2,19 +2,20 @@
|
|||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: control
|
|
||||||
|
|
||||||
|
property real linWidth : 5
|
||||||
|
property real progress: 0.25
|
||||||
|
property bool indeterminate: true
|
||||||
|
readonly property real radius2 : radius - linWidth/2
|
||||||
|
property color primaryColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||||
|
|
||||||
|
id: control
|
||||||
width: 44
|
width: 44
|
||||||
height: 44
|
height: 44
|
||||||
radius: 22
|
radius: 22
|
||||||
border.width: linWidth
|
border.width: linWidth
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
border.color: FluTheme.isDark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
|
border.color: FluTheme.isDark ? Qt.rgba(41/255,41/255,41/255,1) : Qt.rgba(214/255,214/255,214/255,1)
|
||||||
property real linWidth : 5
|
|
||||||
property real progress: 0.25
|
|
||||||
property bool indeterminate: true
|
|
||||||
readonly property real radius2 : radius - linWidth/2
|
|
||||||
property color primaryColor : FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
|
||||||
|
|
||||||
onProgressChanged: {
|
onProgressChanged: {
|
||||||
canvas.requestPaint()
|
canvas.requestPaint()
|
||||||
|
@ -4,38 +4,21 @@ import QtQuick.Layouts 1.15
|
|||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
|
|
||||||
Control {
|
Button {
|
||||||
|
|
||||||
id:control
|
property bool selected: false
|
||||||
property bool checked: false
|
|
||||||
property string text: "RodioButton"
|
|
||||||
signal clicked
|
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
|
|
||||||
|
id:control
|
||||||
|
enabled: !disabled
|
||||||
focusPolicy:Qt.TabFocus
|
focusPolicy:Qt.TabFocus
|
||||||
Keys.onEnterPressed:(visualFocus&&handleClick())
|
padding:0
|
||||||
Keys.onReturnPressed:(visualFocus&&handleClick())
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: handleClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClick(){
|
|
||||||
if(disabled){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
control.clicked()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
background: Item{
|
background: Item{
|
||||||
FluFocusRectangle{
|
FluFocusRectangle{
|
||||||
visible: control.visualFocus
|
visible: control.visualFocus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||||
contentItem: RowLayout{
|
contentItem: RowLayout{
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:rect_check
|
id:rect_check
|
||||||
@ -46,26 +29,26 @@ Control {
|
|||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.smooth: true
|
layer.smooth: true
|
||||||
border.width: {
|
border.width: {
|
||||||
if(checked&&disabled){
|
if(selected&&disabled){
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
if(hovered){
|
if(pressed){
|
||||||
if(checked){
|
if(selected){
|
||||||
return 5
|
return 5
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if(hovered){
|
if(hovered){
|
||||||
if(checked){
|
if(selected){
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
return checked ? 5 : 1
|
return selected ? 5 : 1
|
||||||
}
|
}
|
||||||
Behavior on border.width {
|
Behavior on border.width {
|
||||||
NumberAnimation{
|
NumberAnimation{
|
||||||
duration: 100
|
duration: 150
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border.color: {
|
border.color: {
|
||||||
@ -76,7 +59,7 @@ Control {
|
|||||||
return Qt.rgba(198/255,198/255,198/255,1)
|
return Qt.rgba(198/255,198/255,198/255,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checked){
|
if(selected){
|
||||||
if(FluTheme.isDark){
|
if(FluTheme.isDark){
|
||||||
return FluTheme.primaryColor.lighter
|
return FluTheme.primaryColor.lighter
|
||||||
}else{
|
}else{
|
||||||
@ -93,7 +76,7 @@ Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
color:{
|
color:{
|
||||||
if(disabled&&checked){
|
if(disabled&&selected){
|
||||||
return Qt.rgba(159/255,159/255,159/255,1)
|
return Qt.rgba(159/255,159/255,159/255,1)
|
||||||
}
|
}
|
||||||
if(FluTheme.isDark){
|
if(FluTheme.isDark){
|
||||||
@ -103,7 +86,7 @@ Control {
|
|||||||
return Qt.rgba(50/255,50/255,50/255,1)
|
return Qt.rgba(50/255,50/255,50/255,1)
|
||||||
}else{
|
}else{
|
||||||
if(hovered){
|
if(hovered){
|
||||||
if(checked){
|
if(selected){
|
||||||
return Qt.rgba(1,1,1,1)
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
return Qt.rgba(222/255,222/255,222/255,1)
|
return Qt.rgba(222/255,222/255,222/255,1)
|
||||||
@ -112,14 +95,10 @@ Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
text: control.text
|
text: control.text
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,27 +3,25 @@ import QtQuick.Controls 2.15
|
|||||||
import QtGraphicalEffects 1.15
|
import QtGraphicalEffects 1.15
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
id:root
|
id:control
|
||||||
property var radius:[0,0,0,0]
|
property var radius:[0,0,0,0]
|
||||||
property color color : "#FFFFFF"
|
property color color : "#FFFFFF"
|
||||||
property color borderColor:"red"
|
|
||||||
property int borderWidth: 1
|
|
||||||
property bool shadow: true
|
property bool shadow: true
|
||||||
default property alias contentItem: container.children
|
default property alias contentItem: container.data
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:container
|
id:container
|
||||||
width: root.width
|
width: control.width
|
||||||
height: root.height
|
height: control.height
|
||||||
opacity: 0
|
opacity: 0
|
||||||
color:root.color
|
color:control.color
|
||||||
}
|
}
|
||||||
|
|
||||||
FluShadow{
|
FluShadow{
|
||||||
anchors.fill: container
|
anchors.fill: container
|
||||||
radius: root.radius[0]
|
radius: control.radius[0]
|
||||||
visible: {
|
visible: {
|
||||||
if(root.radius[0] === root.radius[1] && root.radius[0] === root.radius[2] && root.radius[0] === root.radius[3] && root.shadow){
|
if(control.radius[0] === control.radius[1] && control.radius[0] === control.radius[2] && control.radius[0] === control.radius[3] && control.shadow){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -38,8 +36,8 @@ Item{
|
|||||||
var ctx = getContext("2d");
|
var ctx = getContext("2d");
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
var w = root.width;
|
var w = control.width;
|
||||||
var h = root.height;
|
var h = control.height;
|
||||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
@ -54,7 +52,7 @@ Item{
|
|||||||
ctx.lineTo(x, y + radius[0]);
|
ctx.lineTo(x, y + radius[0]);
|
||||||
ctx.arcTo(x, y, x + radius[0], y, radius[0]);
|
ctx.arcTo(x, y, x + radius[0], y, radius[0]);
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
ctx.fillStyle = root.color;
|
ctx.fillStyle = control.color;
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
@ -6,21 +6,24 @@ import FluentUI 1.0
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
id:root
|
|
||||||
|
|
||||||
property alias title: text_title.text
|
property alias title: text_title.text
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
property int spacing : 5
|
property int spacing : 5
|
||||||
|
|
||||||
|
id:root
|
||||||
|
|
||||||
FluText{
|
FluText{
|
||||||
id:text_title
|
id:text_title
|
||||||
fontStyle: FluText.TitleLarge
|
fontStyle: FluText.TitleLarge
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollView{
|
Flickable{
|
||||||
clip: true
|
clip: true
|
||||||
width: parent.width
|
width: parent.width
|
||||||
contentWidth: parent.width
|
contentWidth: parent.width
|
||||||
|
contentHeight: container.height
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar { }
|
||||||
anchors{
|
anchors{
|
||||||
top: text_title.bottom
|
top: text_title.bottom
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
|
property color color: FluTheme.isDark ? "#FFFFFF" : "#999999"
|
||||||
|
property int radius: 4
|
||||||
|
|
||||||
id:root
|
id:root
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: -4
|
anchors.margins: -4
|
||||||
property color color: FluTheme.isDark ? "#FFFFFF" : "#000000"
|
|
||||||
|
|
||||||
property var radius: 4
|
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: root.width
|
width: root.width
|
||||||
|
@ -4,57 +4,68 @@ import QtGraphicalEffects 1.15
|
|||||||
|
|
||||||
Item{
|
Item{
|
||||||
|
|
||||||
id:root
|
|
||||||
|
|
||||||
property int lineSize: 5
|
|
||||||
property int size: 180
|
|
||||||
property int dotSize: 28
|
|
||||||
|
|
||||||
property int value: 50
|
|
||||||
|
|
||||||
enum Orientation {
|
enum Orientation {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
Vertical
|
Vertical
|
||||||
}
|
}
|
||||||
|
property int size: 180
|
||||||
|
property int dotSize: 24
|
||||||
|
property int value: 50
|
||||||
|
property int maxValue: 100
|
||||||
|
property int orientation: FluSlider.Horizontal
|
||||||
|
property bool isHorizontal: orientation === FluSlider.Horizontal
|
||||||
|
property bool enableTip : true
|
||||||
|
property var onLineClickFunc
|
||||||
|
signal pressed
|
||||||
|
signal released
|
||||||
|
|
||||||
|
id:root
|
||||||
height: control.height
|
height: control.height
|
||||||
width: control.width
|
width: control.width
|
||||||
|
|
||||||
property int orientation: FluSlider.Horizontal
|
|
||||||
|
|
||||||
property bool isHorizontal: orientation === FluSlider.Horizontal
|
|
||||||
|
|
||||||
rotation: isHorizontal ? 0 : 180
|
rotation: isHorizontal ? 0 : 180
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
seek(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea{
|
||||||
|
id:mouse_line
|
||||||
|
anchors.centerIn: control
|
||||||
|
width: isHorizontal ? control.width : 10
|
||||||
|
height: isHorizontal ? 10 : control.height
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked:
|
||||||
|
(mouse) => {
|
||||||
|
var val;
|
||||||
if(isHorizontal){
|
if(isHorizontal){
|
||||||
dot.x =value/100*control.width - dotSize/2
|
val = mouse.x*maxValue/control.width
|
||||||
root.value = Qt.binding(function(){
|
|
||||||
return (dot.x+dotSize/2)/control.width*100
|
|
||||||
})
|
|
||||||
}else{
|
}else{
|
||||||
dot.y =value/100*control.height - dotSize/2
|
val = mouse.y*maxValue/control.height
|
||||||
root.value = Qt.binding(function(){
|
}
|
||||||
return (dot.y+dotSize/2)/control.height*100
|
if(onLineClickFunc){
|
||||||
})
|
onLineClickFunc(val)
|
||||||
|
}else{
|
||||||
|
seek(val)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluRectangle {
|
Rectangle {
|
||||||
id: control
|
id: control
|
||||||
width: isHorizontal ? size : root.lineSize
|
width: isHorizontal ? size : 4
|
||||||
height: isHorizontal ? root.lineSize : size
|
height: isHorizontal ? 4 : size
|
||||||
radius: [3,3,3,3]
|
radius: 2
|
||||||
clip: true
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
color:FluTheme.isDark ? Qt.rgba(162/255,162/255,162/255,1) : Qt.rgba(138/255,138/255,138/255,1)
|
color:FluTheme.isDark ? Qt.rgba(162/255,162/255,162/255,1) : Qt.rgba(138/255,138/255,138/255,1)
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id:rect
|
id:rect
|
||||||
radius: 3
|
radius: 2.5
|
||||||
width: isHorizontal ? control.width*(value/100) : control.width
|
width: isHorizontal ? control.width*(value/maxValue) : 5
|
||||||
height: isHorizontal ? control.height : control.height*(value/100)
|
height: isHorizontal ? 5 : control.height*(value/maxValue)
|
||||||
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -74,7 +85,7 @@ Item{
|
|||||||
radius: dotSize/4
|
radius: dotSize/4
|
||||||
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
scale: control_mouse.containsMouse ? 1.2 : 1
|
scale: control_mouse.containsMouse || mouse_line.containsMouse ? 1.3 : 1
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
NumberAnimation{
|
NumberAnimation{
|
||||||
duration: 150
|
duration: 150
|
||||||
@ -94,11 +105,15 @@ Item{
|
|||||||
maximumY: isHorizontal ? 0 : (control.height - dotSize/2)
|
maximumY: isHorizontal ? 0 : (control.height - dotSize/2)
|
||||||
}
|
}
|
||||||
onPressed: {
|
onPressed: {
|
||||||
|
if(enableTip){
|
||||||
tool_tip.visible = true
|
tool_tip.visible = true
|
||||||
}
|
}
|
||||||
|
root.pressed()
|
||||||
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: {
|
||||||
tool_tip.visible = false
|
tool_tip.visible = false
|
||||||
|
root.released()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,5 +124,19 @@ Item{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function seek(val){
|
||||||
|
if(isHorizontal){
|
||||||
|
dot.x =val/maxValue*control.width - dotSize/2
|
||||||
|
root.value = Qt.binding(function(){
|
||||||
|
return (dot.x+dotSize/2)/control.width*maxValue
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
dot.y =val/maxValue*control.height - dotSize/2
|
||||||
|
root.value = Qt.binding(function(){
|
||||||
|
return (dot.y+dotSize/2)/control.height*maxValue
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|