Link attivi nel corpo dei messaggi (0.5.0)
- qml/js/linkify.js: escape di tutto il testo, poi URL e indirizzi diventano link; la punteggiatura finale resta fuori; una sola passata (niente link annidati). ES5, provato con node: tests/test_linkify.js, 9 controlli - MessagePage: RichText e onLinkActivated -> Qt.openUrlExternally
This commit is contained in:
1 parent
5bc53d1c18
commit
8e062adc34
5 files changed
+116
-5
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/linkify.js" as Linkify
|
||||
|
||||
// Lettura di un messaggio, dal motore. Paginazione a tap: un tocco sul lato
|
||||
// destro passa al successivo, sul sinistro al precedente; il corpo resta
|
||||
@@ -118,12 +119,16 @@ Page {
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: page.corpo.length > 0 ? page.corpo : qsTr("(nessun testo)")
|
||||
text: page.corpo.length > 0 ? Linkify.html(page.corpo)
|
||||
: qsTr("(nessun testo)")
|
||||
wrapMode: Text.Wrap
|
||||
textFormat: Text.PlainText
|
||||
// il testo arriva da chiunque: linkify escapa tutto e inserisce
|
||||
// solo i propri tag (vedi qml/js/linkify.js, provato con node)
|
||||
textFormat: Text.RichText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primaryColor
|
||||
bottomPadding: Theme.paddingLarge
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
}
|
||||
|
||||
// Allegati: un tocco li salva in Download e li apre con l'app
|
||||
|
||||
Reference in new issue
Block a user