[prev in list] [next in list] [prev in thread] [next in thread]
List: kopete-devel
Subject: Re: [kopete-devel] [PATCH v2] history plugin (4.1.1): introduce
From: <strohel () gmail ! com>
Date: 2008-10-02 17:53:13
Message-ID: 200810021953.14241.strohel () gmail ! com
[Download RAW message or body]
On Thursday 02 October 2008 18:57:21 Olivier Goffart wrote:
> The patch looks nice. Thanks!
>
> Could we have a screenshot?
lookie lookie: http://www.strohel.eu/soubory/kopete-history-redesign.png
I've attached v2 of the patch, that just adds the regexp that cannot be done
in kopetemessage.cpp. (otherwise newlines would appear after after contact
names)
Regards,
Matěj.
["kopete-historyplugin-v2.patch" (text/x-patch)]
diff --git a/kopete/plugins/history/CMakeLists.txt \
b/kopete/plugins/history/CMakeLists.txt index cd21f36..3129e36 100644
--- a/kopete/plugins/history/CMakeLists.txt
+++ b/kopete/plugins/history/CMakeLists.txt
@@ -48,6 +48,7 @@ install(TARGETS kcm_kopete_history DESTINATION \
${PLUGIN_INSTALL_DIR}) install( FILES historyconfig.kcfg DESTINATION \
${KCFG_INSTALL_DIR}) install( FILES kopete_history.desktop DESTINATION \
${SERVICES_INSTALL_DIR}) install( FILES historyui.rc historychatui.rc DESTINATION \
${DATA_INSTALL_DIR}/kopete_history) +install( FILES default.css DESTINATION \
${DATA_INSTALL_DIR}/kopete/historystyles) install( FILES \
kopete_history_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kconfiguredialog) \
diff --git a/kopete/plugins/history/default.css b/kopete/plugins/history/default.css
new file mode 100644
index 0000000..07300c5
--- /dev/null
+++ b/kopete/plugins/history/default.css
@@ -0,0 +1,43 @@
+/**
+ * This is the default stylesheet for kopete history view.
+ * The HTML layout looks like this:
+ *
+ * <body>
+ * <head>
+ * <link rel='stylesheet' type='text/css' href='[path_to_this_file]' />
+ * <style>
+ * .hf {
+ * font-size: [font_size_set_in_config];
+ * font-family: [font_from_config];
+ * color: [color_from_config];
+ * }
+ * </style>";
+ * </head>
+ * <body class="hf">
+ * <p class="date">Sat Sep 27 2008</p>
+ * <p class="account">you@network.tld</p>
+ * <p class="message outbound"><span class='time'>20:45:34</span> <span \
class='name'>Bob</span>: <span class='text'>Hi!</span></p> + * <p class="message \
inbound"><span class='time'>20:45:34</span> <span class='name'>Alice</span>: \
<span class='text'>Hi Bob.</span></p> + * <p class="account \
newaccount">second@account.org</p> + * <p class="message outbound"><span \
class='time'>20:45:34</span> <span class='name'>Bob</span>: <span \
class='text'>I'm just trying my second account.</span></p> + * </body>
+ * </html>
+***/
+p {
+ margin: 0; }
+.date {
+ color: #ff0000;
+ font-weight: bold; }
+.account {
+ color: #0000ff;
+ font-weight: bold; }
+.newaccount {
+ margin-top: 2em; }
+.message .time {
+ color: #808080; }
+.message .name {
+ font-weight: bold }
+.inbound .name {
+ color: #008000; }
+.outbound .name {
+ color: #000080; }
diff --git a/kopete/plugins/history/historydialog.cpp \
b/kopete/plugins/history/historydialog.cpp index 569c5b0..1048918 100644
--- a/kopete/plugins/history/historydialog.cpp
+++ b/kopete/plugins/history/historydialog.cpp
@@ -147,8 +147,10 @@ HistoryDialog::HistoryDialog(Kopete::MetaContact *mc, QWidget* \
parent) QTextStream( &fontSize ) << \
Kopete::AppearanceSettings::self()->chatFont().pointSize(); fontStyle = "<style>.hf \
{ font-size:" + fontSize + ".0pt; font-family:" + \
Kopete::AppearanceSettings::self()->chatFont().family() + "; color: " + \
Kopete::AppearanceSettings::self()->chatTextColor().name() + "; }</style>";
+ QString stylesheet = KStandardDirs::locate("appdata", "historystyles/default.css");
+
mHtmlPart->begin();
- htmlCode = "<html><head>" + fontStyle + "</head><body class=\"hf\"></body></html>";
+ htmlCode = "<html><head><link rel='stylesheet' type='text/css' href='" + stylesheet \
+ "' />" + fontStyle + "</head><body class=\"hf\"></body></html>"; mHtmlPart->write( \
QString::fromLatin1( htmlCode.toLatin1() ) ); mHtmlPart->end();
@@ -329,10 +331,13 @@ void HistoryDialog::setMessages(QList<Kopete::Message> msgs)
QString::fromLatin1("ltr"));
QString accountLabel;
- QString resultHTML = "<b><font color=\"red\">" + \
msgs.front().timestamp().date().toString() + "</font></b><br/>"; + QString resultHTML \
= msgs.front().timestamp().date().toString(); +
+ QRegExp pTag("^<p[^<>]*>|</p>$");
- DOM::HTMLElement newNode = \
mHtmlPart->document().createElement(QString::fromLatin1("span")); + DOM::HTMLElement \
newNode = mHtmlPart->document().createElement(QString::fromLatin1("p")); \
newNode.setAttribute(QString::fromLatin1("dir"), dir); \
+ newNode.setAttribute(QString::fromLatin1("class"), QString::fromLatin1("date")); \
newNode.setInnerHTML(resultHTML); \
mHtmlPart->htmlDocument().body().appendChild(newNode);
@@ -343,18 +348,23 @@ void HistoryDialog::setMessages(QList<Kopete::Message> msgs)
|| ( mMainWidget->messageFilterBox->currentIndex() == 1 && msg.direction() == \
Kopete::Message::Inbound ) || ( mMainWidget->messageFilterBox->currentIndex() == 2 \
&& msg.direction() == Kopete::Message::Outbound ) ) {
- resultHTML.clear();
-
if (accountLabel.isEmpty() || accountLabel != \
msg.from()->account()->accountLabel()) // If the message's account is new, just \
specify it to the user {
- if (!accountLabel.isEmpty())
- resultHTML += "<br/><br/><br/>";
- resultHTML += "<b><font color=\"blue\">" + msg.from()->account()->accountLabel() \
+ "</font></b><br/>"; + resultHTML = msg.from()->account()->accountLabel();
+
+ newNode = mHtmlPart->document().createElement(QString::fromLatin1("p"));
+ newNode.setAttribute(QString::fromLatin1("dir"), dir);
+ newNode.setAttribute(QString::fromLatin1("class"),
+ accountLabel.isEmpty() ? QString::fromLatin1("account") : \
QString::fromLatin1("account newaccount")); + newNode.setInnerHTML(resultHTML);
+
+ mHtmlPart->htmlDocument().body().appendChild(newNode);
}
accountLabel = msg.from()->account()->accountLabel();
QString body = msg.parsedBody();
+ body.remove(pTag); // get rid of extra paragrapth tag that ebraces parsedBody()
if (!mMainWidget->searchLine->text().isEmpty())
// If there is a search, then we hightlight the keywords
@@ -372,27 +382,28 @@ void HistoryDialog::setMessages(QList<Kopete::Message> msgs)
name = msg.from()->nickName();
}
- QString fontColor;
+ QString msgDirection;
if (msg.direction() == Kopete::Message::Outbound)
{
- fontColor = Kopete::AppearanceSettings::self()->chatTextColor().dark().name();
+ msgDirection = "outbound";
}
else
{
- fontColor = Kopete::AppearanceSettings::self()->chatTextColor().light(200).name();
+ msgDirection = "inbound";
}
- QString messageTemplate = "<b>%1 <font color=\"%2\">%3</font></b> %4";
- resultHTML += messageTemplate.arg( msg.timestamp().time().toString(),
- fontColor, name, body );
+ QString messageTemplate = "<span class='time'>%1</span> <span \
class='name'>%2</span>: <span class='text'>%3</span>"; + resultHTML = \
messageTemplate.arg( msg.timestamp().time().toString(), name, body );
- newNode = mHtmlPart->document().createElement(QString::fromLatin1("span"));
+ newNode = mHtmlPart->document().createElement(QString::fromLatin1("p"));
newNode.setAttribute(QString::fromLatin1("dir"), dir);
+ newNode.setAttribute(QString::fromLatin1("class"), QString::fromLatin1("message \
") + msgDirection); newNode.setInnerHTML(resultHTML);
mHtmlPart->htmlDocument().body().appendChild(newNode);
}
}
+// kDebug(14310) << mHtmlPart->htmlDocument().toString().string(); // \
mHtml->documentSource returns empty string.. }
void HistoryDialog::slotFilterChanged(int /*index*/)
_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic