Flex - how to switch to another SWC theme at run time? - apache-flex

My goal is to have more themes for my application and if possible, bundle them with the application itself, not load them at runtime using IStyleManager.loadStyleDeclarations().
Using the theme command-line option, you can have more than one "compile-time theme" bundled with your application according to docs:
theme filename [...] Specifies a list of theme files to use with this application. Theme files can be SWC files with CSS files inside them or CSS files.
However, I wasn't able to find an example how to actually do that (use the += syntax on command line?) and switch between those themes at runtime. What API should I use?

Using the theme command-line option, you can have more than one
"compile-time theme" bundled with your application according to docs:
Yes, You can add additional themes using the += in your command line.
I do exactly this for the Flextras mobile demos; including both the generic Spark theme with the Mobile theme to create the app.
However, both themes will be attempted to be used. I believe the second takes precedence. That means for every class where you want to use the "other theme" you have to specify that theme be used manually. This could get pretty complex very quickly; and you'll have to re-create a lot of spark skins in your application. I've done some work for a client around this who wanted to use our mobile DropDownList in both their normal application and in a mobile application from the same code base. I think the appropriate skin is conditionally applied at runtime using CSS; however we had to create a skin for the "non-mobile use" that explicitly specified the non-mobile skins for the individual elements (Such as the scroll bars)

Related

How to use own icons in Flet

I can't find how to load my own icons in Flet.
I'm testing Flet with the intention of making a desktop app (pure desktop, not Internet needed), but I'm not able to use my own icons to begin with. I can only use the ones that come inside ft.icons, but I'd rather use my own by loading them from a folder similar to /assets/icons. Can I do that? How?
Thanks.
Currently, I don't see a way of doing this; however, you could use the Image class instead.
I would suggest you create an assets folder under your main project folder.
Let's assume you have the following folder structure on your project:
/assets
/icons/my-icon.png
main.py
When you are running your app, you should provide that folder to the initializer in the following way:
flet.app(target=YourApp(), assets_dir="assets")
Then you can access your images there directly and create an Image instance in the following way:
test_image = flet.Image(src="icons/my-icon.png", width=32, height=32, tooltip="Image Tooltip")
You can nest these Image controls inside of anything you want, so you have a lot of flexibility.
The only downside of doing it this way is if you are using light/dark themes on your app. Compared to the Icon class, you will have to specify the light/dark theme versions yourself and update them manually when you are switching your theme.
Here is the official documentation

Qt Virtual Keyboard Custom Style

I need to build a custom Style for a Qt VirtualKeyboard on a small screen to maximize its readability. I have built a custom layout into my project, and using the QT_VIRTUALKEYBOARD_LAYOUT_PATH it works great.
The problem I am having is that the documentation states that the custom style must be placed in the Qt Directory. I need this style to be portable, however, so storing this newly built style on my local machine, rather than in the project itself, will not be acceptable.
Is there any way to build a use a keyboard style within a project?
It doesn't have to be in the Qt directory, just in a directory that is under QtQuick/VirtualKeyboard/Styles/ and in the QML import path.
As an example, take a look at the auto test:
http://code.qt.io/cgit/qt/qtvirtualkeyboard.git/tree/tests/auto/styles/data
You can also put the style in a .qrc file under that folder structure:
http://code.qt.io/cgit/qt/qtvirtualkeyboard.git/tree/src/virtualkeyboard/virtualkeyboardsettings.cpp#n70
I've created a task to make this clearer: https://bugreports.qt.io/browse/QTBUG-66172

Multiple bootstrap themes with webpack

I am building an app with theming requirements that can only be determined at run time. At build time it is possible to have theme variables available for all themes.
Is it possible to get webpack to build node modules - in this case bootstrap - with different variables file? I guess at build time I would want it to build multiple versions/themes of bootstrap. Then at run time I could reference the correct css file based on some prefix.
e.g.
theme1.bootstrap.css
theme2.bootstrap.css
theme3.bootstrap.css
I am using bootstrap 4, with webpack 2.
Is possible with webpack and how can I achieve this?
Definitely. I'm assuming you are determining the themes based on a user profile type system. Take a look at below and add an if statement to look for the variable in sql then simply apply the css. simple. Try creating it and if you run into trouble post the code you have on here and i'm sure someone can help. Add stylesheet to Head using javascript in body script-in-body. also if you aren't using already bootstrap allows for theme file so you can keep the overall style loading and simply apply the color scheme you want so that you only need to load the bulkier script once.
You can use the webpack plugin themes-switch, put all your theme files in a directory, the plugin would compile themes to individual files. Then use function changeTheme to switch themes at runtime.
https://github.com/terence55/themes-switch

Custom Font in SAPUI5 - override entire theme and its controls font with custom font

Is there anyway we can override existing theme and its controls to a custom font?
Problem: I can able to override the global font with my custom font, but I can't override each and every controls font since all the controls have their own Font property assigned rather than inheriting from the global.
Any solution?
UI5 Theming and LESS
UI5 is using LESS internally to enable Theming in a comfortable way. LESS is a CSS Precompiler that extends CSS functionality. The implication and drawback is that the delivered UI5 Themes are precompiled already meaning your application is only using the generated, plain CSS.
UI5 Tooling for Themes
Unfortunately the real UI5 tooling behind it wasn't unveiled to us developers so far. The only tooling they provide is Theme Designer. There even is a on-demand version here. With Theme Designer you should be able to achieve easy styling changes as you are looking for.
Hacking UI5 Themes
But still all the ControlName.css files contained in the Themes ARE the uncompiled less files and you can find all the LESS variables UI5 is using in the library.less file. So with a little bit of hacking you should be able to recompile those LESS files into a new library.css file which is used at runtime. All css files of a library are combined and compiled with library.less into a single file - library.css
So if you want more details and understand what's going on behind the scenes check the library.less files
e.g. http://[host][:port]/[path_to_my_application]/resources/sap/m/themes/sap_bluecrystal/library.less
You will find all the UI5 LESS variables in there. Probably most interesting for you is #sapUiFontFamily.
Anyways I would not recommend to change a lot in here since your styling can break very easily with new UI5 versions!
Are you using the UI Theme Designer to generate the CSS files for your custom theme? If not, you should give it a try. It makes adjustments really easy.
To customize a few or all font families, simply choose the "Expert" settings tab on the right hand side of the designer and filter for "FontFamily". It will then list all the relevant attributes.

master skin file in ASP.NET

My project has multiple themes with different colors.
I need to skin certain textboxes with a specific font/size/etc.[no color difference]
Currently, I add <asp:TextBox SkinID="skinned" runat="server".../> to all .skin files under each theme.
Is there a way to put this textbox skin in one place, like a master skin?
The lack of inheritance or cascading in the ASP.NET Themes implementation is an unfortunate limitation that doesn't receive a lot of attention. In scenarios where you wish to have a global skin available to all themes (without changing the control definition itself), you have two options:
Option #1: Use a VirtualPathProvider
(The downside of this is that you can't use it on precompiled websites without a reflection-based workaround.)
You can define a Global.skin file under a special Global theme where shared skins are kept; you will also create a placeholder Global.skin file under all other themes as well:
App_Themes
- Global
\Global.skin (primary)
- ThemeA
\Global.skin (empty placeholder)
- ThemeB
\Global.skin (empty placeholder)
In the VirtualPathProvider you would then re-route all requests for App_Themes\*\Global.skin to App_Themes\Global\Global.skin.
Option #2: Use a Post-Build Task
This is an amendment to the above solution that avoids the precompiled websites limitation; instead of doing the re-route at runtime, you can apply it post-build via an ms-build task that simply propagates Global\Global.skin to all other theme folders.
I've used both options successfully.
You will need to list it under each theme, but you only need to list one control definition per theme. If you want a skin to be the default behavior for a control, specify the definition without a SkinID property.

Resources