Changeset View
Changeset View
Standalone View
Standalone View
toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml
Show All 14 Lines | |||||
15 | * | 15 | * | ||
16 | * You should have received a copy of the GNU Library General Public | 16 | * You should have received a copy of the GNU Library General Public | ||
17 | * License along with this program; if not, write to the | 17 | * License along with this program; if not, write to the | ||
18 | * Free Software Foundation, Inc., | 18 | * Free Software Foundation, Inc., | ||
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.2 | 22 | import QtQuick 2.2 | ||
23 | import QtQuick.Window 2.2 | ||||
23 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
24 | import org.kde.plasma.components 2.0 as PlasmaComponents | 25 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
25 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | 26 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | ||
26 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
27 | import org.kde.plasma.plasmoid 2.0 | 28 | import org.kde.plasma.plasmoid 2.0 | ||
28 | 29 | | |||
29 | 30 | | |||
30 | Item { | 31 | Item { | ||
31 | id: main | 32 | id: main | ||
32 | objectName: "org.kde.desktoptoolbox" | 33 | objectName: "org.kde.desktoptoolbox" | ||
33 | 34 | | |||
34 | z: 999 | 35 | z: 999 | ||
35 | anchors.fill: parent | 36 | anchors.fill: parent | ||
36 | 37 | | |||
37 | Connections { | 38 | Connections { | ||
38 | target: plasmoid | 39 | target: plasmoid | ||
39 | onAvailableScreenRegionChanged: placeToolBoxTimer.restart(); | 40 | onAvailableScreenRegionChanged: placeToolBoxTimer.restart(); | ||
40 | } | 41 | } | ||
41 | 42 | | |||
43 | //FIXME: this timer shouldn't exist, but unfortunately when the focus passes | ||||
44 | //from the desktop to the dialog or vice versa, the event is not atomic | ||||
45 | //and ends up with neither of those having focus, hiding the dialog when | ||||
46 | //it shouldn't | ||||
47 | Timer { | ||||
48 | id: hideDialogTimer | ||||
49 | interval: 0 | ||||
50 | //NOTE: it's checking activeFocusItem instead of active as active doesn't correctly signal its change | ||||
51 | property bool desktopOrDialogFocus: main.Window.activeFocusItem != null || (toolBoxLoader.item && toolBoxLoader.item.activeFocusItem != null) | ||||
52 | onDesktopOrDialogFocusChanged: { | ||||
53 | if (!desktopOrDialogFocus) { | ||||
54 | hideDialogTimer.restart(); | ||||
55 | } | ||||
56 | | ||||
57 | } | ||||
58 | onTriggered: { | ||||
59 | if (!desktopOrDialogFocus) { | ||||
60 | open = false; | ||||
61 | } | ||||
62 | } | ||||
63 | } | ||||
64 | | ||||
42 | signal minimumWidthChanged | 65 | signal minimumWidthChanged | ||
43 | signal minimumHeightChanged | 66 | signal minimumHeightChanged | ||
44 | signal maximumWidthChanged | 67 | signal maximumWidthChanged | ||
45 | signal maximumHeightChanged | 68 | signal maximumHeightChanged | ||
46 | signal preferredWidthChanged | 69 | signal preferredWidthChanged | ||
47 | signal preferredHeightChanged | 70 | signal preferredHeightChanged | ||
48 | 71 | | |||
49 | property int iconSize: units.iconSizes.small | 72 | property int iconSize: units.iconSizes.small | ||
50 | property int iconWidth: units.iconSizes.smallMedium | 73 | property int iconWidth: units.iconSizes.smallMedium | ||
51 | property int iconHeight: iconWidth | 74 | property int iconHeight: iconWidth | ||
52 | property bool dialogWasVisible: false | 75 | property bool dialogWasVisible: false | ||
76 | property bool open: false | ||||
77 | onOpenChanged: { | ||||
78 | if (open) { | ||||
79 | toolBoxLoader.active = true; | ||||
80 | toolBoxLoader.item.visible = true; | ||||
81 | } else { | ||||
82 | toolBoxLoader.item.visible = false; | ||||
83 | } | ||||
84 | } | ||||
53 | 85 | | |||
54 | onWidthChanged: placeToolBoxTimer.restart(); | 86 | onWidthChanged: placeToolBoxTimer.restart(); | ||
55 | onHeightChanged: placeToolBoxTimer.restart(); | 87 | onHeightChanged: placeToolBoxTimer.restart(); | ||
56 | 88 | | |||
57 | LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft) | 89 | LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft) | ||
58 | LayoutMirroring.childrenInherit: true | 90 | LayoutMirroring.childrenInherit: true | ||
59 | 91 | | |||
60 | onVisibleChanged: { | 92 | onVisibleChanged: { | ||
Show All 35 Lines | |||||
96 | 128 | | |||
97 | Loader { | 129 | Loader { | ||
98 | id: toolBoxLoader | 130 | id: toolBoxLoader | ||
99 | active: false | 131 | active: false | ||
100 | sourceComponent: PlasmaCore.Dialog { | 132 | sourceComponent: PlasmaCore.Dialog { | ||
101 | flags: Qt.WindowStaysOnTopHint | 133 | flags: Qt.WindowStaysOnTopHint | ||
102 | location: PlasmaCore.Types.Floating | 134 | location: PlasmaCore.Types.Floating | ||
103 | visualParent: toolBoxButton | 135 | visualParent: toolBoxButton | ||
104 | hideOnWindowDeactivate: true | 136 | // hideOnWindowDeactivate: true | ||
105 | mainItem: ToolBoxItem { | 137 | mainItem: ToolBoxItem { | ||
106 | id: dialog | 138 | id: dialog | ||
107 | 139 | | |||
108 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | 140 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | ||
109 | LayoutMirroring.childrenInherit: true | 141 | LayoutMirroring.childrenInherit: true | ||
110 | 142 | | |||
111 | Timer { | 143 | Timer { | ||
112 | id: visibleTimer | 144 | id: visibleTimer | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |