2019-09-08 22:27:57 +02:00
# include "GeneralPage.hpp"
# include <QFontDialog>
# include <QLabel>
# include <QScrollArea>
# include "Application.hpp"
2020-08-24 12:02:56 +02:00
# include "common/Version.hpp"
2019-09-08 22:27:57 +02:00
# include "singletons/Fonts.hpp"
2021-05-16 18:51:25 +02:00
# include "singletons/NativeMessaging.hpp"
2019-09-08 22:27:57 +02:00
# include "singletons/Paths.hpp"
# include "singletons/Theme.hpp"
# include "singletons/WindowManager.hpp"
# include "util/FuzzyConvert.hpp"
# include "util/Helpers.hpp"
# include "util/IncognitoBrowser.hpp"
2020-10-11 13:52:14 +02:00
# include "util/StreamerMode.hpp"
2019-09-08 22:27:57 +02:00
# include "widgets/BaseWindow.hpp"
# include "widgets/helper/Line.hpp"
2020-10-22 23:17:31 +02:00
# include "widgets/settingspages/GeneralPageView.hpp"
2019-09-08 22:27:57 +02:00
2021-05-08 15:57:00 +02:00
# include <QDesktopServices>
# include <QFileDialog>
2019-09-08 22:27:57 +02:00
# define CHROME_EXTENSION_LINK \
" https://chrome.google.com/webstore/detail/chatterino-native-host/ " \
" glknmaideaikkmemifbfkhnomoknepka "
# define FIREFOX_EXTENSION_LINK \
" https://addons.mozilla.org/en-US/firefox/addon/chatterino-native-host/ "
2019-09-16 10:40:02 +02:00
// define to highlight sections in editor
2019-09-08 22:27:57 +02:00
# define addTitle addTitle
2020-10-23 14:26:04 +02:00
# define addSubtitle addSubtitle
2019-09-08 22:27:57 +02:00
2019-09-16 10:40:02 +02:00
# ifdef Q_OS_WIN
# define META_KEY "Windows"
# else
# define META_KEY "Meta"
# endif
2019-09-08 22:27:57 +02:00
namespace chatterino {
2019-09-16 10:40:02 +02:00
namespace {
2020-10-22 23:17:31 +02:00
void addKeyboardModifierSetting ( GeneralPageView & layout ,
2019-09-16 10:40:02 +02:00
const QString & title ,
EnumSetting < Qt : : KeyboardModifier > & setting )
{
2019-09-16 21:08:14 +02:00
layout . addDropdown < std : : underlying_type < Qt : : KeyboardModifier > : : type > (
2019-09-16 10:40:02 +02:00
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
2019-09-08 22:27:57 +02:00
GeneralPage : : GeneralPage ( )
{
auto y = new QVBoxLayout ;
auto x = new QHBoxLayout ;
2020-10-22 23:17:31 +02:00
auto view = new GeneralPageView ;
this - > view_ = view ;
x - > addWidget ( view ) ;
2019-09-08 22:27:57 +02:00
auto z = new QFrame ;
z - > setLayout ( x ) ;
2020-10-22 23:17:31 +02:00
y - > addWidget ( z ) ;
2019-09-08 22:27:57 +02:00
this - > setLayout ( y ) ;
2020-10-22 23:17:31 +02:00
this - > initLayout ( * view ) ;
2019-09-08 22:27:57 +02:00
this - > initExtra ( ) ;
}
bool GeneralPage : : filterElements ( const QString & query )
{
2020-10-22 23:17:31 +02:00
if ( this - > view_ )
return this - > view_ - > filterElements ( query ) | | query . isEmpty ( ) ;
2019-09-08 22:27:57 +02:00
else
return false ;
}
2020-10-22 23:17:31 +02:00
void GeneralPage : : initLayout ( GeneralPageView & layout )
2019-09-08 22:27:57 +02:00
{
auto & s = * getSettings ( ) ;
layout . addTitle ( " Interface " ) ;
layout . addDropdown ( " Theme " , { " White " , " Light " , " Dark " , " Black " } ,
getApp ( ) - > themes - > themeName ) ;
layout . addDropdown < QString > (
" Font " , { " Segoe UI " , " Arial " , " Choose... " } ,
2020-11-08 12:02:19 +01:00
getApp ( ) - > fonts - > chatFontFamily ,
[ ] ( auto val ) {
return val ;
} ,
[ this ] ( auto args ) {
return this - > getFont ( args ) ;
} ) ;
2019-09-08 22:27:57 +02:00
layout . addDropdown < int > (
" Font size " , { " 9pt " , " 10pt " , " 12pt " , " 14pt " , " 16pt " , " 20pt " } ,
getApp ( ) - > fonts - > chatFontSize ,
2020-11-08 12:02:19 +01:00
[ ] ( auto val ) {
return QString : : number ( val ) + " pt " ;
} ,
[ ] ( auto args ) {
return fuzzyToInt ( args . value , 10 ) ;
} ) ;
2019-09-08 22:27:57 +02:00
layout . addDropdown < float > (
2020-08-13 18:03:08 +02:00
" Zoom " ,
2019-09-08 22:27:57 +02:00
{ " 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 " ;
} ,
2020-11-08 12:02:19 +01:00
[ ] ( auto args ) {
return fuzzyToFloat ( args . value , 1.f ) ;
} ) ;
2022-02-12 13:27:25 +01:00
ComboBox * tabDirectionDropdown =
2022-07-23 16:09:12 +02:00
layout . addDropdown < std : : underlying_type < NotebookTabLocation > : : type > (
" Tab layout " , { " Top " , " Left " , " Right " , " Bottom " } , s . tabDirection ,
2022-02-12 13:27:25 +01:00
[ ] ( auto val ) {
switch ( val )
{
2022-07-23 16:09:12 +02:00
case NotebookTabLocation : : Top :
return " Top " ;
case NotebookTabLocation : : Left :
return " Left " ;
case NotebookTabLocation : : Right :
return " Right " ;
case NotebookTabLocation : : Bottom :
return " Bottom " ;
2022-02-12 13:27:25 +01:00
}
return " " ;
} ,
[ ] ( auto args ) {
2022-07-23 16:09:12 +02:00
if ( args . value = = " Bottom " )
2022-02-12 13:27:25 +01:00
{
2022-07-23 16:09:12 +02:00
return NotebookTabLocation : : Bottom ;
}
else if ( args . value = = " Left " )
{
return NotebookTabLocation : : Left ;
}
else if ( args . value = = " Right " )
{
return NotebookTabLocation : : Right ;
2022-02-12 13:27:25 +01:00
}
else
{
2022-07-23 16:09:12 +02:00
// default to top
return NotebookTabLocation : : Top ;
2022-02-12 13:27:25 +01:00
}
} ,
false ) ;
tabDirectionDropdown - > setMinimumWidth (
tabDirectionDropdown - > minimumSizeHint ( ) . width ( ) ) ;
2020-08-13 15:43:08 +02:00
2022-07-31 12:45:25 +02:00
layout . addCheckbox ( " Show message reply button " , s . showReplyButton ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Show tab close button " , s . showTabCloseButton ) ;
layout . addCheckbox ( " Always on top " , s . windowTopMost ) ;
# ifdef USEWINSDK
layout . addCheckbox ( " Start with Windows " , s . autorun ) ;
# endif
2020-02-10 16:41:49 +01:00
if ( ! BaseWindow : : supportsCustomWindowFrame ( ) )
{
2020-07-05 14:04:39 +02:00
layout . addCheckbox ( " Show preferences button (Ctrl+P to show) " ,
2020-02-10 16:41:49 +01:00
s . hidePreferencesButton , true ) ;
layout . addCheckbox ( " Show user button " , s . hideUserButton , true ) ;
}
2020-08-13 18:19:39 +02:00
layout . addCheckbox ( " Show which channels are live in tabs " , s . showTabLive ) ;
2019-09-08 22:27:57 +02:00
layout . addTitle ( " Chat " ) ;
2019-09-16 11:36:19 +02:00
layout . addDropdown < float > (
2020-08-13 18:19:39 +02:00
" Pause on mouse hover " ,
2020-02-28 19:05:50 +01:00
{ " Disabled " , " 0.5s " , " 1s " , " 2s " , " 5s " , " Indefinite " } ,
2019-09-16 11:36:19 +02:00
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 ( ) ) ;
} ) ;
2019-09-16 10:40:02 +02:00
addKeyboardModifierSetting ( layout , " Pause while holding a key " ,
s . pauseChatModifier ) ;
2020-10-23 14:26:04 +02:00
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 " ;
} ,
2020-11-08 12:02:19 +01:00
[ ] ( auto args ) {
return fuzzyToFloat ( args . value , 1.f ) ;
} ) ;
2020-08-13 18:19:39 +02:00
layout . addCheckbox ( " Smooth scrolling " , s . enableSmoothScrolling ) ;
layout . addCheckbox ( " Smooth scrolling on new messages " ,
s . enableSmoothScrollingNewMessages ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Show input when it's empty " , s . showEmptyInput ) ;
layout . addCheckbox ( " Show message length while typing " , s . showMessageLength ) ;
2020-09-11 17:07:06 +02:00
layout . addCheckbox ( " Allow sending duplicate messages " ,
s . allowDuplicateMessages ) ;
2019-09-08 22:27:57 +02:00
layout . addTitle ( " Messages " ) ;
2020-07-05 13:55:32 +02:00
layout . addCheckbox ( " Separate with lines " , s . separateMessages ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Alternate background color " , s . alternateMessages ) ;
layout . addCheckbox ( " Show deleted messages " , s . hideModerated , true ) ;
layout . addDropdown < QString > (
2021-02-06 18:07:02 +01:00
" Timestamp format (a = am/pm, zzz = milliseconds) " ,
2020-03-29 13:06:44 +02:00
{ " Disable " , " h:mm " , " hh:mm " , " h:mm a " , " hh:mm a " , " h:mm:ss " , " hh:mm:ss " ,
2021-02-06 18:07:02 +01:00
" 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 " } ,
2019-09-08 22:27:57 +02:00
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 ;
} ) ;
layout . addDropdown < int > (
2020-08-13 18:19:39 +02:00
" Limit message height " ,
{ " Never " , " 2 lines " , " 3 lines " , " 4 lines " , " 5 lines " } ,
2019-09-08 22:27:57 +02:00
s . collpseMessagesMinLines ,
[ ] ( auto val ) {
2020-08-13 18:19:39 +02:00
return val ? QString : : number ( val ) + " lines " : QString ( " Never " ) ;
2019-09-08 22:27:57 +02:00
} ,
2020-11-08 12:02:19 +01:00
[ ] ( auto args ) {
return fuzzyToInt ( args . value , 0 ) ;
} ) ;
2021-03-13 12:33:54 +01:00
layout . addSeperator ( ) ;
layout . addCheckbox ( " Draw a line below the most recent message before "
" switching applications. " ,
s . showLastMessageIndicator ) ;
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 ) ;
2020-08-13 18:19:39 +02:00
2020-10-23 14:26:04 +02:00
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 emote auto-completion by typing : " ,
s . emoteCompletionWithColon ) ;
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 " ;
} ,
2020-11-08 12:02:19 +01:00
[ ] ( auto args ) {
return fuzzyToFloat ( args . value , 1.f ) ;
} ) ;
2020-10-23 14:26:04 +02:00
2021-04-26 00:25:23 +02:00
layout . addCheckbox ( " Remove spaces between emotes " ,
s . removeSpacesBetweenEmotes ) ;
2020-10-23 14:26:04 +02:00
layout . addDropdown < int > (
" Show info on hover " , { " Don't show " , " Always show " , " Hold shift " } ,
2020-11-08 12:02:19 +01:00
s . emotesTooltipPreview ,
[ ] ( int index ) {
return index ;
} ,
[ ] ( auto args ) {
return args . index ;
} ,
false ) ;
2020-10-23 14:26:04 +02:00
layout . addDropdown ( " Emoji style " ,
2021-02-13 19:17:22 +01:00
{
" Twitter " ,
" Facebook " ,
" Apple " ,
" Google " ,
} ,
2020-10-23 14:26:04 +02:00
s . emojiSet ) ;
layout . addTitle ( " Streamer Mode " ) ;
layout . addDescription (
2022-05-28 14:17:42 +02:00
" Chatterino can automatically change behavior if it detects that any "
" streaming software is running. \n Select which things you want to "
" change while streaming " ) ;
2020-10-23 14:26:04 +02:00
ComboBox * dankDropdown =
layout . addDropdown < std : : underlying_type < StreamerModeSetting > : : type > (
2021-01-09 22:14:25 +01:00
" Enable Streamer Mode " ,
2022-05-28 14:17:42 +02:00
{ " Disabled " , " Enabled " , " Automatic (Detect streaming software) " } ,
2020-11-08 12:02:19 +01:00
s . enableStreamerMode ,
[ ] ( int value ) {
return value ;
} ,
2020-10-23 14:26:04 +02:00
[ ] ( DropdownArgs args ) {
return static_cast < StreamerModeSetting > ( args . index ) ;
} ,
false ) ;
2022-05-28 14:17:42 +02:00
dankDropdown - > setMinimumWidth ( dankDropdown - > minimumSizeHint ( ) . width ( ) + 30 ) ;
2020-10-23 14:26:04 +02:00
layout . addCheckbox ( " Hide usercard avatars " ,
s . streamerModeHideUsercardAvatars ) ;
layout . addCheckbox ( " Hide link thumbnails " ,
s . streamerModeHideLinkThumbnails ) ;
layout . addCheckbox (
" Hide viewer count and stream length while hovering over split header " ,
s . streamerModeHideViewerCountAndDuration ) ;
layout . addCheckbox ( " Mute mention sounds " , s . streamerModeMuteMentions ) ;
2021-02-21 16:42:59 +01:00
layout . addCheckbox ( " Suppress Live Notifications " ,
s . streamerModeSuppressLiveNotifications ) ;
2020-10-23 14:26:04 +02:00
layout . addTitle ( " Link Previews " ) ;
2020-08-13 18:19:39 +02:00
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 "
2020-08-13 19:13:06 +02:00
" thumbnails for emotes, videos and more. The information is pulled "
2021-12-25 14:59:39 +01:00
" 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>. " ) ;
2020-08-13 18:19:39 +02:00
layout . addCheckbox ( " Enable " , s . linkInfoTooltip ) ;
2019-09-08 22:27:57 +02:00
layout . addDropdown < int > (
2020-08-13 18:19:39 +02:00
" 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 ) ;
} ) ;
2019-09-08 22:27:57 +02:00
2020-10-23 09:32:45 +02:00
layout . addNavigationSpacing ( ) ;
2019-09-08 22:27:57 +02:00
layout . addTitle ( " Beta " ) ;
2020-08-24 12:02:56 +02:00
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 "
2021-10-17 15:06:58 +02:00
" updates, please rebuild Chatterino from sources. Report "
2020-08-24 12:02:56 +02:00
" issues <a href='https://chatterino.com/link/issues'>here</a>. " ) ;
}
2019-09-08 22:27:57 +02:00
# ifdef Q_OS_WIN
layout . addTitle ( " Browser Integration " ) ;
layout . addDescription ( " The browser extension replaces the default "
2021-10-17 15:06:58 +02:00
" Twitch.tv chat with Chatterino. " ) ;
2019-09-08 22:27:57 +02:00
2021-05-16 18:51:25 +02:00
{
if ( auto err = nmIpcError ( ) . get ( ) )
{
layout . addDescription (
" An error happened during initialization of the "
" browser extension: " +
* err ) ;
}
}
2019-10-07 20:23:28 +02:00
layout . addDescription ( formatRichNamedLink (
CHROME_EXTENSION_LINK ,
" Download for Google Chrome and similar browsers. " ) ) ;
2019-09-08 22:27:57 +02:00
layout . addDescription (
2019-09-18 16:31:51 +02:00
formatRichNamedLink ( FIREFOX_EXTENSION_LINK , " Download for Firefox " ) ) ;
2019-10-07 20:23:28 +02:00
layout . addDescription ( " Chatterino only attaches to known browsers to avoid "
" attaching to other windows by accident. " ) ;
2020-10-23 14:26:04 +02:00
layout . addCheckbox ( " Attach to any browser (may cause issues) " ,
2019-10-07 20:23:28 +02:00
s . attachExtensionToAnyProcess ) ;
2019-09-08 22:27:57 +02:00
# endif
2020-10-23 14:26:04 +02:00
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 " , [ ] {
2021-03-20 13:40:50 +01:00
# ifdef Q_OS_DARWIN
QDesktopServices : : openUrl ( " file:// " + getPaths ( ) - > rootAppDataDirectory ) ;
# else
2020-10-23 14:26:04 +02:00
QDesktopServices : : openUrl ( getPaths ( ) - > rootAppDataDirectory ) ;
2021-03-20 13:40:50 +01:00
# endif
2020-10-23 14:26:04 +02:00
} ) ;
layout . addSubtitle ( " Temporary files (Cache) " ) ;
2020-08-13 16:59:42 +02:00
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 = 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 ) ;
} ) ) ;
2020-11-08 12:02:19 +01:00
box - > addWidget ( layout . makeButton ( " Reset " , [ ] ( ) {
getSettings ( ) - > cachePath = " " ;
} ) ) ;
2021-11-06 13:00:27 +01:00
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 ( getPaths ( ) - > cacheDirectory ( ) ) ;
cacheDir . removeRecursively ( ) ;
cacheDir . mkdir ( getPaths ( ) - > cacheDirectory ( ) ) ;
}
} ) ) ;
2020-08-13 16:59:42 +02:00
box - > addStretch ( 1 ) ;
layout . addLayout ( box ) ;
}
2020-10-23 14:26:04 +02:00
layout . addTitle ( " Advanced " ) ;
layout . addSubtitle ( " Chat title " ) ;
layout . addDescription ( " In live channels show: " ) ;
layout . addCheckbox ( " Uptime " , s . headerUptime ) ;
layout . addCheckbox ( " Viewer count " , s . headerViewerCount ) ;
layout . addCheckbox ( " Category " , s . headerGame ) ;
layout . addCheckbox ( " Title " , s . headerStreamTitle ) ;
layout . addSubtitle ( " R9K " ) ;
2021-08-14 14:28:08 +02:00
layout . addDescription ( " Hide similar messages. Toggle hidden "
" messages by pressing Ctrl+H. " ) ;
2020-10-23 14:26:04 +02:00
layout . addCheckbox ( " Hide similar messages " , s . similarityEnabled ) ;
//layout.addCheckbox("Gray out matches", s.colorSimilarDisabled);
2021-08-14 14:28:08 +02:00
layout . addCheckbox ( " By the same user " , s . hideSimilarBySameUser ) ;
2020-10-23 14:26:04 +02:00
layout . addCheckbox ( " Hide my own messages " , s . hideSimilarMyself ) ;
layout . addCheckbox ( " Receive notification sounds from hidden messages " ,
s . shownSimilarTriggerHighlights ) ;
s . hideSimilar . connect (
2020-11-08 12:02:19 +01:00
[ ] ( ) {
getApp ( ) - > windows - > forceLayoutChannelViews ( ) ;
} ,
false ) ;
2020-10-23 14:26:04 +02:00
layout . addDropdown < float > (
" Similarity threshold " , { " 0.5 " , " 0.75 " , " 0.9 " } , s . similarityPercentage ,
2020-11-08 12:02:19 +01:00
[ ] ( auto val ) {
return QString : : number ( val ) ;
} ,
[ ] ( auto args ) {
return fuzzyToFloat ( args . value , 0.9f ) ;
} ) ;
2020-10-23 14:26:04 +02:00
layout . addDropdown < int > (
" Maximum delay between messages " ,
{ " 5s " , " 10s " , " 15s " , " 30s " , " 60s " , " 120s " } , s . hideSimilarMaxDelay ,
2020-11-08 12:02:19 +01:00
[ ] ( auto val ) {
return QString : : number ( val ) + " s " ;
} ,
[ ] ( auto args ) {
return fuzzyToInt ( args . value , 5 ) ;
} ) ;
2020-10-23 14:26:04 +02:00
layout . addDropdown < int > (
" Amount of previous messages to check " , { " 1 " , " 2 " , " 3 " , " 4 " , " 5 " } ,
s . hideSimilarMaxMessagesToCheck ,
2020-11-08 12:02:19 +01:00
[ ] ( auto val ) {
return QString : : number ( val ) ;
} ,
[ ] ( auto args ) {
return fuzzyToInt ( args . value , 3 ) ;
} ) ;
2020-08-13 16:59:42 +02:00
2020-10-23 14:26:04 +02:00
layout . addSubtitle ( " Visible badges " ) ;
2021-04-25 14:37:19 +02:00
layout . addCheckbox ( " Authority (staff, admin) " , s . showBadgesGlobalAuthority ) ;
layout . addCheckbox ( " Predictions " , s . showBadgesPredictions ) ;
2020-10-23 14:26:04 +02:00
layout . addCheckbox ( " Channel (broadcaster, moderator) " ,
2021-04-25 14:37:19 +02:00
s . showBadgesChannelAuthority ) ;
layout . addCheckbox ( " Subscriber " , s . showBadgesSubscription ) ;
layout . addCheckbox ( " Vanity (prime, bits, subgifter) " , s . showBadgesVanity ) ;
layout . addCheckbox ( " Chatterino " , s . showBadgesChatterino ) ;
2020-10-25 10:36:00 +01:00
layout . addCheckbox ( " FrankerFaceZ (Bot, FFZ Supporter, FFZ Developer) " ,
2021-04-25 14:37:19 +02:00
s . showBadgesFfz ) ;
2021-05-16 22:07:12 +02:00
layout . addSeperator ( ) ;
layout . addCheckbox ( " Use custom FrankerFaceZ moderator badges " ,
s . useCustomFfzModeratorBadges ) ;
layout . addCheckbox ( " Use custom FrankerFaceZ VIP badges " ,
s . useCustomFfzVipBadges ) ;
2020-10-23 14:26:04 +02:00
layout . addSubtitle ( " Miscellaneous " ) ;
2019-09-08 22:27:57 +02:00
if ( supportsIncognitoLinks ( ) )
{
layout . addCheckbox ( " Open links in incognito/private mode " ,
s . openLinksIncognito ) ;
}
2019-09-18 13:03:16 +02:00
2020-08-13 15:55:42 +02:00
layout . addCheckbox ( " Restart on crash " , s . restartOnCrash ) ;
2021-10-31 20:45:23 +01:00
# if defined(Q_OS_LINUX) && !defined(NO_QTKEYCHAIN)
2019-09-18 13:03:16 +02:00
if ( ! getPaths ( ) - > isPortable ( ) )
{
layout . addCheckbox (
" Use libsecret/KWallet/Gnome keychain to secure passwords " ,
s . useKeyring ) ;
}
# endif
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Show moderation messages " , s . hideModerationActions ,
true ) ;
2021-06-06 17:51:57 +02:00
layout . addCheckbox ( " Show deletions of single messages " ,
s . hideDeletionActions , true ) ;
2020-10-04 12:59:31 +02:00
layout . addCheckbox ( " Colorize users without color set (gray names) " ,
2019-09-08 22:27:57 +02:00
s . colorizeNicknames ) ;
layout . addCheckbox ( " Mention users with a comma (User,) " ,
s . mentionUsersWithComma ) ;
layout . addCheckbox ( " Show joined users (< 1000 chatters) " , s . showJoins ) ;
layout . addCheckbox ( " Show parted users (< 1000 chatters) " , s . showParts ) ;
2020-08-08 14:43:26 +02:00
layout . addCheckbox ( " Automatically close user popup when it loses focus " ,
s . autoCloseUserPopup ) ;
2022-07-31 12:45:25 +02:00
layout . addCheckbox (
" Automatically close reply thread popup when it loses focus " ,
s . autoCloseThreadPopup ) ;
2019-09-16 10:44:05 +02:00
layout . addCheckbox ( " Lowercase domains (anti-phishing) " , s . lowercaseDomains ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Bold @usernames " , s . boldUsernames ) ;
2020-12-19 14:42:20 +01:00
layout . addCheckbox ( " Color @usernames " , s . colorUsernames ) ;
2020-07-18 16:03:51 +02:00
layout . addCheckbox ( " Try to find usernames without @ prefix " ,
s . findAllUsernames ) ;
2021-06-19 18:29:17 +02:00
layout . addCheckbox ( " Show username autocompletion popup menu " ,
s . showUsernameCompletionMenu ) ;
2021-06-13 14:13:19 +02:00
const QStringList usernameDisplayModes = { " Username " , " Localized name " ,
" Username and localized name " } ;
2021-07-11 12:47:23 +02:00
ComboBox * nameDropdown =
layout . addDropdown < std : : underlying_type < UsernameDisplayMode > : : type > (
" Username style " , usernameDisplayModes , s . usernameDisplayMode ,
[ usernameDisplayModes ] ( auto val ) {
return usernameDisplayModes . at ( val - 1 ) ;
// UsernameDisplayMode enum indexes from 1
} ,
[ ] ( auto args ) {
return args . index + 1 ;
} ,
false ) ;
nameDropdown - > setMinimumWidth ( nameDropdown - > minimumSizeHint ( ) . width ( ) ) ;
2019-09-08 22:27:57 +02:00
layout . addDropdown < float > (
" Username font weight " , { " 50 " , " Default " , " 75 " , " 100 " } , s . boldScale ,
[ ] ( auto val ) {
if ( val = = 63 )
return QString ( " Default " ) ;
else
return QString : : number ( val ) ;
} ,
2020-11-08 12:02:19 +01:00
[ ] ( auto args ) {
return fuzzyToFloat ( args . value , 63.f ) ;
} ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Double click to open links and other elements in chat " ,
s . linksDoubleClickOnly ) ;
layout . addCheckbox ( " Unshorten links " , s . unshortLinks ) ;
layout . addCheckbox (
" Only search for emote autocompletion at the start of emote names " ,
s . prefixOnlyEmoteCompletion ) ;
2020-02-29 11:52:49 +01:00
layout . addCheckbox ( " Only search for username autocompletion with an @ " ,
s . userCompletionOnlyWithAt ) ;
2019-09-08 22:27:57 +02:00
2021-10-17 15:06:58 +02:00
layout . addCheckbox ( " Show Twitch whispers inline " , s . inlineWhispers ) ;
2019-09-08 22:27:57 +02:00
layout . addCheckbox ( " Highlight received inline whispers " ,
s . highlightInlineWhispers ) ;
layout . addCheckbox ( " Load message history on connect " ,
s . loadTwitchMessageHistoryOnConnect ) ;
2020-12-06 13:04:49 +01:00
// TODO: Change phrasing to use better english once we can tag settings, right now it's kept as history instead of historical so that the setting shows up when the user searches for history
layout . addIntInput ( " Max number of history messages to load on connect " ,
s . twitchMessageHistoryLimit , 10 , 800 , 10 ) ;
2019-09-08 22:27:57 +02:00
2019-09-22 17:12:09 +02:00
layout . addCheckbox ( " Enable experimental IRC support (requires restart) " ,
s . enableExperimentalIrc ) ;
layout . addCheckbox ( " Show unhandled IRC messages " ,
2019-09-18 13:03:16 +02:00
s . showUnhandledIrcMessages ) ;
2020-08-13 18:19:39 +02:00
layout . addDropdown < int > (
" Stack timeouts " , { " Stack " , " Stack until timeout " , " Don't stack " } ,
2020-11-08 12:02:19 +01:00
s . timeoutStackStyle ,
[ ] ( int index ) {
return index ;
} ,
[ ] ( auto args ) {
return args . index ;
} ,
false ) ;
2020-08-13 18:19:39 +02:00
layout . addCheckbox ( " Combine multiple bit tips into one " , s . stackBits ) ;
2021-01-16 14:27:19 +01:00
layout . addCheckbox ( " Messages in /mentions highlights tab " ,
s . highlightMentions ) ;
2019-09-18 13:03:16 +02:00
2020-10-23 14:26:04 +02:00
layout . addStretch ( ) ;
2019-09-08 22:27:57 +02:00
// invisible element for width
auto inv = new BaseWidget ( this ) ;
2020-10-23 09:32:45 +02:00
// inv->setScaleIndependantWidth(600);
2019-09-08 22:27:57 +02:00
layout . addWidget ( inv ) ;
}
void GeneralPage : : initExtra ( )
{
/// update cache path
if ( this - > cachePath_ )
{
getSettings ( ) - > cachePath . connect (
[ cachePath = this - > cachePath_ ] ( const auto & , auto ) mutable {
QString newPath = getPaths ( ) - > cacheDirectory ( ) ;
QString pathShortened = " Current location: <a href= \" file:/// " +
newPath + " \" > " +
shortenString ( newPath , 50 ) + " </a> " ;
cachePath - > setText ( pathShortened ) ;
cachePath - > setToolTip ( newPath ) ;
} ) ;
}
}
QString GeneralPage : : getFont ( const DropdownArgs & args ) const
{
if ( args . combobox - > currentIndex ( ) = = args . combobox - > count ( ) - 1 )
{
args . combobox - > setCurrentIndex ( 0 ) ;
args . combobox - > setEditText ( " Choosing... " ) ;
QFontDialog dialog ( getApp ( ) - > fonts - > getFont ( FontStyle : : ChatMedium , 1. ) ) ;
auto ok = bool ( ) ;
2022-04-16 10:59:20 +02:00
auto font = dialog . getFont ( & ok , this - > window ( ) ) ;
2019-09-08 22:27:57 +02:00
if ( ok )
return font . family ( ) ;
else
return args . combobox - > itemText ( 0 ) ;
}
return args . value ;
}
} // namespace chatterino