/* LICENSE BEGIN This file is part of the SixtyFPS Project -- https://sixtyfps.io Copyright (c) 2020 Olivier Goffart Copyright (c) 2020 Simon Hausmann SPDX-License-Identifier: GPL-3.0-only This file is also available under commercial licensing terms. Please contact info@sixtyfps.io for more information. LICENSE END */ import { DemoPalette, PrinterQueueItem, PushButton } from "./common.60"; PrintQueueDetailsLabel := Text { font-weight: 500; color: DemoPalette.control_foreground; horizontal-stretch: 0; font-size: DemoPalette.base_font_size * 0.9375; } PrintQueueSeparator := Rectangle { height: 1px; border-width: 1px; border-color: #BDC0D1; horizontal-stretch: 2; } PrintDetails := GridLayout { property queue_item; spacing: 3px; Row { PrintQueueDetailsLabel { text: "Owner"; } Text { text: queue_item.owner; color: DemoPalette.secondary_foreground_color; overflow: elide; horizontal-stretch: 1; font-size: DemoPalette.base_font_size * 0.9375; } } Row { PrintQueueSeparator { colspan: 2; } } Row { PrintQueueDetailsLabel { text: "Pages"; } Text { text: queue_item.pages; color: DemoPalette.secondary_foreground_color; overflow: elide; horizontal-stretch: 1; font-size: DemoPalette.base_font_size * 0.9375; } } Row { PrintQueueSeparator { colspan: 2; } } Row { PrintQueueDetailsLabel { text: "Size"; } Text { text: queue_item.pages; color: DemoPalette.secondary_foreground_color; overflow: elide; horizontal-stretch: 1; font-size: DemoPalette.base_font_size * 0.9375; } } Row { PrintQueueSeparator { colspan: 2; } } Row { PrintQueueDetailsLabel { text: "Submitted"; } Text { text: queue_item.submission_date; color: DemoPalette.secondary_foreground_color; overflow: elide; horizontal-stretch: 1; font-size: DemoPalette.base_font_size * 0.9375; } } } NarrowPrintQueueElement := Rectangle { property queue_item; callback show_job_details(); border-color: DemoPalette.control_outline_color; border-radius: 14px; border-width: 2px; background: DemoPalette.printer_queue_item_background_color; clip: true; property expanded; property expanded_opacity: 0; height: always_visible.minimum-height + layout.padding * 2; states [ expanded when expanded : { height: layout.minimum-height; expanded_opacity: 1; } ] transitions [ in expanded : { animate height { duration: 200ms; easing: ease; } animate expanded_opacity { duration: 200ms; } } out expanded : { animate height { duration: 200ms; easing: ease; } animate expanded_opacity { duration: 200ms; } } ] TouchArea { clicked => { expanded = !expanded; } } Rectangle { height: 100%; layout := VerticalLayout { padding: root.border_radius; spacing: 4px; alignment: start; always_visible := VerticalLayout { padding: 0; spacing: parent.spacing; Text { // TODO: text-transform: uppercase text: { if (queue_item.status == "PRINTING") { "\{queue_item.progress}% - \{queue_item.status}" } else { queue_item.status } } color: DemoPalette.status_label_text_color; font-size: DemoPalette.base_font_size * 0.75; font-weight: 800; letter-spacing: 1.56px; } Text { text: queue_item.title; overflow: elide; color: DemoPalette.text_foreground_color; font-weight: 800; font-size: DemoPalette.base_font_size * 1.125; } } if (expanded || expanded_opacity > 0) : PrintDetails { padding: 0px; padding-bottom: root.border-radius / 2; queue_item: root.queue_item; opacity: expanded_opacity; } if (expanded || expanded_opacity > 0) : HorizontalLayout { Rectangle { horizontal-stretch: 0; width: 10%; } PushButton { opacity: expanded_opacity; text: "More "; clicked => { root.show_job_details(); } } Rectangle { horizontal-stretch: 0; width: 10%; } } } } } NarrowPrinterQueueList := Flickable { callback show_job_details(int); property <[PrinterQueueItem]> printer_queue; VerticalLayout { alignment: start; padding: 0px; spacing: 13.5px; for queue_item[idx] in root.printer_queue: NarrowPrintQueueElement { width: root.width; queue_item: queue_item; show_job_details => { root.show_job_details(idx) } } } } ProgressBar := Rectangle { property progress; // FIXME: The intermediate rectangle is needed to allow the surrounding // layout to freely resize the progress bar without affecting the design-intended // height of 6px. The alternative of specifying a `maximum-height: 6px` will unfortunately // also affect the width calculation and make it vanish altogether. Rectangle { y: parent.height / 2 - 3px; height: 6px; border-radius: 3px; background: DemoPalette.neutral_box; Rectangle { width: max(6px, progress * parent.width / 100); border-radius: parent.border-radius; background: DemoPalette.control_foreground; } } } WidePrintQueueElement := Rectangle { callback cancel_job(); callback pause_job(); property queue_item; border-color: DemoPalette.neutral_box; border-radius: 14px; border-width: 2px; background: DemoPalette.printer_queue_item_background_color; HorizontalLayout { padding: parent.border_radius; spacing: 0px; VerticalLayout { padding: 0px; spacing: 0px; HorizontalLayout { Text { // TODO: text-transform: uppercase text: { if (queue_item.status == "PRINTING") { "\{queue_item.progress}% - \{queue_item.status}" } else { queue_item.status } } color: DemoPalette.status_label_text_color; font-size: DemoPalette.base_font_size * 0.75; font-weight: 700; letter-spacing: 1.56px; horizontal-stretch: 1; } ProgressBar { // Each progress bar should have the same size // In principle it should be the smaller size which would fit next to the text foe each entry // But since it is too hard to compute, just hardcode that for now width: 50%; // 164px; progress: queue_item.progress; } } Text { text: queue_item.title; color: DemoPalette.text_foreground_color; overflow: elide; font-weight: 700; font-size: DemoPalette.base_font_size * 1.125; horizontal-stretch: 1; } Rectangle {} HorizontalLayout { spacing: 14px; padding: 0px; horizontal-stretch: 1; vertical-stretch: 0; PushButton { text: "Pause"; icon: @image-url("images/pause.svg"); clicked => { pause_job(); } } PushButton { primary: false; text: "Delete"; icon: @image-url("images/delete.svg"); clicked => { cancel_job(); } } } } Rectangle { width: 10%; } PrintDetails { padding: 0px; padding-bottom: root.border-radius / 2; queue_item: root.queue_item; } } } export WidePrinterQueueList := Flickable { callback cancel_job(int); callback pause_job(int); property <[PrinterQueueItem]> printer_queue; VerticalLayout { alignment: start; padding: 0px; spacing: 13.5px; for queue_item[idx] in root.printer_queue: WidePrintQueueElement { queue_item: queue_item; cancel_job => { root.cancel_job(idx) } pause_job => { root.pause_job(idx) } } } } export PrinterQueue := Rectangle { property <[PrinterQueueItem]> printer_queue <=> queue_list.printer_queue; callback show_job_details(int); border-radius: 27px; background: DemoPalette.night_mode ? DemoPalette.printer_action_background_color : #F4F6FF; VerticalLayout { padding: 16px; spacing: 16px; Text { text: "Printing-Queue"; color: DemoPalette.text_foreground_color; font-size: DemoPalette.base_font_size * 1.5; font-weight: 700; } queue_list := NarrowPrinterQueueList { width: root.width - 2*parent.padding; // FIXME why do we need this? bug in layout? show_job_details(idx) => { root.show_job_details(idx) } } } }