Fixes #1336 Pause on hover breaks moves selection

This commit is contained in:
fourtf
2019-09-25 23:47:13 +02:00
parent 4e48416600
commit 848d5c8789
2 changed files with 38 additions and 34 deletions
+29 -25
View File
@@ -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();