[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:17:36 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=10c69eb
The following commit has been merged in the master branch:
commit 10c69eb0f55682ae48a86a6eead565b311222d24
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Mon Sep 20 11:11:26 2010 +0000
Fully support loading of custom template.html files. Improves theme support.
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1177491
---
data/template.html | 20 ++++++++-------
lib/chatview.cpp | 72 ++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 65 insertions(+), 27 deletions(-)
diff --git a/data/template.html b/data/template.html
index fe7c4de..79224b8 100644
--- a/data/template.html
+++ b/data/template.html
@@ -2,8 +2,11 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <base href="file://%baseRef%" />
+ <base href="%@">
<script type="text/javascript" defer="defer">
+ // NOTE:
+ // Any percent signs in this file must be escaped!
+ // Use two escape signs (%%) to display it, this is passed through a format call!
function appendHTML(html) {
var node = document.getElementById("Chat");
@@ -271,7 +274,7 @@
function imageToText(node)
{
- if (!node.alt)
+ if (client.zoomImage(node) || !node.alt)
return;
var a = document.createElement('a');
a.setAttribute('onclick', 'imageSwap(this, true)');
@@ -317,25 +320,24 @@
.actionMessageBody:before { content:"*"; }
.actionMessageBody:after { content:"*"; }
* { word-wrap:break-word; text-rendering: optimizelegibility; }
- img.scaledToFitImage { height: auto; max-width: 100%; }
+ img.scaledToFitImage { height: auto; max-width: 100%%; }
</style>
<!-- This style is shared by all variants. !-->
<style id="baseStyle" type="text/css" media="screen,print">
- %extraStyleCode%
+ %@
</style>
<!-- Although we call this mainStyle for legacy reasons, it's actually the variant style !-->
<style id="mainStyle" type="text/css" media="screen,print">
- @import url( "main.css" );
- @import url( "%variant%" );
+ @import url( "%@" );
</style>
</head>
-<body onload="initStyle();">
-%header%
+<body onload="initStyle();" style="==bodyBackground==">
+%@
<div id="Chat">
</div>
-%footer%
+%@
</body>
</html>
diff --git a/lib/chatview.cpp b/lib/chatview.cpp
index cbe775f..59ff3d5 100644
--- a/lib/chatview.cpp
+++ b/lib/chatview.cpp
@@ -67,32 +67,67 @@ void ChatView::initialise(const TelepathyChatInfo &chatInfo)
QString templateHtml;
QString templateFileName(KGlobal::dirs()->findResource("data", "ktelepathy/template.html"));
- if (! templateFileName.isEmpty() && QFile::exists(templateFileName)) {
- QFile fileAccess;
-
- fileAccess.setFileName(templateFileName);
- fileAccess.open(QIODevice::ReadOnly);
- QTextStream headerStream(&fileAccess);
- headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
- templateHtml = headerStream.readAll();
- fileAccess.close();
- } else {
- KMessageBox::error(this, "Missing required file template.html - check your installation.");
+ templateHtml = m_chatStyle->getTemplateHtml();
+
+ if (templateHtml.isEmpty()) {
+ //FIXME, move this to ChatStyle (maybe?)
+ QString templateFileName(KGlobal::dirs()->findResource("data", "ktelepathy/template.html"));
+
+ if (! templateFileName.isEmpty() && QFile::exists(templateFileName)) {
+ QFile fileAccess;
+
+ fileAccess.setFileName(templateFileName);
+ fileAccess.open(QIODevice::ReadOnly);
+ QTextStream headerStream(&fileAccess);
+ headerStream.setCodec(QTextCodec::codecForName("UTF-8"));
+ templateHtml = headerStream.readAll();
+ fileAccess.close();
+ } else {
+ KMessageBox::error(this, "Missing required file template.html - check your installation.");
+ }
}
QString headerHtml;
if (m_displayHeader) {
headerHtml = replaceHeaderKeywords(m_chatStyle->getHeaderHtml(), chatInfo);
} //otherwise leave as blank.
-
- templateHtml.replace("%baseRef%", m_chatStyle->getStyleBaseHref());
- templateHtml.replace("%extraStyleCode%", ""); // FIXME once we get some font/background from the config file, put it here
- templateHtml.replace("%variant%", m_variantPath);
- templateHtml.replace("%header%", headerHtml);
-
QString footerHtml;
footerHtml = replaceHeaderKeywords(m_chatStyle->getFooterHtml(), chatInfo);
- templateHtml.replace("%footer%", footerHtml);
+
+ QString extraStyleHtml = "@import url( \"main.css\" );";
+
+ //The templateHtml is in a horrific NSString format.
+ //Want to use this rather than roll our own, as that way we can get templates from themes too
+ //"%@" is each argument.
+ // all other %'s are escaped.
+
+ // first is baseref
+ // second is extra style code (This is sometimes missing !!!!)
+ // third is variant CSS
+ // 4th is header
+ // 5th is footer
+
+ templateHtml.replace("%%", "%");
+
+ int numberOfPlaceholders = templateHtml.count("%@");
+
+ int index;
+ index = templateHtml.indexOf("%@", index);
+ templateHtml.replace(index, 2, QString("file:///").append(m_chatStyle->getStyleBaseHref()));
+
+ if (numberOfPlaceholders == 5) {
+ index = templateHtml.indexOf("%@", index);
+ templateHtml.replace(index, 2, extraStyleHtml);
+ }
+
+ index = templateHtml.indexOf("%@", index);
+ templateHtml.replace(index, 2, m_variantPath);
+
+ index = templateHtml.indexOf("%@", index);
+ templateHtml.replace(index, 2, headerHtml);
+
+ index = templateHtml.indexOf("%@", index);
+ templateHtml.replace(index, 2, footerHtml);
setHtml(templateHtml);
lastSender = "";
@@ -188,6 +223,7 @@ void ChatView::addMessage(const TelepathyChatMessageInfo &message)
styleHtml.replace("%message%", messageHtml);
styleHtml.replace("%messageDirection%", message.messageDirection());
styleHtml.replace("%sender%", message.senderDisplayName()); // FIXME sender is complex: not always this
+ styleHtml.replace("%senderScreenName%", message.senderScreenName());
styleHtml.replace("%time%", KGlobal::locale()->formatTime(message.time().time(), true));
styleHtml.replace("%shortTime%", KGlobal::locale()->formatTime(message.time().time(), false));
styleHtml.replace("%userIconPath%", "Outgoing/buddy_icon.png");// this fallback should be done in the messageinfo
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list