[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:23:20 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=abfa9f3
The following commit has been merged in the master branch:
commit abfa9f34db4b31b515369fad3512e198d7433a29
Author: Lasath Fernando <kde at lasath.org>
Date: Fri Aug 17 13:51:38 2012 +1000
Implment highlight filter
Conflicts:
filters/CMakeLists.txt
lib/message.cpp
lib/message.h
---
filters/CMakeLists.txt | 1 +
filters/highlight/CMakeLists.txt | 24 +++++++
filters/highlight/highlight-filter.cpp | 74 ++++++++++++++++++++++
.../highlight/highlight-filter.h | 18 +++---
.../ktptextui_message_filter_highlight.desktop | 16 +++++
5 files changed, 125 insertions(+), 8 deletions(-)
diff --git a/filters/CMakeLists.txt b/filters/CMakeLists.txt
index ac25a17..c10a7f1 100644
--- a/filters/CMakeLists.txt
+++ b/filters/CMakeLists.txt
@@ -16,3 +16,4 @@ if(HAS_KTTS)
endif(HAS_KTTS)
macro_log_feature(HAS_KTTS "KTTSD" "KDE Text to Speech Deamon" "" FALSE "" "Needed for optional tts message plugin")
+add_subdirectory(highlight)
diff --git a/filters/highlight/CMakeLists.txt b/filters/highlight/CMakeLists.txt
new file mode 100644
index 0000000..29238fb
--- /dev/null
+++ b/filters/highlight/CMakeLists.txt
@@ -0,0 +1,24 @@
+set (ktptextui_message_filter_highlight_SRCS
+ highlight-filter.cpp
+)
+
+kde4_add_plugin (ktptextui_message_filter_highlight
+ ${ktptextui_message_filter_highlight_SRCS}
+)
+
+target_link_libraries (ktptextui_message_filter_highlight
+ ktpchat
+ ${QT_LIBRARIES}
+ ${KDE4_KDECORE_LIBS}
+ ${TELEPATHY_QT4_LIBRARIES}
+)
+
+# Install:
+install (TARGETS ktptextui_message_filter_highlight
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
+
+install (FILES ktptextui_message_filter_highlight.desktop
+ DESTINATION ${SERVICES_INSTALL_DIR}
+)
+
diff --git a/filters/highlight/highlight-filter.cpp b/filters/highlight/highlight-filter.cpp
new file mode 100644
index 0000000..c0f85cd
--- /dev/null
+++ b/filters/highlight/highlight-filter.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2012 Lasath Fernando <kde at lasath.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "highlight-filter.h"
+
+#include <QStringBuilder>
+
+#include <KPluginFactory>
+#include <KDebug>
+#include <KUrl>
+#include <KUriFilter>
+#include <KUser>
+
+#include <TelepathyQt/AccountManager>
+
+class HighlightFilter::Private
+{
+public:
+ Tp::AccountManagerPtr accountManager;
+ KUser user;
+};
+
+HighlightFilter::HighlightFilter(QObject *parent, const QVariantList &) :
+ AbstractMessageFilter(parent), d(new Private)
+{
+ d->accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus());
+ d->accountManager->becomeReady();
+}
+
+HighlightFilter::~HighlightFilter()
+{
+ delete d;
+}
+
+void HighlightFilter::filterMessage(Message &message)
+{
+ QString msg = message.mainMessagePart();
+
+ Q_FOREACH (Tp::AccountPtr ptr, d->accountManager->allAccounts()) {
+ if (msg.contains(ptr->nickname(), Qt::CaseInsensitive)) {
+ kDebug() << "message contains user alias :" << ptr->nickname();
+ message.setProperty("highlight", true);
+ }
+
+ if (msg.contains(d->user.loginName(), Qt::CaseInsensitive)) {
+ kDebug() << "messge contains user login name" << d->user.loginName();
+ message.setProperty("highlight", true);
+ }
+ }
+
+ if (message.property("highlight").toBool()){
+ msg = QLatin1Literal("<div style='color:red;'>") % msg %
+ QLatin1Literal("</div>");
+ message.setMainMessagePart(msg);
+ }
+}
+
+K_PLUGIN_FACTORY(MessageFilterFactory, registerPlugin<HighlightFilter>();)
+K_EXPORT_PLUGIN(MessageFilterFactory("ktptextui_message_filter_highlight"))
diff --git a/config/messages-config.h b/filters/highlight/highlight-filter.h
similarity index 72%
copy from config/messages-config.h
copy to filters/highlight/highlight-filter.h
index f735443..3848304 100644
--- a/config/messages-config.h
+++ b/filters/highlight/highlight-filter.h
@@ -16,21 +16,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef KCM_MESSAGES_H
-#define KCM_MESSAGES_H
+#ifndef HIGHLIGHT_FILTER_H
+#define HIGHLIGHT_FILTER_H
-#include <KSettings/PluginPage>
+#include <KTp/AbstractMessageFilter>
-class MessagesConfig : public KSettings::PluginPage
+class HighlightFilter : public AbstractMessageFilter
{
-Q_OBJECT
+ Q_OBJECT
public:
- explicit MessagesConfig(QWidget *parent = 0, const QVariantList &args = QVariantList());
+ HighlightFilter(QObject *parent, const QVariantList &);
+ virtual ~HighlightFilter();
+ virtual void filterMessage(Message &message);
private:
class Private;
- Private* d;
+ Private *d;
};
-#endif // KCM_MESSAGES_H
+#endif // HIGHLIGHT_FILTER_H
diff --git a/filters/highlight/ktptextui_message_filter_highlight.desktop b/filters/highlight/ktptextui_message_filter_highlight.desktop
new file mode 100644
index 0000000..45ce2d7
--- /dev/null
+++ b/filters/highlight/ktptextui_message_filter_highlight.desktop
@@ -0,0 +1,16 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+ServiceTypes=KTpTextUi/MessageFilter
+
+X-KDE-Library=ktptextui_message_filter_highlight
+X-KDE-PluginInfo-Author=Lasath Fernando
+X-KDE-PluginInfo-Email=kde at lasath.org
+X-KDE-PluginInfo-Name=highlight
+X-KDE-PluginInfo-Version=0.4
+X-KDE-PluginInfo-Website=http://community.kde.org/Real-Time_Communication_and_Collaboration
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+
+Name=Highlight
+Comment=If any incoming messages contain your nickname, it will highlight them in red
\ No newline at end of file
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list