mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Implement simpler fix for emote completion bug
This commit implements a simpler fix for the problem described in #1209. The setting's signal is connected to a reset of `completionInProgress_` so that the completion model is updated on the next word already. This commit also removes the older approach tackling this issue.
This commit is contained in:
parent
23a5f0bfb2
commit
f2b2e3142f
|
@ -16,6 +16,11 @@ ResizingTextEdit::ResizingTextEdit()
|
||||||
QObject::connect(this, &QTextEdit::textChanged, this,
|
QObject::connect(this, &QTextEdit::textChanged, this,
|
||||||
&QWidget::updateGeometry);
|
&QWidget::updateGeometry);
|
||||||
|
|
||||||
|
// Whenever the setting for emote completion changes, force a
|
||||||
|
// refresh on the completion model the next time "Tab" is pressed
|
||||||
|
getSettings()->prefixOnlyEmoteCompletion.connect(
|
||||||
|
[this] { this->completionInProgress_ = false; });
|
||||||
|
|
||||||
this->setFocusPolicy(Qt::ClickFocus);
|
this->setFocusPolicy(Qt::ClickFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,11 +265,6 @@ void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResizingTextEdit::resetCompletionInProgress()
|
|
||||||
{
|
|
||||||
this->completionInProgress_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QCompleter *ResizingTextEdit::getCompleter() const
|
QCompleter *ResizingTextEdit::getCompleter() const
|
||||||
{
|
{
|
||||||
return this->completer_;
|
return this->completer_;
|
||||||
|
|
|
@ -20,8 +20,6 @@ public:
|
||||||
pajlada::Signals::NoArgSignal focused;
|
pajlada::Signals::NoArgSignal focused;
|
||||||
pajlada::Signals::NoArgSignal focusLost;
|
pajlada::Signals::NoArgSignal focusLost;
|
||||||
|
|
||||||
void resetCompletionInProgress();
|
|
||||||
|
|
||||||
void setCompleter(QCompleter *c);
|
void setCompleter(QCompleter *c);
|
||||||
QCompleter *getCompleter() const;
|
QCompleter *getCompleter() const;
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,10 @@
|
||||||
#include "singletons/Fonts.hpp"
|
#include "singletons/Fonts.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/FuzzyConvert.hpp"
|
#include "util/FuzzyConvert.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
#include "widgets/Notebook.hpp"
|
|
||||||
#include "widgets/Window.hpp"
|
|
||||||
#include "widgets/helper/Line.hpp"
|
#include "widgets/helper/Line.hpp"
|
||||||
#include "widgets/splits/Split.hpp"
|
|
||||||
|
|
||||||
#define CHROME_EXTENSION_LINK \
|
#define CHROME_EXTENSION_LINK \
|
||||||
"https://chrome.google.com/webstore/detail/chatterino-native-host/" \
|
"https://chrome.google.com/webstore/detail/chatterino-native-host/" \
|
||||||
|
@ -286,22 +284,10 @@ void GeneralPage::initLayout(SettingsLayout &layout)
|
||||||
[](int index) { return index; }, [](auto args) { return args.index; },
|
[](int index) { return index; }, [](auto args) { return args.index; },
|
||||||
false);
|
false);
|
||||||
|
|
||||||
auto emoteCompletionCheckbox = layout.addCheckbox(
|
layout.addCheckbox(
|
||||||
"Only search for emote autocompletion at the start of emote names",
|
"Only search for emote autocompletion at the start of emote names",
|
||||||
s.prefixOnlyEmoteCompletion);
|
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.addSpacing(16);
|
||||||
layout.addSeperator();
|
layout.addSeperator();
|
||||||
|
|
||||||
|
|
|
@ -669,23 +669,6 @@ void Split::reloadChannelAndSubscriberEmotes()
|
||||||
twitchChannel->refreshChannelEmotes();
|
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>
|
template <typename Iter, typename RandomGenerator>
|
||||||
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
static Iter select_randomly(Iter start, Iter end, RandomGenerator &g)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ChannelView;
|
class ChannelView;
|
||||||
|
@ -129,7 +131,6 @@ public slots:
|
||||||
void showViewerList();
|
void showViewerList();
|
||||||
void openSubPage();
|
void openSubPage();
|
||||||
void reloadChannelAndSubscriberEmotes();
|
void reloadChannelAndSubscriberEmotes();
|
||||||
void updateEmoteCompletion();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue