2023-06-29 03:46:03 +00:00
import QtCore
import QtQuick
import QtQuick . Controls
import QtQuick . Controls . Basic
import QtQuick . Layouts
import QtQuick . Dialogs
import modellist
import mysettings
2023-07-01 15:34:21 +00:00
import network
2023-06-29 03:46:03 +00:00
MySettingsTab {
2023-07-01 15:34:21 +00:00
onRestoreDefaultsClicked: {
MySettings . restoreApplicationDefaults ( ) ;
}
2023-06-29 03:46:03 +00:00
title: qsTr ( "Application" )
contentItem: GridLayout {
id: applicationSettingsTabInner
columns: 3
rowSpacing: 10
columnSpacing: 10
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-07-26 19:42:07 +00:00
id: themeLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Theme" )
2023-07-26 19:42:07 +00:00
Layout.row: 1
Layout.column: 0
}
MyComboBox {
id: themeBox
Layout.row: 1
Layout.column: 1
Layout.columnSpan: 1
2024-01-29 16:12:12 +00:00
Layout.minimumWidth: 200
2023-07-26 19:42:07 +00:00
Layout.fillWidth: false
2024-01-29 16:12:12 +00:00
model: [ "Dark" , "Light" , "LegacyDark" ]
2023-07-26 19:42:07 +00:00
Accessible.role: Accessible . ComboBox
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Color theme" )
Accessible.description: qsTr ( "Color theme for the chat client to use" )
2023-07-26 19:42:07 +00:00
function updateModel ( ) {
themeBox . currentIndex = themeBox . indexOfValue ( MySettings . chatTheme ) ;
}
Component.onCompleted: {
themeBox . updateModel ( )
}
Connections {
target: MySettings
function onChatThemeChanged ( ) {
themeBox . updateModel ( )
}
}
onActivated: {
MySettings . chatTheme = themeBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-08-07 17:54:13 +00:00
id: fontLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Font Size" )
2023-08-07 17:54:13 +00:00
Layout.row: 2
Layout.column: 0
}
MyComboBox {
id: fontBox
Layout.row: 2
Layout.column: 1
Layout.columnSpan: 1
Layout.minimumWidth: 100
Layout.fillWidth: false
model: [ "Small" , "Medium" , "Large" ]
Accessible.role: Accessible . ComboBox
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Font size" )
Accessible.description: qsTr ( "Font size of the chat client" )
2023-08-07 17:54:13 +00:00
function updateModel ( ) {
fontBox . currentIndex = fontBox . indexOfValue ( MySettings . fontSize ) ;
}
Component.onCompleted: {
fontBox . updateModel ( )
}
Connections {
target: MySettings
function onFontSizeChanged ( ) {
fontBox . updateModel ( )
}
}
onActivated: {
MySettings . fontSize = fontBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-09-13 14:32:08 +00:00
id: deviceLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Device" )
2023-09-13 14:32:08 +00:00
Layout.row: 3
Layout.column: 0
}
MyComboBox {
id: deviceBox
Layout.row: 3
Layout.column: 1
Layout.columnSpan: 1
Layout.minimumWidth: 350
Layout.fillWidth: false
model: MySettings . deviceList
Accessible.role: Accessible . ComboBox
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Device" )
Accessible.description: qsTr ( "Device of the chat client" )
2023-09-13 14:32:08 +00:00
function updateModel ( ) {
deviceBox . currentIndex = deviceBox . indexOfValue ( MySettings . device ) ;
}
Component.onCompleted: {
deviceBox . updateModel ( )
}
Connections {
target: MySettings
function onDeviceChanged ( ) {
deviceBox . updateModel ( )
}
function onDeviceListChanged ( ) {
deviceBox . updateModel ( )
}
}
onActivated: {
MySettings . device = deviceBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: defaultModelLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Default model" )
2023-09-13 14:32:08 +00:00
Layout.row: 4
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyComboBox {
id: comboBox
2023-09-13 14:32:08 +00:00
Layout.row: 4
2023-06-29 03:46:03 +00:00
Layout.column: 1
2023-07-01 15:34:21 +00:00
Layout.columnSpan: 2
2023-06-29 03:46:03 +00:00
Layout.minimumWidth: 350
2023-07-01 15:34:21 +00:00
Layout.fillWidth: true
2023-06-29 03:46:03 +00:00
model: ModelList . userDefaultModelList
Accessible.role: Accessible . ComboBox
2023-10-21 14:38:46 +00:00
Accessible.name: qsTr ( "Default model" )
Accessible.description: qsTr ( "Default model to use; the first item is the current default model" )
2023-06-29 03:46:03 +00:00
function updateModel ( ) {
comboBox . currentIndex = comboBox . indexOfValue ( MySettings . userDefaultModel ) ;
}
Component.onCompleted: {
comboBox . updateModel ( )
}
Connections {
target: MySettings
function onUserDefaultModelChanged ( ) {
comboBox . updateModel ( )
}
}
onActivated: {
MySettings . userDefaultModel = comboBox . currentText
}
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: modelPathLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Download path" )
2023-09-13 14:32:08 +00:00
Layout.row: 5
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyDirectoryField {
id: modelPathDisplayField
text: MySettings . modelPath
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-06-29 03:46:03 +00:00
implicitWidth: 300
2023-09-13 14:32:08 +00:00
Layout.row: 5
2023-06-29 03:46:03 +00:00
Layout.column: 1
Layout.fillWidth: true
ToolTip.text: qsTr ( "Path where model files will be downloaded to" )
ToolTip.visible: hovered
Accessible.role: Accessible . ToolTip
Accessible.name: modelPathDisplayField . text
Accessible.description: ToolTip . text
onEditingFinished: {
if ( isValid ) {
MySettings . modelPath = modelPathDisplayField . text
} else {
text = MySettings . modelPath
}
}
}
2024-01-22 19:41:47 +00:00
MySettingsButton {
2023-09-13 14:32:08 +00:00
Layout.row: 5
2023-06-29 03:46:03 +00:00
Layout.column: 2
text: qsTr ( "Browse" )
2023-10-21 14:38:46 +00:00
Accessible.description: qsTr ( "Choose where to save model files" )
2023-07-09 17:05:06 +00:00
onClicked: {
openFolderDialog ( "file://" + MySettings . modelPath , function ( selectedFolder ) {
MySettings . modelPath = selectedFolder
} )
}
2023-06-29 03:46:03 +00:00
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: nThreadsLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "CPU Threads" )
2023-09-13 14:32:08 +00:00
Layout.row: 6
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyTextField {
text: MySettings . threadCount
color: theme . textColor
2023-08-07 17:54:13 +00:00
font.pixelSize: theme . fontSizeLarge
2023-07-10 20:52:32 +00:00
ToolTip.text: qsTr ( "Amount of processing threads to use bounded by 1 and number of logical processors" )
2023-06-29 03:46:03 +00:00
ToolTip.visible: hovered
2023-09-13 14:32:08 +00:00
Layout.row: 6
2023-06-29 03:46:03 +00:00
Layout.column: 1
validator: IntValidator {
bottom: 1
}
onEditingFinished: {
var val = parseInt ( text )
if ( ! isNaN ( val ) ) {
MySettings . threadCount = val
focus = false
} else {
text = MySettings . threadCount
}
}
Accessible.role: Accessible . EditableText
Accessible.name: nThreadsLabel . text
Accessible.description: ToolTip . text
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-10-11 14:23:33 +00:00
id: saveChatsContextLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Save chats context to disk" )
2023-09-13 14:32:08 +00:00
Layout.row: 7
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyCheckBox {
2023-10-11 14:23:33 +00:00
id: saveChatsContextBox
2023-09-13 14:32:08 +00:00
Layout.row: 7
2023-06-29 03:46:03 +00:00
Layout.column: 1
2023-10-11 14:23:33 +00:00
checked: MySettings . saveChatsContext
2023-06-29 03:46:03 +00:00
onClicked: {
2023-10-11 14:23:33 +00:00
MySettings . saveChatsContext = ! MySettings . saveChatsContext
2023-06-29 03:46:03 +00:00
}
ToolTip.text: qsTr ( "WARNING: Saving chats to disk can be ~2GB per chat" )
ToolTip.visible: hovered
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: serverChatLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Enable API server" )
2023-10-11 14:23:33 +00:00
Layout.row: 8
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
MyCheckBox {
id: serverChatBox
2023-10-11 14:23:33 +00:00
Layout.row: 8
2023-06-29 03:46:03 +00:00
Layout.column: 1
checked: MySettings . serverChat
onClicked: {
MySettings . serverChat = ! MySettings . serverChat
}
ToolTip.text: qsTr ( "WARNING: This enables the gui to act as a local REST web server(OpenAI API compliant) for API requests and will increase your RAM usage as well" )
ToolTip.visible: hovered
}
Rectangle {
2023-10-11 14:23:33 +00:00
Layout.row: 9
2023-06-29 03:46:03 +00:00
Layout.column: 0
Layout.columnSpan: 3
Layout.fillWidth: true
2024-01-22 19:41:47 +00:00
height: 3
2024-01-29 16:12:12 +00:00
color: theme . accentColor
2023-06-29 03:46:03 +00:00
}
2023-07-01 15:34:21 +00:00
}
advancedSettings: GridLayout {
columns: 3
rowSpacing: 10
columnSpacing: 10
2023-06-29 03:46:03 +00:00
Rectangle {
2023-07-01 15:34:21 +00:00
Layout.row: 2
2023-06-29 03:46:03 +00:00
Layout.column: 0
Layout.fillWidth: true
Layout.columnSpan: 3
2024-01-22 19:41:47 +00:00
height: 3
2024-01-29 16:12:12 +00:00
color: theme . accentColor
2023-06-29 03:46:03 +00:00
}
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-06-29 03:46:03 +00:00
id: gpuOverrideLabel
2024-01-22 19:41:47 +00:00
text: qsTr ( "Force Metal (macOS+arm)" )
2023-07-01 15:34:21 +00:00
Layout.row: 1
2023-06-29 03:46:03 +00:00
Layout.column: 0
}
RowLayout {
2023-07-01 15:34:21 +00:00
Layout.row: 1
2023-06-29 03:46:03 +00:00
Layout.column: 1
Layout.columnSpan: 2
MyCheckBox {
id: gpuOverrideBox
checked: MySettings . forceMetal
onClicked: {
MySettings . forceMetal = ! MySettings . forceMetal
}
}
2023-07-01 15:34:21 +00:00
Item {
Layout.fillWidth: true
2023-06-29 03:46:03 +00:00
Layout.alignment: Qt . AlignTop
2023-07-01 15:34:21 +00:00
Layout.minimumHeight: warningLabel . height
2024-01-22 19:41:47 +00:00
MySettingsLabel {
2023-07-01 15:34:21 +00:00
id: warningLabel
width: parent . width
color: theme . textErrorColor
wrapMode: Text . WordWrap
text: qsTr ( "WARNING: On macOS with arm (M1+) this setting forces usage of the GPU. Can cause crashes if the model requires more RAM than the system supports. Because of crash possibility the setting will not persist across restarts of the application. This has no effect on non-macs or intel." )
}
2023-06-29 03:46:03 +00:00
}
}
}
}