From 28e514f927eb90769220ce8678c462a2aa32531b Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 30 Aug 2021 12:32:31 +0200 Subject: [PATCH] feat(StatusModal): add ability to set elide config of header titles There are now two new properties in `StatusModalHeaderSettings`: - `titleElide` - `subTitleElide` These can be used to configure the `elide` property of both header titles. The default values for both of them is `Text.ElideRight`. Closes #353 --- sandbox/Popups.qml | 1 + src/StatusQ/Core/StatusModalHeaderSettings.qml | 3 ++- src/StatusQ/Popups/StatusModal.qml | 2 ++ src/StatusQ/Popups/statusModal/StatusImageWithTitle.qml | 6 ++++-- src/StatusQ/Popups/statusModal/StatusModalHeader.qml | 4 ++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sandbox/Popups.qml b/sandbox/Popups.qml index 7fbf006e..bbceef5c 100644 --- a/sandbox/Popups.qml +++ b/sandbox/Popups.qml @@ -245,6 +245,7 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I anchors.centerIn: parent header.title: "Some super long text here that exceeds the available space" header.subTitle: "Some super long text here that exceeds the available space" + header.subTitleElide: Text.ElideMiddle header.image.source: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0Bh CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC" header.image.isIdenticon: true diff --git a/src/StatusQ/Core/StatusModalHeaderSettings.qml b/src/StatusQ/Core/StatusModalHeaderSettings.qml index 1b759a8c..6cf49bf2 100644 --- a/src/StatusQ/Core/StatusModalHeaderSettings.qml +++ b/src/StatusQ/Core/StatusModalHeaderSettings.qml @@ -3,7 +3,8 @@ import QtQuick 2.14 QtObject { property string title property string subTitle - + property int titleElide: Text.ElideRight + property int subTitleElide: Text.ElideRight property StatusImageSettings image: StatusImageSettings { width: 40 height: 40 diff --git a/src/StatusQ/Popups/StatusModal.qml b/src/StatusQ/Popups/StatusModal.qml index dab861a0..31a6fd96 100644 --- a/src/StatusQ/Popups/StatusModal.qml +++ b/src/StatusQ/Popups/StatusModal.qml @@ -52,7 +52,9 @@ QC.Popup { visible: statusModal.showHeader title: header.title + titleElide: header.titleElide subTitle: header.subTitle + subTitleElide: header.subTitleElide image: header.image icon: header.icon diff --git a/src/StatusQ/Popups/statusModal/StatusImageWithTitle.qml b/src/StatusQ/Popups/statusModal/StatusImageWithTitle.qml index bcd0c47f..9a1aaf43 100644 --- a/src/StatusQ/Popups/statusModal/StatusImageWithTitle.qml +++ b/src/StatusQ/Popups/statusModal/StatusImageWithTitle.qml @@ -9,6 +9,8 @@ Row { property alias title: headerTitle.text property alias subTitle: headerSubTitle.text + property int titleElide: Text.ElideRight + property int subTitleElide: Text.ElideRight property bool editable: false signal editButtonClicked @@ -88,7 +90,7 @@ Row { font.family: Theme.palette.baseFont.name font.pixelSize: 17 font.bold: true - elide: Text.ElideRight + elide: statusImageWithTitle.titleElide color: Theme.palette.directColor1 width: !editButton.visible ? parent.width : parent.width - editButton.width - parent.spacing @@ -116,7 +118,7 @@ Row { font.pixelSize: 15 color:Theme.palette.baseColor1 width: parent.width - elide: Text.ElideRight + elide: statusImageWithTitle.subTitleElide } } } diff --git a/src/StatusQ/Popups/statusModal/StatusModalHeader.qml b/src/StatusQ/Popups/statusModal/StatusModalHeader.qml index 3ad384cd..cb904c43 100644 --- a/src/StatusQ/Popups/statusModal/StatusModalHeader.qml +++ b/src/StatusQ/Popups/statusModal/StatusModalHeader.qml @@ -11,6 +11,8 @@ Rectangle { property alias title: imageWithTitle.title property alias subTitle: imageWithTitle.subTitle + property int titleElide + property int subTitleElide property alias actionButton: actionButtonLoader.sourceComponent property alias image: imageWithTitle.image @@ -35,6 +37,8 @@ Rectangle { anchors.leftMargin: 16 editable: statusModalHeader.editable + titleElide: statusModalHeader.titleElide + subTitleElide: statusModalHeader.subTitleElide onEditButtonClicked: statusModalHeader.editButtonClicked() }