mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix issue #10
This commit is contained in:
parent
697460ca36
commit
5f31921cf4
|
@ -97,6 +97,14 @@ ChatLog::ChatLog(QWidget* parent)
|
||||||
workerTimer->setSingleShot(false);
|
workerTimer->setSingleShot(false);
|
||||||
workerTimer->setInterval(5);
|
workerTimer->setInterval(5);
|
||||||
connect(workerTimer, &QTimer::timeout, this, &ChatLog::onWorkerTimeout);
|
connect(workerTimer, &QTimer::timeout, this, &ChatLog::onWorkerTimeout);
|
||||||
|
|
||||||
|
// selection
|
||||||
|
connect(this, &ChatLog::selectionChanged, this, [this]() {
|
||||||
|
copyAction->setEnabled(hasTextToBeCopied());
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
copySelectedText(true);
|
||||||
|
#endif
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLog::~ChatLog()
|
ChatLog::~ChatLog()
|
||||||
|
@ -126,7 +134,7 @@ void ChatLog::clearSelection()
|
||||||
selClickedRow = -1;
|
selClickedRow = -1;
|
||||||
|
|
||||||
selectionMode = None;
|
selectionMode = None;
|
||||||
copyAction->setEnabled(false);
|
emit selectionChanged();
|
||||||
|
|
||||||
updateMultiSelectionRect();
|
updateMultiSelectionRect();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +242,6 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
content->selectionStarted(sceneClickPos);
|
content->selectionStarted(sceneClickPos);
|
||||||
|
|
||||||
selectionMode = Precise;
|
selectionMode = Precise;
|
||||||
copyAction->setEnabled(true);
|
|
||||||
|
|
||||||
// ungrab mouse grabber
|
// ungrab mouse grabber
|
||||||
if(scene->mouseGrabberItem())
|
if(scene->mouseGrabberItem())
|
||||||
|
@ -247,7 +254,6 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
selLastRow = selClickedRow;
|
selLastRow = selClickedRow;
|
||||||
|
|
||||||
selectionMode = Multi;
|
selectionMode = Multi;
|
||||||
copyAction->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,11 +307,9 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
|
|
||||||
updateMultiSelectionRect();
|
updateMultiSelectionRect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
emit selectionChanged();
|
||||||
copySelectedText(true);
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Much faster than QGraphicsScene::itemAt()!
|
//Much faster than QGraphicsScene::itemAt()!
|
||||||
|
@ -476,6 +480,8 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||||
selFirstRow = content->getRow();
|
selFirstRow = content->getRow();
|
||||||
selLastRow = content->getRow();
|
selLastRow = content->getRow();
|
||||||
selectionMode = Precise;
|
selectionMode = Precise;
|
||||||
|
|
||||||
|
emit selectionChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +613,7 @@ void ChatLog::selectAll()
|
||||||
selFirstRow = 0;
|
selFirstRow = 0;
|
||||||
selLastRow = lines.size()-1;
|
selLastRow = lines.size()-1;
|
||||||
|
|
||||||
copyAction->setEnabled(true);
|
emit selectionChanged();
|
||||||
updateMultiSelectionRect();
|
updateMultiSelectionRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +650,7 @@ void ChatLog::checkVisibility()
|
||||||
std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex);
|
std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex);
|
||||||
|
|
||||||
//if(!visibleLines.empty())
|
//if(!visibleLines.empty())
|
||||||
// qDebug() << "visible from " << visibleLines.first()->getRowIndex() << "to " << visibleLines.last()->getRowIndex() << " total " << visibleLines.size();
|
// qDebug() << "visible from " << visibleLines.first()->getRow() << "to " << visibleLines.last()->getRow() << " total " << visibleLines.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::scrollContentsBy(int dx, int dy)
|
void ChatLog::scrollContentsBy(int dx, int dy)
|
||||||
|
|
|
@ -58,6 +58,9 @@ public:
|
||||||
ChatLine::Ptr getTypingNotification() const;
|
ChatLine::Ptr getTypingNotification() const;
|
||||||
QVector<ChatLine::Ptr> getLines();
|
QVector<ChatLine::Ptr> getLines();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectionChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QRectF calculateSceneRect() const;
|
QRectF calculateSceneRect() const;
|
||||||
QRect getVisibleRect() const;
|
QRect getVisibleRect() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user