ˇ
This commit is contained in:
Martin Rotter 2015-05-26 09:13:02 +02:00
parent 9c26163fb2
commit 161523453f
4 changed files with 29 additions and 0 deletions

View File

@ -1,4 +1,16 @@
<body>
<center><h2>2.4.0</h2></center>
Added:
<ul>
<li>Option to search highlighted text in web browser via Google, available from context menu. (issue #72)</li>
</ul>
Fixed:
<ul>
<li></li>
</ul>
<hr/>
<center><h2>2.3.1</h2></center>
Added:
<ul>

View File

@ -80,6 +80,7 @@
#define ACCEPT_HEADER_FOR_FEED_DOWNLOADER "application/atom+xml,application/xml;q=0.9,text/xml;q=0.8,*/*;q=0.7"
#define MIME_TYPE_ITEM_POINTER "@APP_LOW_NAME@/itempointer"
#define DOWNLOADER_ICON_SIZE 48
#define GOOGLE_SEARCH_URL "https://www.google.com/search?q=%1&ie=utf-8&oe=utf-8"
#define FEED_REGEX_MATCHER "<link[^>]+type=\\\"application/(atom|rss)\\+xml\\\"[^>]*>"
#define FEED_HREF_REGEX_MATCHER "href\\=\\\"[^\\\"]+\\\""

View File

@ -79,6 +79,10 @@ void WebView::openImageInNewTab() {
emit linkMiddleClicked(m_contextImageUrl);
}
void WebView::searchTextViaGoogle() {
emit linkMiddleClicked(QString(GOOGLE_SEARCH_URL).arg((selectedText())));
}
void WebView::saveCurrentPageToFile() {
QString selected_file;
QString implicit_file_base_name = tr("source_page");
@ -150,6 +154,7 @@ void WebView::createConnections() {
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
connect(m_actionOpenLinkExternally, SIGNAL(triggered()), this, SLOT(openLinkExternally()));
connect(m_actionLookupText, SIGNAL(triggered()), this, SLOT(searchTextViaGoogle()));
}
void WebView::setupIcons() {
@ -169,6 +174,9 @@ void WebView::setupIcons() {
m_actionOpenLinkNewTab->setIcon(qApp->icons()->fromTheme("item-open-internal"));
m_actionOpenLinkExternally->setIcon(qApp->icons()->fromTheme("item-open-external"));
m_actionOpenImageNewTab->setIcon(qApp->icons()->fromTheme("edit-copy-image"));
// TODO: Google ikonu přidat.
m_actionLookupText->setIcon(qApp->icons()->fromTheme("item-search-google"));
}
void WebView::initializeActions() {
@ -217,6 +225,7 @@ void WebView::initializeActions() {
m_actionOpenImageNewTab = pageAction(QWebPage::OpenImageInNewWindow);
m_actionOpenImageNewTab->setParent(this);
m_actionLookupText = new QAction("", this);
}
void WebView::setActionTexts() {
@ -319,6 +328,11 @@ void WebView::popupContextMenu(const QPoint &pos) {
image_submenu.addAction(m_actionSaveImageAs);
}
if (!selectedText().isEmpty()) {
m_actionLookupText->setText(tr("Search \"%1\" via Google...").arg(selectedText()));
context_menu.addAction(m_actionLookupText);
}
// Display the menu.
setActionTexts();
context_menu.exec(mapToGlobal(pos));

View File

@ -64,6 +64,7 @@ class WebView : public QWebView {
void openLinkInNewTab();
void openLinkExternally();
void openImageInNewTab();
void searchTextViaGoogle();
void saveCurrentPageToFile();
// Provides custom context menu.
@ -113,6 +114,7 @@ class WebView : public QWebView {
QAction *m_actionOpenLinkNewTab;
QAction *m_actionOpenLinkExternally;
QAction *m_actionOpenImageNewTab;
QAction *m_actionLookupText;
QPoint m_gestureOrigin;
QUrl m_contextLinkUrl;