Skip to content

Commit

Permalink
Allow the user to pick between old and new strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
Mm2PL committed Nov 27, 2023
1 parent 152d564 commit 7829d2e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ set(SOURCE_FILES
controllers/completion/sources/UnifiedSource.hpp
controllers/completion/sources/UserSource.cpp
controllers/completion/sources/UserSource.hpp
controllers/completion/strategies/ClassicEmoteStrategy.hpp
controllers/completion/strategies/ClassicEmoteStrategy.cpp
controllers/completion/strategies/ClassicEmoteStrategy.hpp
controllers/completion/strategies/ClassicUserStrategy.cpp
controllers/completion/strategies/ClassicUserStrategy.hpp
Expand Down
11 changes: 10 additions & 1 deletion src/controllers/completion/TabCompletionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "controllers/completion/sources/EmoteSource.hpp"
#include "controllers/completion/sources/UnifiedSource.hpp"
#include "controllers/completion/sources/UserSource.hpp"
#include "controllers/completion/strategies/ClassicEmoteStrategy.hpp"
#include "controllers/completion/strategies/ClassicUserStrategy.hpp"
#include "controllers/completion/strategies/CommandStrategy.hpp"
#include "controllers/completion/strategies/SmartEmoteStrategy.hpp"
Expand Down Expand Up @@ -123,8 +124,16 @@ std::unique_ptr<completion::Source> TabCompletionModel::buildSource(

std::unique_ptr<completion::Source> TabCompletionModel::buildEmoteSource() const
{
if (getSettings()->useSmartEmoteCompletion)
{
return std::make_unique<completion::EmoteSource>(
&this->channel_,
std::make_unique<completion::SmartTabEmoteStrategy>());
}

return std::make_unique<completion::EmoteSource>(
&this->channel_, std::make_unique<completion::SmartTabEmoteStrategy>());
&this->channel_,
std::make_unique<completion::ClassicTabEmoteStrategy>());
}

std::unique_ptr<completion::Source> TabCompletionModel::buildUserSource(
Expand Down
2 changes: 2 additions & 0 deletions src/singletons/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ class Settings
"/behaviour/autocompletion/emoteCompletionWithColon", true};
BoolSetting showUsernameCompletionMenu = {
"/behaviour/autocompletion/showUsernameCompletionMenu", true};
BoolSetting useSmartEmoteCompletion = {
"/behaviour/autocompletion/useSmartEmoteCompletion", false};

FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0};
EnumSetting<Qt::KeyboardModifier> pauseChatModifier = {
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/settingspages/GeneralPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"cvMask and 7TV's RainTime, will appear as normal emotes.");
layout.addCheckbox("Enable emote auto-completion by typing :",
s.emoteCompletionWithColon);
layout.addCheckbox("Use smarter tab completion.",
s.useSmartEmoteCompletion);
layout.addDropdown<float>(
"Size", {"0.5x", "0.75x", "Default", "1.25x", "1.5x", "2x"},
s.emoteScale,
Expand Down
11 changes: 10 additions & 1 deletion src/widgets/splits/InputCompletionPopup.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "widgets/splits/InputCompletionPopup.hpp"

#include "controllers/completion/sources/UserSource.hpp"
#include "controllers/completion/strategies/ClassicEmoteStrategy.hpp"
#include "controllers/completion/strategies/ClassicUserStrategy.hpp"
#include "controllers/completion/strategies/SmartEmoteStrategy.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/splits/InputCompletionItem.hpp"
Expand Down Expand Up @@ -60,9 +62,16 @@ std::unique_ptr<completion::Source> InputCompletionPopup::getSource() const
switch (*this->currentKind_)
{
case CompletionKind::Emote:
if (getSettings()->useSmartEmoteCompletion)
{
return std::make_unique<completion::EmoteSource>(
this->currentChannel_.get(),
std::make_unique<completion::SmartEmoteStrategy>(),
this->callback_);
}
return std::make_unique<completion::EmoteSource>(
this->currentChannel_.get(),
std::make_unique<completion::SmartEmoteStrategy>(),
std::make_unique<completion::ClassicEmoteStrategy>(),
this->callback_);
case CompletionKind::User:
return std::make_unique<completion::UserSource>(
Expand Down

0 comments on commit 7829d2e

Please sign in to comment.