Partially fixed #15.

This commit is contained in:
Martin Rotter 2014-02-17 18:12:24 +01:00
parent 2a9c6e7a68
commit 9fdf4e5e8a
5 changed files with 142 additions and 104 deletions

View File

@ -1786,58 +1786,30 @@ Status auto-aktualizace: %5</translation>
<source>Reload web page</source>
<translation>Obnovit stránku</translation>
</message>
<message>
<source>Reload current web page</source>
<translation>Znovu načíst aktuální stránku</translation>
</message>
<message>
<source>Copy link url</source>
<translation>Kopírovat adresu odkazu</translation>
</message>
<message>
<source>Copy link url to clipboard</source>
<translation>Kopírovat adresu odkazu to schránky</translation>
</message>
<message>
<source>Copy image</source>
<translation>Kopírovat obrázek</translation>
</message>
<message>
<source>Copy image to clipboard</source>
<translation>Kopírovat obrázek do schránky</translation>
</message>
<message>
<source>Copy image url</source>
<translation>Kopírovat adresu obrázku</translation>
</message>
<message>
<source>Copy image url to clipboard</source>
<translation>Kopírovat adresu obrázku do schránky</translation>
</message>
<message>
<source>Open link in new tab</source>
<translation>Otevřít odkaz v novém panelu</translation>
</message>
<message>
<source>Open this hyperlink in new tab</source>
<translation>Otevřít tento odkaz v novém panelu</translation>
</message>
<message>
<source>Follow link</source>
<translation>Přejít</translation>
</message>
<message>
<source>Open the hyperlink in this tab</source>
<translation>Otevřít tento odkaz v tomto panelu</translation>
</message>
<message>
<source>Open image in new tab</source>
<translation>Otevřít obrázek v novém panelu</translation>
</message>
<message>
<source>Open this image in this tab</source>
<translation>Otevřít tento obrázek v novém panelu</translation>
</message>
<message>
<source>Page not found</source>
<translation>Stránka nenalezena</translation>
@ -1866,5 +1838,41 @@ Status auto-aktualizace: %5</translation>
<source>Error page</source>
<translation>Chyba</translation>
</message>
<message>
<source>Reload current web page.</source>
<translation>Opět načíst aktuální webovou stránku.</translation>
</message>
<message>
<source>Copy selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copies current selection into the clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy link url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this hyperlink in new tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the hyperlink in this tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this image in this tab.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -1759,58 +1759,30 @@ Auto-update status: %5</source>
<source>Reload web page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload current web page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy link url</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy link url to clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image to clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image url</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image url to clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open link in new tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this hyperlink in new tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the hyperlink in this tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open image in new tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this image in this tab</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Page not found</source>
<translation type="unfinished"></translation>
@ -1839,5 +1811,41 @@ Auto-update status: %5</source>
<source>Error page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reload current web page.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copies current selection into the clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy link url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this hyperlink in new tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the hyperlink in this tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this image in this tab.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -1784,58 +1784,30 @@ Status automatisch bijwerken: %5</translation>
<source>Reload web page</source>
<translation>Herlaad webpagina</translation>
</message>
<message>
<source>Reload current web page</source>
<translation>Herlaad huidige webpagina</translation>
</message>
<message>
<source>Copy link url</source>
<translation>URL kopiëren</translation>
</message>
<message>
<source>Copy link url to clipboard</source>
<translation>URL kopiëren naar klembord</translation>
</message>
<message>
<source>Copy image</source>
<translation>Kopiëer afbeelding</translation>
</message>
<message>
<source>Copy image to clipboard</source>
<translation>Kopiëer afbeelding naar klembord</translation>
</message>
<message>
<source>Copy image url</source>
<translation>URL afbeelding kopiëren</translation>
</message>
<message>
<source>Copy image url to clipboard</source>
<translation>URL afbeelding naar klembord kopiëren</translation>
</message>
<message>
<source>Open link in new tab</source>
<translation>Open link in nieuw tabblad</translation>
</message>
<message>
<source>Open this hyperlink in new tab</source>
<translation>Open deze koppeling in nieuw tabblad</translation>
</message>
<message>
<source>Follow link</source>
<translation>Volg koppeling</translation>
</message>
<message>
<source>Open the hyperlink in this tab</source>
<translation>Open koppeling in dit tabblad</translation>
</message>
<message>
<source>Open image in new tab</source>
<translation>Open afbeelding in nieuw tabblad</translation>
</message>
<message>
<source>Open this image in this tab</source>
<translation>Open deze afbeelding in dit tabblad</translation>
</message>
<message>
<source>Page not found</source>
<translation>Pagina niet gevonden</translation>
@ -1864,5 +1836,41 @@ Status automatisch bijwerken: %5</translation>
<source>Error page</source>
<translation>Foutpagina</translation>
</message>
<message>
<source>Reload current web page.</source>
<translation type="unfinished">Vernieuw huidige webpagina.</translation>
</message>
<message>
<source>Copy selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copies current selection into the clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy link url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy image url to clipboard.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this hyperlink in new tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open the hyperlink in this tab.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open this image in this tab.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -14,6 +14,7 @@
#include <QWebFrame>
#include <QContextMenuEvent>
#include <QDateTime>
#include <QClipboard>
WebView::WebView(QWidget *parent)
@ -37,6 +38,10 @@ void WebView::onLoadFinished(bool ok) {
}
}
void WebView::copySelectedText() {
QApplication::clipboard()->setText(selectedText());
}
void WebView::openLinkInNewTab() {
emit linkMiddleClicked(m_contextLinkUrl);
}
@ -50,12 +55,13 @@ void WebView::createConnections() {
connect(this, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(popupContextMenu(QPoint)));
connect(m_actionOpenLinkNewTab,SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
}
void WebView::setupIcons() {
m_actionReload->setIcon(IconThemeFactory::instance()->fromTheme("go-refresh"));
m_actionCopySelectedItem->setIcon(IconThemeFactory::instance()->fromTheme("edit-copy"));
m_actionCopyLink->setIcon(IconThemeFactory::instance()->fromTheme("edit-copy"));
m_actionCopyImage->setIcon(IconThemeFactory::instance()->fromTheme("edit-copy-image"));
@ -73,55 +79,60 @@ void WebView::initializeActions() {
m_actionReload = pageAction(QWebPage::Reload);
m_actionReload->setParent(this);
m_actionReload->setText(tr("Reload web page"));
m_actionReload->setToolTip(tr("Reload current web page"));
m_actionReload->setToolTip(tr("Reload current web page."));
m_actionCopySelectedItem = pageAction(QWebPage::Copy);
m_actionCopySelectedItem->setParent(this);
m_actionCopySelectedItem->setText(tr("Copy selection"));
m_actionCopySelectedItem->setToolTip(tr("Copies current selection into the clipboard."));
m_actionCopyLink = pageAction(QWebPage::CopyLinkToClipboard);
m_actionCopyLink->setParent(this);
m_actionCopyLink->setText(tr("Copy link url"));
m_actionCopyLink->setToolTip(tr("Copy link url to clipboard"));
m_actionCopyLink->setToolTip(tr("Copy link url to clipboard."));
m_actionCopyImage = pageAction(QWebPage::CopyImageToClipboard);
m_actionCopyImage->setParent(this);
m_actionCopyImage->setText(tr("Copy image"));
m_actionCopyImage->setToolTip(tr("Copy image to clipboard"));
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
#if QT_VERSION >= 0x040800
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
m_actionCopyImageUrl->setParent(this);
m_actionCopyImageUrl->setText(tr("Copy image url"));
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard"));
m_actionCopyImageUrl->setToolTip(tr("Copy image url to clipboard."));
#endif
m_actionOpenLinkNewTab = pageAction(QWebPage::OpenLinkInNewWindow);
m_actionOpenLinkNewTab->setParent(this);
m_actionOpenLinkNewTab->setText(tr("Open link in new tab"));
m_actionOpenLinkNewTab->setToolTip(tr("Open this hyperlink in new tab"));
m_actionOpenLinkNewTab->setToolTip(tr("Open this hyperlink in new tab."));
m_actionOpenLinkThisTab = pageAction(QWebPage::OpenLink);
m_actionOpenLinkThisTab->setParent(this);
m_actionOpenLinkThisTab->setText(tr("Follow link"));
m_actionOpenLinkThisTab->setToolTip(tr("Open the hyperlink in this tab"));
m_actionOpenLinkThisTab->setToolTip(tr("Open the hyperlink in this tab."));
m_actionOpenImageNewTab = pageAction(QWebPage::OpenImageInNewWindow);
m_actionOpenImageNewTab->setParent(this);
m_actionOpenImageNewTab->setText(tr("Open image in new tab"));
m_actionOpenImageNewTab->setToolTip(tr("Open this image in this tab"));
m_actionOpenImageNewTab->setToolTip(tr("Open this image in this tab."));
}
void WebView::displayErrorPage() {
setHtml(SkinFactory::instance()->currentMarkupLayout().arg(
tr("Error page"),
SkinFactory::instance()->currentMarkup().arg(tr("Page not found"),
tr("Check your internet connection or website address"),
QString(),
tr("This failure can be caused by:<br><ul>"
"<li>non-functional internet connection,</li>"
"<li>incorrect website address,</li>"
"<li>bad proxy server settings,</li>"
"<li>target destination outage,</li>"
"<li>many other things.</li>"
"</ul>"),
QDateTime::currentDateTime().toString(Qt::DefaultLocaleLongDate))));
tr("Check your internet connection or website address"),
QString(),
tr("This failure can be caused by:<br><ul>"
"<li>non-functional internet connection,</li>"
"<li>incorrect website address,</li>"
"<li>bad proxy server settings,</li>"
"<li>target destination outage,</li>"
"<li>many other things.</li>"
"</ul>"),
QDateTime::currentDateTime().toString(Qt::DefaultLocaleLongDate))));
}
void WebView::popupContextMenu(const QPoint &pos) {
@ -135,6 +146,7 @@ void WebView::popupContextMenu(const QPoint &pos) {
// Assemble the menu from actions.
context_menu.addAction(m_actionReload);
context_menu.addAction(m_actionCopySelectedItem);
QUrl hit_url = hit_result.linkUrl();
QUrl hit_image_url = hit_result.imageUrl();
@ -197,8 +209,8 @@ void WebView::mousePressEvent(QMouseEvent *event) {
void WebView::mouseReleaseEvent(QMouseEvent *event) {
if (event->button() & Qt::MiddleButton) {
bool are_gestures_enabled = Settings::instance()->value(APP_CFG_BROWSER,
"gestures_enabled",
true).toBool();
"gestures_enabled",
true).toBool();
if (are_gestures_enabled) {
QPoint release_point = event->pos();
int left_move = m_gestureOrigin.x() - release_point.x();

View File

@ -43,6 +43,7 @@ class WebView : public QWebView {
// Executes if loading of any page is done.
void onLoadFinished(bool ok);
void copySelectedText();
void openLinkInNewTab();
void openImageInNewTab();
@ -73,6 +74,7 @@ class WebView : public QWebView {
WebPage *m_page;
QAction *m_actionReload;
QAction *m_actionCopySelectedItem;
QAction *m_actionCopyLink;
QAction *m_actionCopyImage;