From 284458d6c7644159eb14479e9f41127fd400ffdb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 3 Dec 2011 21:05:17 +0300 Subject: Allow copy any line from chat log to clipboard by context menu item "Copy to clipboard". --- src/gui/widgets/browserbox.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gui/widgets/browserbox.cpp') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 5ded29c55..4af38bf67 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -645,6 +645,35 @@ void BrowserBox::updateHeight() } } +std::string BrowserBox::getTextAtPos(const int x, const int y) +{ + int textX = 0; + int textY = 0; + + getAbsolutePosition(textX, textY); + if (x < textX || y < textY) + return ""; // mouse position ourside of correct widget (outside of tab) + + textX = x - textX; + textY = y - textY; + + std::string str = ""; + + for (LinePartIterator i = mLineParts.begin(); + i != mLineParts.end(); + ++i) + { + const LinePart &part = *i; + if (part.mY + 50 < mYStart) + continue; + if (part.mY > textY) + break; + str = part.mText; + } + + return str; +} + LinePart::~LinePart() { if (mImage) -- cgit v1.2.3-70-g09d2