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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 14 deletions

View file

@ -2,6 +2,7 @@
## 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 unnecessary saving of windows layout. (#4201)
- Dev: Ignore `WM_SHOWWINDOW` hide events, causing fewer attempted rescales. (#4198)

View file

@ -81,7 +81,8 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, QWidget *parent,
});
// 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(
getApp()->accounts->twitch.currentUserChanged.connect([this] {

View file

@ -166,9 +166,13 @@ ChannelView::ChannelView(BaseWidget *parent, Split *split, Context context,
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);
QObject::connect(shortcut, &QShortcut::activated, [this] {
crossPlatformCopy(this->getSelectedText());
this->copySelectedText();
});
this->clickTimer_ = new QTimer(this);
@ -592,6 +596,11 @@ void ChannelView::clearSelection()
queueLayout();
}
void ChannelView::copySelectedText()
{
crossPlatformCopy(this->getSelectedText());
}
void ChannelView::setEnableScrollingToBottom(bool value)
{
this->enableScrollingToBottom_ = value;

View file

@ -77,9 +77,17 @@ public:
void queueUpdate();
Scrollbar &getScrollBar();
QString getSelectedText();
bool hasSelection();
void clearSelection();
/**
* Copies the currently selected text to the users clipboard.
*
* @see ::getSelectedText()
*/
void copySelectedText();
void setEnableScrollingToBottom(bool);
bool getEnableScrollingToBottom() const;
void setOverrideFlags(boost::optional<MessageElementFlags> value);

View file

@ -1121,11 +1121,6 @@ void Split::openSubPage()
}
}
void Split::copyToClipboard()
{
crossPlatformCopy(this->view_->getSelectedText());
}
void Split::startWatching()
{
#ifdef USEWEBENGINE

View file

@ -168,7 +168,6 @@ public slots:
void openBrowserPlayer();
void openInStreamlink();
void openWithCustomScheme();
void copyToClipboard();
void startWatching();
void setFiltersDialog();
void showSearch(bool singleChannel);

View file

@ -33,14 +33,16 @@
namespace chatterino {
SplitInput::SplitInput(Split *_chatWidget, bool enableInlineReplying)
: SplitInput(_chatWidget, _chatWidget, enableInlineReplying)
: SplitInput(_chatWidget, _chatWidget, _chatWidget->view_,
enableInlineReplying)
{
}
SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
bool enableInlineReplying)
ChannelView *_channelView, bool enableInlineReplying)
: BaseWidget(parent)
, split_(_chatWidget)
, channelView_(_channelView)
, enableInlineReplying_(enableInlineReplying)
{
this->installEventFilter(this);
@ -562,7 +564,7 @@ void SplitInput::addShortcuts()
if (copyFromSplit)
{
this->split_->copyToClipboard();
this->channelView_->copySelectedText();
}
else
{
@ -641,9 +643,9 @@ void SplitInput::installKeyPressedEvent()
if ((event->key() == Qt::Key_C || event->key() == Qt::Key_Insert) &&
event->modifiers() == Qt::ControlModifier)
{
if (this->split_->view_->hasSelection())
if (this->channelView_->hasSelection())
{
this->split_->copyToClipboard();
this->channelView_->copySelectedText();
event->accept();
}
}

View file

@ -22,6 +22,7 @@ class InputCompletionPopup;
class EffectLabel;
class MessageThread;
class ResizingTextEdit;
class ChannelView;
// MessageOverflow is used for controlling how to guide the user into not
// sending a message that will be discarded by Twitch
@ -42,7 +43,7 @@ class SplitInput : public BaseWidget
public:
SplitInput(Split *_chatWidget, bool enableInlineReplying = true);
SplitInput(QWidget *parent, Split *_chatWidget,
SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView,
bool enableInlineReplying = true);
bool hasSelection() const;
@ -124,6 +125,7 @@ protected:
bool shouldPreventInput(const QString &text) const;
Split *const split_;
ChannelView *const channelView_;
QObjectRef<EmotePopup> emotePopup_;
QObjectRef<InputCompletionPopup> inputCompletionPopup_;