added setting for pause on hover length

This commit is contained in:
fourtf 2019-09-16 11:36:19 +02:00
parent 602a66f5bc
commit 3a9f9fa17b
3 changed files with 28 additions and 4 deletions

View file

@ -102,7 +102,7 @@ public:
BoolSetting prefixOnlyEmoteCompletion = { BoolSetting prefixOnlyEmoteCompletion = {
"/behaviour/autocompletion/prefixOnlyCompletion", true}; "/behaviour/autocompletion/prefixOnlyCompletion", true};
BoolSetting pauseChatOnHover = {"/behaviour/pauseChatHover", false}; FloatSetting pauseOnHoverDuration = {"/behaviour/pauseOnHoverDuration", 0};
EnumSetting<Qt::KeyboardModifier> pauseChatModifier = { EnumSetting<Qt::KeyboardModifier> pauseChatModifier = {
"/behaviour/pauseChatModifier", Qt::KeyboardModifier::NoModifier}; "/behaviour/pauseChatModifier", Qt::KeyboardModifier::NoModifier};
BoolSetting autorun = {"/behaviour/autorun", false}; BoolSetting autorun = {"/behaviour/autorun", false};

View file

@ -1038,9 +1038,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
} }
/// Pause on hover /// Pause on hover
if (getSettings()->pauseChatOnHover.getValue()) if (float pauseTime = getSettings()->pauseOnHoverDuration;
pauseTime > 0.001f)
{ {
this->pause(PauseReason::Mouse, 500); this->pause(PauseReason::Mouse, uint(pauseTime * 1000.f));
}
else if (pauseTime < -0.5f)
{
this->pause(PauseReason::Mouse);
} }
auto tooltipWidget = TooltipWidget::getInstance(); auto tooltipWidget = TooltipWidget::getInstance();

View file

@ -319,7 +319,26 @@ void GeneralPage::initLayout(SettingsLayout &layout)
layout.addCheckbox("Smooth scrolling", s.enableSmoothScrolling); layout.addCheckbox("Smooth scrolling", s.enableSmoothScrolling);
layout.addCheckbox("Smooth scrolling on new messages", layout.addCheckbox("Smooth scrolling on new messages",
s.enableSmoothScrollingNewMessages); s.enableSmoothScrollingNewMessages);
layout.addCheckbox("Pause on hover", s.pauseChatOnHover); layout.addDropdown<float>(
"Pause on hover", {"Disabled", "0.5s", "1s", "2s", "5s", "Indefinite"},
s.pauseOnHoverDuration,
[](auto val) {
if (val < -0.5f)
return QString("Indefinite");
else if (val < 0.001f)
return QString("Disabled");
else
return QString::number(val) + "s";
},
[](auto args) {
if (args.index == 0)
return 0.0f;
else if (args.value == "Indefinite")
return -1.0f;
else
return fuzzyToFloat(args.value,
std::numeric_limits<float>::infinity());
});
addKeyboardModifierSetting(layout, "Pause while holding a key", addKeyboardModifierSetting(layout, "Pause while holding a key",
s.pauseChatModifier); s.pauseChatModifier);
layout.addCheckbox("Show input when it's empty", s.showEmptyInput); layout.addCheckbox("Show input when it's empty", s.showEmptyInput);