trying to convert whole qml file into slint file. (added def h and w) #32

Closed
sohrab wants to merge 2 commits from github/fork/axscell/main into main
7 changed files with 4888 additions and 29 deletions

5
.gitignore vendored
View file

@ -52,3 +52,8 @@ compile_commands.json
*creator.user*
*_qmlcache.qrc
# Added by cargo
/target

4796
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

14
Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "parch-welcome"
version = "0.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
slint = "1.4"
[build-dependencies]
slint-build = "1.4"

3
build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
slint_build::compile("ui/appwindow.slint").unwrap();
}

View file

@ -1,29 +0,0 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QResource>
#include <QQmlContext>
#include <QObject>
#include <QQuickItem>
#include <QQuickView>
#include <QProcess>
#include "processhandler.h" // Include the ProcessHandler class header
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
// Register the ProcessHandler class with the QML engine
qmlRegisterType<ProcessHandler>("com.parch", 1, 0, "ProcessHandler");
// Load the QML content from the resource
QResource::registerResource(":/resources.rcc");
// Load the QML file
engine.load(QUrl("qrc:/ParchLinux.qml"));
// Set App Icon
app.setWindowIcon(QIcon("icon.png"));
return app.exec();
}

46
src/main.rs Normal file
View file

@ -0,0 +1,46 @@
// #include <QGuiApplication>
// #include <QQmlApplicationEngine>
// #include <QResource>
// #include <QQmlContext>
// #include <QObject>
// #include <QQuickItem>
// #include <QQuickView>
// #include <QProcess>
// #include "processhandler.h" // Include the ProcessHandler class header
// int main(int argc, char *argv[])
// {
// QGuiApplication app(argc, argv);
// QQmlApplicationEngine engine;
// // Register the ProcessHandler class with the QML engine
// qmlRegisterType<ProcessHandler>("com.parch", 1, 0, "ProcessHandler");
// // Load the QML content from the resource
// QResource::registerResource(":/resources.rcc");
// // Load the QML file
// engine.load(QUrl("qrc:/ParchLinux.qml"));
// // Set App Icon
// app.setWindowIcon(QIcon("icon.png"));
// return app.exec();
// }
slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
let ui = AppWindow::new()?;
ui.on_request_increase_value({
let ui_handle = ui.as_weak();
move || {
let ui = ui_handle.unwrap();
ui.set_counter(ui.get_counter() + 1);
}
});
ui.run()
}

24
ui/ParchLinux.slint Normal file
View file

@ -0,0 +1,24 @@
import { Button, VerticalBox } from "std-widgets.slint";
export component AppWindow inherits Window {
in-out property<int> counter: 42;
callback request-increase-value();
in property <float> default-width: 900;
in property<float> defualt-height: 500;
// window().set_fullscreen();
// width: (self.fullScreen - self.width) / 2; // Center the window horizontally
// height: (self.fullScreen - self.height) / 2; // Center the window vertically
VerticalBox {
Text {
text: "Counter: \{root.counter}";
}
Button {
text: "Increase value";
clicked => {
root.request-increase-value();
}
}
}
}