slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Change default style on windows and mac #3431

Closed ogoffart closed 11 months ago

ogoffart commented 1 year ago
  1. Rename "native" style to "qt" (#3514)
  2. always default to "native" which would be an alias to:
    • "fluent" on windows
    • "cupertino" on mac
    • "qt" on linux if the backend is there, "fluent" otherwise
    • "material" "fluent" on wasm
    • "material" on android
  3. Change the backend selector Cargo.toml to disable qt as the default backend on win and mac (but how?)
ogoffart commented 1 year ago

For 2. the current detection of whether the Qt is done:

The problem is that i-slint-compiler doesn't depend on the runtime (obviously) so it is a bit hard to do all in one place. But under the new system i was thinking we could read SLINT_DEFAULT_STYLE (which we could rename to something else) to resolve the "native" alias around https://github.com/slint-ui/slint/blob/master/internal/compiler/typeloader.rs#L101 that would help with rust and the interpreter, but not with C++ as the compiler and the runtime are build in different targets. We'd need a way to tell the compiler what features are enabled.

tronical commented 1 year ago

Can you elaborate what information exactly the compiler needs in the C++ case that it currently doesn't have access to?

Currently, in C++ we pass --style ${_SLINT_STYLE} to the compiler.

ogoffart commented 1 year ago

After talking about it, we decided to go with fluent on wasm because it looks better than material.

Currently, in C++ we pass --style ${_SLINT_STYLE} to the compiler

Yes, the point is that I'd like the default style selection (what "native" alias to) not to be in the CMakeLists.txt anymore. But in a central place in the compiler. We still need the information whether the Qt style is available though.

Change the backend selector Cargo.toml to disable qt as the default backend on win and mac

We would need to find a way to have a feature enabled by default only in some targets

kekeimiku commented 1 year ago

It would be great if you could use native theme styles without relying on Qt.

ogoffart commented 1 year ago

It would be great if you could use native theme styles without relying on Qt.

That's the idea, on all platform but Linux. Only on Linux we'll keep using the Qt style as a native style because Qt is native there (at least on KDE Plasma). If someone wants to write a GTK style, or an adwaita style ( https://github.com/slint-ui/slint/issues/2566 ) we could also use that.

circlePulse commented 3 months ago

Does anyone happen to know how you can manually change the style in your app? For example, if I want to use Material style everywhere, even on MacOS and Windows? (Hopefully it's okay to ask that here)

ogoffart commented 3 months ago

@circlePulse This should be explained there: https://releases.slint.dev/1.6.0/docs/slint/src/advanced/style#selecting-a-widget-style-with-rust

(It's okay to ask here, but the best is to use the GitHub discussions for questions)