mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added triple-clicking next to message to select whole message.
This commit is contained in:
parent
5c2cdce516
commit
c8326d73e7
2 changed files with 20 additions and 15 deletions
|
@ -951,7 +951,6 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
|
|||
}
|
||||
|
||||
int index = layout->getSelectionIndex(relativePos);
|
||||
|
||||
auto selectionItem = SelectionItem(messageIndex, index);
|
||||
this->setSelection(selectionItem, selectionItem);
|
||||
} break;
|
||||
|
@ -1022,18 +1021,22 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
const MessageLayoutElement *hoverLayoutElement =
|
||||
layout->getElementAt(relativePos);
|
||||
|
||||
// Triple-click next to message selects whole message
|
||||
if (this->clickTimer_->isActive() && this->selecting_) {
|
||||
this->selectWholeMessage(layout.get(), messageIndex);
|
||||
}
|
||||
|
||||
if (hoverLayoutElement == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// handle the click
|
||||
this->handleMouseClick(event, hoverLayoutElement, layout.get(),
|
||||
messageIndex);
|
||||
this->handleMouseClick(event, hoverLayoutElement, layout.get());
|
||||
}
|
||||
|
||||
void ChannelView::handleMouseClick(QMouseEvent *event,
|
||||
const MessageLayoutElement *hoveredElement,
|
||||
MessageLayout *layout, int &messageIndex)
|
||||
MessageLayout *layout)
|
||||
{
|
||||
switch (event->button()) {
|
||||
case Qt::LeftButton: {
|
||||
|
@ -1043,16 +1046,6 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
|
|||
this->showingLatestMessages_ = false;
|
||||
}
|
||||
|
||||
if (this->clickTimer_->isActive()) {
|
||||
auto firstRealCharacterIndex =
|
||||
layout->getFirstMessageCharacterIndex();
|
||||
SelectionItem msgStart(messageIndex,
|
||||
firstRealCharacterIndex);
|
||||
SelectionItem msgEnd(messageIndex,
|
||||
layout->getLastCharacterIndex());
|
||||
this->setSelection(msgStart, msgEnd);
|
||||
}
|
||||
|
||||
// this->pausedBySelection = false;
|
||||
this->selecting_ = false;
|
||||
// this->pauseTimeout.stop();
|
||||
|
@ -1195,6 +1188,9 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||
layout->getElementAt(relativePos);
|
||||
|
||||
if (hoverLayoutElement == nullptr) {
|
||||
// Possibility for triple click which doesn't have to be over an
|
||||
// existing layout element
|
||||
this->clickTimer_->start();
|
||||
return;
|
||||
}
|
||||
if (!this->isMouseDown_) {
|
||||
|
@ -1307,4 +1303,12 @@ int ChannelView::getLayoutWidth() const
|
|||
return this->width();
|
||||
}
|
||||
|
||||
void ChannelView::selectWholeMessage(MessageLayout *layout, int &messageIndex)
|
||||
{
|
||||
SelectionItem msgStart(messageIndex,
|
||||
layout->getFirstMessageCharacterIndex());
|
||||
SelectionItem msgEnd(messageIndex, layout->getLastCharacterIndex());
|
||||
this->setSelection(msgStart, msgEnd);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -105,10 +105,11 @@ private:
|
|||
void setSelection(const SelectionItem &start, const SelectionItem &end);
|
||||
MessageElementFlags getFlags() const;
|
||||
bool isPaused();
|
||||
void selectWholeMessage(MessageLayout *layout, int &messageIndex);
|
||||
|
||||
void handleMouseClick(QMouseEvent *event,
|
||||
const MessageLayoutElement *hoverLayoutElement,
|
||||
MessageLayout *layout, int &messageIndex);
|
||||
MessageLayout *layout);
|
||||
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayout *layout);
|
||||
int getLayoutWidth() const;
|
||||
|
|
Loading…
Reference in a new issue