From a7aa9f290a805f51839e8c66dcb447abf26c4316 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Mon, 27 Jun 2016 16:00:20 +0300 Subject: [PATCH] Common base for popup windows and avoid showing during orientation change --- fingerterm.pro | 3 ++- qml/LayoutWindow.qml | 18 +------------- qml/NotifyWin.qml | 17 +------------ qml/PopupWindow.qml | 58 ++++++++++++++++++++++++++++++++++++++++++++ qml/UrlWindow.qml | 18 +------------- resources.qrc | 1 + 6 files changed, 64 insertions(+), 51 deletions(-) create mode 100644 qml/PopupWindow.qml diff --git a/fingerterm.pro b/fingerterm.pro index 6c8e540..7e4bb00 100644 --- a/fingerterm.pro +++ b/fingerterm.pro @@ -49,7 +49,8 @@ OTHER_FILES += \ qml/MenuFingerterm.qml \ qml/NotifyWin.qml \ qml/UrlWindow.qml \ - qml/LayoutWindow.qml + qml/LayoutWindow.qml \ + qml/PopupWindow.qml RESOURCES += \ resources.qrc diff --git a/qml/LayoutWindow.qml b/qml/LayoutWindow.qml index e10391c..c508c12 100644 --- a/qml/LayoutWindow.qml +++ b/qml/LayoutWindow.qml @@ -19,26 +19,10 @@ import QtQuick 2.0 -Rectangle { +PopupWindow { id: layoutWindow property variant layouts: [""] - property bool show - - width: window.width-1 - height: window.height-1 - color: "#000000" - y: show ? 0 : -(height+1) - border.color: "#c0c0c0" - border.width: 1 - radius: window.radiusMedium - - Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } } - - MouseArea { - // event eater - anchors.fill: parent - } Component { id: listDelegate diff --git a/qml/NotifyWin.qml b/qml/NotifyWin.qml index c58b36d..097acbb 100644 --- a/qml/NotifyWin.qml +++ b/qml/NotifyWin.qml @@ -19,28 +19,13 @@ import QtQuick 2.0 -Rectangle { +PopupWindow { id: notifyWin property string text - property bool show signal dismissed() - width: window.width-1 - height: window.height-1 - color: "#000000" - y: show ? 0 : -(height+1) - border.color: "#c0c0c0" - border.width: 1 - radius: window.radiusMedium - - Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } } - - MouseArea { - // event eater - anchors.fill: parent - } Item { anchors.top: notifyWin.top anchors.left: notifyWin.left diff --git a/qml/PopupWindow.qml b/qml/PopupWindow.qml new file mode 100644 index 0000000..804a3bf --- /dev/null +++ b/qml/PopupWindow.qml @@ -0,0 +1,58 @@ +/* + Copyright 2011-2012 Heikki Holstila + + This file is part of FingerTerm. + + FingerTerm is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + FingerTerm is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FingerTerm. If not, see . +*/ + +import QtQuick 2.0 + +Rectangle { + id: root + + property bool show + + width: window.width + height: window.height + color: "#000000" + y: -height + border.color: "#c0c0c0" + border.width: 1 + radius: window.radiusMedium + + MouseArea { + // event eater + anchors.fill: parent + } + + states: [ + State { + name: "shown" + when: root.show + PropertyChanges { target: root; y: 0 } + } + ] + + transitions: [ + Transition { + to: "*" + NumberAnimation { + properties: "y" + duration: 200 + easing.type: Easing.InOutCubic + } + } + ] +} diff --git a/qml/UrlWindow.qml b/qml/UrlWindow.qml index 085250d..0720780 100644 --- a/qml/UrlWindow.qml +++ b/qml/UrlWindow.qml @@ -19,26 +19,10 @@ import QtQuick 2.0 -Rectangle { +PopupWindow { id: urlWindow property variant urls: [""] - property bool show - - width: window.width-1 - height: window.height-1 - color: "#000000" - y: show ? 0 : -(height+1) - border.color: "#c0c0c0" - border.width: 1 - radius: window.radiusMedium - - Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InOutCubic } } - - MouseArea { - // event eater - anchors.fill: parent - } Component { id: listDelegate diff --git a/resources.qrc b/resources.qrc index f542d9b..3d7217b 100644 --- a/resources.qrc +++ b/resources.qrc @@ -7,6 +7,7 @@ qml/Button.qml qml/MenuFingerterm.qml qml/NotifyWin.qml + qml/PopupWindow.qml icons/backspace.png icons/down.png icons/enter.png