import { VerticalBox, Palette, TextEdit, HorizontalBox, ScrollView, LineEdit, Button } from "std-widgets.slint"; export enum LoginState { LoggedIn, LoggedOut, Processing, LoginError, LoginTimeout } export global JNCSettingsInterface { in-out property login_state: LoginState.LoggedOut; in-out property login_timeout; in-out property otp_code; in-out property series_count: 0; in-out property book_count: 0; callback start_login(); callback logout(); callback refresh_library(); } export global SettingsPageInterface { } component SettingsMember inherits Rectangle { border-width: 1px; border-radius: 4px; border-color: Palette.border; background: Palette.alternate-background; VerticalBox { alignment: start; spacing: 4px; @children } } component StringSetting inherits HorizontalBox { in property name; in property placeholder: "" ; in property w: 100px; in-out property value; alignment: start; height: 24px; Text { font-size: 12px; height: self.font-size + 8px; vertical-alignment: center; text: name; } LineEdit { font-size: 12px; preferred-width: w + 4px; height: self.font-size + 8px; placeholder-text: placeholder; text <=> value; } } export component SettingsPage inherits VerticalBox { SettingsMember { Text { text: "Kavita Settings (sftp)"; } StringSetting { name: "Server:"; placeholder: "XXX.XXX.XXX.XXX"; value: ""; w: 120px; } StringSetting { name: "Username:"; placeholder: "User"; value: ""; w: 80px; } } SettingsMember { Text { text: "J-Novel Club Settings"; } if JNCSettingsInterface.login_state == LoginState.LoggedOut : HorizontalLayout { alignment: start; Button { text: "Log In"; clicked => {JNCSettingsInterface.start_login()} } } if JNCSettingsInterface.login_state == LoginState.Processing : HorizontalBox { otp := Text { text: JNCSettingsInterface.otp_code; } Button { text: "Copy"; clicked => {} } Text { text: "Awaiting Login Confirmation. \{JNCSettingsInterface.login_timeout} until expiry."; } } if JNCSettingsInterface.login_state == LoginState.LoggedIn : VerticalBox { HorizontalBox { Text { text: "Logged In."; } Button { text: "Log Out"; clicked => {JNCSettingsInterface.logout()} } } HorizontalBox { Text { text: "Library: \{JNCSettingsInterface.series_count} Series, \{JNCSettingsInterface.book_count} Books loaded"; } Button { text: "refresh"; clicked => {JNCSettingsInterface.refresh_library()} } } } } SettingsMember { Text { text: "Manual Parser Settings"; } } }