Make it possible to exit the printer demo

... by clicking on the power button :-)

Calling exit is a big rough, but simplest and fastest for now.
This commit is contained in:
Simon Hausmann 2020-10-07 15:52:49 +02:00
parent a84fa68537
commit d771143f68
3 changed files with 19 additions and 4 deletions

View file

@ -9,7 +9,6 @@
LICENSE END */
#include "printerdemo.h"
struct InkLevelModel : sixtyfps::Model<InkLevel>
{
int row_count() const override { return m_data.size(); }
@ -25,5 +24,6 @@ int main()
{
static MainWindow printer_demo;
printer_demo.set_ink_levels(std::make_shared<InkLevelModel>());
printer_demo.on_quit([]() { ::exit(0); });
printer_demo.run();
}

View file

@ -28,5 +28,9 @@ pub fn main() {
InkLevel { color: sixtyfps::Color::from_rgb_u8(0, 0, 0), level: 0.80 },
]));
main_window.as_ref().on_quit(move || {
std::process::exit(0);
});
main_window.run();
}

View file

@ -229,6 +229,7 @@ SettingsPage := Page {
TopPanel := Rectangle {
property<int> active_page: 0;
signal quit();
color: white;
@ -255,6 +256,14 @@ TopPanel := Rectangle {
source: img!"images/power.png";
width: root.width / 20;
height: root.width / 20;
TouchArea {
width: parent.width;
height: parent.height;
clicked => {
root.quit();
}
}
}
}
@ -264,6 +273,7 @@ export InkLevel := {
}
MainWindow := Window {
signal quit();
width: 800lx;
height: 600lx;
@ -283,6 +293,7 @@ MainWindow := Window {
active_page: root.active_page;
width: root.width;
height: root.width / 20 + 10lx;
quit => { root.quit(); }
}
for page_info[idx] in [