Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the printerdemo and printerdemo_mcu PrinterQueueItem compatible with each other #7190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demos/printerdemo_mcu/esp-idf/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern "C" void app_main(void)
char time_buf[100] = { 0 };
std::strftime(time_buf, sizeof(time_buf), "%H:%M:%S %d/%m/%Y", std::localtime(&now));
PrinterQueueItem item;
item.status = JobStatus::Waiting;
item.status = "waiting";
item.progress = 0;
item.title = std::move(name);
item.owner = "[email protected]";
Expand All @@ -94,7 +94,7 @@ extern "C" void app_main(void)
if (top_item.progress > 100) {
printer_queue->erase(0);
} else {
top_item.status = JobStatus::Printing;
top_item.status = "printing";
printer_queue->set_row_data(0, top_item);
}
}
Expand Down
4 changes: 2 additions & 2 deletions demos/printerdemo_mcu/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct PrinterQueueData {
impl PrinterQueueData {
fn push_job(&self, title: slint::SharedString) {
self.data.push(PrinterQueueItem {
status: JobStatus::Waiting,
status: "waiting".into(),
progress: 0,
title,
owner: env!("CARGO_PKG_AUTHORS").into(),
Expand Down Expand Up @@ -78,7 +78,7 @@ fn main() -> ! {
if printer_queue.data.row_count() > 0 {
let mut top_item = printer_queue.data.row_data(0).unwrap();
top_item.progress += 1;
top_item.status = JobStatus::Printing;
top_item.status = "printing".into();
if top_item.progress > 100 {
printer_queue.data.remove(0);
if printer_queue.data.row_count() == 0 {
Expand Down
21 changes: 8 additions & 13 deletions demos/printerdemo_mcu/ui/printer_queue.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@

import { DemoPalette, PushButton } from "./common.slint";

enum JobStatus {
Waiting,
Printing
}

export struct PrinterQueueItem {
status: JobStatus,
status: string,
progress: int,
title: string,
owner: string,
Expand All @@ -20,19 +15,19 @@ export struct PrinterQueueItem {

export global PrinterQueue {
in property <[PrinterQueueItem]> printer-queue: [
{ status: JobStatus.Printing, progress: 63, title: "Slint-Demo.jpeg", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
{ status: JobStatus.Waiting, title: "Adressliste.docx", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
{ status: JobStatus.Waiting, title: "210106-FinalPresentation.pdf", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
{ status: "printing", progress: 63, title: "Slint-Demo.jpeg", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
{ status: "waiting", title: "Adressliste.docx", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
{ status: "waiting", title: "210106-FinalPresentation.pdf", owner: "[email protected]", pages: 6, size: "143kb", submission-date: "11:41 25/01/21" },
];

callback start-job(string);
callback cancel-job(int);
callback pause-job(int);

public pure function statusString(status: JobStatus) -> string {
if (status == JobStatus.Printing) {
public pure function statusString(status: string) -> string {
if (status == "printing") {
"PRINTING"
} else if (status == JobStatus.Waiting) {
} else if (status == "waiting") {
"WAITING..."
} else {
"Unknown job status"
Expand Down Expand Up @@ -186,7 +181,7 @@ component NarrowPrintQueueElement inherits Rectangle {
Text {
// TODO: text-transform: uppercase
text: {
if (root.queue-item.status == JobStatus.Printing) {
if (root.queue-item.status == "printing") {
"\{root.queue-item.progress}% - \{PrinterQueue.statusString(root.queue-item.status)}"
} else {
PrinterQueue.statusString(root.queue-item.status)
Expand Down
Loading