mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixes #1336 Pause on hover breaks moves selection
This commit is contained in:
parent
4e48416600
commit
848d5c8789
2 changed files with 38 additions and 34 deletions
|
@ -1,5 +1,17 @@
|
|||
#include "ChannelView.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
|
@ -25,19 +37,6 @@
|
|||
#include "widgets/helper/EffectLabel.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#define DRAW_WIDTH (this->width())
|
||||
#define SELECTION_RESUME_SCROLLING_MSG_THRESHOLD 3
|
||||
#define CHAT_HOVER_PAUSE_DURATION 1000
|
||||
|
@ -122,7 +121,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
|||
for (auto it = this->pauses_.begin(); it != this->pauses_.end();)
|
||||
it = it->second ? this->pauses_.erase(it) : ++it;
|
||||
|
||||
this->updatePauseTimer();
|
||||
this->updatePauses();
|
||||
});
|
||||
|
||||
auto shortcut = new QShortcut(QKeySequence("Ctrl+C"), this);
|
||||
|
@ -232,7 +231,7 @@ void ChannelView::pause(PauseReason reason, boost::optional<uint> msecs)
|
|||
this->pauses_[reason] = boost::none;
|
||||
}
|
||||
|
||||
this->updatePauseTimer();
|
||||
this->updatePauses();
|
||||
}
|
||||
|
||||
void ChannelView::unpause(PauseReason reason)
|
||||
|
@ -240,23 +239,17 @@ void ChannelView::unpause(PauseReason reason)
|
|||
/// Remove the value from the map
|
||||
this->pauses_.erase(reason);
|
||||
|
||||
this->updatePauseTimer();
|
||||
|
||||
/// Move selection
|
||||
this->selection_.selectionMin.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.selectionMax.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.start.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.end.messageIndex -= this->pauseSelectionOffset_;
|
||||
|
||||
this->pauseSelectionOffset_ = 0;
|
||||
this->updatePauses();
|
||||
}
|
||||
|
||||
void ChannelView::updatePauseTimer()
|
||||
void ChannelView::updatePauses()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
if (this->pauses_.empty())
|
||||
{
|
||||
this->unpaused();
|
||||
|
||||
/// No pauses so we can stop the timer
|
||||
this->pauseEnd_ = boost::none;
|
||||
this->pauseTimer_.stop();
|
||||
|
@ -292,6 +285,17 @@ void ChannelView::updatePauseTimer()
|
|||
}
|
||||
}
|
||||
|
||||
void ChannelView::unpaused()
|
||||
{
|
||||
/// Move selection
|
||||
this->selection_.selectionMin.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.selectionMax.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.start.messageIndex -= this->pauseSelectionOffset_;
|
||||
this->selection_.end.messageIndex -= this->pauseSelectionOffset_;
|
||||
|
||||
this->pauseSelectionOffset_ = 0;
|
||||
}
|
||||
|
||||
void ChannelView::themeChangedEvent()
|
||||
{
|
||||
BaseWidget::themeChangedEvent();
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Selection.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QScroller>
|
||||
#include <QTimer>
|
||||
#include <QWheelEvent>
|
||||
#include <QWidget>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Selection.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
enum class HighlightState;
|
||||
|
||||
|
@ -146,7 +145,8 @@ private:
|
|||
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
|
||||
MessageLayout *layout);
|
||||
int getLayoutWidth() const;
|
||||
void updatePauseTimer();
|
||||
void updatePauses();
|
||||
void unpaused();
|
||||
|
||||
QTimer *layoutCooldown_;
|
||||
bool layoutQueued_;
|
||||
|
|
Loading…
Reference in a new issue