1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
krepa098 2015-02-11 16:32:42 +01:00
parent 697460ca36
commit 5f31921cf4
2 changed files with 18 additions and 9 deletions

View File

@ -97,6 +97,14 @@ ChatLog::ChatLog(QWidget* parent)
workerTimer->setSingleShot(false);
workerTimer->setInterval(5);
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()
@ -126,7 +134,7 @@ void ChatLog::clearSelection()
selClickedRow = -1;
selectionMode = None;
copyAction->setEnabled(false);
emit selectionChanged();
updateMultiSelectionRect();
}
@ -234,7 +242,6 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
content->selectionStarted(sceneClickPos);
selectionMode = Precise;
copyAction->setEnabled(true);
// ungrab mouse grabber
if(scene->mouseGrabberItem())
@ -247,7 +254,6 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
selLastRow = selClickedRow;
selectionMode = Multi;
copyAction->setEnabled(true);
}
}
@ -301,11 +307,9 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
updateMultiSelectionRect();
}
}
#ifdef Q_OS_LINUX
copySelectedText(true);
#endif
emit selectionChanged();
}
}
//Much faster than QGraphicsScene::itemAt()!
@ -476,6 +480,8 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
selFirstRow = content->getRow();
selLastRow = content->getRow();
selectionMode = Precise;
emit selectionChanged();
}
}
@ -607,7 +613,7 @@ void ChatLog::selectAll()
selFirstRow = 0;
selLastRow = lines.size()-1;
copyAction->setEnabled(true);
emit selectionChanged();
updateMultiSelectionRect();
}
@ -644,7 +650,7 @@ void ChatLog::checkVisibility()
std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex);
//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)

View File

@ -58,6 +58,9 @@ public:
ChatLine::Ptr getTypingNotification() const;
QVector<ChatLine::Ptr> getLines();
signals:
void selectionChanged();
protected:
QRectF calculateSceneRect() const;
QRect getVisibleRect() const;