mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fix emote completion bug
This commit fixes a bug that would occur when changing the completion mode from prefix-only to substring while mid-completion. In that case, the suggestion list was not updated until the next completion attempt. This is fixed by forcing a suggestion list refresh whenever the setting's checkbox is updated.
This commit is contained in:
parent
58d892a8c2
commit
be5318f275
|
@ -48,6 +48,7 @@ public:
|
|||
virtual int rowCount(const QModelIndex &) const override;
|
||||
|
||||
void refresh(const QString &prefix);
|
||||
void updateEmoteCompletionMethod();
|
||||
|
||||
private:
|
||||
TaggedString createUser(const QString &str);
|
||||
|
|
|
@ -260,6 +260,11 @@ void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
|
|||
}
|
||||
}
|
||||
|
||||
void ResizingTextEdit::resetCompletionInProgress()
|
||||
{
|
||||
this->completionInProgress_ = false;
|
||||
}
|
||||
|
||||
QCompleter *ResizingTextEdit::getCompleter() const
|
||||
{
|
||||
return this->completer_;
|
||||
|
|
|
@ -20,6 +20,8 @@ public:
|
|||
pajlada::Signals::NoArgSignal focused;
|
||||
pajlada::Signals::NoArgSignal focusLost;
|
||||
|
||||
void resetCompletionInProgress();
|
||||
|
||||
void setCompleter(QCompleter *c);
|
||||
QCompleter *getCompleter() const;
|
||||
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
#include "singletons/Fonts.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/FuzzyConvert.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
#include "widgets/helper/Line.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
|
||||
#define CHROME_EXTENSION_LINK \
|
||||
"https://chrome.google.com/webstore/detail/chatterino-native-host/" \
|
||||
|
@ -283,8 +285,22 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
|||
{"Don't show", "Always show", "Hold shift"}, s.emotesTooltipPreview,
|
||||
[](int index) { return index; }, [](auto args) { return args.index; },
|
||||
false);
|
||||
layout.addCheckbox("Only search for emote autocompletion at the start of emote names",
|
||||
s.prefixOnlyEmoteCompletion);
|
||||
|
||||
auto emoteCompletionCheckbox = layout.addCheckbox(
|
||||
"Only search for emote autocompletion at the start of emote names",
|
||||
s.prefixOnlyEmoteCompletion);
|
||||
|
||||
// Get the currently active split
|
||||
// XXX: Is there a better way to do this?
|
||||
auto selectedSplit =
|
||||
static_cast<SplitContainer *>(
|
||||
getApp()->windows->getMainWindow().getNotebook().getSelectedPage())
|
||||
->getBaseNode()
|
||||
->getSplit();
|
||||
|
||||
// Update emote completion mode when checkbox state is changed
|
||||
QObject::connect(emoteCompletionCheckbox, &QCheckBox::stateChanged,
|
||||
selectedSplit, &Split::updateEmoteCompletion);
|
||||
|
||||
layout.addSpacing(16);
|
||||
layout.addSeperator();
|
||||
|
|
|
@ -669,6 +669,23 @@ void Split::reloadChannelAndSubscriberEmotes()
|
|||
twitchChannel->refreshChannelEmotes();
|
||||
}
|
||||
|
||||
void Split::updateEmoteCompletion()
|
||||
{
|
||||
if (getSettings()->prefixOnlyEmoteCompletion)
|
||||
{
|
||||
this->input_->ui_.textEdit->getCompleter()->setFilterMode(
|
||||
Qt::MatchStartsWith);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->input_->ui_.textEdit->getCompleter()->setFilterMode(
|
||||
Qt::MatchContains);
|
||||
}
|
||||
|
||||
// Reset the completion status so a refresh will be triggered on next "Tab"
|
||||
this->input_->ui_.textEdit->resetCompletionInProgress();
|
||||
}
|
||||
|
||||
template <typename Iter, typename RandomGenerator>
|
||||
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
||||
{
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include <QFont>
|
||||
#include <QShortcut>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelView;
|
||||
|
@ -131,6 +129,7 @@ public slots:
|
|||
void showViewerList();
|
||||
void openSubPage();
|
||||
void reloadChannelAndSubscriberEmotes();
|
||||
void updateEmoteCompletion();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue