From d387448a61c3c220484b3cc08aac04058c35a645 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 13 Mar 2013 18:57:24 +0100 Subject: Restore activity daemon support BUG: 315694 --- src/tabwindow/tabwidget.cpp | 20 +++++++++++++++++++- src/tabwindow/tabwidget.h | 2 ++ src/webtab/webtab.cpp | 35 +++++++++++++++++++++++++++++++++++ src/webtab/webtab.h | 14 ++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tabwindow/tabwidget.cpp b/src/tabwindow/tabwidget.cpp index bdc7a47a..9494fad4 100644 --- a/src/tabwindow/tabwidget.cpp +++ b/src/tabwindow/tabwidget.cpp @@ -35,9 +35,11 @@ #include "application.h" #include "rekonqwindow.h" +#include "tabbar.h" + #include "webpage.h" +#include "webtab.h" #include "webwindow.h" -#include "tabbar.h" #include "tabhistory.h" @@ -78,6 +80,7 @@ TabWidget::TabWidget(bool withTab, bool PrivateBrowsingMode, QWidget *parent) , _openedTabsCounter(0) , _isPrivateBrowsing(PrivateBrowsingMode) , _ac(new KActionCollection(this)) + , _lastCurrentTabIndex(-1) { init(); @@ -98,6 +101,7 @@ TabWidget::TabWidget(WebPage *pg, QWidget *parent) , _openedTabsCounter(0) , _isPrivateBrowsing(false) , _ac(new KActionCollection(this)) + , _lastCurrentTabIndex(-1) { init(); @@ -394,6 +398,8 @@ void TabWidget::pageCreated(WebPage *page) void TabWidget::currentChanged(int newIndex) { + _lastCurrentTabIndex = newIndex; + _openedTabsCounter = 0; tabBar()->setTabHighlighted(newIndex, false); @@ -403,6 +409,8 @@ void TabWidget::currentChanged(int newIndex) if (!tab) return; + tab->tabView()->focusIn(); + QString t = tab->title(); (t.isEmpty() || t == QL1S("rekonq")) @@ -410,6 +418,16 @@ void TabWidget::currentChanged(int newIndex) : setWindowTitle(t + QL1S(" - rekonq")); tab->checkFocus(); + + // ---------------------------------------------------- + + WebWindow *oldTab = webWindow(_lastCurrentTabIndex); + if (!oldTab) + return; + + oldTab->tabView()->focusOut(); + + _lastCurrentTabIndex = newIndex; } diff --git a/src/tabwindow/tabwidget.h b/src/tabwindow/tabwidget.h index 2718904c..a6b36e33 100644 --- a/src/tabwindow/tabwidget.h +++ b/src/tabwindow/tabwidget.h @@ -144,6 +144,8 @@ private: bool _isPrivateBrowsing; KActionCollection *_ac; + + int _lastCurrentTabIndex; }; #endif // TAB_WIDGET diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp index 00a3c819..7a3213b0 100644 --- a/src/webtab/webtab.cpp +++ b/src/webtab/webtab.cpp @@ -58,6 +58,10 @@ #include #include +#ifdef HAVE_KACTIVITIES +#include +#endif + // Qt Includes #include #include @@ -75,6 +79,9 @@ WebTab::WebTab(QWidget *parent, bool isPrivateBrowsing) , m_zoomFactor(10) , m_isPrivateBrowsing(isPrivateBrowsing) , m_splitter(new QSplitter(this)) +#ifdef HAVE_KACTIVITIES + , m_activityResourceInstance(0) +#endif { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -122,6 +129,16 @@ WebTab::WebTab(QWidget *parent, bool isPrivateBrowsing) // Session Manager connect(view(), SIGNAL(loadFinished(bool)), SessionManager::self(), SLOT(saveSession())); + +#ifdef HAVE_KACTIVITIES + if (m_isPrivateBrowsing) + return; + + m_activityResourceInstance = new KActivities::ResourceInstance(window()->winId(), this); + + connect(this, SIGNAL(urlChanged(const QUrl &)), m_activityResourceInstance, SLOT(setUri(const QUrl &))); + connect(this, SIGNAL(titleChanged(const QString &)), m_activityResourceInstance, SLOT(setTitle(const QString &))); +#endif } @@ -482,3 +499,21 @@ void WebTab::toggleInspector(bool on) page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + + +void WebTab::focusIn() +{ + if (m_isPrivateBrowsing || !m_activityResourceInstance) + return; + + m_activityResourceInstance->notifyFocusedIn(); +} + + +void WebTab::focusOut() +{ + if (m_isPrivateBrowsing || !m_activityResourceInstance) + return; + + m_activityResourceInstance->notifyFocusedOut(); +} diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h index 5fc06994..1f501323 100644 --- a/src/webtab/webtab.h +++ b/src/webtab/webtab.h @@ -43,6 +43,9 @@ #include #include +// Config +#include + // Forward Declarations class NotificationBar; class PreviewSelectorBar; @@ -52,6 +55,10 @@ class WebPage; class WebWindow; +#ifdef HAVE_KACTIVITIES +namespace KActivities { class ResourceInstance; } +#endif + class REKONQ_TESTS_EXPORT WebTab : public QWidget { @@ -84,6 +91,9 @@ public: KParts::ReadOnlyPart *part(); void setPart(KParts::ReadOnlyPart *p, const KUrl &u); + + void focusIn(); + void focusOut(); private Q_SLOTS: void updateProgress(int progress); @@ -140,6 +150,10 @@ private: bool m_isPrivateBrowsing; QSplitter *m_splitter; + +#ifdef HAVE_KACTIVITIES + KActivities::ResourceInstance *m_activityResourceInstance; +#endif }; #endif -- cgit v1.2.1