-
-
Notifications
You must be signed in to change notification settings - Fork 470
/
Copy pathGeneralPage.cpp
1328 lines (1241 loc) · 50.7 KB
/
GeneralPage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "widgets/settingspages/GeneralPage.hpp"
#include "Application.hpp"
#include "common/Literals.hpp"
#include "common/QLogging.hpp"
#include "common/Version.hpp"
#include "controllers/hotkeys/HotkeyCategory.hpp"
#include "controllers/hotkeys/HotkeyController.hpp"
#include "controllers/sound/ISoundController.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/CrashHandler.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/NativeMessaging.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/FuzzyConvert.hpp"
#include "util/Helpers.hpp"
#include "util/IncognitoBrowser.hpp"
#include "widgets/BaseWindow.hpp"
#include "widgets/settingspages/GeneralPageView.hpp"
#include "widgets/settingspages/SettingWidget.hpp"
#include <magic_enum/magic_enum.hpp>
#include <QDesktopServices>
#include <QFileDialog>
#include <QFontDialog>
#include <QLabel>
#include <QScrollArea>
namespace {
using namespace chatterino;
using namespace literals;
const QString CHROME_EXTENSION_LINK =
u"https://chrome.google.com/webstore/detail/chatterino-native-host/glknmaideaikkmemifbfkhnomoknepka"_s;
const QString FIREFOX_EXTENSION_LINK =
u"https://addons.mozilla.org/en-US/firefox/addon/chatterino-native-host/"_s;
#ifdef Q_OS_WIN
const QString META_KEY = u"Windows"_s;
#else
const QString META_KEY = u"Meta"_s;
#endif
void addKeyboardModifierSetting(GeneralPageView &layout, const QString &title,
EnumSetting<Qt::KeyboardModifier> &setting)
{
layout.addDropdown<std::underlying_type<Qt::KeyboardModifier>::type>(
title, {"None", "Shift", "Control", "Alt", META_KEY}, setting,
[](int index) {
switch (index)
{
case Qt::ShiftModifier:
return 1;
case Qt::ControlModifier:
return 2;
case Qt::AltModifier:
return 3;
case Qt::MetaModifier:
return 4;
default:
return 0;
}
},
[](DropdownArgs args) {
switch (args.index)
{
case 1:
return Qt::ShiftModifier;
case 2:
return Qt::ControlModifier;
case 3:
return Qt::AltModifier;
case 4:
return Qt::MetaModifier;
default:
return Qt::NoModifier;
}
},
false);
}
} // namespace
namespace chatterino {
GeneralPage::GeneralPage()
{
auto *y = new QVBoxLayout;
auto *x = new QHBoxLayout;
auto *view = new GeneralPageView;
this->view_ = view;
x->addWidget(view);
auto *z = new QFrame;
z->setLayout(x);
y->addWidget(z);
this->setLayout(y);
this->initLayout(*view);
this->initExtra();
}
bool GeneralPage::filterElements(const QString &query)
{
if (this->view_)
{
return this->view_->filterElements(query) || query.isEmpty();
}
else
{
return false;
}
}
void GeneralPage::initLayout(GeneralPageView &layout)
{
auto &s = *getSettings();
layout.addTitle("Interface");
{
auto *themes = getApp()->getThemes();
auto available = themes->availableThemes();
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
available.emplace_back("System", "System");
#endif
auto addThemeDropdown = [&](auto name, auto &setting,
const auto &options,
const QString &tooltip = {}) {
return layout.addDropdown<QString>(
name, options, setting,
[](const auto *combo, const auto &themeKey) {
return combo->findData(themeKey, Qt::UserRole);
},
[](const auto &args) {
return args.combobox->itemData(args.index, Qt::UserRole)
.toString();
},
tooltip, Theme::fallbackTheme.name);
};
addThemeDropdown("Theme", themes->themeName, available);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
auto *darkDropdown = addThemeDropdown(
"Dark system theme", themes->darkSystemThemeName,
themes->availableThemes(),
"This theme is selected if your system is in a dark theme and you "
"enabled the adaptive 'System' theme.");
auto *lightDropdown = addThemeDropdown(
"Light system theme", themes->lightSystemThemeName,
themes->availableThemes(),
"This theme is selected if your system is in a light theme and you "
"enabled the adaptive 'System' theme.");
auto isSystem = [](const auto &s) {
return s == "System";
};
layout.enableIf(darkDropdown, themes->themeName, isSystem);
layout.enableIf(lightDropdown, themes->themeName, isSystem);
#endif
}
layout.addDropdown<QString>(
"Font", {"Segoe UI", "Arial", "Choose..."}, s.chatFontFamily,
[](auto val) {
return val;
},
[this](auto args) {
return this->getFont(args);
},
true, "", true);
layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
s.chatFontSize,
[](auto val) {
return QString::number(val) + "pt";
},
[](auto args) {
return fuzzyToInt(args.value, 10);
});
layout.addDropdown<float>(
"Zoom",
{"0.5x", "0.6x", "0.7x", "0.8x", "0.9x", "Default", "1.2x", "1.4x",
"1.6x", "1.8x", "2x", "2.33x", "2.66x", "3x", "3.5x", "4x"},
s.uiScale,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
ComboBox *tabDirectionDropdown =
layout.addDropdown<std::underlying_type<NotebookTabLocation>::type>(
"Tab layout", {"Top", "Left", "Right", "Bottom"}, s.tabDirection,
[](auto val) {
switch (val)
{
case NotebookTabLocation::Top:
return "Top";
case NotebookTabLocation::Left:
return "Left";
case NotebookTabLocation::Right:
return "Right";
case NotebookTabLocation::Bottom:
return "Bottom";
}
return "";
},
[](auto args) {
if (args.value == "Bottom")
{
return NotebookTabLocation::Bottom;
}
else if (args.value == "Left")
{
return NotebookTabLocation::Left;
}
else if (args.value == "Right")
{
return NotebookTabLocation::Right;
}
else
{
// default to top
return NotebookTabLocation::Top;
}
},
false);
tabDirectionDropdown->setMinimumWidth(
tabDirectionDropdown->minimumSizeHint().width());
layout.addDropdown<std::underlying_type<NotebookTabVisibility>::type>(
"Tab visibility", {"All tabs", "Only live tabs"}, s.tabVisibility,
[](auto val) {
switch (val)
{
case NotebookTabVisibility::LiveOnly:
return "Only live tabs";
case NotebookTabVisibility::AllTabs:
default:
return "All tabs";
}
},
[](auto args) {
if (args.value == "Only live tabs")
{
return NotebookTabVisibility::LiveOnly;
}
else
{
return NotebookTabVisibility::AllTabs;
}
},
false, "Choose which tabs are visible in the notebook");
SettingWidget::inverseCheckbox("Show message reply context",
s.hideReplyContext)
->setTooltip(
"This setting will only affect how messages are shown. You can "
"reply to a message regardless of this setting.")
->addTo(layout);
layout.addCheckbox("Show message reply button", s.showReplyButton, false,
"Show a reply button next to every chat message");
auto removeTabSeq = getApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "removeTab");
QString removeTabShortcut = "an assigned hotkey (Window -> remove tab)";
if (!removeTabSeq.isEmpty())
{
removeTabShortcut =
removeTabSeq.toString(QKeySequence::SequenceFormat::NativeText);
}
layout.addCheckbox(
"Show tab close button", s.showTabCloseButton, false,
"When disabled, the x to close a tab will be hidden.\nTabs can still "
"be closed by right-clicking or pressing " +
removeTabShortcut + ".");
layout.addCheckbox("Always on top", s.windowTopMost, false,
"Always keep Chatterino as the top window.");
#ifdef USEWINSDK
layout.addCheckbox("Start with Windows", s.autorun, false,
"Start Chatterino when your computer starts.");
#endif
if (!BaseWindow::supportsCustomWindowFrame())
{
auto settingsSeq = getApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "openSettings");
QString shortcut = " (no key bound to open them otherwise)";
// TODO: maybe prevent the user from locking themselves out of the settings?
if (!settingsSeq.isEmpty())
{
shortcut = QStringLiteral(" (%1 to show)")
.arg(settingsSeq.toString(
QKeySequence::SequenceFormat::NativeText));
}
layout.addCheckbox("Show preferences button" + shortcut,
s.hidePreferencesButton, true);
layout.addCheckbox("Show user button", s.hideUserButton, true);
}
layout.addCheckbox("Mark tabs with live channels", s.showTabLive, false,
"Shows a red dot in the top right corner of a tab to "
"indicate one of the channels in the tab is live.");
layout.addTitle("Chat");
layout.addDropdown<float>(
"Pause on mouse 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",
s.pauseChatModifier);
layout.addDropdown<float>(
"Mousewheel scroll speed", {"0.5x", "0.75x", "Default", "1.5x", "2x"},
s.mouseScrollMultiplier,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addCheckbox("Smooth scrolling", s.enableSmoothScrolling);
layout.addCheckbox("Smooth scrolling on new messages",
s.enableSmoothScrollingNewMessages);
layout.addCheckbox("Show input when it's empty", s.showEmptyInput, false,
"Show the chat box even when there is nothing typed.");
layout.addCheckbox(
"Show message length while typing", s.showMessageLength, false,
"Show how many characters are currently in your input box.\n"
"Useful for making sure you don't go past the 500 character Twitch "
"limit, or a lower limit enforced by a moderation bot");
layout.addCheckbox(
"Allow sending duplicate messages", s.allowDuplicateMessages, false,
"Allow a single message to be repeatedly sent without any changes.");
layout.addDropdown<std::underlying_type<MessageOverflow>::type>(
"Message overflow", {"Highlight", "Prevent", "Allow"},
s.messageOverflow,
[](auto index) {
return index;
},
[](auto args) {
return static_cast<MessageOverflow>(args.index);
},
false,
"Specify how Chatterino will handle messages that exceed Twitch "
"message limits");
layout.addDropdown<std::underlying_type<UsernameRightClickBehavior>::type>(
"Username right-click behavior",
{
"Reply",
"Mention",
"Ignore",
},
s.usernameRightClickBehavior,
[](auto index) {
return index;
},
[](auto args) {
return static_cast<UsernameRightClickBehavior>(args.index);
},
false,
"Specify how Chatterino will handle right-clicking a username in "
"chat when not holding the modifier.");
layout.addDropdown<std::underlying_type<UsernameRightClickBehavior>::type>(
"Username right-click with modifier behavior",
{
"Reply",
"Mention",
"Ignore",
},
s.usernameRightClickModifierBehavior,
[](auto index) {
return index;
},
[](auto args) {
return static_cast<UsernameRightClickBehavior>(args.index);
},
false,
"Specify how Chatterino will handle right-clicking a username in "
"chat when holding down the modifier.");
layout.addDropdown<std::underlying_type<Qt::KeyboardModifier>::type>(
"Modifier for alternate right-click action",
{"Shift", "Control", "Alt", META_KEY}, s.usernameRightClickModifier,
[](int index) {
switch (index)
{
case Qt::ShiftModifier:
return 0;
case Qt::ControlModifier:
return 1;
case Qt::AltModifier:
return 2;
case Qt::MetaModifier:
return 3;
default:
return 0;
}
},
[](DropdownArgs args) {
switch (args.index)
{
case 0:
return Qt::ShiftModifier;
case 1:
return Qt::ControlModifier;
case 2:
return Qt::AltModifier;
case 3:
return Qt::MetaModifier;
default:
return Qt::NoModifier;
}
},
false);
layout.addCheckbox(
"Hide scrollbar thumb", s.hideScrollbarThumb, false,
"Hiding the scrollbar thumb (the handle you can drag) will disable "
"all mouse interaction in the scrollbar.");
layout.addCheckbox("Hide scrollbar highlights", s.hideScrollbarHighlights,
false);
layout.addTitle("Messages");
layout.addCheckbox(
"Separate with lines", s.separateMessages, false,
"Adds a line between each message to help better tell them apart.");
layout.addCheckbox("Alternate background color", s.alternateMessages, false,
"Slightly change the background behind every other "
"message to help better tell them apart.");
layout.addCheckbox("Hide deleted messages", s.hideModerated, false,
"When enabled, messages deleted by moderators will "
"be hidden.");
layout.addDropdown<QString>(
"Timestamp format",
{"Disable", "h:mm", "hh:mm", "h:mm a", "hh:mm a", "h:mm:ss", "hh:mm:ss",
"h:mm:ss a", "hh:mm:ss a", "h:mm:ss.zzz", "h:mm:ss.zzz a",
"hh:mm:ss.zzz", "hh:mm:ss.zzz a"},
s.timestampFormat,
[](auto val) {
return getSettings()->showTimestamps.getValue()
? val
: QString("Disable");
},
[](auto args) {
getSettings()->showTimestamps.setValue(args.index != 0);
return args.index == 0 ? getSettings()->timestampFormat.getValue()
: args.value;
},
true, "a = am/pm, zzz = milliseconds");
layout.addDropdown<int>(
"Limit message height",
{"Never", "2 lines", "3 lines", "4 lines", "5 lines"},
s.collpseMessagesMinLines,
[](auto val) {
return val ? QString::number(val) + " lines" : QString("Never");
},
[](auto args) {
return fuzzyToInt(args.value, 0);
});
layout.addSeperator();
layout.addCheckbox("Draw a line below the most recent message before "
"switching applications.",
s.showLastMessageIndicator, false,
"Adds an underline below the most recent message "
"sent before you tabbed out of Chatterino.");
layout.addDropdown<std::underlying_type<Qt::BrushStyle>::type>(
"Line style", {"Dotted", "Solid"}, s.lastMessagePattern,
[](int value) {
switch (value)
{
case Qt::VerPattern:
return 0;
case Qt::SolidPattern:
default:
return 1;
}
},
[](DropdownArgs args) {
switch (args.index)
{
case 0:
return Qt::VerPattern;
case 1:
default:
return Qt::SolidPattern;
}
},
false);
layout.addColorButton("Line color",
QColor(getSettings()->lastMessageColor.getValue()),
getSettings()->lastMessageColor);
layout.addTitle("Emotes");
layout.addCheckbox("Enable", s.enableEmoteImages);
layout.addCheckbox("Animate", s.animateEmotes);
layout.addCheckbox("Animate only when Chatterino is focused",
s.animationsWhenFocused);
layout.addCheckbox(
"Enable zero-width emotes", s.enableZeroWidthEmotes, false,
"When disabled, emotes that overlap other emotes, such as BTTV's "
"cvMask and 7TV's RainTime, will appear as normal emotes.");
layout.addCheckbox("Enable emote auto-completion by typing :",
s.emoteCompletionWithColon);
layout.addCheckbox("Use experimental smarter emote completion.",
s.useSmartEmoteCompletion);
layout.addDropdown<float>(
"Size", {"0.5x", "0.75x", "Default", "1.25x", "1.5x", "2x"},
s.emoteScale,
[](auto val) {
if (val == 1)
{
return QString("Default");
}
else
{
return QString::number(val) + "x";
}
},
[](auto args) {
return fuzzyToFloat(args.value, 1.f);
});
layout.addCheckbox("Remove spaces between emotes",
s.removeSpacesBetweenEmotes, false,
"When enabled, adjacent emotes will no longer have an "
"added space seperating them.");
SettingWidget::checkbox("Show unlisted 7TV emotes",
s.showUnlistedSevenTVEmotes)
->addKeywords({"seventv"})
->addTo(layout);
// TODO: Add a tooltip explaining what an unlisted 7TV emote is
// but wait until https://github.com/Chatterino/wiki/pull/255 is resolved,
// as an official description from 7TV devs is best
s.showUnlistedSevenTVEmotes.connect(
[]() {
getApp()->getTwitch()->forEachChannelAndSpecialChannels(
[](const auto &c) {
if (c->isTwitchChannel())
{
auto *channel = dynamic_cast<TwitchChannel *>(c.get());
if (channel != nullptr)
{
channel->refreshSevenTVChannelEmotes(false);
}
}
});
},
false);
layout.addDropdown<std::underlying_type<ThumbnailPreviewMode>::type>(
"Show emote & badge thumbnail on hover",
{
"Don't show",
"Always show",
"Hold shift",
},
s.emotesTooltipPreview,
[](auto val) {
switch (val)
{
case ThumbnailPreviewMode::DontShow:
return "Don't show";
case ThumbnailPreviewMode::AlwaysShow:
return "Always show";
case ThumbnailPreviewMode::ShowOnShift:
return "Hold shift";
}
return "";
},
[](auto args) {
return args.index;
},
false);
layout.addDropdown("Emoji style",
{
"Twitter",
"Facebook",
"Apple",
"Google",
},
s.emojiSet);
SettingWidget::checkbox("Show BetterTTV global emotes",
s.enableBTTVGlobalEmotes)
->addKeywords({"bttv"})
->addTo(layout);
SettingWidget::checkbox("Show BetterTTV channel emotes",
s.enableBTTVChannelEmotes)
->addKeywords({"bttv"})
->addTo(layout);
SettingWidget::checkbox(
"Enable BetterTTV live emote updates (requires restart)",
s.enableBTTVLiveUpdates)
->addKeywords({"bttv"})
->addTo(layout);
SettingWidget::checkbox("Show FrankerFaceZ global emotes",
s.enableFFZGlobalEmotes)
->addKeywords({"ffz"})
->addTo(layout);
SettingWidget::checkbox("Show FrankerFaceZ channel emotes",
s.enableFFZChannelEmotes)
->addKeywords({"ffz"})
->addTo(layout);
SettingWidget::checkbox("Show 7TV global emotes",
s.enableSevenTVGlobalEmotes)
->addKeywords({"seventv"})
->addTo(layout);
SettingWidget::checkbox("Show 7TV channel emotes",
s.enableSevenTVChannelEmotes)
->addKeywords({"seventv"})
->addTo(layout);
SettingWidget::checkbox("Enable 7TV live emote updates (requires restart)",
s.enableSevenTVEventAPI)
->addKeywords({"seventv"})
->addTo(layout);
SettingWidget::checkbox("Send activity to 7TV", s.sendSevenTVActivity)
->setTooltip("When enabled, Chatterino will signal an activity to 7TV "
"when you send a chat mesage. This is used for badges, "
"paints, and personal emotes. When disabled, no activity "
"is sent and others won't see your cosmetics.")
->addKeywords({"seventv"})
->addTo(layout);
layout.addTitle("Streamer Mode");
layout.addDescription(
"Chatterino can automatically change behavior if it detects that any "
"streaming software is running.\nSelect which things you want to "
"change while streaming");
ComboBox *dankDropdown =
layout.addDropdown<std::underlying_type<StreamerModeSetting>::type>(
"Enable Streamer Mode",
{"Disabled", "Enabled", "Automatic (Detect streaming software)"},
s.enableStreamerMode,
[](int value) {
return value;
},
[](DropdownArgs args) {
return static_cast<StreamerModeSetting>(args.index);
},
false);
dankDropdown->setMinimumWidth(dankDropdown->minimumSizeHint().width() + 30);
layout.addCheckbox("Hide usercard avatars",
s.streamerModeHideUsercardAvatars, false,
"Prevent potentially explicit avatars from showing.");
layout.addCheckbox("Hide link thumbnails", s.streamerModeHideLinkThumbnails,
false,
"Prevent potentially explicit thumbnails from showing "
"when hovering links.");
layout.addCheckbox(
"Hide viewer count and stream length while hovering over split header",
s.streamerModeHideViewerCountAndDuration);
layout.addCheckbox(
"Hide moderation actions", s.streamerModeHideModActions, false,
"Hide bans, timeouts, and automod messages from appearing in chat.");
layout.addCheckbox(
"Hide blocked terms", s.streamerModeHideBlockedTermText, false,
"Hide blocked terms from showing up in places like AutoMod messages. "
"This can be useful in case you have some blocked terms that you don't "
"want to show on stream.");
layout.addCheckbox("Mute mention sounds", s.streamerModeMuteMentions, false,
"Mute your ping sound from playing.");
layout.addCheckbox(
"Suppress Live Notifications", s.streamerModeSuppressLiveNotifications,
false, "Hide Live notification popups from appearing. (Windows Only)");
layout.addCheckbox("Suppress Inline Whispers",
s.streamerModeSuppressInlineWhispers, false,
"Hide whispers sent to you from appearing in chat.");
layout.addTitle("Link Previews");
layout.addDescription(
"Extra information like \"youtube video stats\" or title of webpages "
"can be loaded for all links if enabled. Optionally you can also show "
"thumbnails for emotes, videos and more. The information is pulled "
"from our servers. The Link Previews are loaded through <a "
"href=\"https://github.com/Chatterino/api\">an API</a> hosted by the "
"Chatterino developers. These are the API <a "
"href=\"https://braize.pajlada.com/chatterino/legal/"
"terms-of-service\">Terms of Services</a> and <a "
"href=\"https://braize.pajlada.com/chatterino/legal/"
"privacy-policy\">Privacy Policy</a>.");
layout.addCheckbox("Enable", s.linkInfoTooltip);
layout.addDropdown<int>(
"Also show thumbnails if available",
{"Off", "Small", "Medium", "Large"}, s.thumbnailSize,
[](auto val) {
if (val == 0)
{
return QString("Off");
}
else if (val == 100)
{
return QString("Small");
}
else if (val == 200)
{
return QString("Medium");
}
else if (val == 300)
{
return QString("Large");
}
else
{
return QString::number(val);
}
},
[](auto args) {
if (args.value == "Small")
{
return 100;
}
else if (args.value == "Medium")
{
return 200;
}
else if (args.value == "Large")
{
return 300;
}
return fuzzyToInt(args.value, 0);
});
layout.addDropdown<int>(
"Show thumbnails of streams", {"Off", "Small", "Medium", "Large"},
s.thumbnailSizeStream,
[](auto val) {
if (val == 0)
{
return QString("Off");
}
else if (val == 1)
{
return QString("Small");
}
else if (val == 2)
{
return QString("Medium");
}
else if (val == 3)
{
return QString("Large");
}
else
{
return QString::number(val);
}
},
[](auto args) {
if (args.value == "Small")
{
return 1;
}
else if (args.value == "Medium")
{
return 2;
}
else if (args.value == "Large")
{
return 3;
}
return fuzzyToInt(args.value, 0);
});
layout.addNavigationSpacing();
layout.addTitle("Beta");
if (Version::instance().isSupportedOS())
{
layout.addDescription(
"You can receive updates earlier by ticking the box below. Report "
"issues <a href='https://chatterino.com/link/issues'>here</a>.");
layout.addCheckbox("Receive beta updates", s.betaUpdates);
}
else
{
layout.addDescription(
"Your operating system is not officially supplied with builds. For "
"updates, please rebuild Chatterino from sources. Report "
"issues <a href='https://chatterino.com/link/issues'>here</a>.");
}
#ifdef Q_OS_WIN
layout.addTitle("Browser Integration");
layout.addDescription("The browser extension replaces the default "
"Twitch.tv chat with Chatterino.");
{
if (auto err = nmIpcError().get())
{
layout.addDescription(
"An error happened during initialization of the "
"browser extension: " +
*err);
}
}
layout.addDescription(formatRichNamedLink(
CHROME_EXTENSION_LINK,
"Download for Google Chrome and similar browsers."));
layout.addDescription(
formatRichNamedLink(FIREFOX_EXTENSION_LINK, "Download for Firefox"));
layout.addDescription("Chatterino only attaches to known browsers to avoid "
"attaching to other windows by accident.");
layout.addCheckbox(
"Attach to any browser (may cause issues)",
s.attachExtensionToAnyProcess, false,
"Attempt to force the Chatterino Browser Extension to work in certain "
"browsers that do not work automatically.\ne.g. Librewolf");
#endif
layout.addTitle("AppData & Cache");
layout.addSubtitle("Application Data");
layout.addDescription("All local files like settings and cache files are "
"store in this directory.");
layout.addButton("Open AppData directory", [] {
#ifdef Q_OS_DARWIN
QDesktopServices::openUrl("file://" +
getApp()->getPaths().rootAppDataDirectory);
#else
QDesktopServices::openUrl(getApp()->getPaths().rootAppDataDirectory);
#endif
});
layout.addSubtitle("Temporary files (Cache)");
layout.addDescription(
"Files that are used often (such as emotes) are saved to disk to "
"reduce bandwidth usage and to speed up loading.");
auto *cachePathLabel = layout.addDescription("placeholder :D");
getSettings()->cachePath.connect([cachePathLabel](const auto &,
auto) mutable {
QString newPath = getApp()->getPaths().cacheDirectory();
QString pathShortened = "Cache saved at <a href=\"file:///" + newPath +
"\"><span style=\"color: white;\">" +
shortenString(newPath, 50) + "</span></a>";
cachePathLabel->setText(pathShortened);
cachePathLabel->setToolTip(newPath);
});
// Choose and reset buttons
{
auto *box = new QHBoxLayout;
box->addWidget(layout.makeButton("Choose cache path", [this]() {
getSettings()->cachePath = QFileDialog::getExistingDirectory(this);
}));
box->addWidget(layout.makeButton("Reset", []() {
getSettings()->cachePath = "";
}));
box->addWidget(layout.makeButton("Clear Cache", [&layout]() {
auto reply = QMessageBox::question(
layout.window(), "Clear cache",
"Are you sure that you want to clear your cache? Emotes may "
"take longer to load next time Chatterino is started.",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes)
{
auto cacheDir = QDir(getApp()->getPaths().cacheDirectory());
cacheDir.removeRecursively();
cacheDir.mkdir(getApp()->getPaths().cacheDirectory());
}
}));
box->addStretch(1);
layout.addLayout(box);
}
layout.addTitle("Advanced");
layout.addSubtitle("Chat title");
layout.addDescription("In live channels show:");
layout.addCheckbox("Uptime", s.headerUptime, false,
"Show how long the channel has been live");
layout.addCheckbox("Viewer count", s.headerViewerCount, false,
"Show how many users are watching");
layout.addCheckbox("Category", s.headerGame, false,
"Show what Category the stream is listed under");
layout.addCheckbox("Title", s.headerStreamTitle, false,
"Show the stream title");
layout.addSubtitle("R9K");
auto toggleLocalr9kSeq = getApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "toggleLocalR9K");
QString toggleLocalr9kShortcut =
"an assigned hotkey (Window -> Toggle local R9K)";
if (!toggleLocalr9kSeq.isEmpty())
{
toggleLocalr9kShortcut = toggleLocalr9kSeq.toString(
QKeySequence::SequenceFormat::NativeText);
}
layout.addDescription(
"Hide similar messages to those previously seen. Toggle hidden "
"messages by pressing " +
toggleLocalr9kShortcut + ".");
layout.addCheckbox("Enable similarity checks", s.similarityEnabled);
//layout.addCheckbox("Gray out matches", s.colorSimilarDisabled);
layout.addCheckbox(
"Only if by the same user", s.hideSimilarBySameUser, false,
"When checked, messages that are very similar to each other can still "
"be shown as long as they're sent by different users.");
layout.addCheckbox("Hide my own messages", s.hideSimilarMyself);
layout.addCheckbox("Receive notification sounds from hidden messages",
s.shownSimilarTriggerHighlights);
s.hideSimilar.connect(
[]() {
getApp()->getWindows()->forceLayoutChannelViews();
},
false);
layout.addDropdown<float>(
"Similarity threshold", {"0.5", "0.75", "0.9"}, s.similarityPercentage,
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToFloat(args.value, 0.9F);
},
true,
"A value of 0.9 means the messages need to be 90% similar to be marked "
"as similar.");
layout.addDropdown<int>(
"Maximum delay between messages",
{"5s", "10s", "15s", "30s", "60s", "120s"}, s.hideSimilarMaxDelay,
[](auto val) {
return QString::number(val) + "s";
},
[](auto args) {
return fuzzyToInt(args.value, 5);
},
true,
"A value of 5s means if there's a 5s break between messages, we will "
"stop looking further through the messages for similarities.");
layout.addDropdown<int>(
"Amount of previous messages to check", {"1", "2", "3", "4", "5"},
s.hideSimilarMaxMessagesToCheck,
[](auto val) {
return QString::number(val);
},
[](auto args) {
return fuzzyToInt(args.value, 3);
},
true,
"How many messages in the history should be compared to a new one to "
"establish its similarity rating. Messages in the history will be "