mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-01 15:42:20 +08:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
2b9e9b2159 | |||
23bc5cdf68 | |||
f75da5e3ce | |||
8cc828a56b | |||
f36914fdee | |||
0cf3f2aa22 | |||
5bb8f27968 | |||
e6d2513482 | |||
5917d23286 | |||
eb1744d5f8 | |||
b1b727030c | |||
a71831cd9d |
@ -34,7 +34,7 @@ FluWindow {
|
||||
fontStyle: FluText.Title
|
||||
}
|
||||
FluText{
|
||||
text:"v1.0.3"
|
||||
text:"v1.0.6"
|
||||
fontStyle: FluText.Body
|
||||
Layout.alignment: Qt.AlignBottom
|
||||
}
|
||||
@ -70,6 +70,28 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
spacing: 14
|
||||
Layout.topMargin: 20
|
||||
Layout.leftMargin: 15
|
||||
FluText{
|
||||
id:text_info
|
||||
text:"如果该项目对你有作用,就请点击上方链接给一个免费的star吧!"
|
||||
ColorAnimation {
|
||||
id: animation
|
||||
target: text_info
|
||||
property: "color"
|
||||
from: "red"
|
||||
to: "blue"
|
||||
duration: 1000
|
||||
running: true
|
||||
loops: Animation.Infinite
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,8 +15,6 @@ Window {
|
||||
"/":"qrc:/MainPage.qml",
|
||||
"/Setting":"qrc:/SettingPage.qml",
|
||||
"/About":"qrc:/AboutPage.qml",
|
||||
"/Installer":"qrc:/Installer.qml",
|
||||
"/Uninstall":"qrc:/Uninstall.qml"
|
||||
}
|
||||
FluApp.initialRoute = "/"
|
||||
FluApp.run()
|
||||
|
@ -8,8 +8,8 @@ import FluentUI 1.0
|
||||
|
||||
FluWindow {
|
||||
id:rootwindow
|
||||
width: 800
|
||||
height: 600
|
||||
width: 860
|
||||
height: 680
|
||||
title: "FluentUI"
|
||||
minimumWidth: 500
|
||||
minimumHeight: 400
|
||||
@ -59,6 +59,20 @@ FluWindow {
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"TimePicker"
|
||||
onTap:{
|
||||
nav_view.push("qrc:/T_TimePicker.qml")
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItem{
|
||||
title:"DatePicker"
|
||||
onTap:{
|
||||
nav_view.push("qrc:/T_DatePicker.qml")
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItemHeader{
|
||||
title:"Surface"
|
||||
}
|
||||
@ -116,7 +130,6 @@ FluWindow {
|
||||
title:"Theming"
|
||||
}
|
||||
|
||||
|
||||
FluPaneItem{
|
||||
title:"Theme"
|
||||
onTap:{
|
||||
|
@ -30,8 +30,8 @@ FluContentPage {
|
||||
}
|
||||
GridView{
|
||||
id:grid_view
|
||||
cellWidth: 120
|
||||
cellHeight: 60
|
||||
cellWidth: 80
|
||||
cellHeight: 80
|
||||
clip: true
|
||||
model:FluApp.awesomelist()
|
||||
ScrollBar.vertical: FluScrollBar {}
|
||||
@ -43,11 +43,11 @@ FluContentPage {
|
||||
bottom: parent.bottom
|
||||
}
|
||||
delegate: Item {
|
||||
width: 120
|
||||
height: 60
|
||||
width: 68
|
||||
height: 80
|
||||
FluIconButton{
|
||||
id:item_icon
|
||||
icon:modelData.icon
|
||||
iconSource:modelData.icon
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: {
|
||||
var text ="FluentIcons."+modelData.name;
|
||||
@ -57,10 +57,14 @@ FluContentPage {
|
||||
}
|
||||
FluText {
|
||||
id:item_name
|
||||
font.pixelSize: 10;
|
||||
font.pixelSize: 10
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: item_icon.bottom
|
||||
width:parent.width
|
||||
wrapMode: Text.WrapAnywhere
|
||||
text: modelData.name
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,19 @@ FluScrollablePage{
|
||||
|
||||
spacing: 20
|
||||
|
||||
FluArea{
|
||||
FluText{
|
||||
Layout.topMargin: 20
|
||||
text:"支持Tab键切换焦点,空格键执行点击事件"
|
||||
}
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
height: 68
|
||||
paddings: 10
|
||||
|
||||
FluButton{
|
||||
disabled:button_switch.checked
|
||||
disabled:button_switch.selected
|
||||
text:"Standard Button"
|
||||
onClicked: {
|
||||
showInfo("点击StandardButton")
|
||||
}
|
||||
@ -48,9 +53,10 @@ FluScrollablePage{
|
||||
paddings: 10
|
||||
|
||||
FluFilledButton{
|
||||
disabled:filled_button_switch.checked
|
||||
disabled:filled_button_switch.selected
|
||||
text:"Filled Button"
|
||||
onClicked: {
|
||||
showWarning("点击FilledButton")
|
||||
showWarning("点击FilledButton")
|
||||
}
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
@ -81,8 +87,9 @@ FluScrollablePage{
|
||||
paddings: 10
|
||||
|
||||
FluIconButton{
|
||||
icon:FluentIcons.FA_close
|
||||
disabled:icon_button_switch.checked
|
||||
iconSource:FluentIcons.ChromeCloseContrast
|
||||
disabled:icon_button_switch.selected
|
||||
iconSize: 15
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
@ -124,8 +131,8 @@ FluScrollablePage{
|
||||
property int selecIndex : 0
|
||||
model: 3
|
||||
delegate: FluRadioButton{
|
||||
checked : repeater.selecIndex===index
|
||||
disabled:radio_button_switch.checked
|
||||
selected : repeater.selecIndex===index
|
||||
disabled:radio_button_switch.selected
|
||||
text:"Radio Button_"+index
|
||||
onClicked:{
|
||||
repeater.selecIndex = index
|
||||
@ -158,7 +165,8 @@ FluScrollablePage{
|
||||
paddings: 10
|
||||
|
||||
FluCheckBox{
|
||||
disabled:icon_button_check.checked
|
||||
disabled:check_box_switch.selected
|
||||
text:"Check Box"
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
@ -173,7 +181,7 @@ FluScrollablePage{
|
||||
right: parent.right
|
||||
}
|
||||
FluToggleSwitch{
|
||||
id:icon_button_check
|
||||
id:check_box_switch
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
FluText{
|
||||
|
61
example/T_DatePicker.qml
Normal file
61
example/T_DatePicker.qml
Normal file
@ -0,0 +1,61 @@
|
||||
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:"TimePicker"
|
||||
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:"showYear=true"
|
||||
}
|
||||
|
||||
FluDatePicker{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:"showYear=false"
|
||||
}
|
||||
|
||||
FluDatePicker{
|
||||
showYear:false
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ FluScrollablePage{
|
||||
property int selecIndex : 0
|
||||
model: 3
|
||||
delegate: FluRadioButton{
|
||||
checked : repeater.selecIndex===index
|
||||
selected : repeater.selecIndex===index
|
||||
text:"Radio Button_"+index
|
||||
onClicked:{
|
||||
repeater.selecIndex = index
|
||||
|
@ -20,7 +20,7 @@ FluScrollablePage{
|
||||
color: mouse_item.containsMouse ? Qt.lighter(modelData.normal,1.1) : modelData.normal
|
||||
FluIcon {
|
||||
anchors.centerIn: parent
|
||||
icon: FluentIcons.FA_check
|
||||
iconSource: FluentIcons.AcceptMedium
|
||||
iconSize: 15
|
||||
visible: modelData === FluTheme.primaryColor
|
||||
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
||||
@ -38,24 +38,32 @@ FluScrollablePage{
|
||||
}
|
||||
FluText{
|
||||
text:"夜间模式"
|
||||
fontStyle: FluText.Subtitle
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
checked: FluTheme.isDark
|
||||
onClickFunc:function(){
|
||||
selected: FluTheme.isDark
|
||||
clickFunc:function(){
|
||||
FluTheme.isDark = !FluTheme.isDark
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:"无边框"
|
||||
fontStyle: FluText.Subtitle
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
checked: FluTheme.isFrameless
|
||||
onClickFunc:function(){
|
||||
selected: FluTheme.isFrameless
|
||||
clickFunc:function(){
|
||||
FluTheme.isFrameless = !FluTheme.isFrameless
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:"native文本渲染"
|
||||
Layout.topMargin: 20
|
||||
}
|
||||
FluToggleSwitch{
|
||||
selected: FluTheme.isNativeText
|
||||
clickFunc:function(){
|
||||
FluTheme.isNativeText = !FluTheme.isNativeText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
example/T_TimePicker.qml
Normal file
61
example/T_TimePicker.qml
Normal file
@ -0,0 +1,61 @@
|
||||
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:"TimePicker"
|
||||
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:"hourFormat=FluTimePicker.H"
|
||||
}
|
||||
|
||||
FluTimePicker{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
Layout.topMargin: 20
|
||||
height: 80
|
||||
paddings: 10
|
||||
|
||||
ColumnLayout{
|
||||
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:"hourFormat=FluTimePicker.HH"
|
||||
}
|
||||
|
||||
FluTimePicker{
|
||||
hourFormat:FluTimePicker.HH
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -30,5 +30,7 @@
|
||||
<file>T_TreeView.qml</file>
|
||||
<file>T_Expander.qml</file>
|
||||
<file>MainPage.qml</file>
|
||||
<file>T_TimePicker.qml</file>
|
||||
<file>T_DatePicker.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -82,7 +82,7 @@ QJsonArray FluApp::awesomelist(const QString& keyword)
|
||||
obj.insert("icon",icon);
|
||||
arr.append(obj);
|
||||
}else{
|
||||
if(name.mid(3).contains(keyword)){
|
||||
if(name.contains(keyword)){
|
||||
QJsonObject obj;
|
||||
obj.insert("name",name);
|
||||
obj.insert("icon",icon);
|
||||
|
@ -17,6 +17,7 @@ FluTheme::FluTheme(QObject *parent)
|
||||
{
|
||||
primaryColor(FluColors::getInstance()->Blue());
|
||||
textSize(13);
|
||||
isFrameless(true);
|
||||
isNativeText(false);
|
||||
isFrameless(false);
|
||||
isDark(false);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class FluTheme : public QObject
|
||||
Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
|
||||
Q_PROPERTY_AUTO(bool,isFrameless);
|
||||
Q_PROPERTY_AUTO(bool,isDark);
|
||||
Q_PROPERTY_AUTO(bool,isNativeText);
|
||||
Q_PROPERTY_AUTO(int,textSize);
|
||||
public:
|
||||
explicit FluTheme(QObject *parent = nullptr);
|
||||
|
@ -42,6 +42,12 @@ void Fluent::registerTypes(const char *uri){
|
||||
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/FluCalendarDatePicker.qml"),uri,major,minor,"FluCalendarDatePicker");
|
||||
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/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
|
||||
|
||||
|
||||
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/FluTreeView.qml"),uri,major,minor,"FluTreeView");
|
||||
@ -71,7 +77,6 @@ void Fluent::registerTypes(const char *uri){
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluSlider.qml"),uri,major,minor,"FluSlider");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTextBox.qml"),uri,major,minor,"FluTextBox");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluText.qml"),uri,major,minor,"FluText");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTimePicker.qml"),uri,major,minor,"FluTimePicker");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluFilledButton.qml"),uri,major,minor,"FluFilledButton");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluToggleSwitch.qml"),uri,major,minor,"FluToggleSwitch");
|
||||
|
||||
@ -86,9 +91,9 @@ void Fluent::initializeEngine(QQmlEngine *engine, const char *uri)
|
||||
QFont font;
|
||||
font.setFamily("Microsoft YaHei");
|
||||
QGuiApplication::setFont(font);
|
||||
QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
|
||||
// QQuickWindow::setTextRenderType(QQuickWindow::NativeTextRendering);
|
||||
#endif
|
||||
QFontDatabase::addApplicationFont(":/com.zhuzichu/res/font/fontawesome-webfont.ttf");
|
||||
QFontDatabase::addApplicationFont(":/com.zhuzichu/res/font/Segoe_Fluent_Icons.ttf");
|
||||
FluApp* app = FluApp::getInstance();
|
||||
engine->rootContext()->setContextProperty("FluApp",app);
|
||||
FluColors* colors = FluColors::getInstance();
|
||||
|
@ -93,15 +93,15 @@ Rectangle{
|
||||
fontStyle: FluText.Body
|
||||
}
|
||||
FluToggleSwitch{
|
||||
checked: FluTheme.isDark
|
||||
onClickFunc:function(){
|
||||
selected: FluTheme.isDark
|
||||
clickFunc:function(){
|
||||
FluTheme.isDark = !FluTheme.isDark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluIconButton{
|
||||
icon : FluentIcons.FA_window_minimize
|
||||
iconSource : FluentIcons.ChromeMinimizeContrast
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
iconSize: 15
|
||||
text:"最小化"
|
||||
@ -117,7 +117,7 @@ Rectangle{
|
||||
return false
|
||||
return Window.Maximized === window.visibility
|
||||
}
|
||||
icon : isRestore ? FluentIcons.FA_window_restore : FluentIcons.FA_window_maximize
|
||||
iconSource : isRestore ? FluentIcons.ChromeRestoreContrast : FluentIcons.ChromeMaximizeContrast
|
||||
color:hovered ? "#20000000" : "#00000000"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
visible: resizable
|
||||
@ -129,9 +129,10 @@ Rectangle{
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
icon : FluentIcons.FA_close
|
||||
iconSource : FluentIcons.ChromeCloseContrast
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text:"关闭"
|
||||
iconSize: 13
|
||||
textColor: root.textColor
|
||||
color:hovered ? "#20000000" : "#00000000"
|
||||
onClicked: {
|
||||
|
@ -7,6 +7,8 @@ TextField{
|
||||
property var values:[]
|
||||
property int fontStyle: FluText.Body
|
||||
property int pixelSize : FluTheme.textSize
|
||||
property int iconSource: -1
|
||||
signal itemClicked(string data)
|
||||
|
||||
id:input
|
||||
width: 300
|
||||
@ -18,14 +20,29 @@ TextField{
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
}
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
placeholderTextColor: {
|
||||
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(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
|
||||
}
|
||||
rightPadding: 30
|
||||
rightPadding: icon_right.visible ? 50 : 30
|
||||
selectByMouse: true
|
||||
|
||||
Keys.onUpPressed: {
|
||||
list_view.currentIndex = Math.max(list_view.currentIndex-1,0)
|
||||
}
|
||||
|
||||
Keys.onDownPressed: {
|
||||
list_view.currentIndex = Math.min(list_view.currentIndex+1,list_view.count-1)
|
||||
}
|
||||
|
||||
signal handleClicked
|
||||
Keys.onEnterPressed:handleClicked()
|
||||
Keys.onReturnPressed:handleClicked()
|
||||
|
||||
|
||||
font.bold: {
|
||||
switch (fontStyle) {
|
||||
case FluText.Display:
|
||||
@ -74,8 +91,8 @@ TextField{
|
||||
inputItem: input
|
||||
|
||||
FluIconButton{
|
||||
icon:FluentIcons.FA_close
|
||||
iconSize: 14
|
||||
iconSource:FluentIcons.ChromeClose
|
||||
iconSize: 10
|
||||
width: 20
|
||||
height: 20
|
||||
opacity: 0.5
|
||||
@ -83,12 +100,25 @@ TextField{
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
right: parent.right
|
||||
rightMargin: 5
|
||||
rightMargin: icon_right.visible ? 25 : 5
|
||||
}
|
||||
onClicked:{
|
||||
input.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
FluIcon{
|
||||
id:icon_right
|
||||
iconSource: input.iconSource
|
||||
iconSize: 15
|
||||
opacity: 0.5
|
||||
visible: input.iconSource != -1
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
right: parent.right
|
||||
rightMargin: 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
@ -102,13 +132,18 @@ TextField{
|
||||
onClosed: {
|
||||
input.focus = false
|
||||
}
|
||||
onVisibleChanged: {
|
||||
if(visible){
|
||||
list_view.currentIndex = -1
|
||||
}
|
||||
}
|
||||
background: Rectangle{
|
||||
width: input.width
|
||||
radius: 4
|
||||
FluShadow{
|
||||
radius: 4
|
||||
}
|
||||
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(243/255,241/255,240/255,1)
|
||||
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
||||
height: 38*Math.min(Math.max(list_view.count,1),8)
|
||||
ListView{
|
||||
id:list_view
|
||||
@ -116,6 +151,7 @@ TextField{
|
||||
anchors.fill: parent
|
||||
boundsBehavior: ListView.StopAtBounds
|
||||
clip: true
|
||||
currentIndex: -1
|
||||
header: Item{
|
||||
width: input.width
|
||||
height: visible ? 38 : 0
|
||||
@ -130,39 +166,81 @@ TextField{
|
||||
}
|
||||
}
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
delegate: Item{
|
||||
height: 38
|
||||
delegate:Control{
|
||||
width: input.width
|
||||
Rectangle{
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 2
|
||||
anchors.bottomMargin: 2
|
||||
padding:10
|
||||
background: Rectangle{
|
||||
color: {
|
||||
if(item_mouse.containsMouse){
|
||||
return FluTheme.isDark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(234/255,234/255,234/255,1)
|
||||
if(list_view.currentIndex === index){
|
||||
return FluTheme.isDark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(243/255,241/255,240/255,1)
|
||||
if(hovered){
|
||||
return FluTheme.isDark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0)
|
||||
}
|
||||
radius: 3
|
||||
MouseArea{
|
||||
id:item_mouse
|
||||
id:mouse_area
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
Connections{
|
||||
target: input
|
||||
function onHandleClicked(){
|
||||
if((list_view.currentIndex === index)){
|
||||
mouse_area.handleClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
onClicked: handleClick()
|
||||
function handleClick(){
|
||||
input_popup.close()
|
||||
input.itemClicked(modelData)
|
||||
input.text = modelData
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:modelData
|
||||
Rectangle{
|
||||
width: 3
|
||||
color:FluTheme.primaryColor.dark
|
||||
visible: list_view.currentIndex === index
|
||||
radius: 3
|
||||
height: 20
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
leftMargin: 10
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
contentItem: FluText{
|
||||
text:modelData
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Item{
|
||||
// height: 38
|
||||
// width: input.width
|
||||
// Rectangle{
|
||||
// anchors.fill: parent
|
||||
// anchors.topMargin: 2
|
||||
// anchors.bottomMargin: 2
|
||||
// anchors.leftMargin: 5
|
||||
// anchors.rightMargin: 5
|
||||
|
||||
// radius: 3
|
||||
// MouseArea{
|
||||
// id:item_mouse
|
||||
// anchors.fill: parent
|
||||
// hoverEnabled: true
|
||||
// onClicked: {
|
||||
// input_popup.close()
|
||||
// input.itemClicked(modelData)
|
||||
// input.text = modelData
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,6 +251,10 @@ TextField{
|
||||
|
||||
function searchData(){
|
||||
var result = []
|
||||
if(values==null){
|
||||
list_view.model = result
|
||||
return
|
||||
}
|
||||
values.map(function(item){
|
||||
if(item.indexOf(input.text)!==-1){
|
||||
result.push(item)
|
||||
|
@ -1,47 +1,44 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Rectangle {
|
||||
id: button
|
||||
Button {
|
||||
|
||||
property string text: "Standard Button"
|
||||
property int startPadding : 15
|
||||
property int endPadding : 15
|
||||
property int topPadding: 5
|
||||
property int bottomPadding: 5
|
||||
property bool disabled: false
|
||||
property color primaryColor : "#0064B0"
|
||||
signal clicked
|
||||
radius: 4
|
||||
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)
|
||||
|
||||
color:{
|
||||
if(FluTheme.isDark){
|
||||
id: control
|
||||
topPadding:5
|
||||
bottomPadding:5
|
||||
leftPadding:15
|
||||
rightPadding:15
|
||||
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 Qt.rgba(59/255,59/255,59/255,1)
|
||||
return disableColor
|
||||
}
|
||||
return button_mouse.containsMouse ? "#444444" : "#3e3e3e"
|
||||
}else{
|
||||
if(disabled){
|
||||
return Qt.rgba(252/255,252/255,252/255,1)
|
||||
}
|
||||
return button_mouse.containsMouse ? "#FBFBFB" : "#FFFFFF"
|
||||
return hovered ? hoverColor :normalColor
|
||||
}
|
||||
}
|
||||
width: button_text.implicitWidth
|
||||
height: button_text.implicitHeight
|
||||
|
||||
border.color: FluTheme.isDark ? "#505050" : "#DFDFDF"
|
||||
border.width: 1
|
||||
|
||||
|
||||
FluText {
|
||||
id: button_text
|
||||
text: button.text
|
||||
leftPadding: button.startPadding
|
||||
rightPadding: button.endPadding
|
||||
topPadding: button.topPadding
|
||||
bottomPadding: button.bottomPadding
|
||||
contentItem: FluText {
|
||||
text: control.text
|
||||
anchors.centerIn: parent
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if(disabled){
|
||||
@ -56,14 +53,4 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id:button_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: !disabled
|
||||
onClicked: {
|
||||
button.clicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
src/controls/FluCalendarDatePicker.qml
Normal file
5
src/controls/FluCalendarDatePicker.qml
Normal file
@ -0,0 +1,5 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
Item {
|
||||
|
||||
}
|
5
src/controls/FluCalenderView.qml
Normal file
5
src/controls/FluCalenderView.qml
Normal file
@ -0,0 +1,5 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
Item {
|
||||
|
||||
}
|
@ -1,35 +1,45 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
|
||||
id:root
|
||||
property bool checked: false
|
||||
property string text: "Check Box"
|
||||
property var checkClicked
|
||||
property bool hovered: mouse_area.containsMouse
|
||||
Button {
|
||||
|
||||
property bool selected: false
|
||||
property var clickFunc
|
||||
property bool disabled: false
|
||||
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
property color borderNormalColor: FluTheme.isDark ? Qt.rgba(160/255,160/255,160/255,1) : Qt.rgba(136/255,136/255,136/255,1)
|
||||
property color borderCheckedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
property color borderSelectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
property color borderHoverColor: FluTheme.isDark ? Qt.rgba(167/255,167/255,167/255,1) : Qt.rgba(135/255,135/255,135/255,1)
|
||||
property color borderDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
|
||||
|
||||
property color normalColor: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||
property color checkedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
property color selectedColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(244/255,244/255,244/255,1)
|
||||
property color checkedHoverColor: FluTheme.isDark ? Qt.darker(checkedColor,1.1) : Qt.lighter(checkedColor,1.1)
|
||||
|
||||
property color checkedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
|
||||
|
||||
property color selectedHoverColor: FluTheme.isDark ? Qt.darker(selectedColor,1.1) : Qt.lighter(selectedColor,1.1)
|
||||
property color selectedDisableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
|
||||
property color disableColor: FluTheme.isDark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1)
|
||||
|
||||
RowLayout{
|
||||
id:control
|
||||
enabled: !disabled
|
||||
focusPolicy:Qt.TabFocus
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
padding:0
|
||||
onClicked: {
|
||||
if(disabled){
|
||||
return
|
||||
}
|
||||
if(clickFunc){
|
||||
clickFunc()
|
||||
return
|
||||
}
|
||||
selected = !selected
|
||||
}
|
||||
background: Item{
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
}
|
||||
}
|
||||
contentItem: RowLayout{
|
||||
spacing: 4
|
||||
Rectangle{
|
||||
width: 20
|
||||
@ -39,8 +49,8 @@ Item {
|
||||
if(disabled){
|
||||
return borderDisableColor
|
||||
}
|
||||
if(checked){
|
||||
return borderCheckedColor
|
||||
if(selected){
|
||||
return borderSelectedColor
|
||||
}
|
||||
if(hovered){
|
||||
return borderHoverColor
|
||||
@ -49,47 +59,30 @@ Item {
|
||||
}
|
||||
border.width: 1
|
||||
color: {
|
||||
if(checked){
|
||||
if(selected){
|
||||
if(disabled){
|
||||
return checkedDisableColor
|
||||
return selectedDisableColor
|
||||
}
|
||||
if(hovered){
|
||||
return checkedHoverColor
|
||||
return selectedHoverColor
|
||||
}
|
||||
return checkedColor
|
||||
return selectedColor
|
||||
}
|
||||
if(hovered){
|
||||
return hoverColor
|
||||
}
|
||||
return normalColor
|
||||
}
|
||||
|
||||
FluIcon {
|
||||
anchors.centerIn: parent
|
||||
icon: FluentIcons.FA_check
|
||||
iconSource: FluentIcons.AcceptMedium
|
||||
iconSize: 15
|
||||
visible: checked
|
||||
visible: selected
|
||||
color: FluTheme.isDark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:root.text
|
||||
text:control.text
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MouseArea{
|
||||
id:mouse_area
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: !disabled
|
||||
onClicked: {
|
||||
if(checkClicked){
|
||||
checkClicked()
|
||||
return
|
||||
}
|
||||
checked = !checked
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
397
src/controls/FluDatePicker.qml
Normal file
397
src/controls/FluDatePicker.qml
Normal file
@ -0,0 +1,397 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
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 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
|
||||
|
||||
property bool showYear: true
|
||||
|
||||
color: {
|
||||
if(mouse_area.containsMouse){
|
||||
return hoverColor
|
||||
}
|
||||
return normalColor
|
||||
}
|
||||
height: 30
|
||||
width: 300
|
||||
radius: 4
|
||||
border.width: 1
|
||||
border.color: dividerColor
|
||||
|
||||
MouseArea{
|
||||
id:mouse_area
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
popup.showPopup()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:divider_1
|
||||
width: 1
|
||||
x: parent.width/3
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
visible: showYear
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
id:divider_2
|
||||
width: 1
|
||||
x: showYear ? parent.width*2/3 : parent.width/2
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
}
|
||||
|
||||
FluText{
|
||||
id:text_year
|
||||
anchors{
|
||||
left: parent.left
|
||||
right: divider_1.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
visible: showYear
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"年"
|
||||
}
|
||||
|
||||
|
||||
FluText{
|
||||
id:text_month
|
||||
anchors{
|
||||
left: showYear ? divider_1.right : parent.left
|
||||
right: divider_2.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"月"
|
||||
}
|
||||
|
||||
|
||||
FluText{
|
||||
id:text_day
|
||||
anchors{
|
||||
left: divider_2.right
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"日"
|
||||
}
|
||||
|
||||
Popup{
|
||||
id:popup
|
||||
background: Rectangle{
|
||||
width: 300
|
||||
radius: 4
|
||||
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
||||
height: 340
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
}
|
||||
FluShadow{
|
||||
radius: 4
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
id:layout_content
|
||||
spacing: 0
|
||||
width: parent.width
|
||||
height: 300
|
||||
|
||||
Component{
|
||||
id:list_delegate
|
||||
|
||||
Item{
|
||||
height:38
|
||||
width:getListView().width
|
||||
|
||||
function getListView(){
|
||||
if(type === 0)
|
||||
return list_view_1
|
||||
if(type === 1)
|
||||
return list_view_2
|
||||
if(type === 2)
|
||||
return list_view_3
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 2
|
||||
anchors.bottomMargin: 2
|
||||
anchors.leftMargin: 5
|
||||
anchors.rightMargin: 5
|
||||
color: {
|
||||
if(getListView().currentIndex === position){
|
||||
if(FluTheme.isDark){
|
||||
return item_mouse.containsMouse ? Qt.darker(FluTheme.primaryColor.lighter,1.1) : FluTheme.primaryColor.lighter
|
||||
}else{
|
||||
return item_mouse.containsMouse ? Qt.lighter(FluTheme.primaryColor.dark,1.1): FluTheme.primaryColor.dark
|
||||
}
|
||||
}
|
||||
if(item_mouse.containsMouse){
|
||||
return FluTheme.isDark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0)
|
||||
}
|
||||
radius: 3
|
||||
MouseArea{
|
||||
id:item_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
getListView().currentIndex = position
|
||||
if(type === 0){
|
||||
text_year.text = model
|
||||
list_view_2.model = generateMonthArray(1,12)
|
||||
text_month.text = list_view_2.model[list_view_2.currentIndex]
|
||||
|
||||
list_view_3.model = generateMonthDaysArray(list_view_1.model[list_view_1.currentIndex],list_view_2.model[list_view_2.currentIndex])
|
||||
text_day.text = list_view_3.model[list_view_3.currentIndex]
|
||||
}
|
||||
if(type === 1){
|
||||
text_month.text = model
|
||||
list_view_3.model = generateMonthDaysArray(list_view_1.model[list_view_1.currentIndex],list_view_2.model[list_view_2.currentIndex])
|
||||
text_day.text = list_view_3.model[list_view_3.currentIndex]
|
||||
|
||||
}
|
||||
if(type === 2){
|
||||
text_day.text = model
|
||||
}
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:model
|
||||
color: {
|
||||
if(getListView().currentIndex === position){
|
||||
if(FluTheme.isDark){
|
||||
return Qt.rgba(0,0,0,1)
|
||||
}else{
|
||||
return Qt.rgba(1,1,1,1)
|
||||
}
|
||||
}else{
|
||||
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
}
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView{
|
||||
id:list_view_1
|
||||
width: 100
|
||||
height: parent.height
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
model: generateYearArray(1924,2048)
|
||||
clip: true
|
||||
visible: showYear
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:0
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
if(currentIndex!==-1){
|
||||
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 1
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
}
|
||||
ListView{
|
||||
id:list_view_2
|
||||
width: showYear ? 100 : 150
|
||||
height: parent.height
|
||||
clip: true
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:1
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
if(currentIndex!==-1){
|
||||
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 1
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
}
|
||||
ListView{
|
||||
id:list_view_3
|
||||
width: showYear ? 100 : 150
|
||||
height: parent.height
|
||||
clip: true
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:2
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.width
|
||||
height: 1
|
||||
anchors.top: layout_content.bottom
|
||||
color: dividerColor
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:layout_actions
|
||||
height: 40
|
||||
radius: 5
|
||||
color: FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
|
||||
anchors{
|
||||
bottom:parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
Item {
|
||||
id:divider
|
||||
width: 1
|
||||
height: parent.height
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
FluButton{
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: 20
|
||||
rightMargin: 10
|
||||
right: divider.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: "取消"
|
||||
onClicked: {
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
||||
FluFilledButton{
|
||||
anchors{
|
||||
right: parent.right
|
||||
left: divider.right
|
||||
rightMargin: 20
|
||||
leftMargin: 10
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: "确定"
|
||||
onClicked: {
|
||||
changeFlag = false
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
y:35
|
||||
function showPopup() {
|
||||
changeFlag = true
|
||||
rowData[0] = text_year.text
|
||||
rowData[1] = text_month.text
|
||||
rowData[2] = text_day.text
|
||||
|
||||
const now = new Date();
|
||||
var year = text_year.text === "年"? now.getFullYear() : Number(text_year.text);
|
||||
var month = text_month.text === "月"? now.getMonth() + 1 : Number(text_month.text);
|
||||
var day = text_day.text === "日" ? now.getDate() : Number(text_day.text);
|
||||
|
||||
list_view_1.currentIndex = list_view_1.model.indexOf(year)
|
||||
text_year.text = year
|
||||
|
||||
list_view_2.model = generateMonthArray(1,12)
|
||||
list_view_2.currentIndex = list_view_2.model.indexOf(month)
|
||||
text_month.text = month
|
||||
|
||||
list_view_3.model = generateMonthDaysArray(year,month)
|
||||
list_view_3.currentIndex = list_view_3.model.indexOf(day)
|
||||
text_day.text = day
|
||||
|
||||
var pos = root.mapToItem(null, 0, 0)
|
||||
if(window.height>pos.y+35+340){
|
||||
popup.y = 35
|
||||
}else{
|
||||
popup.y = window.height-(pos.y+340)
|
||||
}
|
||||
popup.open()
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
if(changeFlag){
|
||||
text_year.text = rowData[0]
|
||||
text_month.text = rowData[1]
|
||||
text_day.text = rowData[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property bool changeFlag: true
|
||||
readonly property var rowData: ["","",""]
|
||||
|
||||
function generateYearArray(startYear, endYear) {
|
||||
const yearArray = [];
|
||||
for (let year = startYear; year <= endYear; year++) {
|
||||
yearArray.push(year);
|
||||
}
|
||||
return yearArray;
|
||||
}
|
||||
|
||||
function generateMonthArray(startMonth, endMonth) {
|
||||
const monthArray = [];
|
||||
for (let month = startMonth; month <= endMonth; month++) {
|
||||
monthArray.push(month);
|
||||
}
|
||||
return monthArray;
|
||||
}
|
||||
|
||||
function generateMonthDaysArray(year, month) {
|
||||
const monthDaysArray = [];
|
||||
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
||||
for (let day = 1; day <= lastDayOfMonth; day++) {
|
||||
monthDaysArray.push(day);
|
||||
}
|
||||
return monthDaysArray;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -3,6 +3,6 @@ import FluentUI 1.0
|
||||
|
||||
Rectangle {
|
||||
|
||||
color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(238/255,238/255,238/255,1)
|
||||
color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,230/255,234/255,1)
|
||||
|
||||
}
|
||||
|
@ -22,9 +22,8 @@ Item {
|
||||
width: parent.width
|
||||
height: 45
|
||||
radius: 4
|
||||
border.color: FluTheme.isDark ? Qt.rgba(53/255,53/255,53/255,1) : Qt.rgba(240/255,240/255,240/255,1)
|
||||
color: FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||
|
||||
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)
|
||||
|
||||
MouseArea{
|
||||
id:root_mouse
|
||||
@ -50,10 +49,14 @@ Item {
|
||||
right: parent.right
|
||||
rightMargin: 15
|
||||
}
|
||||
hoverColor: FluTheme.isDark ? Qt.rgba(73/255,73/255,73/255,1) : Qt.rgba(245/255,245/255,245/255,1)
|
||||
normalColor: FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||
hovered: root_mouse.containsMouse
|
||||
icon: expand ? FluentIcons.FA_angle_up : FluentIcons.FA_angle_down
|
||||
color:{
|
||||
if(root_mouse.containsMouse){
|
||||
return FluTheme.isDark ? Qt.rgba(73/255,73/255,73/255,1) : Qt.rgba(245/255,245/255,245/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
|
||||
iconSource: expand ? FluentIcons.ChevronUp : FluentIcons.ChevronDown
|
||||
onClicked: {
|
||||
expand = !expand
|
||||
}
|
||||
@ -71,8 +74,8 @@ Item {
|
||||
left: layout_header.left
|
||||
}
|
||||
radius: 4
|
||||
border.color: FluTheme.isDark ? Qt.rgba(53/255,53/255,53/255,1) : Qt.rgba(240/255,240/255,240/255,1)
|
||||
color: FluTheme.isDark ? Qt.rgba(57/255,57/255,57/255,1) : Qt.rgba(249/255,249/255,249/255,1)
|
||||
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)
|
||||
height: expand ? contentHeight : 0
|
||||
Behavior on height {
|
||||
NumberAnimation{
|
||||
|
@ -2,37 +2,38 @@
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Rectangle {
|
||||
id: button
|
||||
Button {
|
||||
id: control
|
||||
|
||||
property string text: "Filled Button"
|
||||
property int startPadding : 15
|
||||
property int endPadding : 15
|
||||
property int topPadding: 5
|
||||
property int bottomPadding: 5
|
||||
property bool disabled: false
|
||||
property color normalColor: FluTheme.isDark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark
|
||||
property color hoverColor: FluTheme.isDark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
|
||||
property color disableColor: FluTheme.isDark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
|
||||
|
||||
signal clicked
|
||||
radius: 4
|
||||
color:{
|
||||
if(FluTheme.isDark){
|
||||
enabled: !disabled
|
||||
topPadding:5
|
||||
bottomPadding:5
|
||||
leftPadding:15
|
||||
rightPadding:15
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
focusPolicy:Qt.TabFocus
|
||||
background: Rectangle{
|
||||
radius: 4
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
radius:8
|
||||
}
|
||||
color:{
|
||||
if(disabled){
|
||||
return Qt.rgba(199/255,199/255,199/255,1)
|
||||
return disableColor
|
||||
}
|
||||
return button_mouse.containsMouse ? Qt.darker(FluTheme.primaryColor.lighter,1.1) : FluTheme.primaryColor.lighter
|
||||
}else{
|
||||
if(disabled){
|
||||
return Qt.rgba(199/255,199/255,199/255,1)
|
||||
}
|
||||
return button_mouse.containsMouse ? Qt.lighter(FluTheme.primaryColor.dark,1.1): FluTheme.primaryColor.dark
|
||||
return hovered ? hoverColor :normalColor
|
||||
}
|
||||
}
|
||||
width: button_text.implicitWidth
|
||||
height: button_text.implicitHeight
|
||||
|
||||
FluText {
|
||||
id: button_text
|
||||
text: button.text
|
||||
contentItem: FluText {
|
||||
text: control.text
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if(disabled){
|
||||
@ -44,21 +45,5 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
font.pixelSize: 14
|
||||
leftPadding: button.startPadding
|
||||
rightPadding: button.endPadding
|
||||
topPadding: button.topPadding
|
||||
bottomPadding: button.bottomPadding
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id:button_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
if(disabled)
|
||||
return
|
||||
button.clicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
src/controls/FluFocusRectangle.qml
Normal file
22
src/controls/FluFocusRectangle.qml
Normal file
@ -0,0 +1,22 @@
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
id:root
|
||||
anchors.fill: parent
|
||||
anchors.margins: -3
|
||||
|
||||
property var radius: 4
|
||||
|
||||
Rectangle{
|
||||
width: root.width
|
||||
height: root.height
|
||||
anchors.centerIn: parent
|
||||
color: "#00000000"
|
||||
border.width: 3
|
||||
radius: root.radius
|
||||
border.color: FluTheme.isDark ? Qt.rgba(1,1,1,1) : Qt.rgba(0,0,0,1)
|
||||
z: 65535
|
||||
}
|
||||
|
||||
}
|
@ -2,15 +2,15 @@
|
||||
|
||||
Text {
|
||||
|
||||
property int icon
|
||||
property int iconSource
|
||||
property int iconSize: 20
|
||||
property color iconColor: FluTheme.isDark ? "#FFFFFF" : "#000000"
|
||||
|
||||
id:text_icon
|
||||
font.family: "fontawesome"
|
||||
font.family: "Segoe Fluent Icons"
|
||||
font.pixelSize: iconSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: iconColor
|
||||
text: (String.fromCharCode(icon).toString(16));
|
||||
text: (String.fromCharCode(iconSource).toString(16));
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Rectangle {
|
||||
|
||||
id:button
|
||||
width: 30
|
||||
height: 30
|
||||
Button {
|
||||
|
||||
property int iconSize: 20
|
||||
property int icon
|
||||
property alias text: tool_tip.text
|
||||
signal clicked
|
||||
property int iconSource
|
||||
property bool disabled: false
|
||||
property bool hovered: button_mouse.containsMouse
|
||||
|
||||
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03)
|
||||
property color normalColor: FluTheme.isDark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
|
||||
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(0,0,0,0)
|
||||
|
||||
property color color: {
|
||||
if(disabled){
|
||||
return disableColor
|
||||
}
|
||||
return hovered ? hoverColor : normalColor
|
||||
}
|
||||
property color textColor: {
|
||||
if(FluTheme.isDark){
|
||||
if(disabled){
|
||||
@ -31,45 +29,46 @@ Rectangle {
|
||||
return Qt.rgba(0,0,0,1)
|
||||
}
|
||||
}
|
||||
radius: 4
|
||||
|
||||
color: {
|
||||
if(disabled){
|
||||
return disableColor
|
||||
}
|
||||
return (hovered || button_mouse.containsMouse) ? hoverColor : normalColor
|
||||
}
|
||||
|
||||
Text {
|
||||
id:text_icon
|
||||
font.family: "fontawesome"
|
||||
font.pixelSize: iconSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.centerIn: parent
|
||||
color:button.textColor
|
||||
text: (String.fromCharCode(icon).toString(16));
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
id:button_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: !disabled
|
||||
onClicked: {
|
||||
button.clicked()
|
||||
id:control
|
||||
width: 30
|
||||
height: 30
|
||||
implicitWidth: width
|
||||
implicitHeight: height
|
||||
padding: 0
|
||||
enabled: !disabled
|
||||
focusPolicy:Qt.TabFocus
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
background: Rectangle{
|
||||
radius: 4
|
||||
color:control.color
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
}
|
||||
}
|
||||
|
||||
FluTooltip{
|
||||
id:tool_tip
|
||||
visible: {
|
||||
if(button.text === ""){
|
||||
return false
|
||||
contentItem: Item{
|
||||
Text {
|
||||
id:text_icon
|
||||
font.family: "Segoe Fluent Icons"
|
||||
font.pixelSize: iconSize
|
||||
width: iconSize
|
||||
height: iconSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
anchors.centerIn: parent
|
||||
color:control.textColor
|
||||
text: (String.fromCharCode(iconSource).toString(16));
|
||||
}
|
||||
FluTooltip{
|
||||
id:tool_tip
|
||||
visible: {
|
||||
if(control.text === ""){
|
||||
return false
|
||||
}
|
||||
return hovered
|
||||
}
|
||||
return (hovered || button_mouse.containsMouse)
|
||||
text:control.text
|
||||
delay: 1000
|
||||
}
|
||||
delay: 1000
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -190,13 +190,13 @@ FluObject {
|
||||
spacing: 10
|
||||
|
||||
FluIcon{
|
||||
icon:{
|
||||
iconSource:{
|
||||
switch(_super.type){
|
||||
case mcontrol.const_success: return FluentIcons.FA_check_circle;
|
||||
case mcontrol.const_warning: return FluentIcons.FA_info_circle;
|
||||
case mcontrol.const_info: return FluentIcons.FA_info_circle;
|
||||
case mcontrol.const_error: return FluentIcons.FA_times_circle;
|
||||
}
|
||||
case mcontrol.const_success: return FluentIcons.CompletedSolid;
|
||||
case mcontrol.const_warning: return FluentIcons.InfoSolid;
|
||||
case mcontrol.const_info: return FluentIcons.InfoSolid;
|
||||
case mcontrol.const_error: return FluentIcons.StatusErrorFull;
|
||||
}FluentIcons.StatusErrorFull
|
||||
return FluentIcons.FA_info_circle
|
||||
}
|
||||
iconSize:20
|
||||
|
@ -11,6 +11,7 @@ TextArea{
|
||||
width: 300
|
||||
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
wrapMode: Text.WrapAnywhere
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
selectByMouse: true
|
||||
selectionColor: {
|
||||
if(FluTheme.isDark){
|
||||
|
@ -105,11 +105,11 @@ Item {
|
||||
}
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if((nav_list.currentIndex === position)&&type===0){
|
||||
return "#2D2D2D"
|
||||
}
|
||||
if(item_mouse.containsMouse){
|
||||
return "#292929"
|
||||
return Qt.rgba(1,1,1,0.03)
|
||||
}
|
||||
if((nav_list.currentIndex === position)&&type===0){
|
||||
return Qt.rgba(1,1,1,0.06)
|
||||
}
|
||||
return Qt.rgba(0,0,0,0)
|
||||
}else{
|
||||
@ -145,10 +145,11 @@ Item {
|
||||
height:parent.height
|
||||
spacing: 0
|
||||
FluIconButton{
|
||||
icon: FluentIcons.FA_arrow_left
|
||||
iconSource: FluentIcons.ChromeBack
|
||||
Layout.leftMargin: 5
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
disabled: nav_swipe.depth === 1
|
||||
iconSize: 13
|
||||
onClicked: {
|
||||
nav_swipe.pop()
|
||||
nav_list.stackIndex.pop()
|
||||
@ -159,8 +160,9 @@ Item {
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
icon: FluentIcons.FA_navicon
|
||||
iconSource: FluentIcons.GlobalNavButton
|
||||
Layout.leftMargin: 5
|
||||
iconSize: 15
|
||||
visible: displayMode === FluNavigationView.Minimal
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
onClicked: {
|
||||
@ -182,8 +184,8 @@ Item {
|
||||
fontStyle: FluText.Body
|
||||
}
|
||||
FluToggleSwitch{
|
||||
checked: FluTheme.isDark
|
||||
onClickFunc:function(){
|
||||
selected: FluTheme.isDark
|
||||
clickFunc:function(){
|
||||
FluTheme.isDark = !FluTheme.isDark
|
||||
}
|
||||
}
|
||||
@ -193,7 +195,7 @@ Item {
|
||||
Item{
|
||||
anchors{
|
||||
left: displayMode === FluNavigationView.Minimal ? parent.left : layout_list.right
|
||||
leftMargin: 2
|
||||
leftMargin: 10
|
||||
top: nav_app_bar.bottom
|
||||
right: parent.right
|
||||
rightMargin: 10
|
||||
@ -205,10 +207,13 @@ Item {
|
||||
id:nav_swipe
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
anchors.margins: 10
|
||||
popEnter : Transition{}
|
||||
popExit : Transition{}
|
||||
pushEnter : Transition{}
|
||||
popExit : Transition {
|
||||
NumberAnimation { properties: "y"; from: 0; to: nav_swipe.height; duration: 200 }
|
||||
}
|
||||
pushEnter: Transition {
|
||||
NumberAnimation { properties: "y"; from: nav_swipe.height; to: 0; duration: 200 }
|
||||
}
|
||||
pushExit : Transition{}
|
||||
replaceEnter : Transition{}
|
||||
replaceExit : Transition{}
|
||||
@ -255,13 +260,58 @@ Item {
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
|
||||
Item{
|
||||
id:layout_header
|
||||
width: layout_list.width
|
||||
height: 50
|
||||
|
||||
FluAutoSuggestBox{
|
||||
width: 280
|
||||
anchors.centerIn: parent
|
||||
iconSource: FluentIcons.Zoom
|
||||
values: {
|
||||
var arr = []
|
||||
if(items==null)
|
||||
return arr
|
||||
if(items.children==null)
|
||||
return arr
|
||||
for(var i=0;i<items.children.length;i++){
|
||||
var item = items.children[i]
|
||||
if(item instanceof FluPaneItem){
|
||||
arr.push(item.title)
|
||||
}
|
||||
}
|
||||
return arr
|
||||
}
|
||||
placeholderText: "查找"
|
||||
onItemClicked:
|
||||
(data)=>{
|
||||
var arr = []
|
||||
if(items==null)
|
||||
return arr
|
||||
if(items.children==null)
|
||||
return arr
|
||||
for(var i=0;i<items.children.length;i++){
|
||||
if(items.children[i].title === data){
|
||||
if(nav_list.currentIndex === i){
|
||||
return
|
||||
}
|
||||
items.children[i].tap()
|
||||
nav_list.currentIndex = i
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ListView{
|
||||
id:nav_list
|
||||
property bool enableStack: true
|
||||
property var stackIndex: []
|
||||
clip: true
|
||||
anchors{
|
||||
top: parent.top
|
||||
top: layout_header.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: layout_footer.top
|
||||
|
@ -1,19 +1,25 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import FluentUI 1.0
|
||||
|
||||
|
||||
Item {
|
||||
Button {
|
||||
|
||||
id:root
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
property bool checked: false
|
||||
property string text: "RodioButton"
|
||||
signal clicked
|
||||
property bool selected: false
|
||||
property bool disabled: false
|
||||
|
||||
RowLayout{
|
||||
id:control
|
||||
enabled: !disabled
|
||||
focusPolicy:Qt.TabFocus
|
||||
padding:0
|
||||
background: Item{
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
}
|
||||
}
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
contentItem: RowLayout{
|
||||
Rectangle{
|
||||
id:rect_check
|
||||
width: 20
|
||||
@ -23,22 +29,22 @@ Item {
|
||||
layer.enabled: true
|
||||
layer.smooth: true
|
||||
border.width: {
|
||||
if(checked&&disabled){
|
||||
if(selected&&disabled){
|
||||
return 3
|
||||
}
|
||||
if(root_mouse.containsPress){
|
||||
if(checked){
|
||||
if(hovered){
|
||||
if(selected){
|
||||
return 5
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if(root_mouse.containsMouse){
|
||||
if(checked){
|
||||
if(hovered){
|
||||
if(selected){
|
||||
return 3
|
||||
}
|
||||
return 1
|
||||
}
|
||||
return checked ? 5 : 1
|
||||
return selected ? 5 : 1
|
||||
}
|
||||
Behavior on border.width {
|
||||
NumberAnimation{
|
||||
@ -53,7 +59,7 @@ Item {
|
||||
return Qt.rgba(198/255,198/255,198/255,1)
|
||||
}
|
||||
}
|
||||
if(checked){
|
||||
if(selected){
|
||||
if(FluTheme.isDark){
|
||||
return FluTheme.primaryColor.lighter
|
||||
}else{
|
||||
@ -70,17 +76,17 @@ Item {
|
||||
}
|
||||
}
|
||||
color:{
|
||||
if(disabled&&checked){
|
||||
if(disabled&&selected){
|
||||
return Qt.rgba(159/255,159/255,159/255,1)
|
||||
}
|
||||
if(FluTheme.isDark){
|
||||
if(root_mouse.containsMouse){
|
||||
if(hovered){
|
||||
return Qt.rgba(43/255,43/255,43/255,1)
|
||||
}
|
||||
return Qt.rgba(50/255,50/255,50/255,1)
|
||||
}else{
|
||||
if(root_mouse.containsMouse){
|
||||
if(checked){
|
||||
if(hovered){
|
||||
if(selected){
|
||||
return Qt.rgba(1,1,1,1)
|
||||
}
|
||||
return Qt.rgba(222/255,222/255,222/255,1)
|
||||
@ -89,23 +95,10 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FluText{
|
||||
text: root.text
|
||||
text: control.text
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
id:root_mouse
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
enabled: !disabled
|
||||
onClicked: {
|
||||
root.clicked()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ Item{
|
||||
|
||||
property int lineSize: 5
|
||||
property int size: 180
|
||||
property int dotSize: 26
|
||||
property int dotSize: 28
|
||||
|
||||
property int value: 50
|
||||
|
||||
|
@ -20,6 +20,7 @@ Text {
|
||||
|
||||
id:text
|
||||
color: textColor
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
font.bold: {
|
||||
switch (fontStyle) {
|
||||
case FluText.Display:
|
||||
|
@ -10,6 +10,7 @@ TextField{
|
||||
id:input
|
||||
width: 300
|
||||
color: FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
renderType: FluTheme.isNativeText ? Text.NativeRendering : Text.QtRendering
|
||||
selectionColor: {
|
||||
if(FluTheme.isDark){
|
||||
return FluTheme.primaryColor.lighter
|
||||
|
@ -1,8 +1,391 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Shapes 1.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
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 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
|
||||
|
||||
property int hourFormat: FluTimePicker.H
|
||||
|
||||
property int isH: hourFormat === FluTimePicker.H
|
||||
|
||||
enum HourFormat {
|
||||
H,
|
||||
HH
|
||||
}
|
||||
|
||||
color: {
|
||||
if(mouse_area.containsMouse){
|
||||
return hoverColor
|
||||
}
|
||||
return normalColor
|
||||
}
|
||||
height: 30
|
||||
width: 300
|
||||
radius: 4
|
||||
border.width: 1
|
||||
border.color: dividerColor
|
||||
|
||||
MouseArea{
|
||||
id:mouse_area
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
popup.showPopup()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:divider_1
|
||||
width: 1
|
||||
x: isH ? parent.width/3 : parent.width/2
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
id:divider_2
|
||||
width: 1
|
||||
x:parent.width*2/3
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
visible: isH
|
||||
}
|
||||
|
||||
FluText{
|
||||
id:text_hour
|
||||
anchors{
|
||||
left: parent.left
|
||||
right: divider_1.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"时"
|
||||
}
|
||||
|
||||
|
||||
FluText{
|
||||
id:text_minute
|
||||
anchors{
|
||||
left: divider_1.right
|
||||
right: isH ? divider_2.left : parent.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"分"
|
||||
}
|
||||
|
||||
|
||||
FluText{
|
||||
id:text_ampm
|
||||
visible: isH
|
||||
anchors{
|
||||
left: divider_2.right
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text:"AM/PM"
|
||||
}
|
||||
|
||||
Popup{
|
||||
id:popup
|
||||
background: Rectangle{
|
||||
width: 300
|
||||
radius: 4
|
||||
color: FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
||||
height: 340
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
}
|
||||
FluShadow{
|
||||
radius: 4
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
id:layout_content
|
||||
spacing: 0
|
||||
width: parent.width
|
||||
height: 300
|
||||
|
||||
Component{
|
||||
id:list_delegate
|
||||
|
||||
Item{
|
||||
height:38
|
||||
width:getListView().width
|
||||
|
||||
function getListView(){
|
||||
if(type === 0)
|
||||
return list_view_1
|
||||
if(type === 1)
|
||||
return list_view_2
|
||||
if(type === 2)
|
||||
return list_view_3
|
||||
}
|
||||
|
||||
|
||||
Rectangle{
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 2
|
||||
anchors.bottomMargin: 2
|
||||
anchors.leftMargin: 5
|
||||
anchors.rightMargin: 5
|
||||
color: {
|
||||
if(getListView().currentIndex === position){
|
||||
if(FluTheme.isDark){
|
||||
return item_mouse.containsMouse ? Qt.darker(FluTheme.primaryColor.lighter,1.1) : FluTheme.primaryColor.lighter
|
||||
}else{
|
||||
return item_mouse.containsMouse ? Qt.lighter(FluTheme.primaryColor.dark,1.1): FluTheme.primaryColor.dark
|
||||
}
|
||||
}
|
||||
if(item_mouse.containsMouse){
|
||||
return FluTheme.isDark ? Qt.rgba(63/255,60/255,61/255,1) : Qt.rgba(237/255,237/255,242/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(0,0,0,0)
|
||||
}
|
||||
radius: 3
|
||||
MouseArea{
|
||||
id:item_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
getListView().currentIndex = position
|
||||
if(type === 0){
|
||||
text_hour.text = model
|
||||
}
|
||||
if(type === 1){
|
||||
text_minute.text = model
|
||||
}
|
||||
if(type === 2){
|
||||
text_ampm.text = model
|
||||
}
|
||||
}
|
||||
}
|
||||
FluText{
|
||||
text:model
|
||||
color: {
|
||||
if(getListView().currentIndex === position){
|
||||
if(FluTheme.isDark){
|
||||
return Qt.rgba(0,0,0,1)
|
||||
}else{
|
||||
return Qt.rgba(1,1,1,1)
|
||||
}
|
||||
}else{
|
||||
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
|
||||
}
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView{
|
||||
id:list_view_1
|
||||
width: isH ? 100 : 150
|
||||
height: parent.height
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
model: isH ? generateArray(1,12) : generateArray(0,23)
|
||||
clip: true
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:0
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 1
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
}
|
||||
ListView{
|
||||
id:list_view_2
|
||||
width: isH ? 100 : 150
|
||||
height: parent.height
|
||||
model: generateArray(0,59)
|
||||
clip: true
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:1
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
Rectangle{
|
||||
width: 1
|
||||
height: parent.height
|
||||
color: dividerColor
|
||||
visible: isH
|
||||
}
|
||||
ListView{
|
||||
id:list_view_3
|
||||
width: 100
|
||||
height: 76
|
||||
model: ["上午","下午"]
|
||||
clip: true
|
||||
visible: isH
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property int type:2
|
||||
property int position:index
|
||||
sourceComponent: list_delegate
|
||||
}
|
||||
onCurrentIndexChanged: {
|
||||
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
width: parent.width
|
||||
height: 1
|
||||
anchors.top: layout_content.bottom
|
||||
color: dividerColor
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:layout_actions
|
||||
height: 40
|
||||
radius: 5
|
||||
color: FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
|
||||
anchors{
|
||||
bottom:parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
Item {
|
||||
id:divider
|
||||
width: 1
|
||||
height: parent.height
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
FluButton{
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: 20
|
||||
rightMargin: 10
|
||||
right: divider.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: "取消"
|
||||
onClicked: {
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
||||
FluFilledButton{
|
||||
anchors{
|
||||
right: parent.right
|
||||
left: divider.right
|
||||
rightMargin: 20
|
||||
leftMargin: 10
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: "确定"
|
||||
onClicked: {
|
||||
changeFlag = false
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
y:35
|
||||
function showPopup() {
|
||||
changeFlag = true
|
||||
rowData[0] = text_hour.text
|
||||
rowData[1] = text_minute.text
|
||||
rowData[2] = text_ampm.text
|
||||
|
||||
var now = new Date();
|
||||
|
||||
var hour
|
||||
var ampm;
|
||||
if(isH){
|
||||
hour = now.getHours();
|
||||
if(hour>12){
|
||||
ampm = "下午"
|
||||
hour = hour-12
|
||||
}else{
|
||||
ampm = "上午"
|
||||
}
|
||||
}else{
|
||||
hour = now.getHours();
|
||||
}
|
||||
hour = text_hour.text === "时"? hour.toString().padStart(2, '0') : text_hour.text
|
||||
var minute = text_minute.text === "分"? now.getMinutes().toString().padStart(2, '0') : text_minute.text
|
||||
ampm = text_ampm.text === "AM/PM"?ampm:text_ampm.text
|
||||
list_view_1.currentIndex = list_view_1.model.indexOf(hour);
|
||||
list_view_2.currentIndex = list_view_2.model.indexOf(minute);
|
||||
list_view_3.currentIndex = list_view_3.model.indexOf(ampm);
|
||||
|
||||
text_hour.text = hour
|
||||
text_minute.text = minute
|
||||
if(isH){
|
||||
text_ampm.text = ampm
|
||||
}
|
||||
|
||||
var pos = root.mapToItem(null, 0, 0)
|
||||
if(window.height>pos.y+35+340){
|
||||
popup.y = 35
|
||||
}else{
|
||||
popup.y = window.height-(pos.y+340)
|
||||
}
|
||||
popup.open()
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
if(changeFlag){
|
||||
text_hour.text = rowData[0]
|
||||
text_minute.text = rowData[1]
|
||||
text_ampm.text = rowData[2]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
property bool changeFlag: true
|
||||
readonly property var rowData: ["","",""]
|
||||
|
||||
|
||||
function generateArray(start, n) {
|
||||
var arr = [];
|
||||
for (var i = start; i <= n; i++) {
|
||||
arr.push(i.toString().padStart(2, '0'));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,64 +2,66 @@
|
||||
import QtQuick.Controls 2.0
|
||||
import FluentUI 1.0
|
||||
|
||||
Switch {
|
||||
id: root
|
||||
property var onClickFunc
|
||||
Button {
|
||||
|
||||
property bool selected: false
|
||||
property var clickFunc
|
||||
|
||||
id: control
|
||||
width: 40
|
||||
implicitWidth: 40
|
||||
height: 20
|
||||
implicitHeight: 20
|
||||
checkable: false
|
||||
indicator: Rectangle {
|
||||
width: root.width
|
||||
height: root.height
|
||||
focusPolicy:Qt.TabFocus
|
||||
Keys.onSpacePressed: control.visualFocus&&clicked()
|
||||
onClicked: {
|
||||
if(clickFunc){
|
||||
clickFunc()
|
||||
return
|
||||
}
|
||||
selected = !selected
|
||||
}
|
||||
background : Rectangle {
|
||||
width: control.width
|
||||
height: control.height
|
||||
radius: height / 2
|
||||
FluFocusRectangle{
|
||||
visible: control.visualFocus
|
||||
radius: 20
|
||||
}
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if(root.checked){
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(switch_mouse.containsMouse){
|
||||
if(hovered){
|
||||
return "#3E3E3C"
|
||||
}
|
||||
return "#323232"
|
||||
}else{
|
||||
if(root.checked){
|
||||
if(selected){
|
||||
return FluTheme.primaryColor.dark
|
||||
}
|
||||
if(switch_mouse.containsMouse){
|
||||
if(hovered){
|
||||
return "#F4F4F4"
|
||||
}
|
||||
return "#FFFFFF"
|
||||
}
|
||||
}
|
||||
border.width: 1
|
||||
border.color: root.checked ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
||||
|
||||
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
|
||||
Rectangle {
|
||||
x: root.checked ? root.implicitWidth - width - 4 : 4
|
||||
width: root.height - 8
|
||||
height: root.height - 8
|
||||
x: selected ? control.implicitWidth - width - 4 : 4
|
||||
width: control.height - 8
|
||||
height: control.height - 8
|
||||
radius: width / 2
|
||||
scale: switch_mouse.containsMouse ? 1.2 : 1.0
|
||||
scale: hovered ? 1.2 : 1.0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: root.checked ? "#FFFFFF" : "#666666"
|
||||
// border.color: "#D5D5D5"
|
||||
color: selected ? "#FFFFFF" : "#666666"
|
||||
Behavior on x {
|
||||
NumberAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
}
|
||||
MouseArea{
|
||||
id:switch_mouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
if(root.onClickFunc){
|
||||
root.onClickFunc()
|
||||
}else{
|
||||
root.checked = !root.checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ Item {
|
||||
FluCheckBox{
|
||||
id:item_layout_checkbox
|
||||
text:""
|
||||
checked: itemModel.multipSelected
|
||||
selected: itemModel.multipSelected
|
||||
visible: selectionMode === FluTreeView.Multiple
|
||||
Layout.leftMargin: 5
|
||||
|
||||
@ -199,7 +199,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
checkClicked:function(){
|
||||
clickFunc:function(){
|
||||
if(hasChild){
|
||||
const stack = [itemModel];
|
||||
while (stack.length > 0) {
|
||||
@ -222,8 +222,9 @@ Item {
|
||||
FluIconButton{
|
||||
id:item_layout_expanded
|
||||
color:"#00000000"
|
||||
icon:item_layout.expanded?FluentIcons.FA_angle_down:FluentIcons.FA_angle_right
|
||||
iconSource:item_layout.expanded?FluentIcons.ChevronDown:FluentIcons.ChevronRight
|
||||
opacity: item_layout.hasChild
|
||||
iconSize: 15
|
||||
onClicked: {
|
||||
if(!item_layout.hasChild){
|
||||
item_layout_rect.onClickItem()
|
||||
|
@ -14,7 +14,6 @@
|
||||
<file>controls/FluDropDownButton.qml</file>
|
||||
<file>controls/FluTextBox.qml</file>
|
||||
<file>controls/FluTimePicker.qml</file>
|
||||
<file>res/font/fontawesome-webfont.ttf</file>
|
||||
<file>controls/FluAppBar.qml</file>
|
||||
<file>controls/FluRectangle.qml</file>
|
||||
<file>controls/FluWindow.qml</file>
|
||||
@ -43,5 +42,10 @@
|
||||
<file>controls/FluScrollablePage.qml</file>
|
||||
<file>controls/FluContentPage.qml</file>
|
||||
<file>controls/FluArea.qml</file>
|
||||
<file>res/font/Segoe_Fluent_Icons.ttf</file>
|
||||
<file>controls/FluDatePicker.qml</file>
|
||||
<file>controls/FluCalenderView.qml</file>
|
||||
<file>controls/FluCalendarDatePicker.qml</file>
|
||||
<file>controls/FluFocusRectangle.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
src/res/font/Segoe_Fluent_Icons.ttf
Normal file
BIN
src/res/font/Segoe_Fluent_Icons.ttf
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user