summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-10-20 12:01:27 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:05 +0100
commitb204e6254bd0c2227bbbb81519a0ddcf174d2ad4 (patch)
tree0badb3885331b2d700388e96ac59532d6b7dd867
parentEnable incognito mode by calling "rekonq --incognito URL" :) (diff)
downloadrekonq-b204e6254bd0c2227bbbb81519a0ddcf174d2ad4.tar.xz
enable webapp mode by calling "rekonq --webapp URL" :D
NOTE: in my opinion, this is a great feature that needs a lot of attention and testing. But it's really cool to see how it works... ;)
-rw-r--r--src/application.cpp60
-rw-r--r--src/application.h5
-rw-r--r--src/webtab/webtab.cpp28
-rw-r--r--src/webtab/webtab.h4
-rw-r--r--src/webtab/webview.cpp59
5 files changed, 131 insertions, 25 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 679fd1d8..fda0caf8 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -39,6 +39,7 @@
#include "tabbar.h"
#include "tabwindow.h"
#include "webwindow.h"
+#include "webtab.h"
#include "urlresolver.h"
// Local Manager(s) Includes
@@ -112,7 +113,54 @@ int Application::newInstance()
kDebug() << "INCOGNITO: " << incognito;
kDebug() << "WEBAPPS: " << webapp;
+ kDebug() << "ARGS COUNT: " << args->count();
+
+ if (webapp)
+ {
+ if (args->count() == 0)
+ {
+ KMessageBox::error(0, i18n("Error"), i18n("Cannot launch webapp mode without an URL to load"));
+ return 1;
+ }
+
+ if (args->count() > 1)
+ {
+ KMessageBox::error(0, i18n("Error"), i18n("Cannot load more than one URL in webapp mode"));
+ return 1;
+ }
+
+ KUrl u = args->url(0);
+ if (!u.isLocalFile() || !QFile::exists(u.toLocalFile()))
+ {
+ u = UrlResolver::urlFromTextTyped(args->arg(0));
+ }
+ kDebug() << "URL: " << u;
+ WebTab *tab = new WebTab;
+ tab->view()->load(u);
+
+ tab->installEventFilter(this);
+ m_webApps.prepend(tab);
+ tab->show();
+
+ if (isFirstLoad)
+ {
+ // updating rekonq configuration
+ updateConfiguration();
+ setWindowIcon(KIcon("rekonq"));
+
+ // just create History Manager...
+ HistoryManager::self();
+
+ // FIXME: should this be removed?
+ AdBlockManager::self();
+ }
+
+ KStartupInfo::appStarted();
+ isFirstLoad = false;
+ return 0;
+ }
+
if (areThereArguments)
{
// prepare URLS to load
@@ -148,7 +196,7 @@ int Application::newInstance()
}
// first argument: 99% of the time we have just that...
- if (isFirstLoad)
+ if (isFirstLoad || m_tabWindows.count() == 0)
{
// No windows in the current desktop? No windows at all?
// Create a new one and load there sites...
@@ -160,7 +208,9 @@ int Application::newInstance()
else
{
if (incognito)
+ {
loadUrl(urlList.at(0), Rekonq::NewPrivateWindow);
+ }
else
if (!ReKonfig::openExternalLinksInNewWindow())
{
@@ -415,9 +465,13 @@ bool Application::eventFilter(QObject* watched, QEvent* event)
if (event->type() == QEvent::Close)
{
TabWindow *window = qobject_cast<TabWindow*>(watched);
- m_tabWindows.removeOne(window);
+ if (window)
+ m_tabWindows.removeOne(window);
- if (m_tabWindows.count() == 0)
+ WebTab *webApp = qobject_cast<WebTab*>(watched);
+ m_webApps.removeOne(webApp);
+
+ if (m_tabWindows.count() == 0 && m_webApps.count() == 0)
quit();
}
diff --git a/src/application.h b/src/application.h
index 0b3711ac..3750547c 100644
--- a/src/application.h
+++ b/src/application.h
@@ -42,9 +42,11 @@
class TabWindow;
class WebWindow;
+class WebTab;
-typedef QList< QWeakPointer<TabWindow> > TabWindowList;
+typedef QList< QWeakPointer<TabWindow> > TabWindowList;
+typedef QList<WebTab *> WebAppList;
// ---------------------------------------------------------------------------------------------------------------
@@ -113,6 +115,7 @@ private Q_SLOTS:
private:
TabWindowList m_tabWindows;
+ WebAppList m_webApps;
};
#endif // APPLICATION_H
diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp
index 036f62c0..bb616770 100644
--- a/src/webtab/webtab.cpp
+++ b/src/webtab/webtab.cpp
@@ -34,6 +34,7 @@
// Local Includes
#include "historymanager.h"
+#include "iconmanager.h"
#include "sessionmanager.h"
#include "syncmanager.h"
@@ -92,9 +93,18 @@ WebTab::WebTab(QWidget *parent)
connect(view(), SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
connect(view(), SIGNAL(loadStarted()), this, SLOT(resetProgress()));
- connect(view(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
connect(view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
+ if (parent)
+ {
+ connect(view(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ }
+ else
+ {
+ connect(view(), SIGNAL(titleChanged(QString)), this, SLOT(webAppTitleChanged(QString)));
+ connect(view(), SIGNAL(iconChanged()), this, SLOT(webAppIconChanged()));
+ }
+
// Session Manager
connect(view(), SIGNAL(loadFinished(bool)), SessionManager::self(), SLOT(saveSession()));
}
@@ -394,3 +404,19 @@ void WebTab::zoomDefault()
emit infoToShow(i18n("Default zoom: ") + QString::number(m_zoomFactor * 10) + QL1S("%"));
}
+
+
+void WebTab::webAppTitleChanged(QString title)
+{
+
+ if (title.isEmpty())
+ setWindowTitle(i18n("rekonq"));
+ else
+ setWindowTitle(title);
+}
+
+
+void WebTab::webAppIconChanged()
+{
+ setWindowIcon(IconManager::self()->iconForUrl(url()));
+}
diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h
index 6a9e844f..361da2c4 100644
--- a/src/webtab/webtab.h
+++ b/src/webtab/webtab.h
@@ -98,6 +98,10 @@ private Q_SLOTS:
void zoomOut();
void zoomDefault();
+ // webapp slots per title & icon
+ void webAppTitleChanged(QString);
+ void webAppIconChanged();
+
Q_SIGNALS:
void loadProgressing();
void titleChanged(const QString &);
diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp
index e8b629ec..df4af0b3 100644
--- a/src/webtab/webview.cpp
+++ b/src/webtab/webview.cpp
@@ -314,7 +314,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(pageAction(KWebPage::Forward));
}
- menu.addAction(webwin->actionByName("view_redisplay"));
+ menu.addAction(pageAction(KWebPage::Reload));
menu.addSeparator();
@@ -333,7 +333,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// Page Actions
menu.addAction(pageAction(KWebPage::SelectAll));
- menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
+ if (webwin)
+ menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
{
@@ -342,13 +343,19 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(a);
}
- menu.addAction(webwin->actionByName("page_source"));
- menu.addAction(inspectAction);
-
+ if (webwin)
+ {
+ menu.addAction(webwin->actionByName("page_source"));
+ menu.addAction(inspectAction);
+ }
+
// we need to show everytime this because we cannot communicate with the tabwindow.
// We are NOT sure it exists..
- menu.addSeparator();
- menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::FullScreen)));
+ if (webwin)
+ {
+ menu.addSeparator();
+ menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::FullScreen)));
+ }
}
// LINK ACTIONS -------------------------------------------------------------------
@@ -358,21 +365,27 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
sendByMailAction->setData(m_contextMenuHitResult.linkUrl());
sendByMailAction->setText(i18n("Share link"));
- a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), this);
- a->setData(m_contextMenuHitResult.linkUrl());
- connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
- menu.addAction(a);
-
+ if (webwin)
+ {
+ a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), this);
+ a->setData(m_contextMenuHitResult.linkUrl());
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
+ menu.addAction(a);
+ }
+
a = new KAction(KIcon("window-new"), i18n("Open in New &Window"), this);
a->setData(m_contextMenuHitResult.linkUrl());
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
menu.addAction(a);
- a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), this);
- a->setData(m_contextMenuHitResult.linkUrl());
- connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow()));
- menu.addAction(a);
-
+ if (webwin)
+ {
+ a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), this);
+ a->setData(m_contextMenuHitResult.linkUrl());
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow()));
+ menu.addAction(a);
+ }
+
menu.addSeparator();
// Don't show dots if we are NOT going to ask for download path
@@ -517,11 +530,17 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
}
else
{
- a = webwin->actionByName(KStandardAction::name(KStandardAction::AddBookmark));
- menu.addAction(a);
+ if (webwin)
+ {
+ a = webwin->actionByName(KStandardAction::name(KStandardAction::AddBookmark));
+ menu.addAction(a);
+ }
}
+
menu.addAction(sendByMailAction);
- menu.addAction(inspectAction);
+
+ if (webwin)
+ menu.addAction(inspectAction);
// SPELL CHECK Actions
if (m_contextMenuHitResult.isContentEditable())