From 50da694fff9b7126f8a98c4b1ffb101d9942c8d0 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 23 Aug 2020 11:28:22 +0200 Subject: [PATCH] Stable (#1905) * fixed SearchWindow memory leak * Update CHANGELOG.md * added DebugCount for BaseWindow * [Bug Fix] Color of second user highlight cannot be set (#1898) * Highlighting: Fix bug preventing user highlight from being set Before this commit, only the row of a clicked cell was checked, but not the tab it was clicked in. Since the "Whispers" row is the second row in the "Messages" tab on the highlighting page, the color picker was not opened for the second entry in the "Users" tab either. This commit fixes the bug by also checking tab the cell was clicked in. * Update CHANGELOG.md * Emote Popup Improvements (#1895) * Put exact matching emotes first * Close GenericListView on Escape press * smol fix * fixed emote input when not in the first char * fixes #1902 * closes #1904 Co-authored-by: Leon Richardt Co-authored-by: Daniel <24928223+dnsge@users.noreply.github.com> --- src/singletons/Settings.hpp | 2 + src/widgets/listview/GenericListView.cpp | 54 +++++++++++++---------- src/widgets/listview/GenericListView.hpp | 4 ++ src/widgets/settingspages/GeneralPage.cpp | 2 + src/widgets/splits/EmoteInputPopup.cpp | 1 + src/widgets/splits/SplitInput.cpp | 4 +- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 3e84fba56..a48c34899 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -143,6 +143,8 @@ public: "/behaviour/autocompletion/prefixOnlyCompletion", true}; BoolSetting userCompletionOnlyWithAt = { "/behaviour/autocompletion/userCompletionOnlyWithAt", false}; + BoolSetting emoteCompletionWithColon = { + "/behaviour/autocompletion/emoteCompletionWithColon", true}; FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0}; EnumSetting pauseChatModifier = { diff --git a/src/widgets/listview/GenericListView.cpp b/src/widgets/listview/GenericListView.cpp index 8eb4312d0..ca910387e 100644 --- a/src/widgets/listview/GenericListView.cpp +++ b/src/widgets/listview/GenericListView.cpp @@ -33,6 +33,11 @@ void GenericListView::setModel(GenericListModel *model) QListView::setModel(model); } +void GenericListView::setInvokeActionOnTab(bool value) +{ + this->invokeActionOnTab_ = value; +} + bool GenericListView::eventFilter(QObject * /*watched*/, QEvent *event) { if (!this->model_) @@ -47,30 +52,10 @@ bool GenericListView::eventFilter(QObject * /*watched*/, QEvent *event) const int curRow = curIdx.row(); const int count = this->model_->rowCount(curIdx); - if (key == Qt::Key_Down || key == Qt::Key_Tab) - { - if (count <= 0) - return true; - - const int newRow = (curRow + 1) % count; - - this->setCurrentIndex(curIdx.siblingAtRow(newRow)); - return true; - } - else if (key == Qt::Key_Up || key == Qt::Key_Backtab) - { - if (count <= 0) - return true; - - int newRow = curRow - 1; - if (newRow < 0) - newRow += count; - - this->setCurrentIndex(curIdx.siblingAtRow(newRow)); - return true; - } - else if (key == Qt::Key_Enter || key == Qt::Key_Return) + if (key == Qt::Key_Enter || key == Qt::Key_Return || + (key == Qt::Key_Tab && this->invokeActionOnTab_)) { + // keep this before the other tab handler if (count <= 0) return true; @@ -82,6 +67,29 @@ bool GenericListView::eventFilter(QObject * /*watched*/, QEvent *event) emit this->closeRequested(); return true; } + else if (key == Qt::Key_Down || key == Qt::Key_Tab) + { + if (count <= 0) + return true; + + const int newRow = (curRow + 1) % count; + + this->setCurrentIndex(curIdx.siblingAtRow(newRow)); + return true; + } + else if (key == Qt::Key_Up || + (!this->invokeActionOnTab_ && key == Qt::Key_Backtab)) + { + if (count <= 0) + return true; + + int newRow = curRow - 1; + if (newRow < 0) + newRow += count; + + this->setCurrentIndex(curIdx.siblingAtRow(newRow)); + return true; + } else if (key == Qt::Key_Escape) { emit this->closeRequested(); diff --git a/src/widgets/listview/GenericListView.hpp b/src/widgets/listview/GenericListView.hpp index 3baebf783..2faee1913 100644 --- a/src/widgets/listview/GenericListView.hpp +++ b/src/widgets/listview/GenericListView.hpp @@ -18,6 +18,7 @@ public: virtual void setModel(QAbstractItemModel *model) override; void setModel(GenericListModel *); + void setInvokeActionOnTab(bool); bool eventFilter(QObject *watched, QEvent *event) override; GenericListModel *model_{}; @@ -27,6 +28,9 @@ public: signals: void closeRequested(); + +private: + bool invokeActionOnTab_{}; }; } // namespace chatterino diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 9f9daf14e..9aa7d2025 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -474,6 +474,8 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox("Animate", s.animateEmotes); layout.addCheckbox("Animate only when Chatterino is focused", s.animationsWhenFocused); + layout.addCheckbox("Enable emote auto-completion by typing :", + s.emoteCompletionWithColon); layout.addDropdown( "Size", {"0.5x", "0.75x", "Default", "1.25x", "1.5x", "2x"}, s.emoteScale, diff --git a/src/widgets/splits/EmoteInputPopup.cpp b/src/widgets/splits/EmoteInputPopup.cpp index dd26d1f61..bd3d26ea1 100644 --- a/src/widgets/splits/EmoteInputPopup.cpp +++ b/src/widgets/splits/EmoteInputPopup.cpp @@ -62,6 +62,7 @@ void EmoteInputPopup::initLayout() auto listView = creator.emplace().assign(&this->ui_.listView); + listView->setInvokeActionOnTab(true); listView->setModel(&this->model_); QObject::connect(listView.getElement(), &GenericListView::closeRequested, diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 4be21ef96..26ed484b7 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -459,9 +459,11 @@ void SplitInput::onCursorPositionChanged() void SplitInput::updateColonMenu() { - if (!dynamic_cast(this->split_->getChannel().get())) + if (!getSettings()->emoteCompletionWithColon || + !dynamic_cast(this->split_->getChannel().get())) { this->hideColonMenu(); + return; } // check if in :