main
zhuzihcu 2023-03-02 12:20:16 +08:00
parent 744102e034
commit 91be0e4da2
16 changed files with 230 additions and 22 deletions

View File

@ -35,22 +35,11 @@ FluWindow {
Layout.leftMargin: 30
}
Rectangle{
color: FluApp.isDark ? "#323232" : "#FFFFFF"
radius: 4
FluTextBox{
Layout.preferredHeight: 40
Layout.fillWidth: true
height: 40
border.width: 1
border.color: FluApp.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
FluText{
text:"C:\\Program Files\\RustDesk"
anchors{
verticalCenter: parent.verticalCenter
left:parent.left
leftMargin: 14
}
}
text:"C:\\Program Files\\RustDesk"
readOnly:true
}
FluButton{

View File

@ -24,6 +24,10 @@ FluWindow {
text:"Buttons"
page:"qrc:/T_Buttons.qml"
}
ListElement{
text:"TextBox"
page:"qrc:/T_TextBox.qml"
}
ListElement{
text:"ToggleSwitch"
page:"qrc:/T_ToggleSwitch.qml"
@ -44,6 +48,10 @@ FluWindow {
text:"Rectangle"
page:"qrc:/T_Rectangle.qml"
}
ListElement{
text:"Awesome"
page:"qrc:/T_Awesome.qml"
}
ListElement{
text:"Typography"
page:"qrc:/T_Typography.qml"

64
example/T_Awesome.qml Normal file
View File

@ -0,0 +1,64 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
Item {
FluText{
id:title
text:"Awesome"
fontStyle: FluText.TitleLarge
}
FluTextBox{
id:text_box
placeholderText: "搜索"
anchors{
topMargin: 20
top:title.bottom
}
}
GridView{
cellWidth: 120
cellHeight: 60
clip: true
model:FluApp.awesomelist()
anchors{
topMargin: 10
top:text_box.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
delegate: Item {
width: 120
height: 60
FluIconButton{
id:item_icon
icon:modelData.icon
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
var text ="FluentIcons."+modelData.name;
FluApp.clipText(text)
showSuccess("您复制了 "+text)
}
}
FluText {
id:item_name
font.pixelSize: 10;
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: item_icon.bottom
text: modelData.name
}
}
}
}

28
example/T_TextBox.qml Normal file
View File

@ -0,0 +1,28 @@
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
Item {
ColumnLayout{
spacing: 5
FluText{
text:"TextBox"
fontStyle: FluText.TitleLarge
}
FluTextBox{
Layout.topMargin: 20
placeholderText: "单行输入框"
Layout.preferredWidth: 300
}
FluMultiLineTextBox{
Layout.topMargin: 20
Layout.preferredWidth: 300
placeholderText: "多行输入框"
}
}
}

View File

@ -25,5 +25,7 @@
<file>res/svg/avatar_11.svg</file>
<file>res/svg/avatar_12.svg</file>
<file>Installer.qml</file>
<file>T_Awesome.qml</file>
<file>T_TextBox.qml</file>
</qresource>
</RCC>

View File

@ -5,7 +5,8 @@
#include <QQmlContext>
#include <QQuickItem>
#include <QTimer>
#include "FramelessView.h"
#include <QClipboard>
#include "Def.h"
FluApp* FluApp::m_instance = nullptr;
@ -63,3 +64,22 @@ void FluApp::navigate(const QString& route){
bool FluApp::equalsWindow(FramelessView *view,QWindow *window){
return view->winId() == window->winId();
}
QJsonArray FluApp::awesomelist()
{
QJsonArray arr;
QMetaEnum enumType = Fluent_Awesome::staticMetaObject.enumerator(Fluent_Awesome::staticMetaObject.indexOfEnumerator("Fluent_AwesomeType"));
for(int i=0; i < enumType.keyCount(); ++i){
QJsonObject obj;
QString name = enumType.key(i);
int icon = enumType.value(i);
obj.insert("name",name);
obj.insert("icon",icon);
arr.append(obj);
}
return arr;
}
void FluApp::clipText(const QString& text){
QGuiApplication::clipboard()->setText(text);
}

View File

@ -3,6 +3,7 @@
#include <QObject>
#include <QWindow>
#include <QJsonArray>
#include <QJsonObject>
#include "FramelessView.h"
#include "stdafx.h"
@ -31,6 +32,11 @@ public:
Q_INVOKABLE bool equalsWindow(FramelessView *view,QWindow *window);
Q_INVOKABLE QJsonArray awesomelist();
Q_INVOKABLE void clipText(const QString& text);
private:
static FluApp* m_instance;

View File

@ -30,6 +30,7 @@ void Fluent::registerTypes(const char *uri){
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluMultiLineTextBox.qml"),uri,major,minor,"FluMultiLineTextBox");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluDropShadow.qml"),uri,major,minor,"FluDropShadow");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTooltip.qml"),uri,major,minor,"FluTooltip");
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluDivider.qml"),uri,major,minor,"FluDivider");

View File

@ -119,7 +119,7 @@ public:
{
borderless = enabled;
//todo 有待研究这个
::SetWindowLongPtrW(handle, GWL_STYLE, static_cast<LONG>(newStyle));
// ::SetWindowLongPtrW(handle, GWL_STYLE, static_cast<LONG>(newStyle));
// when switching between borderless and windowed, restore appropriate shadow state
setShadow(handle, borderless_shadow && (newStyle != Style::windowed));

View File

@ -23,6 +23,6 @@ void WindowHelper::setMaximumSize(const QSize &size){
}
void WindowHelper::refreshWindow(){
this->window->setFlag(Qt::FramelessWindowHint,true);
this->window->setFlag(Qt::FramelessWindowHint,false);
this->window->setFlag(Qt::NoDropShadowWindowHint,true);
this->window->setFlag(Qt::NoDropShadowWindowHint,false);
}

View File

@ -1040,6 +1040,14 @@ Module {
}
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
}
Component {
prototype: "QQuickTextArea"
name: "FluentUI/FluMultiLineTextBox 1.0"
exports: ["FluentUI/FluMultiLineTextBox 1.0"]
exportMetaObjectRevisions: [0]
isComposite: true
defaultProperty: "data"
}
Component {
prototype: "QObject"
name: "FluentUI/FluObject 1.0"
@ -1138,7 +1146,7 @@ Module {
Property { name: "pixelSize"; type: "int" }
}
Component {
prototype: "QQuickItem"
prototype: "QQuickTextField"
name: "FluentUI/FluTextBox 1.0"
exports: ["FluentUI/FluTextBox 1.0"]
exportMetaObjectRevisions: [0]

View File

@ -0,0 +1,22 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
TextArea{
id:input
width: 300
color: FluApp.isDark ? "#FFFFFF" : "#1A1A1A"
wrapMode: Text.WrapAnywhere
selectByMouse: true
selectionColor: {
if(FluApp.isDark){
return Qt.rgba(76/255,160/255,224/255,1)
}else{
return Qt.rgba(0/255,102/255,180/255,1)
}
}
background: FluTextBoxBackground{
inputItem: input
}
}

View File

@ -16,7 +16,6 @@ Item{
height: root.height
visible: false
color:root.color
}
Canvas {

View File

@ -1,6 +1,22 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
Item {
TextField{
id:input
width: 300
color: FluApp.isDark ? "#FFFFFF" : "#1A1A1A"
selectionColor: {
if(FluApp.isDark){
return Qt.rgba(76/255,160/255,224/255,1)
}else{
return Qt.rgba(0/255,102/255,180/255,1)
}
}
selectByMouse: true
background: FluTextBoxBackground{
inputItem: input
}
}

View File

@ -0,0 +1,43 @@
import QtQuick 2.15
import QtGraphicalEffects 1.15
Rectangle{
id:content
property Item inputItem
radius: 4
layer.enabled: true
color: {
if(input.hovered){
return FluApp.isDark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
}
return FluApp.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1)
}
layer.effect:OpacityMask {
maskSource: Rectangle {
width: content.width
height: content.height
radius: 4
}
}
border.width: 1
border.color: FluApp.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
Rectangle{
width: parent.width
height: input.focus ? 3 : 1
anchors.bottom: parent.bottom
color: {
if(FluApp.isDark){
input.focus ? Qt.rgba(76/255,160/255,224/255,1) : Qt.rgba(166/255,166/255,166/255,1)
}else{
return input.focus ? Qt.rgba(0/255,102/255,180/255,1) : Qt.rgba(183/255,183/255,183/255,1)
}
}
Behavior on height{
NumberAnimation{
duration: 200
}
}
}
}

View File

@ -25,5 +25,7 @@
<file>controls/FluTooltip.qml</file>
<file>controls/FluDropShadow.qml</file>
<file>controls/TFpsMonitor.qml</file>
<file>controls/FluTextBoxBackground.qml</file>
<file>controls/FluMultiLineTextBox.qml</file>
</qresource>
</RCC>