diff --git a/bin/locale/cs_CZ.qm b/bin/locale/cs_CZ.qm index f5388ee12..6f3f456a5 100644 Binary files a/bin/locale/cs_CZ.qm and b/bin/locale/cs_CZ.qm differ diff --git a/src/QupZilla.pro b/src/QupZilla.pro index 1c3d55dac..b4d299383 100644 --- a/src/QupZilla.pro +++ b/src/QupZilla.pro @@ -166,7 +166,8 @@ SOURCES += main.cpp\ bookmarksimport/operaimporter.cpp \ bookmarksimport/bookmarksimportdialog.cpp \ tools/iconfetcher.cpp \ - tools/followredirectreply.cpp + tools/followredirectreply.cpp \ + webview/webhistorywrapper.cpp HEADERS += \ 3rdparty/qtwin.h \ @@ -279,7 +280,8 @@ HEADERS += \ bookmarksimport/operaimporter.h \ bookmarksimport/bookmarksimportdialog.h \ tools/iconfetcher.h \ - tools/followredirectreply.h + tools/followredirectreply.h \ + webview/webhistorywrapper.h FORMS += \ preferences/autofillmanager.ui \ @@ -412,6 +414,8 @@ message($$DEFINES) + + diff --git a/src/navigation/navigationbar.cpp b/src/navigation/navigationbar.cpp index 161f68bf7..63eb37b0f 100644 --- a/src/navigation/navigationbar.cpp +++ b/src/navigation/navigationbar.cpp @@ -21,6 +21,7 @@ #include "iconprovider.h" #include "websearchbar.h" #include "reloadstopbutton.h" +#include "webhistorywrapper.h" NavigationBar::NavigationBar(QupZilla *mainClass, QWidget *parent) : QWidget(parent) @@ -102,8 +103,8 @@ NavigationBar::NavigationBar(QupZilla *mainClass, QWidget *parent) connect(m_menuBack, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryBackMenu())); connect(m_menuForward, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryNextMenu())); - connect(m_buttonBack, SIGNAL(clicked()), p_QupZilla, SLOT(goBack())); - connect(m_buttonNext, SIGNAL(clicked()), p_QupZilla, SLOT(goNext())); + connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack())); + connect(m_buttonNext, SIGNAL(clicked()), this, SLOT(goForward())); connect(m_reloadStop->buttonStop(), SIGNAL(clicked()), p_QupZilla, SLOT(stop())); connect(m_reloadStop->buttonReload(), SIGNAL(clicked()), p_QupZilla, SLOT(reload())); connect(m_buttonHome, SIGNAL(clicked()), p_QupZilla, SLOT(goHome())); @@ -142,12 +143,14 @@ void NavigationBar::aboutToShowHistoryBackMenu() return; m_menuBack->clear(); QWebHistory* history = p_QupZilla->weView()->history(); + int curindex = history->currentItemIndex(); int count = 0; + QUrl lastUrl = history->currentItem().url(); for (int i = curindex-1; i >= 0; i--) { QWebHistoryItem item = history->itemAt(i); - if (item.isValid()) { + if (item.isValid() && lastUrl != item.url()) { QString title = item.title(); if (title.length() > 40) { title.truncate(40); @@ -155,11 +158,16 @@ void NavigationBar::aboutToShowHistoryBackMenu() } QAction* action = m_menuBack->addAction(_iconForUrl(item.url()),title, this, SLOT(goAtHistoryIndex())); action->setData(i); - count++; + lastUrl = item.url(); } + + count++; if (count == 20) break; } + + m_menuBack->addSeparator(); + m_menuBack->addAction(tr("Clear history"), this, SLOT(clearHistory())); } void NavigationBar::aboutToShowHistoryNextMenu() @@ -167,13 +175,15 @@ void NavigationBar::aboutToShowHistoryNextMenu() if (!m_menuForward || !p_QupZilla->weView()) return; m_menuForward->clear(); + QWebHistory* history = p_QupZilla->weView()->history(); int curindex = history->currentItemIndex(); int count = 0; + QUrl lastUrl = history->currentItem().url(); for (int i = curindex+1; i < history->count(); i++) { QWebHistoryItem item = history->itemAt(i); - if (item.isValid()) { + if (item.isValid() && lastUrl != item.url()) { QString title = item.title(); if (title.length() > 40) { title.truncate(40); @@ -181,11 +191,23 @@ void NavigationBar::aboutToShowHistoryNextMenu() } QAction* action = m_menuForward->addAction(_iconForUrl(item.url()),title, this, SLOT(goAtHistoryIndex())); action->setData(i); - count++; + lastUrl = item.url(); } + + count++; if (count == 20) break; } + + m_menuForward->addSeparator(); + m_menuForward->addAction(tr("Clear history"), this, SLOT(clearHistory())); +} + +void NavigationBar::clearHistory() +{ + QWebHistory* history = p_QupZilla->weView()->page()->history(); + history->clear(); + refreshHistory(); } void NavigationBar::goAtHistoryIndex() @@ -193,6 +215,7 @@ void NavigationBar::goAtHistoryIndex() if (QAction* action = qobject_cast(sender())) { p_QupZilla->weView()->page()->history()->goToItem(p_QupZilla->weView()->page()->history()->itemAt(action->data().toInt())); } + refreshHistory(); } @@ -202,8 +225,18 @@ void NavigationBar::refreshHistory() return; QWebHistory* history = p_QupZilla->weView()->page()->history(); - m_buttonBack->setEnabled(history->canGoBack()); - m_buttonNext->setEnabled(history->canGoForward()); + m_buttonBack->setEnabled(WebHistoryWrapper::canGoBack(history)); + m_buttonNext->setEnabled(WebHistoryWrapper::canGoForward(history)); +} + +void NavigationBar::goBack() +{ + WebHistoryWrapper::goBack(p_QupZilla->weView()->page()->history()); +} + +void NavigationBar::goForward() +{ + WebHistoryWrapper::goForward(p_QupZilla->weView()->page()->history()); } NavigationBar::~NavigationBar() diff --git a/src/navigation/navigationbar.h b/src/navigation/navigationbar.h index 13a6c6b84..b0bf90e34 100644 --- a/src/navigation/navigationbar.h +++ b/src/navigation/navigationbar.h @@ -53,10 +53,15 @@ signals: public slots: void refreshHistory(); + void goBack(); + void goForward(); + private slots: void aboutToShowHistoryNextMenu(); void aboutToShowHistoryBackMenu(); + void goAtHistoryIndex(); + void clearHistory(); private: QupZilla* p_QupZilla; @@ -75,7 +80,6 @@ private: QMenu* m_menuForward; WebSearchBar* m_searchLine; - }; #endif // NAVIGATIONBAR_H diff --git a/src/webview/webhistorywrapper.cpp b/src/webview/webhistorywrapper.cpp new file mode 100644 index 000000000..c23334fe0 --- /dev/null +++ b/src/webview/webhistorywrapper.cpp @@ -0,0 +1,74 @@ +#include "webhistorywrapper.h" + +WebHistoryWrapper::WebHistoryWrapper(QObject* parent) + : QObject(parent) +{ +} + +QList WebHistoryWrapper::forwardItems(int maxItems, QWebHistory* history) +{ + QList list; + QUrl lastUrl = history->currentItem().url(); + + int count = 0; + foreach (QWebHistoryItem item, history->forwardItems(maxItems + 5)) { + if (item.url() == lastUrl || count == maxItems) + continue; + + lastUrl = item.url(); + list.append(item); + count++; + } + + return list; +} + +QList WebHistoryWrapper::backItems(int maxItems, QWebHistory* history) +{ + QList list; + QUrl lastUrl = history->currentItem().url(); + + int count = 0; + QList bItems = history->backItems(maxItems + 5); + for (int i = bItems.count() - 1; i >= 0; i--) { + QWebHistoryItem item = bItems.at(i); + if (item.url() == lastUrl || count == maxItems) + continue; + + lastUrl = item.url(); + list.append(item); + count++; + } + + return list; +} + +bool WebHistoryWrapper::canGoForward(QWebHistory* history) +{ + return !forwardItems(1, history).isEmpty(); +} + +bool WebHistoryWrapper::canGoBack(QWebHistory* history) +{ + return !backItems(1, history).isEmpty(); +} + +void WebHistoryWrapper::goBack(QWebHistory* history) +{ + QList items = backItems(1, history); + + if (items.isEmpty()) + return; + + history->goToItem(items.at(0)); +} + +void WebHistoryWrapper::goForward(QWebHistory* history) +{ + QList items = forwardItems(1, history); + + if (items.isEmpty()) + return; + + history->goToItem(items.at(0)); +} diff --git a/src/webview/webhistorywrapper.h b/src/webview/webhistorywrapper.h new file mode 100644 index 000000000..22ed33e35 --- /dev/null +++ b/src/webview/webhistorywrapper.h @@ -0,0 +1,28 @@ +#ifndef WEBHISTORYWRAPPER_H +#define WEBHISTORYWRAPPER_H + +#include +#include + + +class WebHistoryWrapper : public QObject +{ + Q_OBJECT +public: + explicit WebHistoryWrapper(QObject *parent = 0); + + static QList forwardItems(int maxItems, QWebHistory* history); + static QList backItems(int maxItems, QWebHistory* history); + + static bool canGoForward(QWebHistory* history); + static bool canGoBack(QWebHistory* history); + + static void goBack(QWebHistory* history); + static void goForward(QWebHistory* history); + + +signals: + +}; + +#endif // WEBHISTORYWRAPPER_H diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index 1b84d6462..3c71080b1 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -106,6 +106,29 @@ WebPage* WebView::webPage() const return m_page; } +void WebView::back() +{ + if (page()) { + emit ipChanged(m_currentIp); + p_QupZilla->navigationBar()->goBack(); + } +} + +void WebView::forward() +{ + if (page()) { + emit ipChanged(m_currentIp); + p_QupZilla->navigationBar()->goForward(); + } +} + +void WebView::slotReload() +{ + if (page()) { + emit ipChanged(m_currentIp); + page()->triggerAction(QWebPage::Reload); + } +} WebTab* WebView::webTab() const { diff --git a/src/webview/webview.h b/src/webview/webview.h index b00f30ae1..08fb3b1fb 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -70,9 +70,9 @@ public: public slots: void stop(); - void back(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Back);} } - void forward(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Forward);} } - void slotReload(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Reload);} } + void back(); + void forward(); + void slotReload(); void iconChanged(); void selectAll(); void closeTab(); diff --git a/translations/cs_CZ.ts b/translations/cs_CZ.ts index f51358748..f62260f84 100644 --- a/translations/cs_CZ.ts +++ b/translations/cs_CZ.ts @@ -1710,12 +1710,12 @@ nebyl nalezen! MainApplication - + Last session crashed Poslední relace spadla - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla spadla :-(</b><br/>Oops, poslední relace QupZilly skončila jejím pádem. Velice se omlouváme. Přejete si obnovit uložený stav? @@ -1723,36 +1723,42 @@ nebyl nalezen! NavigationBar - + Back Zpět - + Forward Vpřed - + Home Domů - + New Tab Nový panel - + Main Menu Hlavní menu - + Exit Fullscreen Zrušit celou obrazovku + + + + Clear history + Smazat historii + NetworkManager @@ -2245,7 +2251,7 @@ nebyl nalezen! Default zoom on pages: - + Základní přiblížení stránek: @@ -4282,62 +4288,62 @@ Po přidání či odstranění cest k certifikátům je nutné k projevení změ WebView - + Loading... Načítám... - + Open link in new &tab Otevřít odkaz v novém &panelu - + Open link in new &window Otevřít odkaz v novém &okně - + B&ookmark link Přidat odkaz do zá&ložek - + &Save link as... &Uložit odkaz jako... - + &Copy link address &Kopírovat adresu odkazu - + Show i&mage Zobrazit &obrázek - + Copy im&age &Kopírovat obrázek - + Copy image ad&dress Kopírovat adr&esu obrázku - + S&top &Zastavit - + Show info ab&out site Zobrazit &informace o stránce - + Show Web &Inspector Zobrazit Web &Inspektor @@ -4346,79 +4352,79 @@ Po přidání či odstranění cest k certifikátům je nutné k projevení změ Hledat "%1 .." na &Googlu - + &Save image as... &Uložit obrázek jako... - + Failed loading page Chyba při načítání stránky - + &Back &Zpět - + &Forward &Vpřed - + &Reload &Obnovit - + Book&mark page Přidat stránku do zá&ložek - + &Save page as... &Uložit stránku jako... - + Select &all Vyb&rat vše - + Show so&urce code Zobrazit zdrojový kó&d - + Search "%1 .." with %2 Hledat "%1 .." s %2 - + No Named Page Bezejmenná stránka - - - + + + New tab Nový panel - + Send link... Odeslat odkaz... - + Send image... Odeslat obrázek... - + Send page... Odeslat stránku... diff --git a/translations/de_DE.ts b/translations/de_DE.ts index 8dfe9d637..ec81a21ca 100644 --- a/translations/de_DE.ts +++ b/translations/de_DE.ts @@ -1700,12 +1700,12 @@ p, li { white-space: pre-wrap; } MainApplication - + Last session crashed Die letzte Sitzung wurde unerwartet beendet - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla ist abgestürzt :-(</b><br/>Hoppla,die letzte Sitzung wurde unerwartet beendet. Verzeihung. Möchten Sie den letzten Status wiederherstellen? @@ -1713,36 +1713,42 @@ p, li { white-space: pre-wrap; } NavigationBar - + Back Zurück - + Forward Vorwärts - + Home Startseite - + New Tab Neuer Tab - + Main Menu Hauptmenü - + Exit Fullscreen Vollbildmodus beenden + + + + Clear history + Verlauf löschen + NetworkManager @@ -4342,62 +4348,62 @@ Nachdem Speicherpfade hinzugefügt oder gelöscht wurden, muss QupZilla neu gest WebView - + Loading... Laden... - + Open link in new &tab Link in neuem &Tab öffnen - + Open link in new &window Link in neuem &Fenster öffnen - + B&ookmark link &Lesezeichen für diesen Link hinzufügen - + &Save link as... &Ziel speichern unter... - + &Copy link address Lin&k-Adresse kopieren - + Show i&mage G&rafik anzeigen - + Copy im&age Grafik k&opieren - + Copy image ad&dress Grafika&dresse kopieren - + S&top S&topp - + Show info ab&out site S&eiteninformationen anzeigen - + Show Web &Inspector Web &Inspector anzeigen @@ -4406,79 +4412,79 @@ Nachdem Speicherpfade hinzugefügt oder gelöscht wurden, muss QupZilla neu gest Suche "%1 .." auf &Google - + &Save image as... Grafik speichern &unter... - + Failed loading page Seite konnte nicht geladen werden - + &Back &Zurück - + &Forward &Vor - + &Reload &Neu laden - + Book&mark page &Lesezeichen für diese Seite hinzufügen - + &Save page as... Seite speichern &unter... - + Select &all Alles au&swählen - + Show so&urce code Seitenquelltext &anzeigen - + Search "%1 .." with %2 Suche "%1 .." mit %2 - + No Named Page Unbekannte Seite - - - + + + New tab Neuer Tab - + Send link... Link senden... - + Send image... Grafik senden... - + Send page... Seite senden... diff --git a/translations/es.ts b/translations/es.ts index bcd0906dc..e890560bc 100644 --- a/translations/es.ts +++ b/translations/es.ts @@ -1657,12 +1657,12 @@ p, li { white-space: pre-wrap; } MainApplication - + Last session crashed - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? @@ -1670,36 +1670,42 @@ p, li { white-space: pre-wrap; } NavigationBar - + Back - + Forward - + Home - + New Tab - + Main Menu - + Exit Fullscreen + + + + Clear history + + NetworkManager @@ -4176,139 +4182,139 @@ After adding or removing certificate paths, it is neccessary to restart browser WebView - + Failed loading page - + Loading... - - - + + + New tab - + Open link in new &tab - + Open link in new &window - + B&ookmark link - + &Save link as... - + Send link... - + &Copy link address - + Show i&mage - + Copy im&age - + Copy image ad&dress - + &Save image as... - + Send image... - + &Back - + &Forward - + &Reload - + S&top - + Book&mark page - + &Save page as... - + Send page... - + Select &all - + Show so&urce code - + Show info ab&out site - + Show Web &Inspector - + Search "%1 .." with %2 - + No Named Page diff --git a/translations/nl_NL.ts b/translations/nl_NL.ts index ad8509a6a..ea363c7b5 100644 --- a/translations/nl_NL.ts +++ b/translations/nl_NL.ts @@ -1698,12 +1698,12 @@ werd niet gevonden! MainApplication - + Last session crashed Laatste sessie gecrashed - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla crashte :-(</b><br/>Oeps, de laatste sessie van QupZilla eindigde met een crash. We verontschuldigen ons. Wilt u proberen om de opgeslagen status te herstellen? @@ -1711,36 +1711,42 @@ werd niet gevonden! NavigationBar - + Back Terug - + Forward Vooruit - + Home Startpagina - + New Tab Nieuw tabblad - + Main Menu Hoofdmenu - + Exit Fullscreen Verlaat volledig scherm + + + + Clear history + Verwijder geschiedenis + NetworkManager @@ -4263,62 +4269,62 @@ Na het toevoegen of verwijderen van paden, is het noodzakelijk om de browser te WebView - + Loading... Bezig met laden... - + Open link in new &tab Open link in nieuw &tabblad - + Open link in new &window Open link in nieuw &venster - + B&ookmark link B&ladwijzer link - + &Save link as... &Sla link op als... - + &Copy link address &Kopieer linkadres - + Show i&mage Toon af&beelding - + Copy im&age &Kopieer afbeelding - + Copy image ad&dress Kopieer af&beeldingsadres - + S&top &Stop - + Show info ab&out site Toon info &over site - + Show Web &Inspector Toon Web-&inspecteur @@ -4327,79 +4333,79 @@ Na het toevoegen of verwijderen van paden, is het noodzakelijk om de browser te Zoek "%1 .." op &Google - + &Save image as... &Sla afbeelding op als... - + Failed loading page Mislukt om pagina te laden - + &Back &Terug - + &Forward &Vooruit - + &Reload &Herlaad - + Book&mark page &Bladwijzer pagina - + &Save page as... &Sla pagina op als... - + Select &all &Selecteer alles - + Show so&urce code &Toon broncode - + Search "%1 .." with %2 Zoek "%1 .." met %2 - + No Named Page Niet benoemde pagina - - - + + + New tab Nieuw tabblad - + Send link... Verstuur link... - + Send image... Verstuur afbeelding... - + Send page... Odeslat stránku... diff --git a/translations/sk_SK.ts b/translations/sk_SK.ts index 789f5e706..8ce33e44c 100644 --- a/translations/sk_SK.ts +++ b/translations/sk_SK.ts @@ -1708,12 +1708,12 @@ p, li { white-space: pre-wrap; } MainApplication - + Last session crashed Minulá relácia spadla - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla spadla :-(</b><br/>Oops, minulá relácia QupZilly skončila pádom. Veľmi sa ospravedlňujeme. Chcete sa pokúsiť obnoviť uložený stav? @@ -1721,36 +1721,42 @@ p, li { white-space: pre-wrap; } NavigationBar - + Back Späť - + Forward Dopredu - + Home Domov - + New Tab Nová karta - + Main Menu Hlavné menu - + Exit Fullscreen Ukončiť režim celej obrazovky + + + + Clear history + Vymazať históriu + NetworkManager @@ -4280,62 +4286,62 @@ Po pridaní či odobratí ciest k certifikátom je nutné reštartovať prehliad WebView - + Loading... Načítava sa... - + Open link in new &tab Otvoriť odkaz na &novej karte - + Open link in new &window Otvoriť odkaz v novom &okne - + B&ookmark link Pridať &odkaz do záložiek - + &Save link as... &Uložiť odkaz ako... - + &Copy link address &Kopírovať adresu odkazu - + Show i&mage Zobraziť o&brázok - + Copy im&age Kopírov&ať obrázok - + Copy image ad&dress Kopírovať a&dresu obrázku - + S&top Zas&taviť - + Show info ab&out site Z&obraziť informácie o stránke - + Show Web &Inspector Zobraziť Web &inšpektora @@ -4344,79 +4350,79 @@ Po pridaní či odobratí ciest k certifikátom je nutné reštartovať prehliad Hľadať "%1 .." na &Googli - + &Save image as... &Uložiť obrázok ako... - + Failed loading page Zlyhalo načítanie stránky - + &Back &Späť - + &Forward &Dopredu - + &Reload &Obnoviť - + Book&mark page Pridať s&tránku do záložiek - + &Save page as... Uložiť &stránku ako... - + Select &all Vybr&ať všetko - + Show so&urce code Zobraziť zdro&jový kód - + Search "%1 .." with %2 Hľadať "%1 .." s %2 - + No Named Page Nepomenovaná stránka - - - + + + New tab Nová karta - + Send link... Odoslať odkaz... - + Send image... Odoslať obrázok... - + Send page... Odoslať stránku... diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 54dbbca15..21b27dff1 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -1685,12 +1685,12 @@ p, li { white-space: pre-wrap; } MainApplication - + Last session crashed - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? @@ -1698,36 +1698,42 @@ p, li { white-space: pre-wrap; } NavigationBar - + Back 后退 - + Forward 前进 - + Home 主页 - + New Tab 新标签 - + Main Menu 主菜单 - + Exit Fullscreen 退出全屏 + + + + Clear history + 清除历史 + NetworkManager @@ -4231,134 +4237,134 @@ After adding or removing certificate paths, it is neccessary to restart browser WebView - + Failed loading page 载入页面失败 - + Loading... 载入中... - - - + + + New tab 新标签 - + Open link in new &tab 在新标签中打开链接 - + Open link in new &window 在新窗口中打开链接 - + B&ookmark link 书签链接 - + &Save link as... 链接另存为... - + Send link... 发送链接... - + &Copy link address 复制链接地址&C - + Show i&mage 显示图像&m - + Copy im&age 复制图像&a - + Copy image ad&dress 复制图像地址&d - + &Save image as... 图像另存为&S... - + Send image... 发送图像... - + &Back 后退&B - + &Forward 前进&F - + &Reload 刷新&R - + S&top 停止 - + Book&mark page 加入书签 - + &Save page as... 保存网页为... - + Send page... 发送网页... - + Select &all 选取所有 - + Show so&urce code 显示源代码 - + Show info ab&out site 显示有关网站的信息 - + Show Web &Inspector 显示Web及督察 - + Search "%1 .." with %2 @@ -4367,7 +4373,7 @@ After adding or removing certificate paths, it is neccessary to restart browser 使用Google搜索 - + No Named Page 无命名页面