X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=a7f2360a8da3a8511d7a8de4439e96b3086278c6;hp=dc0abf1013aeeefc4e9e5e52687f4ccd9a577018;hb=4ee4a3edb832d7ac01951007cf55f7fa4b5918b4;hpb=7f0bcdbfaa2f435baad9b833441aca86517cb84c diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index dc0abf10..a7f2360a 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,12 +20,14 @@ #include #include +#include #include #include #include #include #include #include +#include #ifdef HAVE_KDE # include @@ -809,9 +811,17 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) // If we have text selected, insert the Copy Selection as first item if (isPosOverSelection(pos)) { + QAction *sep = menu.insertSeparator(menu.actions().first()); QAction *act = new Action(SmallIcon("edit-copy"), tr("Copy Selection"), &menu, this, SLOT(selectionToClipboard()), QKeySequence::Copy); - menu.insertAction(menu.actions().at(0), act); + menu.insertAction(sep, act); + + QString searchSelectionText = selection(); + if (searchSelectionText.length() > _webSearchSelectionTextMaxVisible) + searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("…")); + searchSelectionText = tr("Search '%1'").arg(searchSelectionText); + + menu.addAction(SmallIcon("edit-find"), searchSelectionText, this, SLOT(webSearchOnSelection())); } if (QtUi::mainWindow()->menuBar()->isHidden()) @@ -1046,6 +1056,21 @@ void ChatScene::clearSelection() } +/******** *************************************************************************************/ + +void ChatScene::webSearchOnSelection() +{ + if (!hasSelection()) + return; + + ChatViewSettings settings; + QString webSearchBaseUrl = settings.webSearchUrlFormatString(); + QString webSearchUrl = webSearchBaseUrl.replace(QString("%s"), selection()); + QUrl url = QUrl::fromUserInput(webSearchUrl); + QDesktopServices::openUrl(url); +} + + /******** *************************************************************************************/ void ChatScene::requestBacklog()