summaryrefslogtreecommitdiff
path: root/src/newtabpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newtabpage.cpp')
-rw-r--r--src/newtabpage.cpp68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index 2b80b7f0..78496bc2 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -44,7 +44,6 @@
// KDE Includes
#include <KStandardDirs>
-#include <KIconLoader>
#include <KConfig>
#include <KDialog>
#include <KCalendarSystem>
@@ -167,11 +166,10 @@ void NewTabPage::favoritesPage()
{
m_root.addClass("favorites");
- QWebElement add = markup(".link");
- add.findFirst("a").setAttribute("href", "about:preview/add");
- add.findFirst("img").setAttribute("src" , QString("file:///" +
- KIconLoader::global()->iconPath("list-add", KIconLoader::Small || KIconLoader::SizeSmall)));
- add.findFirst("span").appendInside(i18n("Add Favorite"));
+ const QWebElement add = createLinkItem(i18n("Add Favorite"),
+ QLatin1String("about:preview/add"),
+ QLatin1String("list-add"),
+ KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(add);
QStringList names = ReKonfig::previewNames();
@@ -343,20 +341,34 @@ void NewTabPage::browsingMenu(const KUrl &currentUrl)
QList<QWebElement> navItems;
// Favorites
- navItems.append(createNavItem(i18n("Favorites"), QLatin1String("about:favorites"), QLatin1String("emblem-favorite")));
-
+ navItems.append(createLinkItem(i18n("Favorites"),
+ QLatin1String("about:favorites"),
+ QLatin1String("emblem-favorite"),
+ KIconLoader::Toolbar));
// Closed Tabs
- navItems.append(createNavItem(i18n("Closed Tabs"), QLatin1String("about:closedTabs"), QLatin1String("tab-close")));
+ navItems.append(createLinkItem(i18n("Closed Tabs"),
+ QLatin1String("about:closedTabs"),
+ QLatin1String("tab-close"),
+ KIconLoader::Toolbar));
// Bookmarks
- navItems.append(createNavItem(i18n("Bookmarks"), QLatin1String("about:bookmarks"), QLatin1String("bookmarks")));
+ navItems.append(createLinkItem(i18n("Bookmarks"),
+ QLatin1String("about:bookmarks"),
+ QLatin1String("bookmarks"),
+ KIconLoader::Toolbar));
// History
- navItems.append(createNavItem(i18n("History"), QLatin1String("about:history"), QLatin1String("view-history")));
+ navItems.append(createLinkItem(i18n("History"),
+ QLatin1String("about:history"),
+ QLatin1String("view-history"),
+ KIconLoader::Toolbar));
// Downloads
- navItems.append(createNavItem(i18n("Downloads"), QLatin1String("about:downloads"), QLatin1String("download")));
+ navItems.append(createLinkItem(i18n("Downloads"),
+ QLatin1String("about:downloads"),
+ QLatin1String("download"),
+ KIconLoader::Toolbar));
foreach(QWebElement it, navItems)
{
@@ -376,11 +388,10 @@ void NewTabPage::historyPage()
{
m_root.addClass("history");
- QWebElement clearData = markup(".link");
- clearData.findFirst("a").setAttribute("href", "about:history/clear");
- QString iconPath = QString("file:///" + KIconLoader::global()->iconPath("edit-clear", KIconLoader::SizeSmall || KIconLoader::Small));
- clearData.findFirst("img").setAttribute("src" , iconPath);
- clearData.findFirst("span").appendInside(i18n("Clear Private Data"));
+ const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
+ QLatin1String("about:history/clear"),
+ QLatin1String("edit-clear"),
+ KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(clearData);
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
@@ -422,11 +433,10 @@ void NewTabPage::bookmarksPage()
{
m_root.addClass("bookmarks");
- QWebElement editBookmarks = markup(".link");
- editBookmarks.findFirst("a").setAttribute("href", "about:bookmarks/edit");
- QString iconPath = QString("file:///" + KIconLoader::global()->iconPath("bookmarks-organize", KIconLoader::SizeSmall || KIconLoader::Small));
- editBookmarks.findFirst("img").setAttribute("src" , iconPath);
- editBookmarks.findFirst("span").appendInside(i18n("Edit Bookmarks"));
+ const QWebElement editBookmarks = createLinkItem(i18n("Edit Bookmarks"),
+ QLatin1String("about:bookmarks/edit"),
+ QLatin1String("bookmarks-organize"),
+ KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(editBookmarks);
KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
@@ -523,11 +533,10 @@ void NewTabPage::downloadsPage()
{
m_root.addClass("downloads");
- QWebElement clearData = markup(".link");
- clearData.findFirst("a").setAttribute("href", "about:downloads/clear");
- QString iconPath = QString("file:///" + KIconLoader::global()->iconPath("edit-clear", KIconLoader::SizeSmall || KIconLoader::Small));
- clearData.findFirst("img").setAttribute("src" , iconPath);
- clearData.findFirst("span").appendInside(i18n("Clear Private Data"));
+ const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
+ QLatin1String("about:downloads/clear"),
+ QLatin1String("edit-clear"),
+ KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(clearData);
DownloadList list = Application::instance()->downloads();
@@ -577,15 +586,14 @@ void NewTabPage::downloadsPage()
}
}
-QWebElement NewTabPage::createNavItem(const QString &title, const QString &urlString, const QString &iconPath) const
+QWebElement NewTabPage::createLinkItem(const QString &title, const QString &urlString, const QString &iconPath, int groupOrSize) const
{
const KIconLoader * const loader = KIconLoader::global();
QWebElement nav = markup(QLatin1String(".link"));
nav.findFirst(QString('a')).setAttribute(QLatin1String("href"), urlString);
nav.findFirst(QLatin1String("img")).setAttribute(QLatin1String("src"),
- QString::fromLatin1("file://") + loader->iconPath(iconPath,
- KIconLoader::Desktop || KIconLoader::SizeSmall));
+ QString::fromLatin1("file://") + loader->iconPath(iconPath, groupOrSize));
nav.findFirst(QLatin1String("span")).appendInside(title);
return nav;
}