import { Direction , QBoxLayout , QLabel , QWidget , WidgetEventTypes } from '@nodegui/nodegui' ; import { __ } from '../../../utilities/StringProvider' ; import { app , MAX_QSIZE } from '../../..' ; import { createLogger } from '../../../utilities/Console' ; import { IConfig } from '../../../utilities/IConfig' ; import { SettingsCheckBox } from '../SettingsCheckBox' ; import { PhraseID } from '../../../utilities/PhraseID' ; const { debug } = createLogger ( '[SettingsView]' ) ; export abstract class Page extends QWidget { abstract title : string ; layout = new QBoxLayout ( Direction . TopToBottom ) ; constructor ( ) { super ( ) ; this . setObjectName ( 'Page' ) ; this . setLayout ( this . layout ) ; this . setMaximumSize ( 740 , MAX_QSIZE ) ; this . layout . setContentsMargins ( 40 , 60 , 40 , 80 ) ; this . layout . setSpacing ( 0 ) ; } onOpened ( ) { debug ( 'Opened' , this . title ) ; } onClosed ( ) { debug ( 'Closed' , this . title ) ; } param checkbox param configId param text protected addSimpleCheckbox ( checkbox , configId , text ) { const { layout } = this ; checkbox . setText ( text ) ; checkbox . addEventListener ( WidgetEventTypes . MouseButtonRelease , ( ) => { const checked = checkbox . isChecked ( ) ; checkbox . setChecked ( ! checked ) ; app . config . set ( configId , ! checked ) ; void app . config . save ( ) ; } ) ; layout . addWidget ( checkbox ) ; } protected addRestartRequiredLabel ( ) { const restartNotice = new QLabel ( this ) ; restartNotice . setText ( __ ( 'OPTION_RESTART_REQUIRED' ) ) ; restartNotice . setInlineStyle ( 'color: #f04747' ) ; return restartNotice ; } protected createSubheader = ( id ) => { const label = new QLabel ( this ) ; label . setObjectName ( 'Header3' ) ; label . setText ( __ ( id ) ) ; return label ; } ; }