mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-13 16:15:18 +00:00
108 lines
3.5 KiB
Text
108 lines
3.5 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
import { Time, TimePickerBase } from "../common/time-picker-base.slint";
|
|
import { VerticalBox } from "../common/layout.slint";
|
|
import { Button } from "./button.slint";
|
|
import { Palette } from "./std-widgets-impl.slint";
|
|
import { Icons } from "./styling.slint";
|
|
import { StandardButton } from "../common/standardbutton.slint";
|
|
|
|
export { Time }
|
|
|
|
export component TimePickerPopup inherits PopupWindow {
|
|
in property <bool> use-24-hour-format <=> base.use-24-hour-format;
|
|
in property <string> title: "Select time";
|
|
in property <Time> time <=> base.time;
|
|
|
|
callback canceled();
|
|
callback accepted(/* current-time */ Time);
|
|
|
|
close-policy: PopupClosePolicy.no-auto-close;
|
|
|
|
background-layer := Rectangle {
|
|
width: dialog.width;
|
|
height: dialog.height;
|
|
border-radius: 8px;
|
|
background: Palette.control-background;
|
|
}
|
|
|
|
dialog := Dialog {
|
|
padding: 8px;
|
|
|
|
base := TimePickerBase {
|
|
title: root.title;
|
|
style: {
|
|
foreground: Palette.foreground,
|
|
vertical-spacing: 8px,
|
|
horizontal-spacing: 4px,
|
|
clock-style: {
|
|
background: Palette.alternate-background,
|
|
foreground: Palette.accent-background,
|
|
time-selector-style: {
|
|
foreground: Palette.foreground,
|
|
foreground-selected: Palette.accent-foreground,
|
|
font-size: 12 * 0.0625rem,
|
|
font-weight: 400
|
|
}
|
|
},
|
|
input-style: {
|
|
background: Palette.alternate-background,
|
|
background-selected: Palette.accent-background,
|
|
foreground: Palette.foreground,
|
|
foreground-selected: Palette.foreground,
|
|
border-radius: 8px,
|
|
font-size: 57 * 0.0625rem,
|
|
font-weight: 400
|
|
},
|
|
period-selector-style: {
|
|
border-radius: 8px,
|
|
border-width: 1px,
|
|
border-brush: Palette.border,
|
|
item-style: {
|
|
font-size: 14 * 0.0625rem,
|
|
font-weight: 400,
|
|
foreground: Palette.foreground,
|
|
background-selected: Palette.accent-background,
|
|
foreground-selected: Palette.accent-foreground
|
|
}
|
|
},
|
|
title-style: {
|
|
font-size: 12 * 0.0625rem,
|
|
font-weight: 300,
|
|
foreground: Palette.foreground,
|
|
},
|
|
};
|
|
}
|
|
|
|
Button {
|
|
icon: base.selection-mode ? Icons.keyboard : Icons.clock;
|
|
colorize-icon: true;
|
|
accessible-label: "Toggle input picker";
|
|
dialog-button-role: action;
|
|
|
|
clicked => {
|
|
base.selection-mode = !base.selection-mode;
|
|
}
|
|
}
|
|
|
|
StandardButton {
|
|
kind: cancel;
|
|
|
|
clicked => {
|
|
root.close();
|
|
root.canceled();
|
|
}
|
|
}
|
|
|
|
StandardButton {
|
|
enabled: base.ok-enabled();
|
|
kind: ok;
|
|
|
|
clicked => {
|
|
root.close();
|
|
root.accepted(base.get-current-time());
|
|
}
|
|
}
|
|
}
|
|
}
|