kavita-upload-helper/ui/pages/settings_page.slint

131 lines
3.1 KiB
Text
Raw Normal View History

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 <LoginState> login_state: LoginState.LoggedOut;
in-out property <string> login_timeout;
in-out property <string> otp_code;
in-out property <int> series_count: 0;
in-out property <int> 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 <string> name;
in property <string> placeholder: "" ;
in property <length> w: 100px;
in-out property <string> 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";
}
}
}