Loading files
import { Button } from "button.slint";
import { Data } from "../api.slint";
export enum Arrow {
none,
left,
}
export component MessagePopup inherits PopupWindow {
in property <string> title;
in property <bool> has-ok: true;
in property <bool> has-yes: false;
in property <bool> has-cancel: true;
in property <Arrow> arrow: none;
in property <color> background: Data.theme.tooltip;
in property <color> border-color: self.header-color;
in property <color> header-color: Data.theme.base-text;
in property <color> header-text-color: Data.theme.base;
in property <color> text-color: Data.theme.tooltip-text;
property <length> border-radius: 10px;
property <length> arrow-size: 12px;
width: r.preferred-width + ((arrow == Arrow.left) ? arrow-size : 0);
height: r.preferred-height;
forward-focus: fs;
callback accepted;
callback rejected;
fs := FocusScope {
r := Rectangle {
x: (arrow == Arrow.left) ? arrow-size : 0;
width: self.preferred-width;
background: background;
border-color: border-color;
border-width: (border-color == Colors.transparent) ? 0 : 1px;
border-radius: border-radius;
VerticalLayout {
Rectangle {
height: title-txt.preferred-height + 8px;
background: header-color;
border-color: border-color;
border-width: (border-color == Colors.transparent) ? 0 : 1px;
border-top-left-radius: border-radius;
border-top-right-radius: border-radius;
title-txt := Text {
x: border-radius;
vertical-alignment: center;
font-weight: 700;
font-size: 13px;
color: header-text-color;
text: title;
}
}
VerticalLayout {
padding: 10px;
spacing: 10px;
@children
HorizontalLayout {
alignment: (arrow == Arrow.left) ? start : center;
spacing: 8px;
if has-ok: Button {
text: @tr("OK");
primary: true;
clicked => {
accepted();
}
}
if has-yes: Button {
text: @tr("Yes");
primary: true;
clicked => {
accepted();
}
}
Button {
text: @tr("Cancel");
clicked => {
rejected();
}
}
}
}
}
}
key-pressed(event) => {
if event.text == Key.Return {
accepted();
return accept;
}
reject
}
}
if arrow == Arrow.left: Rectangle {
x: 0;
width: arrow-size + 1px;
Path {
commands: "M 100 80 L 0 0 L 100 -80 Z";
fill: border-color;
}
}
}
0e185510cThis file is pinned to the selected release. Download the original to open it in your design tool.