Logo FluentUI

Tools QML Type

A singleton utility type providing cross-platform system tools. More...

Import Statement: import FluentUI.impl 1.0

Properties

Methods

Detailed Description

Tools offers a collection of helper functions for common tasks such as clipboard access, file I/O, color manipulation, cursor control, desktop capture, and system version detection. It is registered as a QML singleton and can be used anywhere within FluentUI applications.

Usage Example

 import QtQuick
 import FluentUI.impl

 Item {
     Component.onCompleted: {
         // Copy text to clipboard
         Tools.clipText("Hello, FluentUI!")

         // Read file content
         var content = Tools.readFile("/path/to/file.txt")

         // Check OS version
         if (Tools.isWindows11OrGreater()) {
             console.log("Running on Windows 11 or later")
         }
     }
 }

Property Documentation

systemDark : bool

Returns true if the system is currently in dark mode, false otherwise. This property is read-only.

windowIcon : url

The URL of the application window icon. Setting this property changes the window icon for the application.

Method Documentation

image captureDesktop()

Captures a screenshot of the entire desktop and returns it as a QImage. This can be used to implement desktop capture or screenshot functionality.

See also DesktopCaptureItem.

void clipText(string text)

Copies the specified text to the system clipboard.

int cursorScreenIndex()

Returns the index of the screen where the cursor is currently located. This is useful for multi-monitor setups.

void deleteLater(object object)

Schedules the given QML object for safe deletion. This is equivalent to calling QObject::deleteLater() from C++.

bool isUrl(string url)

Returns true if the given url string is a valid URL, false otherwise.

bool isWindows11OrGreater()

Returns true if the application is running on Windows 11 or a later version of Windows. On other platforms, this returns false.

string readFile(string fileName)

Reads the contents of the file at fileName and returns them as a string. Returns an empty string if the file cannot be read.

See also writeFile().

void restoreOverrideCursor()

Restores the previously overridden cursor shape to its default.

See also setOverrideCursor().

void setOverrideCursor(enumeration shape)

Overrides the application cursor shape with the given shape. Valid values correspond to Qt.CursorShape enumerations.

See also restoreOverrideCursor().

color withOpacity(color baseColor, real alpha)

Returns a new color derived from baseColor with the specified alpha opacity. The alpha value should be between 0.0 (fully transparent) and 1.0 (fully opaque).

See also Qt.rgba().

bool writeFile(string fileName, string content)

Writes content to the file at fileName. Returns true on success, false if the file could not be written.

See also readFile().