Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/imagepackage/contents/ui/WindowModel.qml
- This file was added.
1 | import QtQuick 2.1 | ||||
---|---|---|---|---|---|
2 | import QtQuick.Controls 1.0 | ||||
3 | import QtQuick.Layouts 1.3 | ||||
4 | import QtQuick.Window 2.1 | ||||
5 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
6 | | ||||
7 | import org.kde.taskmanager 0.1 as TaskManager | ||||
8 | | ||||
9 | Item { | ||||
10 | property alias screenGeometry: tasksModel.screenGeometry | ||||
11 | property bool noWindowActive: true | ||||
12 | property bool currentWindowMaximized: false | ||||
13 | property bool isActiveWindowPinned: false | ||||
14 | | ||||
15 | TaskManager.VirtualDesktopInfo { id: virtualDesktopInfo } | ||||
16 | TaskManager.ActivityInfo { id: activityInfo } | ||||
17 | TaskManager.TasksModel { | ||||
18 | id: tasksModel | ||||
19 | sortMode: TaskManager.TasksModel.SortVirtualDesktop | ||||
20 | groupMode: TaskManager.TasksModel.GroupDisabled | ||||
21 | | ||||
22 | activity: activityInfo.currentActivity | ||||
23 | virtualDesktop: virtualDesktopInfo.currentDesktop | ||||
24 | screenGeometry: wallpaper.screenGeometry // Warns "Unable to assign [undefined] to QRect" during init, but works thereafter. | ||||
25 | | ||||
26 | filterByActivity: true | ||||
27 | filterByVirtualDesktop: true | ||||
28 | filterByScreen: true | ||||
29 | | ||||
30 | onActiveTaskChanged: { | ||||
31 | // console.log('tasksModel.onActiveTaskChanged') | ||||
32 | updateActiveWindowInfo() | ||||
33 | } | ||||
34 | onDataChanged: { | ||||
35 | // console.log('tasksModel.onDataChanged') | ||||
36 | updateActiveWindowInfo() | ||||
37 | } | ||||
38 | Component.onCompleted: { | ||||
39 | // console.log('tasksModel.Component.onCompleted') | ||||
40 | activeWindowModel.sourceModel = tasksModel | ||||
41 | } | ||||
42 | } | ||||
43 | PlasmaCore.SortFilterModel { | ||||
44 | id: activeWindowModel | ||||
45 | filterRole: 'IsActive' | ||||
46 | filterRegExp: 'true' | ||||
47 | onDataChanged: { | ||||
48 | // console.log('activeWindowModel.onDataChanged') | ||||
49 | updateActiveWindowInfo() | ||||
50 | } | ||||
51 | onCountChanged: { | ||||
52 | // console.log('activeWindowModel.onCountChanged') | ||||
53 | updateActiveWindowInfo() | ||||
54 | } | ||||
55 | } | ||||
56 | | ||||
57 | | ||||
58 | function activeTask() { | ||||
59 | return activeWindowModel.get(0) || {} | ||||
60 | } | ||||
61 | | ||||
62 | function updateActiveWindowInfo() { | ||||
63 | var actTask = activeTask() | ||||
64 | noWindowActive = activeWindowModel.count === 0 || actTask.IsActive !== true | ||||
65 | currentWindowMaximized = !noWindowActive && actTask.IsMaximized === true | ||||
66 | isActiveWindowPinned = actTask.VirtualDesktop === -1 | ||||
67 | } | ||||
68 | } |