1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'master' of ssh://github.com/krepa098/qTox

This commit is contained in:
Dubslow 2015-03-11 17:44:08 -05:00
commit 2f2e51fb6a
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
4 changed files with 23 additions and 5 deletions

View File

@ -436,7 +436,7 @@ void FileTransferWidget::handleButton(QPushButton *btn)
else if (btn->objectName() == "dir") else if (btn->objectName() == "dir")
{ {
QString dirPath = QFileInfo(fileInfo.filePath).dir().path(); QString dirPath = QFileInfo(fileInfo.filePath).dir().path();
QDesktopServices::openUrl(QUrl("file://" + dirPath, QUrl::TolerantMode)); QDesktopServices::openUrl(QUrl::fromLocalFile(dirPath));
} }
} }

View File

@ -221,6 +221,9 @@ void Text::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
setCursor(QCursor(Qt::PointingHandCursor)); setCursor(QCursor(Qt::PointingHandCursor));
else else
setCursor(QCursor()); setCursor(QCursor());
// tooltip
setToolTip(extractImgTooltip(cursorFromPos(event->scenePos(), false)));
} }
QString Text::getText() const QString Text::getText() const
@ -287,10 +290,10 @@ QSizeF Text::idealSize()
return size; return size;
} }
int Text::cursorFromPos(QPointF scenePos) const int Text::cursorFromPos(QPointF scenePos, bool fuzzy) const
{ {
if(doc) if(doc)
return doc->documentLayout()->hitTest(mapFromScene(scenePos), Qt::FuzzyHit); return doc->documentLayout()->hitTest(mapFromScene(scenePos), fuzzy ? Qt::FuzzyHit : Qt::ExactHit);
return -1; return -1;
} }
@ -348,3 +351,17 @@ QString Text::extractSanitizedText(int from, int to) const
return txt; return txt;
} }
QString Text::extractImgTooltip(int pos) const
{
for(QTextBlock::Iterator itr = doc->firstBlock().begin(); itr!=doc->firstBlock().end(); ++itr)
{
if(itr.fragment().contains(pos) && itr.fragment().charFormat().isImageFormat())
{
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();
return imgFmt.toolTip();
}
}
return QString();
}

View File

@ -61,11 +61,12 @@ protected:
void freeResources(); void freeResources();
QSizeF idealSize(); QSizeF idealSize();
int cursorFromPos(QPointF scenePos) const; int cursorFromPos(QPointF scenePos, bool fuzzy = true) const;
int getSelectionEnd() const; int getSelectionEnd() const;
int getSelectionStart() const; int getSelectionStart() const;
bool hasSelection() const; bool hasSelection() const;
QString extractSanitizedText(int from, int to) const; QString extractSanitizedText(int from, int to) const;
QString extractImgTooltip(int pos) const;
private: private:
QTextDocument* doc = nullptr; QTextDocument* doc = nullptr;

View File

@ -448,7 +448,7 @@ void Widget::confirmExecutableOpen(const QFileInfo file)
} }
else else
{ {
QDesktopServices::openUrl(QUrl("file://" + file.filePath(), QUrl::TolerantMode)); QDesktopServices::openUrl(QUrl::fromLocalFile(file.filePath()));
} }
} }