summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/application.cpp61
-rw-r--r--src/application.h11
-rw-r--r--src/iconmanager.cpp6
-rw-r--r--src/mainview.cpp20
-rw-r--r--src/mainview.h2
-rw-r--r--src/mainwindow.cpp46
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/newtabpage.cpp214
-rw-r--r--src/opensearch/searchengine.cpp10
-rw-r--r--src/urlbar/listitem.cpp51
-rw-r--r--src/urlbar/urlbar.cpp18
-rw-r--r--src/urlbar/urlbar.h2
13 files changed, 263 insertions, 183 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67c5e0fb..5e340240 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ PROJECT( rekonq )
# Informations to update before to release this package.
# rekonq info
-SET(REKONQ_VERSION "0.6.50" )
+SET(REKONQ_VERSION "0.6.52" )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h )
diff --git a/src/application.cpp b/src/application.cpp
index 233be527..cadfa50f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -55,10 +55,12 @@
#include <KMessageBox>
#include <KStandardDirs>
#include <ThreadWeaver/Weaver>
+#include <KAction>
// Qt Includes
#include <QVBoxLayout>
+
QWeakPointer<AdBlockManager> Application::s_adblockManager;
QWeakPointer<BookmarkProvider> Application::s_bookmarkProvider;
QWeakPointer<HistoryManager> Application::s_historyManager;
@@ -66,13 +68,20 @@ QWeakPointer<IconManager> Application::s_iconManager;
QWeakPointer<OpenSearchManager> Application::s_opensearchManager;
QWeakPointer<SessionManager> Application::s_sessionManager;
+
using namespace ThreadWeaver;
+
Application::Application()
: KUniqueApplication()
+ , _privateBrowsingAction(0)
{
connect(Weaver::instance(), SIGNAL(jobDone(ThreadWeaver::Job*)),
this, SLOT(loadResolvedUrl(ThreadWeaver::Job*)));
+
+ _privateBrowsingAction = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
+ _privateBrowsingAction->setCheckable(true);
+ connect(_privateBrowsingAction, SIGNAL(triggered(bool)), this, SLOT(setPrivateBrowsingMode(bool)));
}
@@ -575,3 +584,55 @@ bool Application::clearDownloadsHistory()
QFile downloadFile(downloadFilePath);
return downloadFile.remove();
}
+
+
+void Application::setPrivateBrowsingMode(bool b)
+{
+// NOTE
+// to let work nicely Private Browsing, we need the following:
+// - enable WebKit Private Browsing mode :)
+// - treat all cookies as session cookies
+// (so that they do not get saved to a persistent storage). Available from KDE SC 4.5.72, see BUG: 250122
+// - favicons (fixed in rekonq 0.5.87)
+// - save actual session (to restore it when Private Mode is closed) and stop storing it
+// - disable history saving
+
+ QWebSettings *settings = QWebSettings::globalSettings();
+ bool isJustEnabled = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled);
+ if(isJustEnabled == b)
+ return; // uhm... something goes wrong...
+
+ if (b)
+ {
+ QString caption = i18n("Are you sure you want to turn on private browsing?");
+ QString text = i18n("<b>%1</b>"
+ "<p>rekonq will save your current tabs for when you'll stop private browsing the net..</p>", caption);
+
+ int button = KMessageBox::warningContinueCancel(mainWindow(), text, caption, KStandardGuiItem::cont(), KStandardGuiItem::cancel(), i18n("don't ask again") );
+ if (button != KMessageBox::Continue)
+ return;
+
+ settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+ _privateBrowsingAction->setChecked(true);
+
+ Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
+ {
+ w.data()->close();
+ }
+ loadUrl( KUrl("about:home"), Rekonq::NewWindow);
+ }
+ else
+ {
+ Q_FOREACH(const QWeakPointer<MainWindow> &w, m_mainWindows)
+ {
+ w.data()->close();
+ }
+
+ settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
+ _privateBrowsingAction->setChecked(false);
+
+ loadUrl( KUrl("about:blank"), Rekonq::NewWindow);
+ if(!sessionManager()->restoreSession())
+ loadUrl( KUrl("about:home"), Rekonq::NewWindow);
+ }
+}
diff --git a/src/application.h b/src/application.h
index 8afb956f..b30e337c 100644
--- a/src/application.h
+++ b/src/application.h
@@ -50,6 +50,9 @@ class MainWindow;
class OpenSearchManager;
class SessionManager;
+class KAction;
+
+
namespace ThreadWeaver {class Job;}
@@ -107,6 +110,8 @@ public:
void addDownload(const QString &srcUrl, const QString &destUrl);
DownloadList downloads();
bool clearDownloadsHistory();
+
+ KAction *privateBrowsingAction() { return _privateBrowsingAction; };
public slots:
/**
@@ -124,7 +129,6 @@ public slots:
void removeMainWindow(MainWindow *window);
private slots:
-
/**
* Any actions that can be delayed until the window is visible
*/
@@ -134,6 +138,9 @@ private slots:
void updateConfiguration();
+ // the general place to set private browsing
+ void setPrivateBrowsingMode(bool);
+
private:
static QWeakPointer<HistoryManager> s_historyManager;
static QWeakPointer<BookmarkProvider> s_bookmarkProvider;
@@ -143,6 +150,8 @@ private:
static QWeakPointer<IconManager> s_iconManager;
MainWindowList m_mainWindows;
+
+ KAction *_privateBrowsingAction;
};
#endif // APPLICATION_H
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
index 5086c59d..f5b60ea6 100644
--- a/src/iconmanager.cpp
+++ b/src/iconmanager.cpp
@@ -65,10 +65,6 @@ KIcon IconManager::iconForUrl(const KUrl &url)
// first things first.. avoid infinite loop at startup
if (url.isEmpty() || Application::instance()->mainWindowList().isEmpty())
return KIcon("text-html");
-
- // no icons in private browsing..
- if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- return KIcon("view-media-artist");
QByteArray encodedUrl = url.toEncoded();
// rekonq icons..
@@ -114,7 +110,7 @@ void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify)
return;
}
- // no icons in private browsing..
+ // do not load new icons in private browsing..
if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
kDebug() << "Private browsing, private icon...";
diff --git a/src/mainview.cpp b/src/mainview.cpp
index beaf4e21..325afb4c 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -63,6 +63,7 @@ MainView::MainView(MainWindow *parent)
, m_addTabButton(0)
, m_currentTabIndex(0)
, m_parentWindow(parent)
+ , _lastClosedTab(0)
{
// setting tabbar
TabBar *tabBar = new TabBar(this);
@@ -100,6 +101,7 @@ MainView::~MainView()
{
delete _widgetBar;
delete m_addTabButton;
+ delete _lastClosedTab;
}
@@ -500,7 +502,10 @@ void MainView::closeTab(int index, bool del)
if (del)
{
- tabToClose->deleteLater();
+ if(_lastClosedTab)
+ _lastClosedTab->deleteLater();
+ _lastClosedTab = tabToClose;
+// tabToClose->deleteLater();
}
emit tabsChanged();
@@ -634,6 +639,19 @@ void MainView::openLastClosedTab()
return;
const HistoryItem item = m_recentlyClosedTabs.takeFirst();
+
+ // if there is a tab yet loaded, use it
+ if(_lastClosedTab)
+ {
+ addTab(_lastClosedTab, _lastClosedTab->view()->title() );
+ _widgetBar->addWidget(_lastClosedTab->urlBar());
+ updateTabBar();
+ emit tabsChanged();
+
+ _lastClosedTab = 0;
+ return;
+ }
+
Application::instance()->loadUrl(KUrl(item.url), Rekonq::NewTab);
}
diff --git a/src/mainview.h b/src/mainview.h
index 29162dd1..6ef40ac7 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -189,6 +189,8 @@ private:
QList<HistoryItem> m_recentlyClosedTabs;
MainWindow *m_parentWindow;
+
+ WebTab *_lastClosedTab;
};
#endif // MAINVIEW_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 555e58ae..7b4cf8a3 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -408,11 +408,9 @@ void MainWindow::setupActions()
actionCollection()->addAction(QL1S("page_source"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));
- a = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
- a->setCheckable(true);
+ a = Application::instance()->privateBrowsingAction();
actionCollection()->addAction(QL1S("private_browsing"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(privateBrowsing(bool)));
-
+
a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
actionCollection()->addAction(QL1S("clear_private_data"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData()));
@@ -728,42 +726,6 @@ void MainWindow::printRequested(QWebFrame *frame)
}
-void MainWindow::privateBrowsing(bool enable)
-{
- QWebSettings *settings = QWebSettings::globalSettings();
- if (enable && !settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- QString title = i18n("Are you sure you want to turn on private browsing?");
- QString text = i18n("<b>%1</b>"
- "<p>When private browsing is turned on,"
- " web pages are not added to the history,"
- " new cookies are not stored, current cookies cannot be accessed,"
- " site icons will not be stored, the session will not be saved."
- " Until you close the window, you can still click the Back and Forward buttons"
- " to return to the web pages you have opened.</p>", title);
-
- int button = KMessageBox::warningContinueCancel(this, text, title);
- if (button == KMessageBox::Continue)
- {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
- m_view->urlBar()->setPrivateMode(true);
- }
- else
- {
- actionCollection()->action( QL1S("private_browsing") )->setChecked(false);
- }
- }
- else
- {
- settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
- m_view->urlBar()->setPrivateMode(false);
-
- m_lastSearch.clear();
- m_view->reloadAllTabs();
- }
-}
-
-
void MainWindow::find(const QString & search)
{
if (!currentTab())
@@ -1349,6 +1311,10 @@ bool MainWindow::queryClose()
if(Application::instance()->sessionSaving())
return true;
+ // smooth private browsing mode
+ if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ return true;
+
if (m_view->count() > 1)
{
int answer = KMessageBox::questionYesNoCancel(
diff --git a/src/mainwindow.h b/src/mainwindow.h
index ad4fa4b8..0395db4d 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -147,9 +147,6 @@ private slots:
void viewPageSource();
void viewFullScreen(bool enable);
- // Tools Menu slots
- void privateBrowsing(bool enable);
-
// Settings Menu slot
void preferences();
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 36462f8c..7dcc9581 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -60,7 +60,7 @@ NewTabPage::NewTabPage(QWebFrame *frame)
, m_root(frame->documentElement())
{
QString htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html");
- QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics");
+ QString imagesPath = QL1S("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QL1S("rekonq/pics");
QFile file(htmlFilePath);
bool isOpened = file.open(QIODevice::ReadOnly);
@@ -71,7 +71,7 @@ NewTabPage::NewTabPage(QWebFrame *frame)
else
{
m_html = file.readAll();
- m_html.replace(QString("%2"), imagesPath);
+ m_html.replace(QL1S("%2"), imagesPath);
}
}
@@ -85,7 +85,7 @@ void NewTabPage::generate(const KUrl &url)
{
if (KUrl("about:preview").isParentOf(url))
{
- if (url.fileName() == QString("add"))
+ if (url.fileName() == QL1S("add"))
{
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
@@ -102,22 +102,22 @@ void NewTabPage::generate(const KUrl &url)
generate(KUrl("about:favorites"));
return;
}
- if (url.directory() == QString("preview/remove"))
+ if (url.directory() == QL1S("preview/remove"))
{
removePreview(url.fileName().toInt());
return;
}
- if (url.directory() == QString("preview/modify"))
+ if (url.directory() == QL1S("preview/modify"))
{
int index = url.fileName().toInt();
Application::instance()->mainWindow()->currentTab()->createPreviewSelectorBar(index);
return;
}
}
- if (url.fileName() == QString("clear"))
+ if (url.fileName() == QL1S("clear"))
{
Application::instance()->mainWindow()->actionByName("clear_private_data")->trigger();
- generate(QString("about:" + url.directory()));
+ generate( QL1S("about:") + url.directory() );
return;
}
if (url == KUrl("about:bookmarks/edit"))
@@ -130,7 +130,7 @@ void NewTabPage::generate(const KUrl &url)
page->mainFrame()->setHtml(m_html);
page->setIsOnRekonqPage(true);
- m_root = page->mainFrame()->documentElement().findFirst("#content");
+ m_root = page->mainFrame()->documentElement().findFirst( QL1S("#content") );
browsingMenu(url);
@@ -162,13 +162,13 @@ void NewTabPage::generate(const KUrl &url)
title = i18n("Downloads");
}
- m_root.document().findFirst("title").setPlainText(title);
+ m_root.document().findFirst( QL1S("title") ).setPlainText(title);
}
void NewTabPage::favoritesPage()
{
- m_root.addClass("favorites");
+ m_root.addClass( QL1S("favorites") );
const QWebElement add = createLinkItem(i18n("Add Favorite"),
QL1S("about:preview/add"),
@@ -181,7 +181,7 @@ void NewTabPage::favoritesPage()
if (urls.isEmpty())
{
- m_root.addClass("empty");
+ m_root.addClass( QL1S("empty") );
m_root.setPlainText(i18n("You can add a favorite by clicking the \"Add Favorite\" button in the top-right corner of this page"));
return;
}
@@ -207,12 +207,13 @@ void NewTabPage::favoritesPage()
QWebElement NewTabPage::emptyPreview(int index)
{
- QWebElement prev = markup(".thumbnail");
+ QWebElement prev = markup( QL1S(".thumbnail") );
- prev.findFirst(".preview img").setAttribute("src" , QString("file:///") +
- KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop));
- prev.findFirst("span a").setPlainText(i18n("Set a Preview..."));
- prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString()));
+ prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src") ,
+ QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop));
+ prev.findFirst( QL1S("span a") ).setPlainText(i18n("Set a Preview..."));
+ prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"),
+ QL1S("about:preview/modify/") + QVariant(index).toString());
setupPreview(prev, index);
//hideControls(prev);
@@ -223,12 +224,12 @@ QWebElement NewTabPage::emptyPreview(int index)
QWebElement NewTabPage::loadingPreview(int index, const KUrl &url)
{
- QWebElement prev = markup(".thumbnail");
+ QWebElement prev = markup( QL1S(".thumbnail") );
- prev.findFirst(".preview img").setAttribute("src" ,
- QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif"));
- prev.findFirst("span a").setPlainText(i18n("Loading Preview..."));
- prev.findFirst("a").setAttribute("href", url.toMimeDataString());
+ prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src"),
+ QL1S("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif"));
+ prev.findFirst( QL1S("span a") ).setPlainText(i18n("Loading Preview..."));
+ prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"), url.toMimeDataString());
setupPreview(prev, index);
showControls(prev);
@@ -245,13 +246,13 @@ QWebElement NewTabPage::loadingPreview(int index, const KUrl &url)
QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString &title)
{
- QWebElement prev = markup(".thumbnail");
+ QWebElement prev = markup( QL1S(".thumbnail") );
QString previewPath = QL1S("file://") + WebSnap::imagePathFromUrl(url);
- prev.findFirst(".preview img").setAttribute("src" , previewPath);
- prev.findFirst("a").setAttribute("href", url.toMimeDataString()); // NOTE ?
- prev.findFirst("span a").setAttribute("href", url.toMimeDataString()); // NOTE ?
- prev.findFirst("span a").setPlainText(checkTitle(title));
+ prev.findFirst( QL1S(".preview img") ).setAttribute( QL1S("src") , previewPath);
+ prev.findFirst( QL1S("a") ).setAttribute( QL1S("href"), url.toMimeDataString());
+ prev.findFirst( QL1S("span a") ).setAttribute( QL1S("href"), url.toMimeDataString());
+ prev.findFirst( QL1S("span a") ).setPlainText(checkTitle(title));
setupPreview(prev, index);
showControls(prev);
@@ -261,40 +262,38 @@ QWebElement NewTabPage::validPreview(int index, const KUrl &url, const QString &
void NewTabPage::hideControls(QWebElement e)
{
- e.findFirst(".remove").setStyleProperty("visibility", "hidden");
- e.findFirst(".modify").setStyleProperty("visibility", "hidden");
+ e.findFirst( QL1S(".remove") ).setStyleProperty( QL1S("visibility"), QL1S("hidden") );
+ e.findFirst( QL1S(".modify") ).setStyleProperty( QL1S("visibility"), QL1S("hidden") );
}
void NewTabPage::showControls(QWebElement e)
{
- e.findFirst(".remove").setStyleProperty("visibility", "visible");
- e.findFirst(".modify").setStyleProperty("visibility", "visible");
+ e.findFirst( QL1S(".remove") ).setStyleProperty( QL1S("visibility"), QL1S("visible") );
+ e.findFirst( QL1S(".modify") ).setStyleProperty( QL1S("visibility"), QL1S("visible") );
}
void NewTabPage::setupPreview(QWebElement e, int index)
{
- e.findFirst(".remove img").setAttribute("src", QString("file:///") +
- KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState));
- e.findFirst(".remove").setAttribute("title", "Remove favorite");
- e.findFirst(".modify img").setAttribute("src", QString("file:///") +
- KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState));
- e.findFirst(".modify").setAttribute("title", "Set new favorite");
+ e.findFirst( QL1S(".remove img") ).setAttribute( QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState));
+ e.findFirst( QL1S(".remove") ).setAttribute( QL1S("title"), QL1S("Remove favorite"));
+ e.findFirst( QL1S(".modify img") ).setAttribute( QL1S("src"), QL1S("file:///") + KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState));
+ e.findFirst( QL1S(".modify") ).setAttribute( QL1S("title"), QL1S("Set new favorite"));
- e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString()));
- e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString()));
+ e.findFirst( QL1S(".modify") ).setAttribute( QL1S("href"), QL1S("about:preview/modify/") + QVariant(index).toString() );
+ e.findFirst( QL1S(".remove") ).setAttribute( QL1S("href"), QL1S("about:preview/remove/") + QVariant(index).toString() );
- e.setAttribute("id", "preview" + QVariant(index).toString());
+ e.setAttribute( QL1S("id"), QL1S("preview") + QVariant(index).toString());
}
void NewTabPage::snapFinished()
{
// Update page, but only if open
- if (m_root.document().findAll("#rekonq-newtabpage").count() == 0)
+ if (m_root.document().findAll( QL1S("#rekonq-newtabpage") ).count() == 0)
return;
- if (m_root.findAll(".favorites").count() == 0 && m_root.findAll(".closedTabs").count() == 0)
+ if (m_root.findAll( QL1S(".favorites") ).count() == 0 && m_root.findAll( QL1S(".closedTabs") ).count() == 0)
return;
QStringList urls = ReKonfig::previewUrls();
@@ -307,12 +306,12 @@ void NewTabPage::snapFinished()
if (WebSnap::existsImage(url))
{
- QWebElement prev = m_root.findFirst("#preview" + QVariant(i).toString());
- if (KUrl(prev.findFirst("a").attribute("href")) == url)
+ QWebElement prev = m_root.findFirst( QL1S("#preview") + QVariant(i).toString());
+ if (KUrl(prev.findFirst("a").attribute( QL1S("href") )) == url)
{
QWebElement newPrev = validPreview(i, url, title);
- if (m_root.findAll(".closedTabs").count() != 0)
+ if (m_root.findAll( QL1S(".closedTabs") ).count() != 0)
hideControls(newPrev);
prev.replace(newPrev);
@@ -338,6 +337,7 @@ void NewTabPage::removePreview(int index)
ReKonfig::self()->writeConfig();
}
+
void NewTabPage::browsingMenu(const KUrl &currentUrl)
{
QList<QWebElement> navItems;
@@ -374,55 +374,68 @@ void NewTabPage::browsingMenu(const KUrl &currentUrl)
foreach(QWebElement it, navItems)
{
- const QString aTagString('a');
+ const QString aTagString( QL1C('a') );
const QString hrefAttributeString(QL1S("href"));
if (it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString())
- it.addClass(QL1S("current"));
+ it.addClass( QL1S("current") );
else if (currentUrl == QL1S("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QL1S("about:favorites"))
- it.addClass(QL1S("current"));
- m_root.document().findFirst(QL1S("#navigation")).appendInside(it);
+ it.addClass( QL1S("current") );
+ m_root.document().findFirst( QL1S("#navigation") ).appendInside(it);
}
}
void NewTabPage::historyPage()
{
- m_root.addClass("history");
+ m_root.addClass( QL1S("history") );
const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
QL1S("about:history/clear"),
QL1S("edit-clear"),
KIconLoader::Toolbar);
- m_root.document().findFirst("#actions").appendInside(clearData);
+ m_root.document().findFirst( QL1S("#actions") ).appendInside(clearData);
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
if (model->rowCount() == 0)
{
- m_root.addClass("empty");
+ m_root.addClass( QL1S("empty") );
m_root.setPlainText(i18n("Your browsing history is empty"));
return;
}
int i = 0;
+ QString faviconsDir = KStandardDirs::locateLocal("cache" , "favicons/" , true);
+ QString icon = QL1S("file://") + KGlobal::dirs()->findResource("icon", "oxygen/16x16/mimetypes/text-html.png");
do
{
QModelIndex index = model->index(i, 0, QModelIndex());
if (model->hasChildren(index))
{
- m_root.appendInside(markup("h3"));
+ m_root.appendInside(markup( QL1S("h3") ));
m_root.lastChild().setPlainText(index.data().toString());
for (int j = 0; j < model->rowCount(index); ++j)
- {
+ {
QModelIndex son = model->index(j, 0, index);
+ KUrl u = son.data(HistoryModel::UrlStringRole).toUrl();
+
+ QString b = faviconsDir + u.host() + QL1S(".png");
+ if( QFile::exists(b) )
+ icon = QL1S("file://") + b;
+
m_root.appendInside(son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm"));
- m_root.appendInside(" ");
- m_root.appendInside(markup("a"));
- m_root.lastChild().setAttribute("href" , son.data(HistoryModel::UrlStringRole).toString());
+ m_root.appendInside( QL1S(" ") );
+ m_root.appendInside(markup( QL1S("img") ));
+ m_root.lastChild().setAttribute( QL1S("src"), icon);
+ m_root.lastChild().setAttribute( QL1S("width"), QL1S("16"));
+ m_root.lastChild().setAttribute( QL1S("height"), QL1S("16"));
+ m_root.appendInside( QL1S(" ") );
+ m_root.appendInside(markup( QL1S("a") ));
+ m_root.lastChild().setAttribute( QL1S("href") , u.url());
m_root.lastChild().appendInside(son.data().toString());
- m_root.appendInside("<br/>");
+ m_root.appendInside( QL1S("<br />") );
}
}
i++;
@@ -433,18 +446,18 @@ void NewTabPage::historyPage()
void NewTabPage::bookmarksPage()
{
- m_root.addClass("bookmarks");
+ m_root.addClass( QL1S("bookmarks") );
const QWebElement editBookmarks = createLinkItem(i18n("Edit Bookmarks"),
QL1S("about:bookmarks/edit"),
QL1S("bookmarks-organize"),
KIconLoader::Toolbar);
- m_root.document().findFirst("#actions").appendInside(editBookmarks);
+ m_root.document().findFirst( QL1S("#actions") ).appendInside(editBookmarks);
KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
if (bookGroup.isNull())
{
- m_root.addClass("empty");
+ m_root.addClass( QL1S("empty") );
m_root.setPlainText(i18n("You have no bookmarks"));
return;
}
@@ -460,13 +473,15 @@ void NewTabPage::bookmarksPage()
void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
{
+ QString cacheDir = QL1S("file://") + KStandardDirs::locateLocal("cache" , "" , true);
+ QString icon = QL1S("file://") + KGlobal::dirs()->findResource("icon", "oxygen/16x16/mimetypes/text-html.png");
if (bookmark.isGroup())
{
KBookmarkGroup group = bookmark.toGroup();
KBookmark bm = group.first();
- parent.appendInside(markup("h3"));
+ parent.appendInside(markup( QL1S("h3") ));
parent.lastChild().setPlainText(group.fullText());
- parent.appendInside(markup(".bookfolder"));
+ parent.appendInside(markup( QL1S(".bookfolder") ));
while (!bm.isNull())
{
createBookItem(bm, parent.lastChild()); // it is .bookfolder
@@ -475,27 +490,36 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
}
else if (bookmark.isSeparator())
{
- parent.appendInside("<hr/>");
+ parent.appendInside( QL1S("<hr />") );
}
else
{
- parent.appendInside(markup("a"));
- parent.lastChild().setAttribute("href" , bookmark.url().prettyUrl());
+ QString b = bookmark.icon();
+ if(b.contains( QL1S("favicons") ))
+ icon = cacheDir + bookmark.icon() + QL1S(".png");
+
+ parent.appendInside(markup( QL1S("img") ));
+ parent.lastChild().setAttribute( QL1S("src") , icon);
+ parent.lastChild().setAttribute( QL1S("width") , QL1S("16"));
+ parent.lastChild().setAttribute( QL1S("height") , QL1S("16"));
+ parent.appendInside( QL1S(" ") );
+ parent.appendInside(markup( QL1S("a") ));
+ parent.lastChild().setAttribute( QL1S("href") , bookmark.url().prettyUrl());
parent.lastChild().setPlainText(bookmark.fullText());
- parent.appendInside("<br/>");
+ parent.appendInside( QL1S("<br />") );
}
}
void NewTabPage::closedTabsPage()
{
- m_root.addClass("closedTabs");
+ m_root.addClass( QL1S("closedTabs") );
QList<HistoryItem> links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
if (links.isEmpty())
{
- m_root.addClass("empty");
+ m_root.addClass( QL1S("empty") );
m_root.setPlainText(i18n("There are no recently closed tabs"));
return;
}
@@ -512,7 +536,7 @@ void NewTabPage::closedTabsPage()
? validPreview(i, item.url, item.title)
: loadingPreview(i, item.url);
- prev.setAttribute("id", "preview" + QVariant(i).toString());
+ prev.setAttribute( QL1S("id"), QL1S("preview") + QVariant(i).toString());
hideControls(prev);
m_root.appendInside(prev);
}
@@ -525,7 +549,7 @@ QString NewTabPage::checkTitle(const QString &title)
if (t.length() > 23)
{
t.truncate(20);
- t += "...";
+ t += QL1S("...");
}
return t;
}
@@ -533,69 +557,69 @@ QString NewTabPage::checkTitle(const QString &title)
void NewTabPage::downloadsPage()
{
- m_root.addClass("downloads");
+ m_root.addClass( QL1S("downloads") );
const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
QL1S("about:downloads/clear"),
QL1S("edit-clear"),
KIconLoader::Toolbar);
- m_root.document().findFirst("#actions").appendInside(clearData);
+ m_root.document().findFirst( QL1S("#actions") ).appendInside(clearData);
DownloadList list = Application::instance()->downloads();
if (list.isEmpty())
{
- m_root.addClass("empty");
+ m_root.addClass( QL1S("empty") );
m_root.setPlainText(i18n("There are no recently downloaded files to show"));
return;
}
foreach(const DownloadItem &item, list)
{
- m_root.prependInside(markup("div"));
+ m_root.prependInside(markup( QL1S("div") ));
QWebElement div = m_root.firstChild();
- div.addClass("download");
+ div.addClass( QL1S("download") );
KUrl u = KUrl(item.destUrlString);
QString fName = u.fileName();
QString dir = QL1S("file://") + u.directory();
- QString file = dir + '/' + fName;
+ QString file = dir + QL1C('/') + fName;
KIconLoader *loader = KIconLoader::global();
- QString iconPath = "file://" + loader->iconPath(KMimeType::iconNameForUrl(u), KIconLoader::Desktop);
+ QString iconPath = QL1S("file://") + loader->iconPath(KMimeType::iconNameForUrl(u), KIconLoader::Desktop);
- div.appendInside(markup("img"));
- div.lastChild().setAttribute("src", iconPath);
+ div.appendInside(markup( QL1S("img") ));
+ div.lastChild().setAttribute( QL1S("src"), iconPath);
- div.appendInside("<strong>" + fName + "</strong>");
- div.appendInside(" - ");
+ div.appendInside( QL1S("<strong>") + fName + QL1S("</strong>") );
+ div.appendInside( QL1S(" - ") );
QString date = KGlobal::locale()->formatDateTime(item.dateTime, KLocale::FancyLongDate);
- div.appendInside("<em>" + date + "</em>");
- div.appendInside("<br/>");
+ div.appendInside( QL1S("<em>") + date + QL1S("</em>") );
+ div.appendInside( QL1S("<br />") );
- div.appendInside("<a href=" + item.srcUrlString + '>' + item.srcUrlString + "</a>");
- div.appendInside("<br/>");
+ div.appendInside( QL1S("<a href=") + item.srcUrlString + QL1C('>') + item.srcUrlString + QL1S("</a>") );
+ div.appendInside( QL1S("<br />") );
- div.appendInside(markup("a"));
- div.lastChild().setAttribute("href", dir);
+ div.appendInside(markup( QL1S("a") ));
+ div.lastChild().setAttribute( QL1S("href"), dir);
div.lastChild().setPlainText(i18n("Open directory"));
- div.appendInside(" - ");
- div.appendInside(markup("a"));
- div.lastChild().setAttribute("href", file);
+ div.appendInside( QL1S(" - ") );
+ div.appendInside(markup( QL1S("a") ));
+ div.lastChild().setAttribute( QL1S("href"), file);
div.lastChild().setPlainText(i18n("Open file"));
}
}
+
QWebElement NewTabPage::createLinkItem(const QString &title, const QString &urlString, const QString &iconPath, int groupOrSize) const
{
const KIconLoader * const loader = KIconLoader::global();
- QWebElement nav = markup(QL1S(".link"));
- nav.findFirst(QString('a')).setAttribute(QL1S("href"), urlString);
- nav.findFirst(QL1S("img")).setAttribute(QL1S("src"),
- QString::fromLatin1("file://") + loader->iconPath(iconPath, groupOrSize));
- nav.findFirst(QL1S("span")).appendInside(title);
+ QWebElement nav = markup( QL1S(".link") );
+ nav.findFirst( QL1S("a") ).setAttribute( QL1S("href"), urlString);
+ nav.findFirst( QL1S("img") ).setAttribute( QL1S("src"), QL1S("file://") + loader->iconPath(iconPath, groupOrSize));
+ nav.findFirst( QL1S("span") ).appendInside(title);
return nav;
}
diff --git a/src/opensearch/searchengine.cpp b/src/opensearch/searchengine.cpp
index 89e62dee..415e5b35 100644
--- a/src/opensearch/searchengine.cpp
+++ b/src/opensearch/searchengine.cpp
@@ -140,10 +140,12 @@ QString SearchEngine::extractQuery(const QString &text)
{
QString query = text;
KService::Ptr engine = SearchEngine::fromString(text);
- if (engine)
- {
- query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
- }
+
+ // WARNING: this lets rekonq hangs on kde: urlbar typing..
+// if (engine)
+// {
+// query = query.remove(0, text.indexOf(SearchEngine::delimiter()) + 1);
+// }
return query;
}
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index df9ef286..8406c792 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -465,7 +465,7 @@ SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString
hLayout->setSpacing(4);
hLayout->addWidget(new IconLabel(item.url, this));
- hLayout->addWidget(new TextLabel(item.title, SearchEngine::extractQuery(text), this));
+ hLayout->addWidget(new TextLabel(item.title, text, this));
hLayout->addWidget(new TypeIconLabel(item.type, this));
setLayout(hLayout);
@@ -502,32 +502,39 @@ BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, Q
ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text, QWidget *parent)
-{
- ListItem *newItem;
+{
+ if (item.type & UrlSearchItem::Search)
+ {
+ kDebug() << "Search";
+ return new SearchListItem(item, text, parent);
+ }
+
if (item.type & UrlSearchItem::Browse)
{
- newItem = new BrowseListItem(item, text, parent);
+ kDebug() << "Browse";
+ return new BrowseListItem(item, text, parent);
}
- else
+
+ if (item.type & UrlSearchItem::History)
{
- if (item.type & UrlSearchItem::Search)
- {
- newItem = new SearchListItem(item, text, parent);
- }
- else
- {
-
- if (item.type & UrlSearchItem::Suggestion)
- {
- newItem = new SuggestionListItem(item, text, parent);
- }
- else
- {
- newItem = new PreviewListItem(item, text, parent);
- }
- }
+ kDebug() << "History";
+ return new PreviewListItem(item, text, parent);
+ }
+
+ if (item.type & UrlSearchItem::Bookmark)
+ {
+ kDebug() << "Bookmark";
+ return new PreviewListItem(item, text, parent);
+ }
+
+ if (item.type & UrlSearchItem::Suggestion)
+ {
+ kDebug() << "Suggestion";
+ return new SuggestionListItem(item, text, parent);
}
- return newItem;
+ kDebug() << "Undefined";
+ return new PreviewListItem(item, text, parent);
+
}
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 3ec0b2fa..1f4a0367 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -79,7 +79,6 @@ void IconButton::mouseReleaseEvent(QMouseEvent* event)
UrlBar::UrlBar(QWidget *parent)
: KLineEdit(parent)
, _tab(0)
- , _privateMode(false)
, _icon(new IconButton(this))
, _suggestionTimer(new QTimer(this))
{
@@ -159,7 +158,7 @@ void UrlBar::paintEvent(QPaintEvent *event)
QColor backgroundColor;
QColor foregroundColor;
- if (_privateMode)
+ if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
backgroundColor = QColor(220, 220, 220); // light gray
foregroundColor = Qt::black;
@@ -289,12 +288,6 @@ void UrlBar::focusInEvent(QFocusEvent *event)
}
-void UrlBar::setPrivateMode(bool on)
-{
- _privateMode = on;
-}
-
-
void UrlBar::dropEvent(QDropEvent *event)
{
KLineEdit::dropEvent(event);
@@ -505,8 +498,15 @@ void UrlBar::suggest()
void UrlBar::refreshFavicon()
{
+ if(QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ {
+ _icon->setIcon(KIcon("view-media-artist"));
+ return;
+ }
+
KUrl u = _tab->url();
- if(u.scheme() == QL1S("about")) {
+ if(u.scheme() == QL1S("about"))
+ {
_icon->setIcon(KIcon("arrow-right"));
return;
}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index dcd0ba5b..4cdd9d9c 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -89,7 +89,6 @@ public:
explicit UrlBar(QWidget *parent = 0);
~UrlBar();
- void setPrivateMode(bool on);
void activateSuggestions(bool);
public slots:
@@ -124,7 +123,6 @@ private:
QWeakPointer<CompletionWidget> _box;
WebTab *_tab;
- bool _privateMode;
IconButton *_icon;
IconButtonPointerList _rightIconsList;