ApplicationWindow

Search for usage in LXR

ApplicationWindow Class Reference
Inheritance diagram for ApplicationWindow:

Public Member Functions

void about ()
 
void setAndroidStatusBarColor ()
 

Detailed Description

A window that provides some basic features needed for most applications.

This controls inherits from QQC2 Window, to checkout its inherited properties refer to the Qt Docs.

The ApplicationWindow is the best component to start creating a new MauiKit application. It's usually used as the root QML component for the application. It is different from the QQC2 alternative, as this one does not include a header or footer section, and does not have either a menu-bar. For a header and footer section use a MauiKit Page, and for the menu-bar alternative, use a MauiKit ToolButtonMenu.

Warning
By default the window is completely empty (and transparent since it doesn't have any container's background) - and if used with CSD (Client Side Decorations) enabled, not window controls are visible. See the example below on how to fill the application window.

Commonly, this is paired with another child container control, such as a Page, an AppViews or a SideBarView, to name a few MauiKit controls; or with any other QQC2 element, such as a StackView, SwipeView, etc..

See also
Page
AppViews
SideBarView
TabView
PageLayout
{
id: root
Page
{
anchors.fill: parent
Maui.Controls.showCSD: true
}
}
A window that provides some basic features needed for most applications.
ApplicationWindow filled with a Page and the CSD controls enabled

Client Side Decorations

Note
Client-side decorations refers to an application window that takes care of drawing its own window borders, shadows, and the window control buttons - and also provides the resizing and moving/dragging functionality.

The application window can make use of client side decorations (CSD) by setting the attached property Maui.CSD.enabled: true in the root element just once, or globally by making use of MauiMan configuration options - that said, even if the system is configured to use CSD globally, you can override this property in your application, to force to use CSD (or not).

See also
MauiMan
Note
The alternative is to use the server side decorations (SSD).

When using CSD, the ApplicationWindow will take care of drawing the window borders, the shadow and masking its content to support the border rounded corners.

The radius of the corners is configured via MauiMan. To know more about how to configure it from a user level take a look at MauiMan documentation. This property can not be overridden by the application itself.

If used with a Page, you can easily enable the CSD window buttons using the attached property Maui.Controls.showCSD, this will make the window-control-buttons visible. A few other MauiKit controls support this property, such as the TabView, ToolBar, AppViews, AltBrowser and TabView, and any other control that inherits from Page.

See also
Controls

If a custom control is to be used instead, and CSD is still enabled, you can place the window control buttons manually, by using the WindowControls component.

See also
WindowControlsLinux
{
id: root
QQC2.Page
{
anchors.fill: parent
WindowControls
{
anchors.top: parent.top
anchors.right: parent.right
}
}
}

Built-in Functionality

About Dialog

The Application window has some components already built-in, such as an about dialog, which can be invoked using the function about().

See also
about

The information presented in the dialog is taken from the data set with KAboutData at the application entry point. There is an example on how to set the information in the code snippet below.

Some extra information can be added via the MauiApp singleton instance, such as more links.

About dialog with information provided by the app

Toast Area - Notifications

The ApplicationWindow also includes an overlay layer for displaying inline notifications, which can be dispatched by using the function notify(). The notifications sent can be interactive.

See also
notify
Note
If you want to use the system notifications instead, take a look at the Notify object class, and the docs on how to configure the needed steps to set it up.
See also
Notify
Inline notifications in the toast area

Notes

By default the window geometry is saved and restored automatically.

In order for the style and other functionality to work correctly the MauiApp singleton instance must have been initialize before the ApplicationWindow is created. This is usually done on the main entry point of the application.

See also
MauiApp

It is important to notice that some of the application information needs to be provided beforehand as well, using the KAboutData methods, this way the built-in about dialog can pick up all the relevant information.

See also
KAboutData
#include <MauiKit4/Core/mauiapp.h>
#include <KAboutData>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
app.setOrganizationName(QStringLiteral("Maui"));
app.setWindowIcon(QIcon(":/assets/mauidemo.svg"));
KAboutData about(QStringLiteral("mauidemo"),
i18n("Maui Demo"),
"3.0.0",
i18n("MauiKit Qt6 Demo."),
KAboutLicense::LGPL_V3); //here you can set information about the application, which will be fetched by the about dialog.
about.addAuthor(i18n("Camilo Higuita"), i18n("Developer"), QStringLiteral("milo.h@aol.com"));
about.setHomepage("https://mauikit.org");
about.setProductName("maui/index");
about.setBugAddress("https://invent.kde.org/maui/index-fm/-/issues");
about.setOrganizationDomain("org.qt6.tst");
about.setProgramLogo(app.windowIcon());
about.addComponent("KIO");
MauiApp::instance()->setIconName("qrc:/assets/mauidemo.svg"); // this not only sets the path to the icon file asset, but also takes care of initializing the MauiApp singleton instance.
const QUrl url(u"qrc:/qt/qml/MauiDemo4/main.qml"_qs);
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
engine.load(url);
return app.exec();
}
void about()
Invokes the about dialog with information of the application.
static void setApplicationData(const KAboutData &aboutData)
void setIconName(const QString &value)
Set the file URL to the application icon.
Definition mauiapp.cpp:95
static MauiApp * instance()
Retrieves the single instance of MauiApp.
Definition mauiapp.cpp:144
QString i18n(const char *text, const TYPE &arg...)
void exit(int returnCode)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void load(const QString &filePath)
void objectCreated(QObject *object, const QUrl &url)
QueuedConnection

Styling

The ApplicationWindow style - as other MauiKit controls - can be tweaked, for example its color scheme: from dark to light variant, but also true-black, high-contrast, and an adaptive style which picks colors from an image source, such as a wallpaper. The available options are:

The accent color can also be changed easily to distinguish the app own branding, by using the Style.accentColor property once.

See also
Style::accentColor
Warning
When mixing Kirigami components with MauiKit controls, it is best to set the style type to the Maui.Style.Auto option (which value is 3), for it to correctly pick up the same color-scheme Kirigami uses - since Kirigami uses another methods for setting the color palette. The option can be set using Maui.Style.styleType: Maui.Style.Auto. With this set Maui will pickup the colors from the Plasma color scheme.
See also
Style
{
id: root
Maui.Style.styleType: 1 // 0-light, 1-dark, 2-adaptive, 3-auto etc
Maui.Style.accentColor: "pink"
Page
{
anchors.fill: parent
Maui.Controls.showCSD: true
}
}
All the different color styles available

You can check out our quick tutorial on creating a simple Maui application here:

External file

Minimal Example

The most basic use case is to use a Page inside of the ApplicationWindow as shown below.

{
id: root
Page
{
anchors.fill: parent
Maui.Controls.showCSD: true
}
}

You can find a more complete example at this link.

Definition at line 225 of file ApplicationWindow.qml.

Member Function Documentation

◆ about()

void ApplicationWindow::about ( )

Invokes the about dialog with information of the application.

This information is taken from KAboutData and MauiApp singleton instance.

Note
This method can be invoked for the main root ApplicationWindow using the Maui.App.aboutDialog() attached property method.

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:47:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.