[SCM] ktp-text-ui packaging branch, master, updated. debian/16.04.2-1-88-g820317b
Maximiliano Curia
maxy at moszumanska.debian.org
Tue Sep 12 14:10:06 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=06f9110
The following commit has been merged in the master branch:
commit 06f9110dd1f4fdc8552d48ed3d10277d4e44a152
Author: Niels Ole Salscheider <niels_ole at salscheider-online.de>
Date: Sun Feb 7 17:33:28 2016 +0100
Port to QWebEngine
REVIEW: 127005
---
CMakeLists.txt | 4 +-
adiumxtra-protocol-handler/CMakeLists.txt | 2 +-
app/CMakeLists.txt | 2 +-
config/appearance/CMakeLists.txt | 2 +-
config/appearance/appearance-config-tab.cpp | 3 +-
lib/CMakeLists.txt | 3 +-
lib/adium-theme-view.cpp | 167 +++++++++++-----------------
lib/adium-theme-view.h | 28 ++---
lib/chat-search-bar.cpp | 7 +-
lib/chat-search-bar.h | 12 +-
lib/chat-widget.cpp | 24 ++--
lib/chat-widget.h | 8 +-
logviewer/CMakeLists.txt | 1 -
logviewer/log-viewer.cpp | 1 -
logviewer/message-view.cpp | 71 ++++++------
logviewer/message-view.h | 3 +-
16 files changed, 151 insertions(+), 187 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 86aa80a..88f1446 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,9 +15,9 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package (KF5 REQUIRED COMPONENTS Archive Sonnet WidgetsAddons Service Emoticons
KIO KCMUtils NotifyConfig Notifications I18n
- WebKit WindowSystem XmlGui ItemViews TextWidgets
+ WindowSystem XmlGui ItemViews TextWidgets
IconThemes DBusAddons)
-find_package (Qt5 REQUIRED COMPONENTS WebKitWidgets)
+find_package (Qt5 REQUIRED COMPONENTS WebEngine WebEngineWidgets)
find_package(Qt5 ${QT_REQUIRED_VERSION} OPTIONAL_COMPONENTS TextToSpeech)
if (NOT Qt5TextToSpeech_FOUND)
message(STATUS "Qt5TextToSpeech not found, speech features will be disabled")
diff --git a/adiumxtra-protocol-handler/CMakeLists.txt b/adiumxtra-protocol-handler/CMakeLists.txt
index f78a62f..72c04a7 100644
--- a/adiumxtra-protocol-handler/CMakeLists.txt
+++ b/adiumxtra-protocol-handler/CMakeLists.txt
@@ -11,7 +11,7 @@ set(ktp-adiumxtra-protocol-handler_SRCS
add_executable(ktp-adiumxtra-protocol-handler ${ktp-adiumxtra-protocol-handler_SRCS})
target_link_libraries(ktp-adiumxtra-protocol-handler
- Qt5::WebKit
+ Qt5::WebEngine
KF5::Emoticons
Qt5::Xml
KF5::KIOWidgets
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 9a90cec..836b88e 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -12,7 +12,7 @@ set(ktp-text-ui_SRCS
)
set (ktp-text-ui_LIBS
- Qt5::WebKit
+ Qt5::WebEngine
KF5::CoreAddons
KF5::I18n
KF5::KIOWidgets
diff --git a/config/appearance/CMakeLists.txt b/config/appearance/CMakeLists.txt
index dfb5d04..e8794ab 100644
--- a/config/appearance/CMakeLists.txt
+++ b/config/appearance/CMakeLists.txt
@@ -7,7 +7,7 @@ ki18n_wrap_ui(kcm_ktp_chat_appearance_SRCS ${kcm_ktp_chat_appearance_UI})
add_library(kcm_ktp_chat_appearance MODULE ${kcm_ktp_chat_appearance_SRCS})
target_link_libraries(kcm_ktp_chat_appearance
- Qt5::WebKitWidgets
+ Qt5::WebEngineWidgets
KF5::KCMUtils
KF5::WidgetsAddons
KF5::IconThemes
diff --git a/config/appearance/appearance-config-tab.cpp b/config/appearance/appearance-config-tab.cpp
index f2f298b..d5f053c 100644
--- a/config/appearance/appearance-config-tab.cpp
+++ b/config/appearance/appearance-config-tab.cpp
@@ -31,6 +31,7 @@
#include <KIconLoader>
#include <QFontDatabase>
+#include <QWebEngineSettings>
AppearanceConfigTab::AppearanceConfigTab(QWidget *parent, TabMode mode)
: QWidget(parent),
@@ -338,7 +339,7 @@ void AppearanceConfigTab::defaultTab()
ui->customFontBox->setChecked(false);
ui->chatView->setUseCustomFont(false);
ui->fontFamily->setCurrentFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
- ui->fontSize->setValue(QWebSettings::DefaultFontSize);
+ ui->fontSize->setValue(QWebEngineSettings::DefaultFontSize);
ui->showPresenceCheckBox->setChecked(!m_groupChat);
ui->showJoinLeaveCheckBox->setChecked(!m_groupChat);
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 5294521..e9b73b8 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -39,7 +39,6 @@ target_link_libraries(ktpchat
KF5::KIOWidgets
KF5::KIOCore
KF5::I18n
- KF5::WebKit
KF5::Emoticons
KF5::IconThemes
KF5::Archive
@@ -54,7 +53,7 @@ target_link_libraries(ktpchat
KTp::Logger
KTp::OTR
KTp::Widgets
- Qt5::WebKitWidgets
+ Qt5::WebEngineWidgets
ktpimagesharer
)
install(TARGETS ktpchat ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index d1c93f4..3b37285 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -35,54 +35,68 @@
#include <QFontDatabase>
#include <QMenu>
#include <QDesktopWidget>
-#include <QWebFrame>
-#include <QWebElement>
-#include <QWebInspector>
-#include <QWebSettings>
+#include <QWebEngineContextMenuData>
+#include <QWebEngineProfile>
+#include <QWebEngineSettings>
#include <QApplication>
#include <QAction>
#include <QLocale>
+#include <QDesktopServices>
#include <KEmoticonsTheme>
#include <KSharedConfig>
#include <KConfig>
#include <KConfigGroup>
#include <KMessageBox>
-#include <KToolInvocation>
#include <KIconLoader>
#include <KProtocolInfo>
#include <KLocalizedString>
+AdiumThemePage::AdiumThemePage(QObject *parent)
+ : QWebEnginePage(parent)
+{
+}
+
+bool AdiumThemePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType navigationType, bool isMainFrame)
+{
+ if (!isMainFrame && navigationType == QWebEnginePage::NavigationTypeLinkClicked) {
+ /* This might be an iframe (e. g. for the YouTube plugin) */
+ return true;
+ }
+
+ if (url.fragment() == QLatin1String("x-nextConversation")) {
+ Q_EMIT nextConversation();
+ } else if (url.fragment() == QLatin1String("x-prevConversation")) {
+ Q_EMIT prevConversation();
+ } else {
+ QDesktopServices::openUrl(url);
+ }
+
+ // don't let QWebEngineView handle the links, we do
+ return false;
+}
+
AdiumThemeView::AdiumThemeView(QWidget *parent)
- : KWebView(parent),
+ : QWebEngineView(parent),
// check iconPath docs for minus sign in -KIconLoader::SizeLarge
m_defaultAvatar(KIconLoader::global()->iconPath(QLatin1String("im-user"),-KIconLoader::SizeLarge)),
- m_displayHeader(true),
- jsproxy(new AdiumThemeViewProxy())
+ m_displayHeader(true)
{
- //blocks QWebView functionality which allows you to change page by dragging a URL onto it.
- setAcceptDrops(false);
-
- // don't let QWebView handle the links, we do
- page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+ AdiumThemePage *adiumPage = new AdiumThemePage(this);
+ setPage(adiumPage);
- QAction *defaultOpenLinkAction = pageAction(QWebPage::OpenLink);
- m_openLinkAction = new QAction(defaultOpenLinkAction->text(), this);
- connect(m_openLinkAction, SIGNAL(triggered()),
- this, SLOT(onOpenLinkActionTriggered()));
+ //blocks QWebEngineView functionality which allows you to change page by dragging a URL onto it.
+ setAcceptDrops(false);
- connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(onLinkClicked(QUrl)));
- connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
- this, SLOT(injectProxyIntoJavascript()));
- connect(jsproxy, SIGNAL(viewReady()), this, SLOT(viewLoadFinished()));
- QWebSettings *ws = settings();
- ws->setAttribute(QWebSettings::ZoomTextOnly, true);
+ setFocusPolicy(Qt::NoFocus);
KConfigGroup config(KSharedConfig::openConfig(), "KTpStyleDebug");
bool disableCache = config.readEntry("disableStyleCache", false);
if (disableCache) {
- ws->setObjectCacheCapacities(0, 0, 0);
+ page()->profile()->setHttpCacheType(QWebEngineProfile::NoCache);
}
+
+ connect(page(), &AdiumThemePage::loadFinished, this, &AdiumThemeView::viewLoadFinished);
}
void AdiumThemeView::load(ChatType chatType) {
@@ -122,45 +136,33 @@ void AdiumThemeView::load(ChatType chatType) {
m_displayHeader = appearanceConfig.readEntry("displayHeader", true);
- //special HTML debug mode. Debugging/Profiling only (or theme creating) should have no visible way to turn this flag on.
- m_webInspector = appearanceConfig.readEntry("debug", false);
-
m_useCustomFont = appearanceConfig.readEntry("useCustomFont", false);
- m_fontFamily = appearanceConfig.readEntry("fontFamily", QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont));
- m_fontSize = appearanceConfig.readEntry("fontSize", QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize));
+ m_fontFamily = appearanceConfig.readEntry("fontFamily", QWebEngineSettings::globalSettings()->fontFamily(QWebEngineSettings::StandardFont));
+ m_fontSize = appearanceConfig.readEntry("fontSize", QWebEngineSettings::globalSettings()->fontSize(QWebEngineSettings::DefaultFontSize));
m_showPresenceChanges = appearanceConfig.readEntry("showPresenceChanges", true);
m_showJoinLeaveChanges = appearanceConfig.readEntry("showJoinLeaveChanges", true);
}
-void AdiumThemeView::viewLoadFinished()
+void AdiumThemeView::viewLoadFinished(bool ok)
{
- if (themeOnLoadJS.length()) {
- page()->mainFrame()->evaluateJavaScript(themeOnLoadJS);
+ if (ok) {
+ viewReady();
}
- viewReady();
-}
-
-void AdiumThemeView::injectProxyIntoJavascript()
-{
- page()->mainFrame()->addToJavaScriptWindowObject(QLatin1String("AdiumThemeViewProxy"), jsproxy);
}
void AdiumThemeView::contextMenuEvent(QContextMenuEvent *event)
{
- QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos());
- QUrl url = r.linkUrl();
- if (!url.isEmpty()) {
- // save current link url in openLinkAction
- m_openLinkAction->setData(url);
-
- QMenu menu(this);
- menu.addAction(m_openLinkAction);
- menu.addAction(pageAction(QWebPage::CopyLinkToClipboard));
- menu.exec(mapToGlobal(event->pos()));
- } else {
- QWebView::contextMenuEvent(event);
+ QMenu *menu = new QMenu(this);
+ if (page()->contextMenuData().linkUrl().isValid()) {
+ menu->addAction(page()->action(QWebEnginePage::OpenLinkInThisWindow));
+ menu->addAction(page()->action(QWebEnginePage::CopyLinkToClipboard));
}
+ if (!page()->contextMenuData().selectedText().isEmpty()) {
+ menu->addAction(page()->action(QWebEnginePage::Copy));
+ }
+ connect(menu, &QMenu::aboutToHide, menu, &QObject::deleteLater);
+ menu->popup(event->globalPos());
}
void AdiumThemeView::wheelEvent(QWheelEvent* event)
@@ -180,7 +182,7 @@ void AdiumThemeView::wheelEvent(QWheelEvent* event)
return;
}
- QWebView::wheelEvent(event);
+ QWebEngineView::wheelEvent(event);
}
void AdiumThemeView::mouseReleaseEvent(QMouseEvent *event)
@@ -190,7 +192,7 @@ void AdiumThemeView::mouseReleaseEvent(QMouseEvent *event)
event->accept();
return;
}
- QWebView::mouseReleaseEvent(event);
+ QWebEngineView::mouseReleaseEvent(event);
}
void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
@@ -218,11 +220,11 @@ void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
// set fontFamily and fontSize
if (m_useCustomFont) {
// use user specified fontFamily and Size
- settings()->setFontFamily(QWebSettings::StandardFont, m_fontFamily);
+ settings()->setFontFamily(QWebEngineSettings::StandardFont, m_fontFamily);
// We get desktop's DPI and divide it 96, which is the DPI that WebKit has hardcoded in
// Then we can just scale the fonts using the obtained coefficient and they should look
// good/better on high-dpi screens
- settings()->setFontSize(QWebSettings::DefaultFontSize, m_fontSize * (QApplication::desktop()->logicalDpiY() / 96.0 ));
+ settings()->setFontSize(QWebEngineSettings::DefaultFontSize, m_fontSize * (QApplication::desktop()->logicalDpiY() / 96.0 ));
// since some themes are pretty odd and hardcode fonts to the css we need to override that
// with some extra css. this may not work for all themes!
@@ -238,14 +240,9 @@ void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
<< fontDB.families().contains(m_chatStyle->defaultFontFamily());
// use theme fontFamily/Size, if not existent, it falls back to systems default font
- settings()->setFontFamily(QWebSettings::StandardFont, m_chatStyle->defaultFontFamily());
+ settings()->setFontFamily(QWebEngineSettings::StandardFont, m_chatStyle->defaultFontFamily());
// Computing the font size can result in floats and have some rounding errors, so add 0.5 and floor
- settings()->setFontSize(QWebSettings::DefaultFontSize, qFloor(0.5 + m_chatStyle->defaultFontSize() * (QApplication::desktop()->logicalDpiY() / 96.0 )));
- }
-
- //hidden HTML debugging mode. Should have no visible way to turn it on.
- if (m_webInspector) {
- QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
+ settings()->setFontSize(QWebEngineSettings::DefaultFontSize, qFloor(0.5 + m_chatStyle->defaultFontSize() * (QApplication::desktop()->logicalDpiY() / 96.0 )));
}
//The templateHtml is in a horrific NSString format.
@@ -285,34 +282,9 @@ void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
index = templateHtml.indexOf(QLatin1String("</head>"));
templateHtml.insert(index, KTp::MessageProcessor::instance()->header());
- // The purpose of this regular expression is to find the body tag in the template
- // and make it possible to replace the onload event.
- // The [^>]* expression is to match things that are not the end tag
- // the (onload=\"...\")? expression is to make easy for me to do
- // a string replace and replace the entire onload event (as cap(1).
- // the trailing ? makes it optional in case a theme doesn't actually
- // use the onload event.
- // the inner ([^\"]*) expression attempts to match the javascript
- // that is actually being called by the onLoad event so after we replace
- // it with our C++ function that can call whatever javascript code the theme
- // actually intended.
- // Note: styles that use \" or > in unexpected places in their body tag will break
- // this regexp.
- QRegExp body(QLatin1String("<body[^>]*(onload=\"([^\"]*)\")?[^>]*>"), Qt::CaseInsensitive);
- const QString onload(QLatin1String(" onload=\"AdiumThemeViewProxy.viewReady();\" "));
- index = templateHtml.indexOf(body);
- if (0 <= index ) {
- if (body.cap(1).length() == 0) {
- templateHtml.insert(index + 5, onload);
- } else {
- themeOnLoadJS = body.cap(2);
- //qCDebug(KTP_TEXTUI_LIB) << "Captured js onLoad" << themeOnLoadJS;
- templateHtml.replace(body.pos(1), body.cap(1).length(), onload);
- }
- }
//qCDebug(KTP_TEXTUI_LIB) << templateHtml;
- setHtml(templateHtml);
+ setHtml(templateHtml, QUrl::fromLocalFile(m_chatStyle->getStyleBaseHref()));
m_service = chatInfo.service();
m_serviceIconPath = chatInfo.serviceIconPath();
@@ -415,8 +387,8 @@ void AdiumThemeView::setHeaderDisplayed(bool displayHeader)
void AdiumThemeView::clear()
{
- if (!page()->mainFrame()->url().isEmpty()) {
- page()->mainFrame()->setHtml(QString());
+ if (!page()->url().isEmpty()) {
+ page()->setHtml(QString());
}
}
@@ -576,7 +548,7 @@ void AdiumThemeView::addAdiumStatusMessage(const AdiumThemeStatusInfo& statusMes
QString AdiumThemeView::appendScript(AdiumThemeView::AppendMode mode)
{
- //by making the JS return false evaluateJavaScript is a _lot_ faster, as it has nothing to convert to QVariant.
+ //by making the JS return false runJavaScript is a _lot_ faster, as it has nothing to convert to QVariant.
//escape quotes, and merge HTML onto one line.
switch (mode) {
case AppendMessageWithScroll:
@@ -648,24 +620,13 @@ void AdiumThemeView::appendMessage(QString &html, const QString &script, AppendM
.replace(QLatin1Char('\"'), QLatin1String("\\"")) /* replace " with \" */
.replace(QLatin1Char('
'), QLatin1String(""))); /* remove new lines */
- page()->mainFrame()->evaluateJavaScript(js);
+ page()->runJavaScript(js);
if (!script.isEmpty()) {
- page()->mainFrame()->evaluateJavaScript(script);
+ page()->runJavaScript(script);
}
}
-void AdiumThemeView::onLinkClicked(const QUrl &url)
-{
- KToolInvocation::invokeBrowser(url.toString());
-}
-
-void AdiumThemeView::onOpenLinkActionTriggered()
-{
- QUrl url = m_openLinkAction->data().toUrl();
- onLinkClicked(url);
-}
-
/** Private */
QString AdiumThemeView::replaceHeaderKeywords(QString htmlTemplate, const AdiumThemeHeaderInfo & info)
diff --git a/lib/adium-theme-view.h b/lib/adium-theme-view.h
index 5a0c2e6..621bc39 100644
--- a/lib/adium-theme-view.h
+++ b/lib/adium-theme-view.h
@@ -20,7 +20,7 @@
#ifndef ADIUMTHEMEVIEW_H
#define ADIUMTHEMEVIEW_H
-#include <KWebView>
+#include <QWebEngineView>
#include "adium-theme-header-info.h"
#include "adium-theme-content-info.h"
@@ -35,21 +35,30 @@ class AdiumThemeContentInfo;
class AdiumThemeHeaderInfo;
class AdiumThemeStatusInfo;
class ChatWindowStyle;
+class ChatWidget;
class QContextMenuEvent;
class QAction;
-class AdiumThemeViewProxy : public QObject
+class KDE_TELEPATHY_CHAT_EXPORT AdiumThemePage : public QWebEnginePage
{
Q_OBJECT
+public:
+ AdiumThemePage(QObject *parent = 0);
+
+protected:
+ virtual bool acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType navigationType, bool isMainFrame);
+
Q_SIGNALS:
- void viewReady();
+ void nextConversation();
+ void prevConversation();
};
-class KDE_TELEPATHY_CHAT_EXPORT AdiumThemeView : public KWebView
+class KDE_TELEPATHY_CHAT_EXPORT AdiumThemeView : public QWebEngineView
{
Q_OBJECT
+ friend class ChatWidget;
public:
enum ChatType {
@@ -107,13 +116,10 @@ public Q_SLOTS:
void addStatusMessage(const QString &text,
const QString &sender=QString(),
const QDateTime &time=QDateTime::currentDateTime());
- void onOpenLinkActionTriggered();
- virtual void onLinkClicked(const QUrl &);
- void injectProxyIntoJavascript();
void addAdiumContentMessage(const AdiumThemeContentInfo&);
void addAdiumStatusMessage(const AdiumThemeStatusInfo&);
- void viewLoadFinished();
+ void viewLoadFinished(bool ok);
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
@@ -152,15 +158,9 @@ private:
QString m_defaultAvatar;
AdiumThemeContentInfo m_lastContent;
bool m_displayHeader;
- QAction *m_openLinkAction;
QString m_service;
QString m_serviceIconPath;
-
- bool m_webInspector;
-
- AdiumThemeViewProxy *jsproxy;
- QString themeOnLoadJS;
};
#endif // ADIUMTHEMEVIEW_H
diff --git a/lib/chat-search-bar.cpp b/lib/chat-search-bar.cpp
index 484975a..8c0bb34 100644
--- a/lib/chat-search-bar.cpp
+++ b/lib/chat-search-bar.cpp
@@ -90,13 +90,12 @@ void ChatSearchBar::enableSearchButtons(bool enable)
Q_EMIT enableSearchButtonsSignal(enable);
}
-QWebPage::FindFlags ChatSearchBar::findFlags()
+QWebEnginePage::FindFlags ChatSearchBar::findFlags()
{
- QWebPage::FindFlags flags;
- flags |= QWebPage::FindWrapsAroundDocument;
+ QWebEnginePage::FindFlags flags;
if(m_caseSensitive) {
- flags |= QWebPage::FindCaseSensitively;
+ flags |= QWebEnginePage::FindCaseSensitively;
}
return flags;
}
diff --git a/lib/chat-search-bar.h b/lib/chat-search-bar.h
index c8c5118..f5eaba2 100644
--- a/lib/chat-search-bar.h
+++ b/lib/chat-search-bar.h
@@ -22,7 +22,7 @@
#include "ktpchat_export.h"
-#include <QWebPage>
+#include <QWebEnginePage>
#include <QWidget>
class QLineEdit;
@@ -66,12 +66,12 @@ private Q_SLOTS:
void toggleCaseSensitive(bool toggle);
Q_SIGNALS:
- void findTextSignal(const QString &text, QWebPage::FindFlags flags);
- void findNextSignal(const QString &text, QWebPage::FindFlags flags);
- void findPreviousSignal(const QString &text, QWebPage::FindFlags flags);
+ void findTextSignal(const QString &text, QWebEnginePage::FindFlags flags);
+ void findNextSignal(const QString &text, QWebEnginePage::FindFlags flags);
+ void findPreviousSignal(const QString &text, QWebEnginePage::FindFlags flags);
/** emitted when search criteria is changed by user and updates current view */
- void flagsChangedSignal(const QString &, QWebPage::FindFlags flags);
+ void flagsChangedSignal(const QString &, QWebEnginePage::FindFlags flags);
/** send signal to mainwindow to enable/disable search buttons */
void enableSearchButtonsSignal(bool enable);
@@ -81,7 +81,7 @@ private:
void enableSearchButtons(bool enable);
/** returns selected search criteria chosen by user */
- QWebPage::FindFlags findFlags();
+ QWebEnginePage::FindFlags findFlags();
QLineEdit *m_searchInput;
QToolButton *m_closeButton;
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index fdc9c1e..504aa2b 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -243,10 +243,10 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
connect(d->ui.sendMessageBox, SIGNAL(returnKeyPressed()), SLOT(sendMessage()));
- connect(d->ui.searchBar, SIGNAL(findTextSignal(QString,QWebPage::FindFlags)), this, SLOT(findTextInChat(QString,QWebPage::FindFlags)));
- connect(d->ui.searchBar, SIGNAL(findNextSignal(QString,QWebPage::FindFlags)), this, SLOT(findNextTextInChat(QString,QWebPage::FindFlags)));
- connect(d->ui.searchBar, SIGNAL(findPreviousSignal(QString,QWebPage::FindFlags)), this, SLOT(findPreviousTextInChat(QString,QWebPage::FindFlags)));
- connect(d->ui.searchBar, SIGNAL(flagsChangedSignal(QString,QWebPage::FindFlags)), this, SLOT(findTextInChat(QString,QWebPage::FindFlags)));
+ connect(d->ui.searchBar, &ChatSearchBar::findTextSignal, this, &ChatWidget::findTextInChat);
+ connect(d->ui.searchBar, &ChatSearchBar::findNextSignal, this, &ChatWidget::findNextTextInChat);
+ connect(d->ui.searchBar, &ChatSearchBar::findPreviousSignal, this, &ChatWidget::findPreviousTextInChat);
+ connect(d->ui.searchBar, &ChatSearchBar::flagsChangedSignal, this, &ChatWidget::findTextInChat);
connect(this, SIGNAL(searchTextComplete(bool)), d->ui.searchBar, SLOT(onSearchTextComplete(bool)));
@@ -386,7 +386,7 @@ Tp::TextChannelPtr ChatWidget::textChannel() const
void ChatWidget::keyPressEvent(QKeyEvent *e)
{
if (e->matches(QKeySequence::Copy)) {
- d->ui.chatArea->triggerPageAction(QWebPage::Copy);
+ d->ui.chatArea->triggerPageAction(QWebEnginePage::Copy);
return;
}
@@ -1273,27 +1273,23 @@ void ChatWidget::onInputBoxChanged()
}
}
-void ChatWidget::findTextInChat(const QString& text, QWebPage::FindFlags flags)
+void ChatWidget::findTextInChat(const QString& text, QWebEnginePage::FindFlags flags)
{
// reset highlights
d->ui.chatArea->findText(QString(), flags);
- if(d->ui.chatArea->findText(text, flags)) {
- Q_EMIT searchTextComplete(true);
- } else {
- Q_EMIT searchTextComplete(false);
- }
+ d->ui.chatArea->findText(text, flags, [&] (bool found) { Q_EMIT searchTextComplete(found); });
}
-void ChatWidget::findNextTextInChat(const QString& text, QWebPage::FindFlags flags)
+void ChatWidget::findNextTextInChat(const QString& text, QWebEnginePage::FindFlags flags)
{
d->ui.chatArea->findText(text, flags);
}
-void ChatWidget::findPreviousTextInChat(const QString& text, QWebPage::FindFlags flags)
+void ChatWidget::findPreviousTextInChat(const QString& text, QWebEnginePage::FindFlags flags)
{
// for "backwards" search
- flags |= QWebPage::FindBackward;
+ flags |= QWebEnginePage::FindBackward;
d->ui.chatArea->findText(text, flags);
}
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 588407c..752e1fd 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -28,7 +28,7 @@
#include <QtCore/QString>
#include <QWidget>
-#include <QWebPage>
+#include <QWebEnginePage>
#include <QIcon>
#include <KColorScheme>
@@ -213,9 +213,9 @@ Q_SIGNALS:
private Q_SLOTS:
/** received when user changes search criteria or when searching for text */
- void findTextInChat(const QString &text, QWebPage::FindFlags flags);
- void findNextTextInChat(const QString &text, QWebPage::FindFlags flags);
- void findPreviousTextInChat(const QString &text, QWebPage::FindFlags flags);
+ void findTextInChat(const QString &text, QWebEnginePage::FindFlags flags);
+ void findNextTextInChat(const QString &text, QWebEnginePage::FindFlags flags);
+ void findPreviousTextInChat(const QString &text, QWebEnginePage::FindFlags flags);
void onHistoryFetched(const QList<KTp::Message> &messages);
void onChatPausedTimerExpired();
void currentPresenceChanged(const Tp::Presence &presence);
diff --git a/logviewer/CMakeLists.txt b/logviewer/CMakeLists.txt
index c36157c..28bbe7e 100644
--- a/logviewer/CMakeLists.txt
+++ b/logviewer/CMakeLists.txt
@@ -29,7 +29,6 @@ target_link_libraries(ktp-log-viewer
KF5::KIOWidgets
KF5::Emoticons
KF5::KCMUtils
- KF5::WebKit
KTp::CommonInternals
KTp::Logger
KTp::Models
diff --git a/logviewer/log-viewer.cpp b/logviewer/log-viewer.cpp
index b1dad26..bcdfdfd 100644
--- a/logviewer/log-viewer.cpp
+++ b/logviewer/log-viewer.cpp
@@ -35,7 +35,6 @@
#include <KTp/Models/contacts-model.h>
-#include <QWebFrame>
#include <QMenu>
#include <QAction>
#include <QLineEdit>
diff --git a/logviewer/message-view.cpp b/logviewer/message-view.cpp
index 1b3bbe4..6d222a4 100644
--- a/logviewer/message-view.cpp
+++ b/logviewer/message-view.cpp
@@ -39,7 +39,6 @@ MessageView::MessageView(QWidget *parent) :
AdiumThemeView(parent),
m_infoLabel(new QLabel(this))
{
-
loadSettings();
QFont font = m_infoLabel->font();
@@ -47,7 +46,13 @@ MessageView::MessageView(QWidget *parent) :
m_infoLabel->setFont(font);
m_infoLabel->setAlignment(Qt::AlignCenter);
- connect(this, SIGNAL(loadFinished(bool)), SLOT(processStoredEvents()));
+ connect(this, &MessageView::loadFinished, this, &MessageView::processStoredEvents);
+
+ AdiumThemePage *adiumThemePage = dynamic_cast<AdiumThemePage *>(page());
+ if (adiumThemePage) {
+ connect(adiumThemePage, &AdiumThemePage::nextConversation, this, &MessageView::switchNext);
+ connect(adiumThemePage, &AdiumThemePage::prevConversation, this, &MessageView::switchPrev);
+ }
}
void MessageView::loadLog(const Tp::AccountPtr &account, const KTp::LogEntity &entity,
@@ -102,7 +107,7 @@ void MessageView::resizeEvent(QResizeEvent* e)
{
m_infoLabel->setGeometry(0, 0, e->size().width(), e->size().height());
- QWebView::resizeEvent(e);
+ QWebEngineView::resizeEvent(e);
}
void MessageView::setHighlightText(const QString &text)
@@ -149,17 +154,22 @@ bool logMessageNewerThan(const KTp::LogMessage &e1, const KTp::LogMessage &e2)
void MessageView::processStoredEvents()
{
+ AdiumThemePage *adiumThemePage = dynamic_cast<AdiumThemePage *>(page());
+ if (!adiumThemePage) {
+ return;
+ }
+
AdiumThemeStatusInfo prevConversation;
if (m_prev.isValid()) {
prevConversation = AdiumThemeStatusInfo(AdiumThemeMessageInfo::HistoryStatus);
- prevConversation.setMessage(QString(QLatin1String("<a href=\"#x-prevConversation\"><<< %1</a>")).arg(i18n("Older conversation")));
+ prevConversation.setMessage(QString(QLatin1String("<a href=\"file:///invalid#x-prevConversation\"><<< %1</a>")).arg(i18n("Older conversation")));
prevConversation.setTime(QDateTime(m_prev));
}
AdiumThemeStatusInfo nextConversation;
if (m_next.isValid()) {
nextConversation = AdiumThemeStatusInfo(AdiumThemeMessageInfo::HistoryStatus);
- nextConversation.setMessage(QString(QLatin1String("<a href=\"#x-nextConversation\">%1 >>></a>")).arg(i18n("Newer conversation")));
+ nextConversation.setMessage(QString(QLatin1String("<a href=\"file:///invalid#x-nextConversation\">%1 >>></a>")).arg(i18n("Newer conversation")));
nextConversation.setTime(QDateTime(m_next));
}
@@ -197,30 +207,6 @@ void MessageView::processStoredEvents()
QTimer::singleShot(100, this, SLOT(doHighlightText()));
}
-void MessageView::onLinkClicked(const QUrl &link)
-{
- // Don't emit the signal directly, KWebView does not like when we reload the
- // page from an event handler (and then chain up) and we can't guarantee
- // that everyone will use QueuedConnection when connecting to
- // conversationSwitchRequested() slot
-
- if (link.fragment() == QLatin1String("x-nextConversation")) {
- // Q_EMIT conversationSwitchRequested(m_next)
- QMetaObject::invokeMethod(this, "conversationSwitchRequested", Qt::QueuedConnection,
- Q_ARG(QDate, m_next));
- return;
- }
-
- if (link.fragment() == QLatin1String("x-prevConversation")) {
- // Q_EMIT conversationSwitchRequested(m_prev)
- QMetaObject::invokeMethod(this, "conversationSwitchRequested", Qt::QueuedConnection,
- Q_ARG(QDate, m_prev));
- return;
- }
-
- AdiumThemeView::onLinkClicked(link);
-}
-
void MessageView::loadSettings()
{
const KConfig config(QLatin1String("ktelepathyrc"));
@@ -238,7 +224,30 @@ void MessageView::doHighlightText()
{
findText(QString());
if (!m_highlightedText.isEmpty()) {
- findText(m_highlightedText, QWebPage::HighlightAllOccurrences |
- QWebPage::FindWrapsAroundDocument);
+ findText(m_highlightedText);
}
}
+
+void MessageView::switchPrev()
+{
+ // Don't emit the signal directly, QWebEngineView does not like when we reload the
+ // page from an event handler (and then chain up) and we can't guarantee
+ // that everyone will use QueuedConnection when connecting to
+ // conversationSwitchRequested() slot
+
+ // Q_EMIT conversationSwitchRequested(m_prev)
+ QMetaObject::invokeMethod(this, "conversationSwitchRequested", Qt::QueuedConnection,
+ Q_ARG(QDate, m_prev));
+}
+
+void MessageView::switchNext()
+{
+ // Don't emit the signal directly, QWebEngineView does not like when we reload the
+ // page from an event handler (and then chain up) and we can't guarantee
+ // that everyone will use QueuedConnection when connecting to
+ // conversationSwitchRequested() slot
+
+ // Q_EMIT conversationSwitchRequested(m_next)
+ QMetaObject::invokeMethod(this, "conversationSwitchRequested", Qt::QueuedConnection,
+ Q_ARG(QDate, m_next));
+}
diff --git a/logviewer/message-view.h b/logviewer/message-view.h
index ec592c7..f9bbd6a 100644
--- a/logviewer/message-view.h
+++ b/logviewer/message-view.h
@@ -51,13 +51,14 @@ public:
void showInfoMessage(const QString &message);
public Q_SLOTS:
- void onLinkClicked(const QUrl &link);
void reloadTheme();
private Q_SLOTS:
void onEventsLoaded(KTp::PendingLoggerOperation* po);
void doHighlightText();
void processStoredEvents();
+ void switchPrev();
+ void switchNext();
Q_SIGNALS:
void conversationSwitchRequested(const QDate &date);
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list