mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-01 14:53:59 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
b83e70ba24 | |||
e29cb7433e | |||
9545175445 | |||
a447b260e7 | |||
8eb7e1df4a | |||
c622f80659 | |||
c0ed9cb41c | |||
e5a24ec642 | |||
6553584c3d | |||
1ea043ee13 | |||
0d6b0d9d25 | |||
5f71ad57d0 | |||
c789d53d6a | |||
f2bbbd5250 | |||
4e95923847 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,14 +1,3 @@
|
||||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
|
@ -7,16 +7,17 @@ ChatController::ChatController(QObject *parent)
|
||||
networkManager = new QNetworkAccessManager(this);
|
||||
}
|
||||
|
||||
|
||||
void ChatController::sendMessage(const QString& text){
|
||||
isLoading(true);
|
||||
QUrl apiUrl("https://api.openai.com/v1/engines/text-davinci-003/completions");
|
||||
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("prompt", text);
|
||||
requestData.insert("max_tokens", 1000);
|
||||
requestData.insert("temperature", 0.5);
|
||||
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);
|
||||
@ -26,11 +27,13 @@ void ChatController::sendMessage(const QString& text){
|
||||
qDebug() << responseString;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(responseString.toUtf8());
|
||||
QJsonObject jsonObj = doc.object();
|
||||
QString text = jsonObj.value("choices").toArray().at(0).toObject().value("text").toString();
|
||||
QString text = jsonObj.value("choices").toArray().at(0).toObject().value("message").toObject().value("content").toString();
|
||||
if(text.isEmpty()){
|
||||
text = "不好意思,我似乎听不懂您的意思";
|
||||
text = "响应错误:content为空数据";
|
||||
}else{
|
||||
messages.append(createMessage("assistant",text));
|
||||
}
|
||||
responseData(text);
|
||||
responseData(text.trimmed());
|
||||
} else {
|
||||
responseData("网络错误:"+reply->errorString());
|
||||
}
|
||||
@ -38,3 +41,16 @@ void ChatController::sendMessage(const QString& text){
|
||||
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);
|
||||
}
|
||||
|
@ -7,7 +7,10 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QGuiApplication>
|
||||
#include <QClipboard>
|
||||
#include <QByteArray>
|
||||
#include <QFile>
|
||||
#include "stdafx.h"
|
||||
|
||||
class ChatController : public QObject
|
||||
@ -19,9 +22,13 @@ 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";
|
||||
};
|
||||
|
||||
|
101
example/T_Badge.qml
Normal file
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -40,8 +40,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:button_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
@ -73,8 +71,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:filled_button_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
@ -108,8 +104,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:icon_button_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
@ -151,8 +145,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:drop_down_button_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
@ -194,8 +186,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:radio_button_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
@ -226,8 +216,6 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
id:check_box_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
|
@ -13,17 +13,26 @@ FluScrollablePage{
|
||||
Layout.topMargin: 20
|
||||
placeholderText: "单行输入框"
|
||||
Layout.preferredWidth: 300
|
||||
disabled:toggle_switch.selected
|
||||
}
|
||||
FluMultiLineTextBox{
|
||||
Layout.topMargin: 20
|
||||
Layout.preferredWidth: 300
|
||||
placeholderText: "多行输入框"
|
||||
disabled:toggle_switch.selected
|
||||
}
|
||||
FluAutoSuggestBox{
|
||||
Layout.topMargin: 20
|
||||
values:generateRandomNames(100)
|
||||
placeholderText: "AutoSuggestBox"
|
||||
Layout.preferredWidth: 300
|
||||
disabled:toggle_switch.selected
|
||||
}
|
||||
|
||||
FluToggleSwitch{
|
||||
id:toggle_switch
|
||||
text:"Disabled"
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
|
||||
function generateRandomNames(numNames) {
|
||||
|
@ -12,4 +12,8 @@ FluScrollablePage{
|
||||
FluToggleSwitch{
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
Layout.topMargin: 20
|
||||
text:"Disabled"
|
||||
}
|
||||
}
|
||||
|
75
example/T_Tooltip.qml
Normal file
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -26,5 +26,26 @@ CONFIG(debug,debug|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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
HEADERS += \
|
||||
ChatController.h
|
||||
|
@ -34,7 +34,7 @@ FluWindow {
|
||||
fontStyle: FluText.Title
|
||||
}
|
||||
FluText{
|
||||
text:"v1.0.10"
|
||||
text:"v1.1.1"
|
||||
fontStyle: FluText.Body
|
||||
Layout.alignment: Qt.AlignBottom
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import QtQuick.Layouts 1.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import Controller 1.0
|
||||
import QtQuick.Dialogs 1.3
|
||||
|
||||
FluWindow {
|
||||
|
||||
@ -13,6 +14,11 @@ FluWindow {
|
||||
|
||||
title:"ChatGPT"
|
||||
|
||||
onInitArgument:
|
||||
(argument)=>{
|
||||
scrollview.focus = true
|
||||
}
|
||||
|
||||
ChatController{
|
||||
id:controller
|
||||
|
||||
@ -42,13 +48,13 @@ FluWindow {
|
||||
Component{
|
||||
id:com_text
|
||||
TextEdit {
|
||||
text: modelData.text
|
||||
id:item_text
|
||||
text: message
|
||||
wrapMode: Text.WrapAnywhere
|
||||
readOnly: true
|
||||
textFormat: Text.RichText
|
||||
selectByMouse: true
|
||||
selectByKeyboard: true
|
||||
selectedTextColor: color
|
||||
selectedTextColor: Qt.rgba(51,153,255,1)
|
||||
color:FluColors.Black
|
||||
selectionColor: {
|
||||
if(FluTheme.isDark){
|
||||
@ -58,6 +64,12 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
width: Math.min(list_message.width-200,600,implicitWidth)
|
||||
TapHandler{
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: {
|
||||
menu_item.showMenu(item_text.selectedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +83,6 @@ FluWindow {
|
||||
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
|
||||
@ -130,7 +141,7 @@ FluWindow {
|
||||
|
||||
Loader{
|
||||
id:item_msg_loader
|
||||
property var modelData: model
|
||||
property var message: model.text
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: com_text
|
||||
}
|
||||
@ -161,6 +172,7 @@ FluWindow {
|
||||
|
||||
|
||||
ScrollView{
|
||||
id:scrollview
|
||||
anchors{
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
@ -172,6 +184,8 @@ FluWindow {
|
||||
height: Math.min(textbox.implicitHeight,64)
|
||||
FluMultiLineTextBox{
|
||||
id:textbox
|
||||
focus:true
|
||||
placeholderText: "请输入消息"
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,6 +236,23 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -90,6 +90,13 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"Badge"
|
||||
onTap:{
|
||||
nav_view.push("qrc:/T_Badge.qml")
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"Rectangle"
|
||||
onTap:{
|
||||
@ -97,7 +104,6 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FluPaneItem{
|
||||
title:"Carousel"
|
||||
onTap:{
|
||||
@ -123,6 +129,13 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"Tooltip"
|
||||
onTap:{
|
||||
nav_view.push("qrc:/T_Tooltip.qml")
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"Menu"
|
||||
onTap:{
|
||||
|
@ -40,5 +40,7 @@
|
||||
<file>res/image/banner_3.jpg</file>
|
||||
<file>res/image/logo_openai.png</file>
|
||||
<file>page/ChatPage.qml</file>
|
||||
<file>T_Tooltip.qml</file>
|
||||
<file>T_Badge.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -17,7 +17,7 @@ function Main() {
|
||||
|
||||
New-Item -ItemType Directory $archiveName
|
||||
# 拷贝exe
|
||||
Copy-Item bin\release\$targetName $archiveName\
|
||||
Copy-Item bin\release\* $archiveName\
|
||||
# 拷贝依赖
|
||||
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
||||
# 删除不必要的文件
|
||||
|
@ -27,7 +27,7 @@ function Main() {
|
||||
|
||||
New-Item -ItemType Directory $archiveName
|
||||
# 拷贝exe
|
||||
Copy-Item bin\release\$targetName $archiveName\
|
||||
Copy-Item bin\release\* $archiveName\
|
||||
# 拷贝依赖
|
||||
windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
|
||||
# 删除不必要的文件
|
||||
|
@ -35,6 +35,7 @@ void Fluent::registerTypes(const char *uri){
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluArea.qml"),uri,major,minor,"FluArea");
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluBadge.qml"),uri,major,minor,"FluBadge");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
|
||||
|
@ -4,9 +4,6 @@
|
||||
#include <QQuickView>
|
||||
#include <QRegion>
|
||||
|
||||
//无边框窗口,主要用来实现自定义标题栏。
|
||||
//Windows平台支持拖动和改变大小,支持Aero效果
|
||||
//非Windows平台,去掉边框,不做其它处理。由Qml模拟resize和拖动。
|
||||
class FramelessViewPrivate;
|
||||
class FramelessView : public QQuickView
|
||||
{
|
||||
|
@ -8,11 +8,18 @@ TextField{
|
||||
property int fontStyle: FluText.Body
|
||||
property int pixelSize : FluTheme.textSize
|
||||
property int iconSource: 0
|
||||
property bool disabled: false
|
||||
signal itemClicked(string data)
|
||||
|
||||
id:input
|
||||
width: 300
|
||||
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
enabled: !disabled
|
||||
color: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
}
|
||||
selectionColor: {
|
||||
if(FluTheme.isDark){
|
||||
return FluTheme.primaryColor.lighter
|
||||
@ -22,6 +29,9 @@ TextField{
|
||||
}
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
placeholderTextColor: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
if(focus){
|
||||
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
||||
}
|
||||
|
77
src/controls/FluBadge.qml
Normal file
77
src/controls/FluBadge.qml
Normal file
@ -0,0 +1,77 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
Rectangle{
|
||||
|
||||
property bool isDot: false
|
||||
property bool showZero: true
|
||||
property int count: 0
|
||||
|
||||
|
||||
id:control
|
||||
color:Qt.rgba(255/255,77/255,79/255,1)
|
||||
width: {
|
||||
if(isDot)
|
||||
return 10
|
||||
if(count<10){
|
||||
return 20
|
||||
}else if(count<100){
|
||||
return 30
|
||||
}
|
||||
return 40
|
||||
}
|
||||
height: {
|
||||
if(isDot)
|
||||
return 10
|
||||
return 20
|
||||
}
|
||||
radius: {
|
||||
if(isDot)
|
||||
return 5
|
||||
return 10
|
||||
}
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(1,1,1,1)
|
||||
visible: {
|
||||
if(showZero)
|
||||
return true
|
||||
return count!==0
|
||||
}
|
||||
anchors{
|
||||
right: {
|
||||
if(parent)
|
||||
return parent.right
|
||||
return undefined
|
||||
}
|
||||
top: {
|
||||
if(parent)
|
||||
return parent.top
|
||||
return undefined
|
||||
}
|
||||
rightMargin: {
|
||||
if(isDot){
|
||||
return -2.5
|
||||
}
|
||||
return -(control.width/2)
|
||||
}
|
||||
topMargin: {
|
||||
if(isDot){
|
||||
return -2.5
|
||||
}
|
||||
return -10
|
||||
}
|
||||
}
|
||||
|
||||
Text{
|
||||
anchors.centerIn: parent
|
||||
color: Qt.rgba(1,1,1,1)
|
||||
visible: !isDot
|
||||
text:{
|
||||
if(count<100)
|
||||
return count
|
||||
return count+"+"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -6,10 +6,17 @@ TextArea{
|
||||
|
||||
property int fontStyle: FluText.Body
|
||||
property int pixelSize : FluTheme.textSize
|
||||
property bool disabled: false
|
||||
|
||||
id:input
|
||||
width: 300
|
||||
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
color: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
}
|
||||
enabled: !disabled
|
||||
wrapMode: Text.WrapAnywhere
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
selectByMouse: true
|
||||
@ -24,6 +31,9 @@ TextArea{
|
||||
inputItem: input
|
||||
}
|
||||
placeholderTextColor: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
if(focus){
|
||||
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ Item {
|
||||
id:root
|
||||
anchors.fill: parent
|
||||
anchors.margins: -4
|
||||
property color color: FluTheme.isDark ? "#FFFFFF" : "#000000"
|
||||
property color color: FluTheme.isDark ? "#FFFFFF" : "#999999"
|
||||
|
||||
property int radius: 4
|
||||
|
||||
|
@ -6,10 +6,17 @@ TextField{
|
||||
|
||||
property int fontStyle: FluText.Body
|
||||
property int pixelSize : FluTheme.textSize
|
||||
property bool disabled: false
|
||||
|
||||
id:input
|
||||
width: 300
|
||||
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
enabled: !disabled
|
||||
color: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
}
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
selectionColor: {
|
||||
if(FluTheme.isDark){
|
||||
@ -19,6 +26,9 @@ TextField{
|
||||
}
|
||||
}
|
||||
placeholderTextColor: {
|
||||
if(disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
}
|
||||
if(focus){
|
||||
return FluTheme.isDark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
||||
}
|
||||
|
@ -9,10 +9,13 @@ Rectangle{
|
||||
radius: 4
|
||||
layer.enabled: true
|
||||
color: {
|
||||
if(input.focus){
|
||||
if(inputItem.disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
||||
}
|
||||
if(inputItem.focus){
|
||||
return FluTheme.isDark ? Qt.rgba(36/255,36/255,36/255,1) : Qt.rgba(1,1,1,1)
|
||||
}
|
||||
if(input.hovered){
|
||||
if(inputItem.hovered){
|
||||
return FluTheme.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1)
|
||||
@ -25,16 +28,22 @@ Rectangle{
|
||||
}
|
||||
}
|
||||
border.width: 1
|
||||
border.color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
|
||||
border.color: {
|
||||
if(inputItem.disabled){
|
||||
return FluTheme.isDark ? Qt.rgba(73/255,73/255,73/255,1) : Qt.rgba(237/255,237/255,237/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(76/255,76/255,76/255,1) : Qt.rgba(240/255,240/255,240/255,1)
|
||||
}
|
||||
Rectangle{
|
||||
width: parent.width
|
||||
height: input.focus ? 3 : 1
|
||||
height: inputItem.focus ? 3 : 1
|
||||
anchors.bottom: parent.bottom
|
||||
visible: !inputItem.disabled
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
input.focus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
|
||||
inputItem.focus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
|
||||
}else{
|
||||
return input.focus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
|
||||
return inputItem.focus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
|
||||
}
|
||||
}
|
||||
Behavior on height{
|
||||
|
@ -1,6 +1,7 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.0
|
||||
import FluentUI 1.0
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
Button {
|
||||
|
||||
@ -8,10 +9,8 @@ Button {
|
||||
property var clickFunc
|
||||
|
||||
id: control
|
||||
width: 40
|
||||
implicitWidth: 40
|
||||
height: 20
|
||||
implicitHeight: 20
|
||||
implicitHeight: height
|
||||
focusPolicy:Qt.TabFocus
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
onClicked: {
|
||||
@ -21,50 +20,68 @@ Button {
|
||||
}
|
||||
selected = !selected
|
||||
}
|
||||
background : Rectangle {
|
||||
width: control.width
|
||||
height: control.height
|
||||
radius: height / 2
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
radius: 20
|
||||
}
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(hovered){
|
||||
return "#3E3E3C"
|
||||
}
|
||||
return "#323232"
|
||||
}else{
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(hovered){
|
||||
return "#F4F4F4"
|
||||
}
|
||||
return "#FFFFFF"
|
||||
}
|
||||
}
|
||||
border.width: 1
|
||||
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
||||
|
||||
contentItem: Item{}
|
||||
|
||||
background : RowLayout{
|
||||
spacing: 0
|
||||
Rectangle {
|
||||
x: selected ? control.implicitWidth - width - 4 : 4
|
||||
width: control.height - 8
|
||||
height: control.height - 8
|
||||
radius: width / 2
|
||||
scale: hovered ? 1.2 : 1.0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: selected ? "#FFFFFF" : "#666666"
|
||||
Behavior on x {
|
||||
NumberAnimation { duration: 200 }
|
||||
id:control_backgound
|
||||
width: 40
|
||||
height: control.height
|
||||
radius: height / 2
|
||||
smooth: true
|
||||
antialiasing: true
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
radius: 20
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: 150 }
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(hovered){
|
||||
return "#3E3E3C"
|
||||
}
|
||||
return "#323232"
|
||||
}else{
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(hovered){
|
||||
return "#F4F4F4"
|
||||
}
|
||||
return "#FFFFFF"
|
||||
}
|
||||
}
|
||||
border.width: 1
|
||||
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
||||
Rectangle {
|
||||
x: selected ? control_backgound.width - width - 4 : 4
|
||||
width: control.height - 8
|
||||
height: control.height - 8
|
||||
radius: width / 2
|
||||
antialiasing: true
|
||||
scale: hovered ? 1.2 : 1.0
|
||||
smooth: true
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: selected ? "#FFFFFF" : "#666666"
|
||||
Behavior on x {
|
||||
NumberAnimation { duration: 200 }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: 150 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluText{
|
||||
text: control.text
|
||||
Layout.leftMargin: 5
|
||||
visible: text !== ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,5 +48,6 @@
|
||||
<file>controls/FluCalendarDatePicker.qml</file>
|
||||
<file>controls/FluFocusRectangle.qml</file>
|
||||
<file>controls/FluCarousel.qml</file>
|
||||
<file>controls/FluBadge.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
third/Win_x64/libcrypto-1_1-x64.dll
Normal file
BIN
third/Win_x64/libcrypto-1_1-x64.dll
Normal file
Binary file not shown.
BIN
third/Win_x64/libssl-1_1-x64.dll
Normal file
BIN
third/Win_x64/libssl-1_1-x64.dll
Normal file
Binary file not shown.
BIN
third/Win_x86/libcrypto-1_1.dll
Normal file
BIN
third/Win_x86/libcrypto-1_1.dll
Normal file
Binary file not shown.
BIN
third/Win_x86/libssl-1_1.dll
Normal file
BIN
third/Win_x86/libssl-1_1.dll
Normal file
Binary file not shown.
Reference in New Issue
Block a user