mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Dragging the whole non-shrinked text in SqueezeLabel now
This commit is contained in:
parent
c992778556
commit
033bfa246b
29
src/lib/3rdparty/squeezelabelv2.cpp
vendored
29
src/lib/3rdparty/squeezelabelv2.cpp
vendored
|
@ -85,3 +85,32 @@ void SqueezeLabelV2::resizeEvent(QResizeEvent* event)
|
|||
QString elided = fm.elidedText(m_originalText, Qt::ElideMiddle, width());
|
||||
QLabel::setText(elided);
|
||||
}
|
||||
|
||||
void SqueezeLabelV2::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
m_dragStart = event->pos();
|
||||
}
|
||||
|
||||
QLabel::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void SqueezeLabelV2::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!(event->buttons() & Qt::LeftButton) || selectedText().length() != text().length()) {
|
||||
QLabel::mouseMoveEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
int manhattanLength = (event->pos() - m_dragStart).manhattanLength();
|
||||
if (manhattanLength <= QApplication::startDragDistance()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mime = new QMimeData;
|
||||
mime->setText(m_originalText);
|
||||
|
||||
drag->setMimeData(mime);
|
||||
drag->exec();
|
||||
}
|
||||
|
|
4
src/lib/3rdparty/squeezelabelv2.h
vendored
4
src/lib/3rdparty/squeezelabelv2.h
vendored
|
@ -41,8 +41,12 @@ protected:
|
|||
void keyPressEvent(QKeyEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
QString m_originalText;
|
||||
QPoint m_dragStart;
|
||||
};
|
||||
|
||||
#endif // SQUEEZELABELV2_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user