Some time ago I wrote several articles about using the QtWinExtras library, which opens access to special features that are available only for Windows. Now I want to say a few words about how to repeat, too, using QML. For this we need to create a Qt Quick project, connect the winextras module in the project
import QtWinExtras 1.0
And use 3 objects: TaskbarButton to create a progress bar and manage it, ThumbnailToolBar for work with buttons on the pop-up window of the taskbar and JumpList (for working with jumpList). Also add FileDialog for the full work of jumpList.
For TaskbarButton, you need to set the id properties (to access this object from outside), progress.visible: true. Additionally, you can set the overlay.iconSource icon.
In ThumbnailToolBar we create the ThumbnailToolButton (from one to seven) buttons, set the icons and write the click processing.
In JumpList, the recent section is visible to show the last opened files and frequent to display frequently opened files.
JumpList { id: jumpList recent.visible: true frequent.visible: true }
Do not forget that the file extensions that fall into the jumpList must be registered in the registry. Therefore, add the function associateFileTypes () to the main file, as shown in the previous article. .
Another curious possibility is the setting of the transparency of the window. To do this, you need the DwmFeatures object. Its blurBehindEnabled property makes the window transparent if its value is true. If you set it to false, the background color becomes black. I also note that the transparency can be set using the opacity property of the Window object. It differs from blurBehindEnabled in that the latter can have only 2 states (transparent and opaque) and makes only the main part of the window transparent (without widgets placed on it), while opacity sets the degree of transparency and makes the whole window transparent with all the widgets And a frame. Another 4 leftGlassMargin, rightGlassMargin, topGlassMargin, and bottomGlassMargin properties are responsible for the size of the extra margin from the left, right, top, and bottom side of the window, respectively. Indentation values are specified in pixels. The default values are 0. I do not see the application application in these properties, but I wrote about them for completeness.
Main.qml
import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 2.0 import QtQuick.Dialogs 1.0 import QtWinExtras 1.0 Window { visible: true width: 640 height: 480 title: qsTr("Hello WinExtras") DwmFeatures { id: dwmFeatures blurBehindEnabled: true leftGlassMargin : 10 rightGlassMargin : 10 topGlassMargin : 10 bottomGlassMargin : 10 excludedFromPeek : false peekDisallowed : false flip3DPolicy: QtWin.FlipExcludeBelow } Button{ x:100 y:200 width:200 height: 100 text: "button" } TaskbarButton { id: taskbarButton //overlay.iconSource: "loading.png" overlay.accessibleDescription: "Loading" progress.visible: true progress.value: 50 } ThumbnailToolBar { ThumbnailToolButton { iconSource: "r.png"; tooltip: "Next"; onClicked: taskbarButton.progress.value = taskbarButton.progress.value+1 } ThumbnailToolButton { iconSource: "l.png"; tooltip: "Prep"; onClicked: taskbarButton.progress.value = taskbarButton.progress.value-1 } ThumbnailToolButton { iconSource: "pause.png"; tooltip: "Pause"; onClicked: taskbarButton.progress.setPaused(!taskbarButton.progress.paused) } ThumbnailToolButton { interactive: false; flat: true } ThumbnailToolButton { iconSource: "open.png"; tooltip: "OpenFile"; onClicked: fileDialog.open()} ThumbnailToolButton { iconSource: "exit.png"; tooltip: "Open"; onClicked: Qt.quit() } } JumpList { id: jumpList recent.visible: true frequent.visible: true //tasks.visible: true } FileDialog { id: fileDialog selectFolder: true title: "Please choose a file" folder: shortcuts.home onAccepted: { console.log("You chose: " + fileDialog.fileUrls) } } }
Main.cpp
clude <QFileInfo> #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QDir> #include <QSettings> static void associateFileTypes(const QStringList &fileTypes) { QString displayName = QGuiApplication::applicationDisplayName(); QString filePath = QCoreApplication::applicationFilePath(); QString fileName = QFileInfo(filePath).fileName(); //qDebug() << displayName << filePath << fileName; QSettings settings("HKEY_CURRENT_USER\\Software\\Classes\\Applications\\" + fileName, QSettings::NativeFormat); settings.setValue("FriendlyAppName", displayName); settings.beginGroup("SupportedTypes"); foreach (const QString& fileType, fileTypes) settings.setValue(fileType, QString()); settings.endGroup(); settings.beginGroup("shell"); settings.beginGroup("open"); settings.setValue("FriendlyAppName", displayName); settings.beginGroup("Command"); settings.setValue(".", QChar('"') + QDir::toNativeSeparators(filePath) + QString("\" \"%1\"")); } int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); app.setApplicationDisplayName("QtWinExtras Test"); associateFileTypes(QStringList(".txt")); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }