Fix: the app widget will display a exception while zooming.

This commit is contained in:
JunjieBai 2022-10-28 14:30:34 +08:00 committed by iaom
parent 5254c49ffa
commit 95736ef771
1 changed files with 13 additions and 12 deletions

View File

@ -7,12 +7,13 @@ import org.ukui.appwidget 1.0
import org.ukui.qqc2style.private 1.0 as StylePrivate import org.ukui.qqc2style.private 1.0 as StylePrivate
AppWidget { AppWidget {
width: 640
height: 100
visible: true visible: true
id: window id: window
appname: "search" appname: "search"
username: parent.username username: parent.username
anchors.fill: parent
property real scaling: parent.width / 480
function parseJson(jsonStr) { function parseJson(jsonStr) {
try { try {
@ -43,8 +44,8 @@ AppWidget {
Rectangle { Rectangle {
id:searchBar id:searchBar
anchors.centerIn: parent anchors.centerIn: parent
width:448 width : 448 * scaling
height: 64 height: 64 * scaling
radius: searchBar.height / 2 radius: searchBar.height / 2
RowLayout { RowLayout {
@ -54,10 +55,10 @@ AppWidget {
Image { Image {
id: image_search id: image_search
Layout.leftMargin: 16 Layout.leftMargin: 16 * scaling;
Layout.rightMargin: 16 Layout.rightMargin: 16 * scaling;
Layout.preferredWidth: 32; Layout.preferredWidth: 32 * scaling;
Layout.preferredHeight: 32; Layout.preferredHeight: 32 * scaling;
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
source: "file:///usr/share/appwidget/search/ukui-search.svg" source: "file:///usr/share/appwidget/search/ukui-search.svg"
@ -67,7 +68,7 @@ AppWidget {
clip: true; clip: true;
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true; Layout.fillHeight: true;
Layout.rightMargin: 32; Layout.rightMargin: 32 * scaling;
TextInput { TextInput {
id: searchtext id: searchtext
@ -85,17 +86,17 @@ AppWidget {
focus: true focus: true
color: StylePrivate.StyleHelper.windowtextcolorrole color: StylePrivate.StyleHelper.windowtextcolorrole
maximumLength: 100 maximumLength: 100 * scaling
selectByMouse: true selectByMouse: true
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
font.pixelSize: 21 font.pixelSize: 21 * scaling
property string placeholderText: /*qsTr("search")*/"全局搜索" property string placeholderText: /*qsTr("search")*/"全局搜索"
Text { Text {
id: placeholderText id: placeholderText
text: searchtext.placeholderText text: searchtext.placeholderText
font.pixelSize: 21 font.pixelSize: 21 * scaling
visible: !searchtext.text visible: !searchtext.text
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter