D18019: [Digital Clock] Add ability to set a custom date format string
Chris Holland
noreply at phabricator.kde.org
Tue Jan 8 05:49:43 GMT 2019
Zren added a comment.
In D18019#388811 <https://phabricator.kde.org/D18019#388811>, @ndavis wrote:
> I'm leaning towards no, but a second link to text formatting documentation might be a good idea.
Adding a second link is pretty easy, though I wrote this before I noticed your edit. A second link would look better + simpler to maintain though. Though without a RichText example, the user might not understand the need to escape using apostrophes without an example (`'<b>'ddd'</b>'` ).
> I'm leaning towards no, but an example of the custom time formatting and another of Rich Text formatting would be a good idea.
Here's an example table, using an unconventional method of drawing a grid.
F6533733: 2019-01-08___00-40-47.png <https://phabricator.kde.org/F6533733>
QtLayouts.GridLayout {
id: exampleFormatsTable
columns: 2
property var model: [
"yyyy-MM-dd",
"MMM d",
"'<b>'ddd'</b>'d",
"'<font color=\"#f00\">'ddd'</font>'d",
]
Repeater {
model: exampleFormatsTable.model.length * 2
Item {
id: cell
property int padding: units.smallSpacing
implicitWidth: exampleLabel.implicitWidth + padding*2
implicitHeight: exampleLabel.implicitHeight + padding*2
QtLayouts.Layout.fillWidth: true
readonly property int row: Math.floor(index / exampleFormatsTable.columns)
readonly property int column: index % exampleFormatsTable.columns
Rectangle {
anchors.fill: parent
color: exampleLabel.color
opacity: 0.1
}
QtControls.Label {
id: exampleLabel
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: cell.padding
textFormat: cell.column === 0 ? Text.PlainText : Text.RichText
text: {
var exampleFormat = exampleFormatsTable.model[cell.row]
if (cell.column === 0) {
return exampleFormat
} else {
return Qt.formatDate(new Date(), exampleFormat)
}
}
}
}
}
}
REPOSITORY
R120 Plasma Workspace
REVISION DETAIL
https://phabricator.kde.org/D18019
To: Zren, #plasma, #vdg
Cc: ndavis, rooty, plasma-devel, kvanton, jraleigh, GB_2, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20190108/60058453/attachment-0001.html>
More information about the Plasma-devel
mailing list