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 Layout.leftMargin: 30
} }
Rectangle{ FluTextBox{
color: FluApp.isDark ? "#323232" : "#FFFFFF" Layout.preferredHeight: 40
radius: 4
Layout.fillWidth: true Layout.fillWidth: true
height: 40 text:"C:\\Program Files\\RustDesk"
border.width: 1 readOnly:true
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
}
}
} }
FluButton{ FluButton{

View File

@ -24,6 +24,10 @@ FluWindow {
text:"Buttons" text:"Buttons"
page:"qrc:/T_Buttons.qml" page:"qrc:/T_Buttons.qml"
} }
ListElement{
text:"TextBox"
page:"qrc:/T_TextBox.qml"
}
ListElement{ ListElement{
text:"ToggleSwitch" text:"ToggleSwitch"
page:"qrc:/T_ToggleSwitch.qml" page:"qrc:/T_ToggleSwitch.qml"
@ -44,6 +48,10 @@ FluWindow {
text:"Rectangle" text:"Rectangle"
page:"qrc:/T_Rectangle.qml" page:"qrc:/T_Rectangle.qml"
} }
ListElement{
text:"Awesome"
page:"qrc:/T_Awesome.qml"
}
ListElement{ ListElement{
text:"Typography" text:"Typography"
page:"qrc:/T_Typography.qml" 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_11.svg</file>
<file>res/svg/avatar_12.svg</file> <file>res/svg/avatar_12.svg</file>
<file>Installer.qml</file> <file>Installer.qml</file>
<file>T_Awesome.qml</file>
<file>T_TextBox.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -5,7 +5,8 @@
#include <QQmlContext> #include <QQmlContext>
#include <QQuickItem> #include <QQuickItem>
#include <QTimer> #include <QTimer>
#include "FramelessView.h" #include <QClipboard>
#include "Def.h"
FluApp* FluApp::m_instance = nullptr; FluApp* FluApp::m_instance = nullptr;
@ -63,3 +64,22 @@ void FluApp::navigate(const QString& route){
bool FluApp::equalsWindow(FramelessView *view,QWindow *window){ bool FluApp::equalsWindow(FramelessView *view,QWindow *window){
return view->winId() == window->winId(); 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 <QObject>
#include <QWindow> #include <QWindow>
#include <QJsonArray>
#include <QJsonObject> #include <QJsonObject>
#include "FramelessView.h" #include "FramelessView.h"
#include "stdafx.h" #include "stdafx.h"
@ -31,6 +32,11 @@ public:
Q_INVOKABLE bool equalsWindow(FramelessView *view,QWindow *window); Q_INVOKABLE bool equalsWindow(FramelessView *view,QWindow *window);
Q_INVOKABLE QJsonArray awesomelist();
Q_INVOKABLE void clipText(const QString& text);
private: private:
static FluApp* m_instance; static FluApp* m_instance;

View File

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

View File

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

View File

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

View File

@ -1040,6 +1040,14 @@ Module {
} }
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true } 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 { Component {
prototype: "QObject" prototype: "QObject"
name: "FluentUI/FluObject 1.0" name: "FluentUI/FluObject 1.0"
@ -1138,7 +1146,7 @@ Module {
Property { name: "pixelSize"; type: "int" } Property { name: "pixelSize"; type: "int" }
} }
Component { Component {
prototype: "QQuickItem" prototype: "QQuickTextField"
name: "FluentUI/FluTextBox 1.0" name: "FluentUI/FluTextBox 1.0"
exports: ["FluentUI/FluTextBox 1.0"] exports: ["FluentUI/FluTextBox 1.0"]
exportMetaObjectRevisions: [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 height: root.height
visible: false visible: false
color:root.color color:root.color
} }
Canvas { Canvas {

View File

@ -1,6 +1,22 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0 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/FluTooltip.qml</file>
<file>controls/FluDropShadow.qml</file> <file>controls/FluDropShadow.qml</file>
<file>controls/TFpsMonitor.qml</file> <file>controls/TFpsMonitor.qml</file>
<file>controls/FluTextBoxBackground.qml</file>
<file>controls/FluMultiLineTextBox.qml</file>
</qresource> </qresource>
</RCC> </RCC>