fix: Copy Shortcut Not Working In Reply Thread Popup (#4209)

This commit is contained in:
nerix
2022-12-03 14:02:39 +01:00
committed by GitHub
parent 6ee7ef8cab
commit 8d4ee72478
8 changed files with 31 additions and 14 deletions
+1
View File
@@ -2,6 +2,7 @@
## Unversioned ## Unversioned
- Bugfix: Fixed CTRL + C not working in reply thread popups. (#4209)
- Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204) - Bugfix: Fixed message input showing as red after removing a message that was more than 500 characters. (#4204)
- Bugfix: Fixed unnecessary saving of windows layout. (#4201) - Bugfix: Fixed unnecessary saving of windows layout. (#4201)
- Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198) - Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198)
+2 -1
View File
@@ -81,7 +81,8 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, QWidget *parent,
}); });
// Create SplitInput with inline replying disabled // Create SplitInput with inline replying disabled
this->ui_.replyInput = new SplitInput(this, this->split_, false); this->ui_.replyInput =
new SplitInput(this, this->split_, this->ui_.threadView, false);
this->bSignals_.emplace_back( this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] { getApp()->accounts->twitch.currentUserChanged.connect([this] {
+10 -1
View File
@@ -166,9 +166,13 @@ ChannelView::ChannelView(BaseWidget *parent, Split *split, Context context,
this->updatePauses(); this->updatePauses();
}); });
// This shortcut is not used in splits, it's used in views that
// don't have a SplitInput like the SearchPopup or EmotePopup.
// See SplitInput::installKeyPressedEvent for the copy event
// from views with a SplitInput.
auto shortcut = new QShortcut(QKeySequence::StandardKey::Copy, this); auto shortcut = new QShortcut(QKeySequence::StandardKey::Copy, this);
QObject::connect(shortcut, &QShortcut::activated, [this] { QObject::connect(shortcut, &QShortcut::activated, [this] {
crossPlatformCopy(this->getSelectedText()); this->copySelectedText();
}); });
this->clickTimer_ = new QTimer(this); this->clickTimer_ = new QTimer(this);
@@ -592,6 +596,11 @@ void ChannelView::clearSelection()
queueLayout(); queueLayout();
} }
void ChannelView::copySelectedText()
{
crossPlatformCopy(this->getSelectedText());
}
void ChannelView::setEnableScrollingToBottom(bool value) void ChannelView::setEnableScrollingToBottom(bool value)
{ {
this->enableScrollingToBottom_ = value; this->enableScrollingToBottom_ = value;
+8
View File
@@ -77,9 +77,17 @@ public:
void queueUpdate(); void queueUpdate();
Scrollbar &getScrollBar(); Scrollbar &getScrollBar();
QString getSelectedText(); QString getSelectedText();
bool hasSelection(); bool hasSelection();
void clearSelection(); void clearSelection();
/**
* Copies the currently selected text to the users clipboard.
*
* @see ::getSelectedText()
*/
void copySelectedText();
void setEnableScrollingToBottom(bool); void setEnableScrollingToBottom(bool);
bool getEnableScrollingToBottom() const; bool getEnableScrollingToBottom() const;
void setOverrideFlags(boost::optional<MessageElementFlags> value); void setOverrideFlags(boost::optional<MessageElementFlags> value);
-5
View File
@@ -1121,11 +1121,6 @@ void Split::openSubPage()
} }
} }
void Split::copyToClipboard()
{
crossPlatformCopy(this->view_->getSelectedText());
}
void Split::startWatching() void Split::startWatching()
{ {
#ifdef USEWEBENGINE #ifdef USEWEBENGINE
-1
View File
@@ -168,7 +168,6 @@ public slots:
void openBrowserPlayer(); void openBrowserPlayer();
void openInStreamlink(); void openInStreamlink();
void openWithCustomScheme(); void openWithCustomScheme();
void copyToClipboard();
void startWatching(); void startWatching();
void setFiltersDialog(); void setFiltersDialog();
void showSearch(bool singleChannel); void showSearch(bool singleChannel);
+7 -5
View File
@@ -33,14 +33,16 @@
namespace chatterino { namespace chatterino {
SplitInput::SplitInput(Split *_chatWidget, bool enableInlineReplying) SplitInput::SplitInput(Split *_chatWidget, bool enableInlineReplying)
: SplitInput(_chatWidget, _chatWidget, enableInlineReplying) : SplitInput(_chatWidget, _chatWidget, _chatWidget->view_,
enableInlineReplying)
{ {
} }
SplitInput::SplitInput(QWidget *parent, Split *_chatWidget, SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
bool enableInlineReplying) ChannelView *_channelView, bool enableInlineReplying)
: BaseWidget(parent) : BaseWidget(parent)
, split_(_chatWidget) , split_(_chatWidget)
, channelView_(_channelView)
, enableInlineReplying_(enableInlineReplying) , enableInlineReplying_(enableInlineReplying)
{ {
this->installEventFilter(this); this->installEventFilter(this);
@@ -562,7 +564,7 @@ void SplitInput::addShortcuts()
if (copyFromSplit) if (copyFromSplit)
{ {
this->split_->copyToClipboard(); this->channelView_->copySelectedText();
} }
else else
{ {
@@ -641,9 +643,9 @@ void SplitInput::installKeyPressedEvent()
if ((event->key() == Qt::Key_C || event->key() == Qt::Key_Insert) && if ((event->key() == Qt::Key_C || event->key() == Qt::Key_Insert) &&
event->modifiers() == Qt::ControlModifier) event->modifiers() == Qt::ControlModifier)
{ {
if (this->split_->view_->hasSelection()) if (this->channelView_->hasSelection())
{ {
this->split_->copyToClipboard(); this->channelView_->copySelectedText();
event->accept(); event->accept();
} }
} }
+3 -1
View File
@@ -22,6 +22,7 @@ class InputCompletionPopup;
class EffectLabel; class EffectLabel;
class MessageThread; class MessageThread;
class ResizingTextEdit; class ResizingTextEdit;
class ChannelView;
// MessageOverflow is used for controlling how to guide the user into not // MessageOverflow is used for controlling how to guide the user into not
// sending a message that will be discarded by Twitch // sending a message that will be discarded by Twitch
@@ -42,7 +43,7 @@ class SplitInput : public BaseWidget
public: public:
SplitInput(Split *_chatWidget, bool enableInlineReplying = true); SplitInput(Split *_chatWidget, bool enableInlineReplying = true);
SplitInput(QWidget *parent, Split *_chatWidget, SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView,
bool enableInlineReplying = true); bool enableInlineReplying = true);
bool hasSelection() const; bool hasSelection() const;
@@ -124,6 +125,7 @@ protected:
bool shouldPreventInput(const QString &text) const; bool shouldPreventInput(const QString &text) const;
Split *const split_; Split *const split_;
ChannelView *const channelView_;
QObjectRef<EmotePopup> emotePopup_; QObjectRef<EmotePopup> emotePopup_;
QObjectRef<InputCompletionPopup> inputCompletionPopup_; QObjectRef<InputCompletionPopup> inputCompletionPopup_;