Switch from Qt6 to Slint

This commit is contained in:
Vyn 2024-08-16 21:35:12 +02:00
parent f8be14bcf8
commit 63bf267a22
107 changed files with 27532 additions and 2896 deletions

View file

@ -0,0 +1,47 @@
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VButton inherits Rectangle {
in property<string> text;
in property<brush> text-color: Palette.foreground;
in property<image> icon-source;
in property<brush> icon-colorize;
in property<length> icon-size: 1rem;
in property enabled <=> ta.enabled;
callback clicked;
private property<bool> active: false;
background: enabled ? Palette.control-background : Palette.control-background.darker(0.2);
border-radius: 4px;
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
active = !active;
root.clicked();
}
}
HorizontalLayout {
alignment: center;
spacing: 8px;
padding: 8px;
padding-top: 4px;
padding-bottom: 4px;
if root.icon-source.width != 0 : Image {
padding: 8px;
source: icon-source;
colorize: icon-colorize;
width: icon-size;
}
if root.text != "" : VerticalLayout {
VText {
text: root.text;
color: root.text-color;
horizontal-alignment: center;
}
}
}
}

View file

@ -0,0 +1,42 @@
import { VLabeledComponent } from "LabeledComponent.slint";
import { VText } from "Text.slint";
import { Palette } from "Palette.slint";
export component VCheckBox {
in-out property<string> text;
in property <brush> color <=> textComponent.color;
in-out property<bool> checked: false;
callback toggled(bool); // toggled(state: bool)
HorizontalLayout {
spacing: 8px;
VerticalLayout {
alignment: center;
if checked : Rectangle {
background: Palette.accent;
height: 1rem;
width: self.height;
border-radius: 32px;
}
if !checked : Rectangle {
border-color: Palette.accent;
border-width: 2px;
height: 1rem;
width: self.height;
border-radius: 32px;
}
}
textComponent := VText {
text: root.text;
vertical-alignment: center;
}
}
ta := TouchArea {
clicked => {
checked = !checked;
root.toggled(checked)
}
}
}

View file

@ -0,0 +1,27 @@
import { Button, DatePickerPopup, Date, Palette } from "std-widgets.slint";
import { VLabeledComponent } from "LabeledComponent.slint";
import { VButton } from "Button.slint";
export component VDatePicker inherits VLabeledComponent {
in-out property<Date> date;
in-out property<string> dateDisplay: formatZeroPadding(date.day) + "/" + formatZeroPadding(date.month) + "/" + date.year;
pure function formatZeroPadding(number: int) -> string {
if (number < 10) {
return "0\{number}";
}
return number;
}
button := VButton {
text: dateDisplay;
enabled: root.enabled;
clicked => { taskDateInput.show() }
}
taskDateInput := DatePickerPopup {
accepted(date) => { root.date = date }
}
}

View file

@ -0,0 +1,22 @@
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VLabeledComponent {
in property<string> label <=> labelComponent.text;
in property<bool> enabled: true;
VerticalLayout {
labelComponent := VText {
}
Rectangle {
background: enabled ? Palette.control-background : Palette.control-background.darker(0.2);
border-radius: 4px;
VerticalLayout {
padding: 4px;
@children
}
}
}
}

View file

@ -0,0 +1,43 @@
// OneDark
//black = "#181a1f",
//bg0 = "#282c34",
//bg1 = "#31353f",
//bg2 = "#393f4a",
//bg3 = "#3b3f4c",
//bg_d = "#21252b",
//bg_blue = "#73b8f1",
//bg_yellow = "#ebd09c",
//fg = "#abb2bf",
//purple = "#c678dd",
//green = "#98c379",
//orange = "#d19a66",
//blue = "#61afef",
//yellow = "#e5c07b",
//cyan = "#56b6c2",
//red = "#e86671",
//grey = "#5c6370",
//light_grey = "#848b98",
//dark_cyan = "#2b6f77",
//dark_red = "#993939",
//dark_yellow = "#93691d",
//dark_purple = "#8a3fa0",
//diff_add = "#31392b",
//diff_delete = "#382b2c",
//diff_change = "#1c3448",
//diff_text = "#2c5372",
// ----
export global Palette {
out property<brush> accent: Colors.cyan.darker(0.4);
out property<brush> foreground: #abb2bf;
out property<brush> foreground-hint: foreground.darker(0.2);
out property<brush> background: #282c34;
out property<brush> pane: #21252b;
out property<brush> control-foreground: #abb2bf;
out property<brush> control-background: #393f4a;
out property<brush> card-background: background.brighter(0.2);
out property<brush> green: Colors.greenyellow;
out property<brush> orange: Colors.orange;
out property<brush> red: Colors.red;
}

View file

@ -0,0 +1,27 @@
import { Palette } from "Palette.slint";
import { VButton } from "Button.slint";
export component VPopupIconMenu inherits Rectangle {
private property<length> popup-x: 200px;
private property<length> popup-y: 200px;
public function show(x: length, y: length) {
popup-x = x;
popup-y = y;
popup.show();
}
popup := PopupWindow {
x: popup-x;
y: popup-y;
Rectangle {
background: Palette.background.brighter(0.2);
border-radius: 8px;
clip: true;
HorizontalLayout {
alignment: start;
@children
}
}
}
}

31
lib/slint-vynui/Tag.slint Normal file
View file

@ -0,0 +1,31 @@
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component VTag inherits Rectangle {
in property text <=> text-component.text;
in property text-color <=> text-component.color;
in property size <=> text-component.font-size;
in property background-color <=> self.background;
callback clicked;
background: Palette.control-background;
border-radius: 8px;
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
VerticalLayout {
padding-left: 8px;
padding-right: 8px;
alignment: center;
text-component := VText {
horizontal-alignment: center;
}
}
}

View file

@ -0,0 +1,5 @@
import { Palette } from "Palette.slint";
export component VText inherits Text {
color: Palette.foreground;
}

View file

@ -0,0 +1,13 @@
import { VLabeledComponent } from "LabeledComponent.slint";
import { Palette } from "Palette.slint";
export component VTextInput inherits VLabeledComponent {
in-out property text <=> textInputComponent.text;
in-out property wrap <=> textInputComponent.wrap;
callback accepted();
textInputComponent := TextInput {
color: Palette.foreground;
accepted => { root.accepted() }
}
}

View file

@ -0,0 +1,25 @@
import { Button, TimePickerPopup, Date, Palette, Time } from "std-widgets.slint";
import { VLabeledComponent } from "LabeledComponent.slint";
import { VButton } from "Button.slint";
export component VTimePicker inherits VLabeledComponent {
in-out property<Time> time;
in-out property<string> timeDisplay: formatZeroPadding(time.hour) + "h" + formatZeroPadding(time.minute);
pure function formatZeroPadding(number: int) -> string {
if (number < 10) {
return "0\{number}";
}
return number;
}
button := VButton {
text: timeDisplay;
enabled: root.enabled;
clicked => { timePickerPopup.show() }
}
timePickerPopup := TimePickerPopup {
accepted(time) => { root.time = time }
}
}

View file

@ -0,0 +1,35 @@
import { Palette } from "Palette.slint";
import { VText } from "Text.slint";
export component ToggleButton inherits Rectangle {
in property text <=> text-component.text;
in property text-color <=> text-component.color;
in property text-alignment <=> text-component.horizontal-alignment;
callback clicked;
private property<bool> active: false;
background: root.active ? Palette.control-background
: ta.has-hover ? Palette.control-background.transparentize(0.5)
: Colors.transparent;
border-radius: 4px;
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
active = !active;
root.clicked();
}
}
VerticalLayout {
padding: 8px;
padding-top: 4px;
padding-bottom: 4px;
text-component := VText {
horizontal-alignment: center;
}
}
}

View file

@ -0,0 +1,11 @@
export { Palette } from "Palette.slint";
export { VButton } from "Button.slint";
export { VText } from "Text.slint";
export { VCheckBox } from "CheckBox.slint";
export { VDatePicker } from "DatePicker.slint";
export { VTimePicker } from "TimePicker.slint";
export { VLabeledComponent } from "LabeledComponent.slint";
export { VPopupIconMenu } from "PopupIconMenu.slint";
export { VTag } from "Tag.slint";
export { VTextInput } from "TextInput.slint";
export { ToggleButton } from "ToggleButton.slint";