main
朱子楚\zhuzi 2023-03-25 20:45:33 +08:00
parent e2d72d4510
commit 5e61af99ba
7 changed files with 84 additions and 75 deletions

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>example</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.example</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
<key>NOTE</key>
<string>This file was generated by Qt/QMake.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
</dict>
</plist>

View File

@ -9,6 +9,14 @@ FluScrollablePage{
title:"MediaPlayer" title:"MediaPlayer"
onVisibleChanged: {
if(visible){
player.play()
}else{
player.pause()
}
}
FluArea{ FluArea{
width: parent.width width: parent.width
height: 320 height: 320
@ -21,6 +29,7 @@ FluScrollablePage{
} }
FluMediaPlayer{ FluMediaPlayer{
id:player
source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" source:"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
} }

View File

@ -8,6 +8,10 @@ FluContentPage {
title: "Typography" title: "Typography"
property int textSize: 13 property int textSize: 13
Component.onCompleted: {
slider.seek(31)
}
ScrollView{ ScrollView{
clip: true clip: true
width: parent.width width: parent.width
@ -68,17 +72,17 @@ FluContentPage {
FluSlider{ FluSlider{
id:slider
orientation:FluSlider.Vertical orientation:FluSlider.Vertical
anchors{ anchors{
right: parent.right right: parent.right
rightMargin: 30 rightMargin: 45
top: parent.top top: parent.top
topMargin: 30 topMargin: 30
} }
onValueChanged:{ onValueChanged:{
textSize = value/100*16+8 textSize = value/100*16+8
} }
value: 31
} }
} }

View File

@ -1,6 +1,5 @@
QT += quick concurrent network multimedia QT += quick concurrent network multimedia
CONFIG += c++11 CONFIG += c++11
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
SOURCES += \ SOURCES += \
@ -8,9 +7,12 @@ SOURCES += \
main.cpp main.cpp
RESOURCES += qml.qrc RESOURCES += qml.qrc
RC_ICONS = favicon.ico RC_ICONS = favicon.ico
QML_IMPORT_PATH = QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH = QML_DESIGNER_IMPORT_PATH =
CONFIG(debug,debug|release) { CONFIG(debug,debug|release) {
DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/debug) DESTDIR = $$absolute_path($${_PRO_FILE_PWD_}/../bin/debug)
} else { } else {

View File

@ -1,20 +1,24 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtMultimedia 5.15 import QtMultimedia 5.15
import QtGraphicalEffects 1.15
import FluentUI 1.0 import FluentUI 1.0
Item { Rectangle {
property url source
id:control id:control
width: 480 width: 480
height: 270 height: 270
property url source
Rectangle{
anchors.fill: parent
color: FluColors.Black color: FluColors.Black
clip: true
property bool showControl: true
MouseArea{
anchors.fill: parent
onClicked: {
showControl = !showControl
}
} }
MediaPlayer { MediaPlayer {
@ -48,24 +52,27 @@ Item {
Item{ Item{
height: 100 height: 100
y:showControl ? control.height - 110 : control.height
anchors{ anchors{
bottom: parent.bottom
left: parent.left left: parent.left
right: parent.right right: parent.right
leftMargin: 10 leftMargin: 10
rightMargin: 10 rightMargin: 10
bottomMargin: 10 }
MouseArea{
anchors.fill: parent
}
Behavior on y{
NumberAnimation{
duration: 150
}
} }
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97) color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97)
radius: 5 radius: 5
layer.enabled: true
layer.effect: GaussianBlur {
radius: 5
samples: 16
}
} }
FluSlider{ FluSlider{
@ -81,6 +88,9 @@ Item {
mediaplayer.seek(value*mediaplayer.duration/slider.maxValue) mediaplayer.seek(value*mediaplayer.duration/slider.maxValue)
mediaplayer.autoSeek = true mediaplayer.autoSeek = true
} }
onLineClickFunc:function(val){
mediaplayer.seek(val*mediaplayer.duration/slider.maxValue)
}
} }
FluText{ FluText{
@ -135,7 +145,13 @@ Item {
return value.toString().padStart(2, '0'); return value.toString().padStart(2, '0');
} }
function pause(){
mediaplayer.pause()
}
function play(){
mediaplayer.play()
}
} }

View File

@ -1,7 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
Menu { Menu {
id: popup id: popup
@ -11,18 +10,11 @@ Menu {
height: container.height height: container.height
background: Item { background: Item {
Rectangle{ Rectangle{
anchors.fill: parent anchors.fill: parent
color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97) color:FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97)
radius: 5 radius: 5
layer.enabled: true
layer.effect: GaussianBlur {
radius: 5
samples: 16
} }
}
FluShadow{ FluShadow{
radius: 5 radius: 5
} }

View File

@ -4,39 +4,51 @@ import QtGraphicalEffects 1.15
Item{ Item{
id:root
property int size: 180
property int dotSize: 24
property int value: 50
property int maxValue: 100
enum Orientation { enum Orientation {
Horizontal, Horizontal,
Vertical Vertical
} }
property int size: 180
height: control.height property int dotSize: 24
width: control.width property int value: 50
property int maxValue: 100
property int orientation: FluSlider.Horizontal property int orientation: FluSlider.Horizontal
property bool isHorizontal: orientation === FluSlider.Horizontal property bool isHorizontal: orientation === FluSlider.Horizontal
property bool enableTip : true property bool enableTip : true
property var onLineClickFunc
signal pressed signal pressed
signal released signal released
id:root
height: control.height
width: control.width
rotation: isHorizontal ? 0 : 180 rotation: isHorizontal ? 0 : 180
Component.onCompleted: { Component.onCompleted: {
seek(0) seek(0)
} }
MouseArea{
id:mouse_line
anchors.centerIn: control
width: isHorizontal ? control.width : 10
height: isHorizontal ? 10 : control.height
hoverEnabled: true
onClicked:
(mouse) => {
var val;
if(isHorizontal){
val = mouse.x*maxValue/control.width
}else{
val = mouse.y*maxValue/control.height
}
if(onLineClickFunc){
onLineClickFunc(val)
}else{
seek(val)
}
}
}
Rectangle { Rectangle {
id: control id: control
width: isHorizontal ? size : 4 width: isHorizontal ? size : 4
@ -51,6 +63,8 @@ Item{
height: isHorizontal ? 5 : control.height*(value/maxValue) height: isHorizontal ? 5 : control.height*(value/maxValue)
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
} }
} }
Rectangle{ Rectangle{
@ -70,7 +84,7 @@ Item{
radius: dotSize/4 radius: dotSize/4
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
anchors.centerIn: parent anchors.centerIn: parent
scale: control_mouse.containsMouse ? 1.2 : 1 scale: control_mouse.containsMouse || mouse_line.containsMouse ? 1.3 : 1
Behavior on scale { Behavior on scale {
NumberAnimation{ NumberAnimation{
duration: 150 duration: 150
@ -109,14 +123,14 @@ Item{
} }
} }
function seek(position){ function seek(val){
if(isHorizontal){ if(isHorizontal){
dot.x =position/maxValue*control.width - dotSize/2 dot.x =val/maxValue*control.width - dotSize/2
root.value = Qt.binding(function(){ root.value = Qt.binding(function(){
return (dot.x+dotSize/2)/control.width*maxValue return (dot.x+dotSize/2)/control.width*maxValue
}) })
}else{ }else{
dot.y =position/maxValue*control.height - dotSize/2 dot.y =val/maxValue*control.height - dotSize/2
root.value = Qt.binding(function(){ root.value = Qt.binding(function(){
return (dot.y+dotSize/2)/control.height*maxValue return (dot.y+dotSize/2)/control.height*maxValue
}) })