diff options
| -rw-r--r-- | src/data/rekonq.desktop | 1 | ||||
| -rw-r--r-- | src/findbar.cpp | 1 | ||||
| -rw-r--r-- | src/newtabpage.cpp | 130 | ||||
| -rw-r--r-- | src/newtabpage.h | 5 | ||||
| -rw-r--r-- | src/zoombar.cpp | 2 | 
5 files changed, 73 insertions, 66 deletions
| diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index b75f86dc..a29d37e5 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -30,6 +30,7 @@ Name[zh_CN]=rekonq  Name[zh_TW]=rekonq  GenericName=Web Browser  GenericName[da]=Webbrowser +GenericName[de]=Webbrowser  GenericName[en_GB]=Web Browser  GenericName[es]=Navegador web  GenericName[fr]=Navigateur web diff --git a/src/findbar.cpp b/src/findbar.cpp index 5d88dc1b..495e4f96 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -75,6 +75,7 @@ FindBar::FindBar(QWidget *parent)      // hide timer      connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(hide())); +    m_hideTimer->setSingleShot(true);      // label      QLabel *label = new QLabel(i18n("Find:")); diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 62b97d4d..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 Preview")); +    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(); @@ -180,7 +178,7 @@ void NewTabPage::favoritesPage()      if (urls.isEmpty())      {          m_root.addClass("empty"); -        m_root.setPlainText(i18n("You can add a preview by clicking the \"Add Preview\" button in the top-right corner of this page")); +        m_root.setPlainText(i18n("You can add a favorite by clicking the \"Add Favorite\" button in the top-right corner of this page"));          return;      } @@ -338,55 +336,50 @@ void NewTabPage::removePreview(int index)      ReKonfig::self()->writeConfig();  } -  void NewTabPage::browsingMenu(const KUrl ¤tUrl)  {      QList<QWebElement> navItems; -    KIconLoader *loader = KIconLoader::global(); - -    QWebElement nav = markup(".link"); // Favorites -    nav.findFirst("a").setAttribute("href", "about:favorites"); -    nav.findFirst("img").setAttribute("src" , QString("file:///" + -                                      loader->iconPath("emblem-favorite", KIconLoader::Desktop || KIconLoader::SizeSmall))); -    nav.findFirst("span").appendInside(i18n("Favorites")); -    navItems.append(nav); - -    nav = markup(".link"); // Closed Tabs -    nav.findFirst("a").setAttribute("href", "about:closedTabs"); -    nav.findFirst("img").setAttribute("src" , QString("file:///" + -                                      loader->iconPath("tab-close", KIconLoader::Desktop || KIconLoader::SizeSmall))); -    nav.findFirst("span").appendInside(i18n("Closed Tabs")); -    navItems.append(nav); - -    nav = markup(".link"); // Bookmarks -    nav.findFirst("a").setAttribute("href", "about:bookmarks"); -    nav.findFirst("img").setAttribute("src" , QString("file:///" + -                                      loader->iconPath("bookmarks", KIconLoader::Desktop || KIconLoader::SizeSmall))); -    nav.findFirst("span").appendInside(i18n("Bookmarks")); -    navItems.append(nav); - -    nav = markup(".link"); // History -    nav.findFirst("a").setAttribute("href", "about:history"); -    nav.findFirst("img").setAttribute("src" , QString("file:///" + -                                      loader->iconPath("view-history", KIconLoader::Desktop || KIconLoader::SizeSmall))); -    nav.findFirst("span").appendInside(i18n("History")); -    navItems.append(nav); - -    nav = markup(".link"); // Downloads -    nav.findFirst("a").setAttribute("href", "about:downloads"); -    nav.findFirst("img").setAttribute("src" , QString("file:///" + -                                      loader->iconPath("download", KIconLoader::Desktop || KIconLoader::SizeSmall))); -    nav.findFirst("span").appendInside(i18n("Downloads")); -    navItems.append(nav); +    // Favorites +    navItems.append(createLinkItem(i18n("Favorites"), +                                   QLatin1String("about:favorites"), +                                   QLatin1String("emblem-favorite"), +                                   KIconLoader::Toolbar)); + +    // Closed Tabs +    navItems.append(createLinkItem(i18n("Closed Tabs"), +                                   QLatin1String("about:closedTabs"), +                                   QLatin1String("tab-close"), +                                   KIconLoader::Toolbar)); + +    // Bookmarks +    navItems.append(createLinkItem(i18n("Bookmarks"), +                                   QLatin1String("about:bookmarks"), +                                   QLatin1String("bookmarks"), +                                   KIconLoader::Toolbar)); + +    // History +    navItems.append(createLinkItem(i18n("History"), +                                   QLatin1String("about:history"), +                                   QLatin1String("view-history"), +                                   KIconLoader::Toolbar)); + +    // Downloads +    navItems.append(createLinkItem(i18n("Downloads"), +                                   QLatin1String("about:downloads"), +                                   QLatin1String("download"), +                                   KIconLoader::Toolbar));      foreach(QWebElement it, navItems)      { -        if (it.findFirst("a").attribute("href") == currentUrl.toMimeDataString()) -            it.addClass("current"); -        else if (currentUrl == "about:home" && it.findFirst("a").attribute("href") == "about:favorites") -            it.addClass("current"); -        m_root.document().findFirst("#navigation").appendInside(it); +        const QString aTagString('a'); +        const QString hrefAttributeString(QLatin1String("href")); + +        if (it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString()) +            it.addClass(QLatin1String("current")); +        else if (currentUrl == QLatin1String("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QLatin1String("about:favorites")) +            it.addClass(QLatin1String("current")); +        m_root.document().findFirst(QLatin1String("#navigation")).appendInside(it);      }  } @@ -395,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(); @@ -441,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(); @@ -542,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(); @@ -595,3 +585,15 @@ void NewTabPage::downloadsPage()          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(QLatin1String(".link")); +    nav.findFirst(QString('a')).setAttribute(QLatin1String("href"), urlString); +    nav.findFirst(QLatin1String("img")).setAttribute(QLatin1String("src"), +                                                     QString::fromLatin1("file://") + loader->iconPath(iconPath, groupOrSize)); +    nav.findFirst(QLatin1String("span")).appendInside(title); +    return nav; +} diff --git a/src/newtabpage.h b/src/newtabpage.h index ad4941d3..2560beb2 100644 --- a/src/newtabpage.h +++ b/src/newtabpage.h @@ -33,6 +33,7 @@  #include "rekonq_defines.h"  // KDE Includes +#include <KIconLoader>  #include <KUrl>  // Qt Includes @@ -107,7 +108,7 @@ private:       * It works for all elements defined here.       *       */ -    inline QWebElement markup(const QString &selector) +    inline QWebElement markup(const QString &selector) const      {          return m_root.document().findFirst("#models > " + selector).clone();      } @@ -115,6 +116,8 @@ private:      QString checkTitle(const QString &title);  private: +    QWebElement createLinkItem(const QString &title, const QString &urlString, const QString &iconPath, int groupOrSize) const; +      QString m_html;      QWebElement m_root;  }; diff --git a/src/zoombar.cpp b/src/zoombar.cpp index 14e88cf5..485d71a9 100644 --- a/src/zoombar.cpp +++ b/src/zoombar.cpp @@ -64,7 +64,7 @@ ZoomBar::ZoomBar(QWidget *parent)      layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop);      // label -    QLabel *label = new QLabel(i18n("Zoom :")); +    QLabel *label = new QLabel(i18n("Zoom:"));      layout->addWidget(label);      m_zoomSlider->setTracking(true); | 
