From 0d4d301aa0979ec0bf44e470bd75d0991ba46dc9 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 2 Dec 2018 18:37:51 +0100 Subject: [PATCH] added `pausable` property to ChannelView --- src/widgets/helper/ChannelView.cpp | 12 +++++++++++- src/widgets/helper/ChannelView.hpp | 3 +++ src/widgets/splits/Split.cpp | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index a5def402..4b723e68 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -184,10 +184,20 @@ void ChannelView::initializeSignals() getApp()->fonts->fontChanged.connect([this] { this->queueLayout(); })); } +bool ChannelView::pausable() const +{ + return pausable_; +} + +void ChannelView::setPausable(bool value) +{ + this->pausable_ = value; +} + bool ChannelView::paused() const { /// No elements in the map -> not paused - return !this->pauses_.empty(); + return this->pausable() && !this->pauses_.empty(); } void ChannelView::pause(PauseReason reason, boost::optional msecs) diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 8c2c2f13..041ced77 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -66,6 +66,8 @@ public: void updateLastReadMessage(); /// Pausing + bool pausable() const; + void setPausable(bool value); bool paused() const; void pause(PauseReason reason, boost::optional msecs = boost::none); void unpause(PauseReason reason); @@ -153,6 +155,7 @@ private: bool lastMessageHasAlternateBackground_ = false; bool lastMessageHasAlternateBackgroundReverse_ = true; + bool pausable_ = false; QTimer pauseTimer_; std::unordered_map> pauses_; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index f50d938f..829014a9 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -88,6 +88,7 @@ Split::Split(QWidget *parent) , overlay_(new SplitOverlay(this)) { this->setMouseTracking(true); + this->view_->setPausable(true); this->vbox_->setSpacing(0); this->vbox_->setMargin(1); @@ -124,8 +125,7 @@ Split::Split(QWidget *parent) this->input_->ui_.textEdit->installEventFilter(parent); - this->view_->mouseDown.connect([this](QMouseEvent *) { - // + this->view_->mouseDown.connect([this](QMouseEvent *) { // this->giveFocus(Qt::MouseFocusReason); }); this->view_->selectionChanged.connect([this]() {