~ubuntu-branches/ubuntu/trusty/quassel/trusty-proposed

« back to all changes in this revision

Viewing changes to src/qtui/chatscene.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-02-18 23:18:25 UTC
  • mto: This revision was merged to the branch mainline in revision 98.
  • Revision ID: package-import@ubuntu.com-20140218231825-hfgaeo3nmszt2pth
Tags: upstream-0.10~beta1
Import upstream version 0.10~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2005-2013 by the Quassel Project                        *
 
2
 *   Copyright (C) 2005-2014 by the Quassel Project                        *
3
3
 *   devel@quassel-irc.org                                                 *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
20
20
 
21
21
#include <QApplication>
22
22
#include <QClipboard>
 
23
#include <QDesktopServices>
23
24
#include <QDrag>
24
25
#include <QGraphicsSceneMouseEvent>
25
26
#include <QMenu>
26
27
#include <QMenuBar>
27
28
#include <QMimeData>
28
29
#include <QPersistentModelIndex>
 
30
#include <QUrl>
29
31
 
30
32
#ifdef HAVE_KDE
31
33
#  include <KMenuBar>
813
815
        QAction *act = new Action(SmallIcon("edit-copy"), tr("Copy Selection"), &menu, this,
814
816
            SLOT(selectionToClipboard()), QKeySequence::Copy);
815
817
        menu.insertAction(sep, act);
 
818
 
 
819
        QString searchSelectionText = selection();
 
820
        if (searchSelectionText.length() > _webSearchSelectionTextMaxVisible)
 
821
            searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("…"));
 
822
        searchSelectionText = tr("Search '%1'").arg(searchSelectionText);
 
823
 
 
824
        menu.addAction(SmallIcon("edit-find"), searchSelectionText, this, SLOT(webSearchOnSelection()));
816
825
    }
817
826
 
818
827
    if (QtUi::mainWindow()->menuBar()->isHidden())
1049
1058
 
1050
1059
/******** *************************************************************************************/
1051
1060
 
 
1061
void ChatScene::webSearchOnSelection()
 
1062
{
 
1063
    if (!hasSelection())
 
1064
        return;
 
1065
 
 
1066
    ChatViewSettings settings;
 
1067
    QString webSearchBaseUrl = settings.webSearchUrlFormatString();
 
1068
    QString webSearchUrl = webSearchBaseUrl.replace(QString("%s"), selection());
 
1069
    QUrl url = QUrl::fromUserInput(webSearchUrl);
 
1070
    QDesktopServices::openUrl(url);
 
1071
}
 
1072
 
 
1073
 
 
1074
/******** *************************************************************************************/
 
1075
 
1052
1076
void ChatScene::requestBacklog()
1053
1077
{
1054
1078
    MessageFilter *filter = qobject_cast<MessageFilter *>(model());