mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
small refactor
This commit is contained in:
parent
0f9ef9d0aa
commit
d8fcc1a3ed
10 changed files with 106 additions and 128 deletions
src
messages/layouts
singletons
widgets
|
@ -174,9 +174,9 @@ TextLayoutElement::TextLayoutElement(MessageElement &_creator, QString &_text,
|
||||||
const QSize &_size, QColor _color,
|
const QSize &_size, QColor _color,
|
||||||
FontStyle _style, float _scale)
|
FontStyle _style, float _scale)
|
||||||
: MessageLayoutElement(_creator, _size)
|
: MessageLayoutElement(_creator, _size)
|
||||||
, color(_color)
|
, color_(_color)
|
||||||
, style(_style)
|
, style_(_style)
|
||||||
, scale(_scale)
|
, scale_(_scale)
|
||||||
{
|
{
|
||||||
this->setText(_text);
|
this->setText(_text);
|
||||||
}
|
}
|
||||||
|
@ -212,9 +212,9 @@ void TextLayoutElement::paint(QPainter &painter)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
painter.setPen(this->color);
|
painter.setPen(this->color_);
|
||||||
|
|
||||||
painter.setFont(app->fonts->getFont(this->style, this->scale));
|
painter.setFont(app->fonts->getFont(this->style_, this->scale_));
|
||||||
|
|
||||||
painter.drawText(
|
painter.drawText(
|
||||||
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000),
|
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000),
|
||||||
|
@ -234,7 +234,8 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||||
|
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->style, this->scale);
|
QFontMetrics metrics =
|
||||||
|
app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||||
|
|
||||||
int x = this->getRect().left();
|
int x = this->getRect().left();
|
||||||
|
|
||||||
|
@ -264,7 +265,8 @@ int TextLayoutElement::getXFromIndex(int index)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->style, this->scale);
|
QFontMetrics metrics =
|
||||||
|
app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||||
|
|
||||||
if (index <= 0)
|
if (index <= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,8 +80,8 @@ class TextLayoutElement : public MessageLayoutElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextLayoutElement(MessageElement &creator_, QString &text,
|
TextLayoutElement(MessageElement &creator_, QString &text,
|
||||||
const QSize &size, QColor color, FontStyle style,
|
const QSize &size, QColor color_, FontStyle style_,
|
||||||
float scale);
|
float scale_);
|
||||||
|
|
||||||
void listenToLinkChanges();
|
void listenToLinkChanges();
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ protected:
|
||||||
int getXFromIndex(int index) override;
|
int getXFromIndex(int index) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor color;
|
QColor color_;
|
||||||
FontStyle style;
|
FontStyle style_;
|
||||||
float scale;
|
float scale_;
|
||||||
|
|
||||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,8 +127,7 @@ void WindowManager::updateWordTypeMask()
|
||||||
|
|
||||||
// bits
|
// bits
|
||||||
flags.set(MEF::BitsAmount);
|
flags.set(MEF::BitsAmount);
|
||||||
flags.set(settings->animateEmotes ? MEF::BitsAnimated
|
flags.set(settings->animateEmotes ? MEF::BitsAnimated : MEF::BitsStatic);
|
||||||
: MEF::BitsStatic);
|
|
||||||
|
|
||||||
// badges
|
// badges
|
||||||
flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority
|
flags.set(settings->showBadgesGlobalAuthority ? MEF::BadgeGlobalAuthority
|
||||||
|
@ -148,9 +147,9 @@ void WindowManager::updateWordTypeMask()
|
||||||
flags.set(MEF::AlwaysShow);
|
flags.set(MEF::AlwaysShow);
|
||||||
flags.set(MEF::Collapsed);
|
flags.set(MEF::Collapsed);
|
||||||
flags.set(settings->boldUsernames ? MEF::BoldUsername
|
flags.set(settings->boldUsernames ? MEF::BoldUsername
|
||||||
: MEF::NonBoldUsername);
|
: MEF::NonBoldUsername);
|
||||||
flags.set(settings->lowercaseDomains ? MEF::LowercaseLink
|
flags.set(settings->lowercaseDomains ? MEF::LowercaseLink
|
||||||
: MEF::OriginalLink);
|
: MEF::OriginalLink);
|
||||||
|
|
||||||
// update flags
|
// update flags
|
||||||
MessageElementFlags newFlags = static_cast<MessageElementFlags>(flags);
|
MessageElementFlags newFlags = static_cast<MessageElementFlags>(flags);
|
||||||
|
@ -165,7 +164,7 @@ void WindowManager::updateWordTypeMask()
|
||||||
|
|
||||||
void WindowManager::layoutChannelViews(Channel *channel)
|
void WindowManager::layoutChannelViews(Channel *channel)
|
||||||
{
|
{
|
||||||
this->layout.invoke(channel);
|
this->layoutRequested.invoke(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::forceLayoutChannelViews()
|
void WindowManager::forceLayoutChannelViews()
|
||||||
|
@ -176,15 +175,12 @@ void WindowManager::forceLayoutChannelViews()
|
||||||
|
|
||||||
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
if (this->mainWindow_ != nullptr)
|
this->layoutRequested.invoke(channel);
|
||||||
{
|
|
||||||
this->mainWindow_->repaintVisibleChatWidgets(channel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::repaintGifEmotes()
|
void WindowManager::repaintGifEmotes()
|
||||||
{
|
{
|
||||||
this->repaintGifs.invoke();
|
this->gifRepaintRequested.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void WindowManager::updateAll()
|
// void WindowManager::updateAll()
|
||||||
|
|
|
@ -67,14 +67,6 @@ public:
|
||||||
MessageElementFlags getWordFlags();
|
MessageElementFlags getWordFlags();
|
||||||
void updateWordTypeMask();
|
void updateWordTypeMask();
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal repaintGifs;
|
|
||||||
|
|
||||||
// This signal fires whenever views rendering a channel, or all views if the
|
|
||||||
// channel is a nullptr, need to redo their layout
|
|
||||||
pajlada::Signals::Signal<Channel *> layout;
|
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
|
||||||
|
|
||||||
// Sends an alert to the main window
|
// Sends an alert to the main window
|
||||||
// It reads the `longAlert` setting to decide whether the alert will expire
|
// It reads the `longAlert` setting to decide whether the alert will expire
|
||||||
// or not
|
// or not
|
||||||
|
@ -85,6 +77,15 @@ public:
|
||||||
// again
|
// again
|
||||||
void queueSave();
|
void queueSave();
|
||||||
|
|
||||||
|
/// Signals
|
||||||
|
pajlada::Signals::NoArgSignal gifRepaintRequested;
|
||||||
|
|
||||||
|
// This signal fires whenever views rendering a channel, or all views if the
|
||||||
|
// channel is a nullptr, need to redo their layout
|
||||||
|
pajlada::Signals::Signal<Channel *> layoutRequested;
|
||||||
|
|
||||||
|
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
||||||
|
|
||||||
|
|
|
@ -68,19 +68,6 @@ SplitNotebook &Window::getNotebook()
|
||||||
return *this->notebook_;
|
return *this->notebook_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::repaintVisibleChatWidgets(Channel *channel)
|
|
||||||
{
|
|
||||||
auto page = this->notebook_->getOrAddSelectedPage();
|
|
||||||
|
|
||||||
for (const auto &split : page->getSplits())
|
|
||||||
{
|
|
||||||
if (channel == nullptr || channel == split->getChannel().get())
|
|
||||||
{
|
|
||||||
split->layoutMessages();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Window::event(QEvent *event)
|
bool Window::event(QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
|
|
|
@ -25,8 +25,6 @@ public:
|
||||||
WindowType getType();
|
WindowType getType();
|
||||||
SplitNotebook &getNotebook();
|
SplitNotebook &getNotebook();
|
||||||
|
|
||||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal closed;
|
pajlada::Signals::NoArgSignal closed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -168,13 +168,16 @@ void ChannelView::initializeSignals()
|
||||||
getSettings()->showLastMessageIndicator.connect(
|
getSettings()->showLastMessageIndicator.connect(
|
||||||
[this](auto, auto) { this->update(); }, this->connections_);
|
[this](auto, auto) { this->update(); }, this->connections_);
|
||||||
|
|
||||||
connections_.push_back(
|
connections_.push_back(getApp()->windows->gifRepaintRequested.connect(
|
||||||
getApp()->windows->repaintGifs.connect([&] { this->queueUpdate(); }));
|
[&] { this->queueUpdate(); }));
|
||||||
|
|
||||||
connections_.push_back(
|
connections_.push_back(
|
||||||
getApp()->windows->layout.connect([&](Channel *channel) {
|
getApp()->windows->layoutRequested.connect([&](Channel *channel) {
|
||||||
if (channel == nullptr || this->channel_.get() == channel)
|
if (this->isVisible() &&
|
||||||
|
(channel == nullptr || this->channel_.get() == channel))
|
||||||
|
{
|
||||||
this->queueLayout();
|
this->queueLayout();
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
connections_.push_back(
|
connections_.push_back(
|
||||||
|
@ -402,13 +405,9 @@ void ChannelView::updateScrollbar(
|
||||||
void ChannelView::clearMessages()
|
void ChannelView::clearMessages()
|
||||||
{
|
{
|
||||||
// Clear all stored messages in this chat widget
|
// Clear all stored messages in this chat widget
|
||||||
this->messages.clear();
|
this->messages_.clear();
|
||||||
this->scrollBar_->clearHighlights();
|
this->scrollBar_->clearHighlights();
|
||||||
|
|
||||||
// Layout chat widget messages, and force an update regardless if there are
|
|
||||||
// no messages
|
|
||||||
this->queueLayout();
|
this->queueLayout();
|
||||||
this->queueUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scrollbar &ChannelView::getScrollBar()
|
Scrollbar &ChannelView::getScrollBar()
|
||||||
|
@ -483,18 +482,21 @@ LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
||||||
{
|
{
|
||||||
if (!this->paused() /*|| this->scrollBar_->isVisible()*/)
|
if (!this->paused() /*|| this->scrollBar_->isVisible()*/)
|
||||||
{
|
{
|
||||||
this->snapshot_ = this->messages.getSnapshot();
|
this->snapshot_ = this->messages_.getSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->snapshot_;
|
return this->snapshot_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelPtr ChannelView::channel()
|
||||||
|
{
|
||||||
|
return this->channel_;
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelView::setChannel(ChannelPtr newChannel)
|
void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
{
|
{
|
||||||
if (this->channel_)
|
/// Clear connections from the last channel
|
||||||
{
|
this->channelConnections_.clear();
|
||||||
this->detachChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->clearMessages();
|
this->clearMessages();
|
||||||
|
|
||||||
|
@ -539,7 +541,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
this->lastMessageHasAlternateBackground_ =
|
this->lastMessageHasAlternateBackground_ =
|
||||||
!this->lastMessageHasAlternateBackground_;
|
!this->lastMessageHasAlternateBackground_;
|
||||||
|
|
||||||
this->messages.pushBack(MessageLayoutPtr(messageRef), deleted);
|
this->messages_.pushBack(MessageLayoutPtr(messageRef), deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->channel_ = newChannel;
|
this->channel_ = newChannel;
|
||||||
|
@ -580,7 +582,7 @@ void ChannelView::messageAppended(MessagePtr &message,
|
||||||
this->lastMessageHasAlternateBackground_ =
|
this->lastMessageHasAlternateBackground_ =
|
||||||
!this->lastMessageHasAlternateBackground_;
|
!this->lastMessageHasAlternateBackground_;
|
||||||
|
|
||||||
if (this->messages.pushBack(MessageLayoutPtr(messageRef), deleted))
|
if (this->messages_.pushBack(MessageLayoutPtr(messageRef), deleted))
|
||||||
{
|
{
|
||||||
// if (!this->isPaused()) {
|
// if (!this->isPaused()) {
|
||||||
if (this->scrollBar_->isAtBottom())
|
if (this->scrollBar_->isAtBottom())
|
||||||
|
@ -635,7 +637,7 @@ void ChannelView::messageAddedAtStart(std::vector<MessagePtr> &messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add the messages at the start
|
/// Add the messages at the start
|
||||||
if (this->messages.pushFront(messageRefs).size() > 0)
|
if (this->messages_.pushFront(messageRefs).size() > 0)
|
||||||
{
|
{
|
||||||
if (this->scrollBar_->isAtBottom())
|
if (this->scrollBar_->isAtBottom())
|
||||||
this->scrollBar_->scrollToBottom();
|
this->scrollBar_->scrollToBottom();
|
||||||
|
@ -669,13 +671,13 @@ void ChannelView::messageRemoveFromStart(MessagePtr &message)
|
||||||
|
|
||||||
void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
|
void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
|
||||||
{
|
{
|
||||||
if (index >= this->messages.getSnapshot().size() || index < 0)
|
if (index >= this->messages_.getSnapshot().size() || index < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageLayoutPtr newItem(new MessageLayout(replacement));
|
MessageLayoutPtr newItem(new MessageLayout(replacement));
|
||||||
auto snapshot = this->messages.getSnapshot();
|
auto snapshot = this->messages_.getSnapshot();
|
||||||
if (index >= snapshot.size())
|
if (index >= snapshot.size())
|
||||||
{
|
{
|
||||||
log("Tried to replace out of bounds message. Index: {}. "
|
log("Tried to replace out of bounds message. Index: {}. "
|
||||||
|
@ -693,15 +695,10 @@ void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
|
||||||
this->scrollBar_->replaceHighlight(index,
|
this->scrollBar_->replaceHighlight(index,
|
||||||
replacement->getScrollBarHighlight());
|
replacement->getScrollBarHighlight());
|
||||||
|
|
||||||
this->messages.replaceItem(message, newItem);
|
this->messages_.replaceItem(message, newItem);
|
||||||
this->queueLayout();
|
this->queueLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::detachChannel()
|
|
||||||
{
|
|
||||||
this->channelConnections_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelView::updateLastReadMessage()
|
void ChannelView::updateLastReadMessage()
|
||||||
{
|
{
|
||||||
auto _snapshot = this->getMessagesSnapshot();
|
auto _snapshot = this->getMessagesSnapshot();
|
||||||
|
@ -1048,18 +1045,18 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
SelectionItem newEnd(messageIndex, wordEnd);
|
SelectionItem newEnd(messageIndex, wordEnd);
|
||||||
|
|
||||||
// Selection changed in same message
|
// Selection changed in same message
|
||||||
if (messageIndex == this->dCSelection_.origMessageIndex)
|
if (messageIndex == this->doubleClickSelection_.origMessageIndex)
|
||||||
{
|
{
|
||||||
// Selecting to the left
|
// Selecting to the left
|
||||||
if (wordStart < this->selection_.start.charIndex &&
|
if (wordStart < this->selection_.start.charIndex &&
|
||||||
!this->dCSelection_.selectingRight)
|
!this->doubleClickSelection_.selectingRight)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = true;
|
this->doubleClickSelection_.selectingLeft = true;
|
||||||
// Ensure that the original word stays selected(Edge case)
|
// Ensure that the original word stays selected(Edge case)
|
||||||
if (wordStart > this->dCSelection_.originalEnd)
|
if (wordStart > this->doubleClickSelection_.originalEnd)
|
||||||
{
|
{
|
||||||
this->setSelection(this->dCSelection_.origStartItem,
|
this->setSelection(
|
||||||
newEnd);
|
this->doubleClickSelection_.origStartItem, newEnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1068,14 +1065,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
// Selecting to the right
|
// Selecting to the right
|
||||||
}
|
}
|
||||||
else if (wordEnd > this->selection_.end.charIndex &&
|
else if (wordEnd > this->selection_.end.charIndex &&
|
||||||
!this->dCSelection_.selectingLeft)
|
!this->doubleClickSelection_.selectingLeft)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingRight = true;
|
this->doubleClickSelection_.selectingRight = true;
|
||||||
// Ensure that the original word stays selected(Edge case)
|
// Ensure that the original word stays selected(Edge case)
|
||||||
if (wordEnd < this->dCSelection_.originalStart)
|
if (wordEnd < this->doubleClickSelection_.originalStart)
|
||||||
{
|
{
|
||||||
this->setSelection(newStart,
|
this->setSelection(newStart,
|
||||||
this->dCSelection_.origEndItem);
|
this->doubleClickSelection_.origEndItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1084,14 +1081,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
// Swapping from selecting left to selecting right
|
// Swapping from selecting left to selecting right
|
||||||
if (wordStart > this->selection_.start.charIndex &&
|
if (wordStart > this->selection_.start.charIndex &&
|
||||||
!this->dCSelection_.selectingRight)
|
!this->doubleClickSelection_.selectingRight)
|
||||||
{
|
{
|
||||||
if (wordStart > this->dCSelection_.originalEnd)
|
if (wordStart > this->doubleClickSelection_.originalEnd)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = false;
|
this->doubleClickSelection_.selectingLeft = false;
|
||||||
this->dCSelection_.selectingRight = true;
|
this->doubleClickSelection_.selectingRight = true;
|
||||||
this->setSelection(this->dCSelection_.origStartItem,
|
this->setSelection(
|
||||||
newEnd);
|
this->doubleClickSelection_.origStartItem, newEnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1100,14 +1097,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
// Swapping from selecting right to selecting left
|
// Swapping from selecting right to selecting left
|
||||||
}
|
}
|
||||||
else if (wordEnd < this->selection_.end.charIndex &&
|
else if (wordEnd < this->selection_.end.charIndex &&
|
||||||
!this->dCSelection_.selectingLeft)
|
!this->doubleClickSelection_.selectingLeft)
|
||||||
{
|
{
|
||||||
if (wordEnd < this->dCSelection_.originalStart)
|
if (wordEnd < this->doubleClickSelection_.originalStart)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = true;
|
this->doubleClickSelection_.selectingLeft = true;
|
||||||
this->dCSelection_.selectingRight = false;
|
this->doubleClickSelection_.selectingRight = false;
|
||||||
this->setSelection(newStart,
|
this->setSelection(newStart,
|
||||||
this->dCSelection_.origEndItem);
|
this->doubleClickSelection_.origEndItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1122,38 +1119,40 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
if (messageIndex < this->selection_.start.messageIndex)
|
if (messageIndex < this->selection_.start.messageIndex)
|
||||||
{
|
{
|
||||||
// Swapping from left to right selecting
|
// Swapping from left to right selecting
|
||||||
if (!this->dCSelection_.selectingLeft)
|
if (!this->doubleClickSelection_.selectingLeft)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = true;
|
this->doubleClickSelection_.selectingLeft = true;
|
||||||
this->dCSelection_.selectingRight = false;
|
this->doubleClickSelection_.selectingRight = false;
|
||||||
}
|
}
|
||||||
if (wordStart < this->selection_.start.charIndex &&
|
if (wordStart < this->selection_.start.charIndex &&
|
||||||
!this->dCSelection_.selectingRight)
|
!this->doubleClickSelection_.selectingRight)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = true;
|
this->doubleClickSelection_.selectingLeft = true;
|
||||||
}
|
}
|
||||||
this->setSelection(newStart, this->dCSelection_.origEndItem);
|
this->setSelection(newStart,
|
||||||
|
this->doubleClickSelection_.origEndItem);
|
||||||
// Message under the original
|
// Message under the original
|
||||||
}
|
}
|
||||||
else if (messageIndex > this->selection_.end.messageIndex)
|
else if (messageIndex > this->selection_.end.messageIndex)
|
||||||
{
|
{
|
||||||
// Swapping from right to left selecting
|
// Swapping from right to left selecting
|
||||||
if (!this->dCSelection_.selectingRight)
|
if (!this->doubleClickSelection_.selectingRight)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = false;
|
this->doubleClickSelection_.selectingLeft = false;
|
||||||
this->dCSelection_.selectingRight = true;
|
this->doubleClickSelection_.selectingRight = true;
|
||||||
}
|
}
|
||||||
if (wordEnd > this->selection_.end.charIndex &&
|
if (wordEnd > this->selection_.end.charIndex &&
|
||||||
!this->dCSelection_.selectingLeft)
|
!this->doubleClickSelection_.selectingLeft)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingRight = true;
|
this->doubleClickSelection_.selectingRight = true;
|
||||||
}
|
}
|
||||||
this->setSelection(this->dCSelection_.origStartItem, newEnd);
|
this->setSelection(this->doubleClickSelection_.origStartItem,
|
||||||
|
newEnd);
|
||||||
// Selection changed in non original message
|
// Selection changed in non original message
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (this->dCSelection_.selectingLeft)
|
if (this->doubleClickSelection_.selectingLeft)
|
||||||
{
|
{
|
||||||
this->setSelection(newStart, this->selection_.end);
|
this->setSelection(newStart, this->selection_.end);
|
||||||
}
|
}
|
||||||
|
@ -1164,11 +1163,11 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reset direction of selection
|
// Reset direction of selection
|
||||||
if (wordStart == this->dCSelection_.originalStart &&
|
if (wordStart == this->doubleClickSelection_.originalStart &&
|
||||||
wordEnd == this->dCSelection_.originalEnd)
|
wordEnd == this->doubleClickSelection_.originalEnd)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft =
|
this->doubleClickSelection_.selectingLeft =
|
||||||
this->dCSelection_.selectingRight = false;
|
this->doubleClickSelection_.selectingRight = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,8 +1273,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
// check if mouse was pressed
|
// check if mouse was pressed
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
this->dCSelection_.selectingLeft = this->dCSelection_.selectingRight =
|
this->doubleClickSelection_.selectingLeft =
|
||||||
false;
|
this->doubleClickSelection_.selectingRight = false;
|
||||||
if (this->isDoubleClick_)
|
if (this->isDoubleClick_)
|
||||||
{
|
{
|
||||||
this->isDoubleClick_ = false;
|
this->isDoubleClick_ = false;
|
||||||
|
@ -1560,6 +1559,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
this->clickTimer_->start();
|
this->clickTimer_->start();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->isMouseDown_)
|
if (!this->isMouseDown_)
|
||||||
{
|
{
|
||||||
this->isDoubleClick_ = true;
|
this->isDoubleClick_ = true;
|
||||||
|
@ -1574,11 +1574,11 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
SelectionItem wordMin(messageIndex, wordStart);
|
SelectionItem wordMin(messageIndex, wordStart);
|
||||||
SelectionItem wordMax(messageIndex, wordEnd);
|
SelectionItem wordMax(messageIndex, wordEnd);
|
||||||
|
|
||||||
this->dCSelection_.originalStart = wordStart;
|
this->doubleClickSelection_.originalStart = wordStart;
|
||||||
this->dCSelection_.originalEnd = wordEnd;
|
this->doubleClickSelection_.originalEnd = wordEnd;
|
||||||
this->dCSelection_.origMessageIndex = messageIndex;
|
this->doubleClickSelection_.origMessageIndex = messageIndex;
|
||||||
this->dCSelection_.origStartItem = wordMin;
|
this->doubleClickSelection_.origStartItem = wordMin;
|
||||||
this->dCSelection_.origEndItem = wordMax;
|
this->doubleClickSelection_.origEndItem = wordMax;
|
||||||
|
|
||||||
this->setSelection(wordMin, wordMax);
|
this->setSelection(wordMin, wordMax);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,14 @@ public:
|
||||||
const boost::optional<MessageElementFlags> &getOverrideFlags() const;
|
const boost::optional<MessageElementFlags> &getOverrideFlags() const;
|
||||||
void updateLastReadMessage();
|
void updateLastReadMessage();
|
||||||
|
|
||||||
|
/// Pausing
|
||||||
bool paused() const;
|
bool paused() const;
|
||||||
void pause(PauseReason reason, boost::optional<uint> msecs = boost::none);
|
void pause(PauseReason reason, boost::optional<uint> msecs = boost::none);
|
||||||
void unpause(PauseReason reason);
|
void unpause(PauseReason reason);
|
||||||
|
|
||||||
|
ChannelPtr channel();
|
||||||
void setChannel(ChannelPtr channel_);
|
void setChannel(ChannelPtr channel_);
|
||||||
|
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> getMessagesSnapshot();
|
LimitedQueueSnapshot<MessageLayoutPtr> getMessagesSnapshot();
|
||||||
void queueLayout();
|
void queueLayout();
|
||||||
|
|
||||||
|
@ -118,8 +121,6 @@ private:
|
||||||
void messageRemoveFromStart(MessagePtr &message);
|
void messageRemoveFromStart(MessagePtr &message);
|
||||||
void messageReplaced(size_t index, MessagePtr &replacement);
|
void messageReplaced(size_t index, MessagePtr &replacement);
|
||||||
|
|
||||||
void detachChannel();
|
|
||||||
|
|
||||||
void performLayout(bool causedByScollbar = false);
|
void performLayout(bool causedByScollbar = false);
|
||||||
void layoutVisibleMessages(
|
void layoutVisibleMessages(
|
||||||
LimitedQueueSnapshot<MessageLayoutPtr> &messages);
|
LimitedQueueSnapshot<MessageLayoutPtr> &messages);
|
||||||
|
@ -177,7 +178,7 @@ private:
|
||||||
bool isMouseDown_ = false;
|
bool isMouseDown_ = false;
|
||||||
bool isRightMouseDown_ = false;
|
bool isRightMouseDown_ = false;
|
||||||
bool isDoubleClick_ = false;
|
bool isDoubleClick_ = false;
|
||||||
DoubleClickSelection dCSelection_;
|
DoubleClickSelection doubleClickSelection_;
|
||||||
QPointF lastPressPosition_;
|
QPointF lastPressPosition_;
|
||||||
QPointF lastRightPressPosition_;
|
QPointF lastRightPressPosition_;
|
||||||
QPointF lastDClickPosition_;
|
QPointF lastDClickPosition_;
|
||||||
|
@ -186,7 +187,7 @@ private:
|
||||||
Selection selection_;
|
Selection selection_;
|
||||||
bool selecting_ = false;
|
bool selecting_ = false;
|
||||||
|
|
||||||
LimitedQueue<MessageLayoutPtr> messages;
|
LimitedQueue<MessageLayoutPtr> messages_;
|
||||||
|
|
||||||
pajlada::Signals::Connection messageAppendedConnection_;
|
pajlada::Signals::Connection messageAppendedConnection_;
|
||||||
pajlada::Signals::Connection messageAddedAtStartConnection_;
|
pajlada::Signals::Connection messageAddedAtStartConnection_;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "widgets/splits/Split.hpp"
|
#include "widgets/splits/Split.hpp"
|
||||||
|
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/EmoteValue.hpp"
|
#include "providers/twitch/EmoteValue.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
|
@ -106,7 +106,7 @@ Split::Split(QWidget *parent)
|
||||||
// CTRL+F: Search
|
// CTRL+F: Search
|
||||||
createShortcut(this, "CTRL+F", &Split::showSearch);
|
createShortcut(this, "CTRL+F", &Split::showSearch);
|
||||||
|
|
||||||
// F5: reload emotes
|
// F5: reload emotes
|
||||||
createShortcut(this, "F5", &Split::reloadChannelAndSubscriberEmotes);
|
createShortcut(this, "F5", &Split::reloadChannelAndSubscriberEmotes);
|
||||||
|
|
||||||
// F12
|
// F12
|
||||||
|
@ -320,11 +320,6 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||||
this->selectChannelDialog_ = dialog;
|
this->selectChannelDialog_ = dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Split::layoutMessages()
|
|
||||||
{
|
|
||||||
this->view_->queueLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Split::updateGifEmotes()
|
void Split::updateGifEmotes()
|
||||||
{
|
{
|
||||||
this->view_->queueUpdate();
|
this->view_->queueUpdate();
|
||||||
|
@ -659,7 +654,6 @@ void Split::reloadChannelAndSubscriberEmotes()
|
||||||
twitchChannel->refreshChannelEmotes();
|
twitchChannel->refreshChannelEmotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename Iter, typename RandomGenerator>
|
template <typename Iter, typename RandomGenerator>
|
||||||
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,6 @@ public:
|
||||||
std::function<void(bool)> callback);
|
std::function<void(bool)> callback);
|
||||||
void giveFocus(Qt::FocusReason reason);
|
void giveFocus(Qt::FocusReason reason);
|
||||||
bool hasFocus() const;
|
bool hasFocus() const;
|
||||||
void layoutMessages();
|
|
||||||
void updateGifEmotes();
|
void updateGifEmotes();
|
||||||
void updateLastReadMessage();
|
void updateLastReadMessage();
|
||||||
void setIsTopRightSplit(bool value);
|
void setIsTopRightSplit(bool value);
|
||||||
|
|
Loading…
Reference in a new issue