on xenial help sign in
try to add a special flickable that doesn't eat the mouse presses
commit6f759cfa017eaffc5223d6f7670d76524e549992 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 13 Apr 2015, 12:53 (12 years ago) parent45fa1e6
5 files changed+43−2
plugins/Utils/CMakeLists.txt+2 plugins/Utils/plugin.cpp+2 qml/Stages/DesktopStage.qml+35−2 tests/mocks/Utils/CMakeLists.txt+2 tests/mocks/Utils/plugin.cpp+2
plugins/Utils/CMakeLists.txt+2
@@ -4,6 +4,7 @@ include_directories(
44 ${CMAKE_CURRENT_SOURCE_DIR}
55 ${CMAKE_CURRENT_BINARY_DIR}
66 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
7+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
78 ${GIO_INCLUDE_DIRS}
89)
910
@@ -17,6 +18,7 @@ set(QMLPLUGIN_SRC
1718 windowkeysfilter.cpp
1819 easingcurve.cpp
1920 windowstatestorage.cpp
21+ spreadflickable.cpp
2022 plugin.cpp
2123 )
2224
plugins/Utils/plugin.cpp+2
@@ -35,6 +35,7 @@
3535#include "windowkeysfilter.h"
3636#include "easingcurve.h"
3737#include "windowstatestorage.h"
38+#include "spreadflickable.h"
3839
3940static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
4041{
@@ -57,6 +58,7 @@ void UtilsPlugin::registerTypes(const char *uri)
5758 qmlRegisterType<RelativeTimeFormatter>(uri, 0, 1, "RelativeTimeFormatter");
5859 qmlRegisterSingletonType<WindowStateStorage>(uri, 0, 1, "WindowStateStorage", createWindowStateStorage);
5960 qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
61+ qmlRegisterType<SpreadFlickable>(uri, 0, 1, "SpreadFlickable");
6062}
6163
6264void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
qml/Stages/DesktopStage.qml+35−2
@@ -174,6 +174,10 @@ FocusScope {
174174 visible: true
175175 opacity: spreadMaths.tileInfoOpacity
176176 }
177+ PropertyChanges {
178+ target: spreadSelectArea
179+ enabled: true
180+ }
177181 }
178182 ]
179183 transitions: [
@@ -239,6 +243,17 @@ FocusScope {
239243 angle: appDelegate.angle
240244 }
241245 ]
246+
247+ MouseArea {
248+ id: spreadSelectArea
249+ anchors.fill: parent
250+ enabled: false
251+ onClicked: {
252+ print("clicked")
253+ appDelegate.focusWindow()
254+ root.state = ""
255+ }
256+ }
242257 }
243258
244259
@@ -269,7 +284,7 @@ FocusScope {
269284 }
270285 }
271286
272− Flickable {
287+ SpreadFlickable {
273288 id: spreadFlickable
274289 anchors.fill: parent
275290 contentWidth: Math.max(6, ApplicationManager.count) * width / 5
@@ -359,7 +374,10 @@ FocusScope {
359374 Transition {
360375 from: "*"
361376 to: "altTab"
362− PropertyAction { target: spreadFlickable; property: "contentX"; value: 0 }
377+ PropertyAction { target: spreadFlickable; property: "contentX";
378+ value: ((spreadFlickable.contentWidth) / (ApplicationManager.count + 1)) * Math.max(0, Math.min(ApplicationManager.count - 3, 1));
379+
380+ }
363381 PropertyAnimation { property: "opacity" }
364382 },
365383 Transition {
@@ -369,4 +387,19 @@ FocusScope {
369387 }
370388
371389 ]
390+
391+ MouseArea {
392+ anchors {
393+ top: parent.top
394+ right: parent.right
395+ bottom: parent.bottom
396+ }
397+ width: 1 // yes, we want 1 pixel, regardless of the scaling
398+ hoverEnabled: true
399+ onContainsMouseChanged: {
400+ if (containsMouse) {
401+ root.state = "altTab"
402+ }
403+ }
404+ }
372405}
tests/mocks/Utils/CMakeLists.txt+2
@@ -4,6 +4,7 @@ include_directories(
44 ${CMAKE_CURRENT_SOURCE_DIR}
55 ${CMAKE_CURRENT_BINARY_DIR}
66 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
7+ ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
78 ${GIO_INCLUDE_DIRS}
89 ${CMAKE_SOURCE_DIR}/plugins/Utils
910)
@@ -17,6 +18,7 @@ set(QMLPLUGIN_SRC
1718 ${CMAKE_SOURCE_DIR}/plugins/Utils/windowkeysfilter.cpp
1819 ${CMAKE_SOURCE_DIR}/plugins/Utils/easingcurve.cpp
1920 ${CMAKE_SOURCE_DIR}/plugins/Utils/inputwatcher.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/Utils/spreadflickable.cpp
2022 windowstatestorage.cpp
2123 plugin.cpp
2224 )
tests/mocks/Utils/plugin.cpp+2
@@ -33,6 +33,7 @@
3333#include "unitymenumodelpaths.h"
3434#include "windowkeysfilter.h"
3535#include "windowstatestorage.h"
36+#include "spreadflickable.h"
3637
3738static QObject *createWindowStateStorage(QQmlEngine *engine, QJSEngine *scriptEngine)
3839{
@@ -55,6 +56,7 @@ void FakeUtilsPlugin::registerTypes(const char *uri)
5556 qmlRegisterType<RelativeTimeFormatter>(uri, 0, 1, "RelativeTimeFormatter");
5657 qmlRegisterSingletonType<WindowStateStorage>(uri, 0, 1, "WindowStateStorage", createWindowStateStorage);
5758 qmlRegisterType<InputWatcher>(uri, 0, 1, "InputWatcher");
59+ qmlRegisterType<SpreadFlickable>(uri, 0, 1, "SpreadFlickable");
5860}
5961
6062void FakeUtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)