File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change 3535 }
3636
3737 // Message body
38- TextEdit {
38+ TextEdit {
39+ id: messageText;
3940 text: delegateMessage;
4041 color: " white" ;
4142 font .pixelSize : 18 ;
@@ -56,6 +57,30 @@ Item {
5657 Qt .openUrlExternally (link);
5758 }
5859 }
60+
61+ Component .onCompleted : {
62+ // Images do not appear when done loading until
63+ // the component is redrawn, which it does not do
64+ // automatically; so we need to create a hidden
65+ // Image object and wait for that to load
66+ // before we cause it to redraw by altering the content.
67+ var re = / <img[^ >] + src="([^ "] + )"[^ >] + >/ gi
68+ var m;
69+ while ((m = re .exec (text)) !== null ) {
70+ var loader = Qt .createQmlObject (' import QtQuick 2.0; Image {}' , messageText);
71+ loader .source = m[1 ];
72+ loader .visible = false ;
73+ loader .onStatusChanged .connect (function () {
74+ if (loader .status === Image .Ready ) {
75+ // Alter the content of messageText
76+ // to prompt it to redraw
77+ var originalText = messageText .text ;
78+ messageText .text = " " ; // force a change
79+ messageText .text = originalText;
80+ }
81+ });
82+ }
83+ }
5984 }
6085 }
6186
7398 width: 5 ;
7499 height: parent .height ;
75100 }
76- }
101+ }
You can’t perform that action at this time.
0 commit comments