mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-14 09:45:41 +00:00
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:
parent
a84fa68537
commit
d771143f68
3 changed files with 19 additions and 4 deletions
|
|
@ -9,21 +9,21 @@
|
|||
LICENSE END */
|
||||
#include "printerdemo.h"
|
||||
|
||||
|
||||
struct InkLevelModel : sixtyfps::Model<InkLevel>
|
||||
{
|
||||
int row_count() const override { return m_data.size(); }
|
||||
InkLevel row_data(int i) const override { return m_data[i]; }
|
||||
|
||||
std::vector<InkLevel> m_data = { { sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8 },
|
||||
{ sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1 } };
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
static MainWindow printer_demo;
|
||||
printer_demo.set_ink_levels(std::make_shared<InkLevelModel>());
|
||||
printer_demo.on_quit([]() { ::exit(0); });
|
||||
printer_demo.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue