88 lines
2.9 KiB
Plaintext
88 lines
2.9 KiB
Plaintext
import { Page } from "page.slint";
|
|
import { AppManager } from "../app-manager.slint";
|
|
import { ComboBox, Switch, Palette, Icons, ColorVariant, CheckBox, ColorTheme } from "../_imports/coop-widgets.slint";
|
|
import { ColorPalette, ThemeSettings, ThemeSwitcher } from "../themes/palettes.slint";
|
|
import { Onedark } from "../themes/onedark.slint";
|
|
import { BrushesPage } from "brushes-page.slint";
|
|
|
|
export global ColorReload {
|
|
public function reload_color() {
|
|
ThemeSettings.built-in-theme = true;
|
|
if (ThemeSettings.color-index == 0) {
|
|
Palette.set-color-theme(ColorTheme.Coop);
|
|
return;
|
|
} else if (ThemeSettings.color-index == 1) {
|
|
Palette.set-color-theme(ColorTheme.Cosmic);
|
|
return;
|
|
} else if (ThemeSettings.color-index == 2){
|
|
ThemeSettings.color-palette = Onedark.palette;
|
|
}
|
|
ThemeSettings.built-in-theme = false;
|
|
ThemeSwitcher.switch(ThemeSettings.color-palette);
|
|
|
|
}
|
|
}
|
|
|
|
export component SettingsPage inherits Page {
|
|
title: "Settings";
|
|
in-out property <bool> keyboard_check_box: true;
|
|
in-out property <bool> disabled_check_box: true;
|
|
|
|
Flickable {
|
|
VerticalLayout {
|
|
alignment: start;
|
|
padding: 30px;
|
|
spacing: 30px;
|
|
|
|
if (root.keyboard_check_box) : CheckBox {
|
|
text: "Keyboard enabled";
|
|
checked <=> AppManager.keyboard_enabled;
|
|
}
|
|
|
|
if (root.disabled_check_box) : CheckBox {
|
|
text: "Widgets enabled";
|
|
checked <=> AppManager.widgets_enabled;
|
|
}
|
|
|
|
ComboBox {
|
|
width: 128px;
|
|
height: 40px;
|
|
placeholder-text: @tr("Select theme:");
|
|
current-index: ThemeSettings.color-index;
|
|
|
|
model: [
|
|
{ text: "Coop" },
|
|
{ text: "Cosmic" },
|
|
{ text: "Onedark" },
|
|
];
|
|
|
|
selected (index) => {
|
|
ThemeSettings.color-index=index;
|
|
ColorReload.reload-color();
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
|
|
Switch {
|
|
height: 48px;
|
|
on_icon: Icons.mode-night;
|
|
off_icon: Icons.light-mode;
|
|
checked: !ThemeSettings.dark-color-scheme;
|
|
|
|
toggled(checked) => {
|
|
ThemeSettings.dark-color-scheme = !checked;
|
|
if (ThemeSettings.built-in-theme){
|
|
Palette.set-color-variant(checked ? ColorVariant.Light : ColorVariant.Dark);
|
|
} else {
|
|
ColorReload.reload-color();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if AppManager.debug : BrushesPage { }
|
|
}
|
|
}
|
|
}
|