| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import Felgo 4.0
- import QtQuick 2.12
- import QtQuick.Controls
- import QtMultimedia
- import "../common"
- import "../controls"
- AppPage {
- id: root
- title: "日志"
- rightBarItem: IconButtonBarItem {
- iconType: IconType.paintbrush
- onClicked: {
- audio.play()
- }
- }
- MediaPlayer{
- id: audio
- audioOutput: AudioOutput{}
- source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
- }
- //property string message:""
- AppFlickable {
- id: scroll
- anchors.fill: parent
- contentHeight: content.height
- bottomMargin: nativeUtils.safeAreaInsets.bottom
- // 接收并显示日志消息
- // Connections {
- // target: logger
- // onLogMessage: {
- // logTextArea.text += message + "\n"
- // console.log("logTextArea:",logTextArea.contentHeight)
- // if(logTextArea.contentHeight>5000){
- // logTextArea.clear()
- // }
- // }
- // }
- Column {
- id: content
- width: parent.width
- TextArea {
- id: logTextArea
- readOnly: true
- wrapMode: TextArea.WrapAtWordBoundaryOrAnywhere
- width: parent.width
- text: "日志"
- function scrollToLatestLine() {
- // 获取TextArea的内容高度
- var contentHeight = logTextArea.contentHeight;
- // 计算滚动位置,使视图滚动到最底部
- var scrollPosition = contentHeight - scroll.height;
- // 使用动画效果来平滑滚动
- scroll.contentY = scrollPosition;
- }
- onTextChanged: {
- // 当文本发生变化时,调用滚动函数以将视图滚动到最新行
- scrollToLatestLine();
- }
- }
- }
- }
- //}
- }
|