Changeset View
Changeset View
Standalone View
Standalone View
src/qml/TopNotificationItem.qml
Show All 11 Lines | |||||
12 | * Lesser General Public License for more details. | 12 | * Lesser General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public License | 14 | * You should have received a copy of the GNU Lesser General Public License | ||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | import QtQuick 2.7 | 18 | import QtQuick 2.7 | ||
19 | import QtQuick.Layouts 1.2 | 19 | import QtQuick.Layouts 1.2 | ||
20 | import QtQuick.Controls 2.2 | 20 | import QtQuick.Controls 2.3 | ||
21 | import QtQuick.Controls 1.4 as Controls1 | | |||
22 | import org.kde.elisa 1.0 | 21 | import org.kde.elisa 1.0 | ||
23 | 22 | | |||
24 | FocusScope { | 23 | FocusScope { | ||
25 | id: topItem | 24 | id: topItem | ||
26 | 25 | | |||
27 | signal close() | 26 | signal close() | ||
28 | signal mainButtonClicked() | 27 | signal mainButtonClicked() | ||
29 | signal secondaryButtonClicked() | 28 | signal secondaryButtonClicked() | ||
30 | signal entered() | 29 | signal entered() | ||
31 | 30 | | |||
32 | property alias itemMessage: notificationText.text | 31 | property alias itemMessage: notificationText.text | ||
33 | property alias itemMainButtonText: mainButton.text | 32 | property alias itemMainButtonText: mainButton.text | ||
34 | property alias itemMainButtonIconName: mainButton.iconName | 33 | property alias itemMainButtonIconName: mainButton.icon.name | ||
35 | property alias itemSecondaryButtonText: secondaryButton.text | 34 | property alias itemSecondaryButtonText: secondaryButton.text | ||
36 | property alias itemSecondaryButtonIconName: secondaryButton.iconName | 35 | property alias itemSecondaryButtonIconName: secondaryButton.icon.name | ||
37 | property var parentList | 36 | property var parentList | ||
38 | 37 | | |||
39 | MouseArea { | 38 | MouseArea { | ||
40 | anchors.fill: parent | 39 | anchors.fill: parent | ||
41 | 40 | | |||
42 | hoverEnabled: true | 41 | hoverEnabled: true | ||
43 | acceptedButtons: Qt.NoButton | 42 | acceptedButtons: Qt.NoButton | ||
44 | 43 | | |||
Show All 10 Lines | 51 | Label { | |||
55 | 54 | | |||
56 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | 55 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | ||
57 | Layout.alignment: Qt.AlignHCenter | 56 | Layout.alignment: Qt.AlignHCenter | ||
58 | 57 | | |||
59 | visible: topItem.height > height | 58 | visible: topItem.height > height | ||
60 | opacity: (topItem.height - height) / height | 59 | opacity: (topItem.height - height) / height | ||
61 | } | 60 | } | ||
62 | 61 | | |||
63 | Controls1.Button { | 62 | Button { | ||
64 | id: mainButton | 63 | id: mainButton | ||
65 | 64 | | |||
66 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | 65 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | ||
67 | Layout.alignment: Qt.AlignHCenter | 66 | Layout.alignment: Qt.AlignHCenter | ||
68 | Layout.maximumHeight: elisaTheme.delegateHeight | 67 | Layout.maximumHeight: elisaTheme.delegateHeight | ||
69 | 68 | | |||
70 | visible: text !== "" && topItem.height > height | 69 | visible: text !== "" && topItem.height > height | ||
71 | opacity: (topItem.height - height) / height | 70 | opacity: (topItem.height - height) / height | ||
72 | 71 | | |||
73 | onClicked: { | 72 | onClicked: { | ||
74 | mainButton.enabled = false | 73 | mainButton.enabled = false | ||
75 | enableAgainMainButtonTimer.start() | 74 | enableAgainMainButtonTimer.start() | ||
76 | mainButtonClicked() | 75 | mainButtonClicked() | ||
77 | } | 76 | } | ||
78 | 77 | | |||
79 | Timer { | 78 | Timer { | ||
80 | id: enableAgainMainButtonTimer | 79 | id: enableAgainMainButtonTimer | ||
81 | interval: 500 | 80 | interval: 500 | ||
82 | onTriggered: mainButton.enabled = true | 81 | onTriggered: mainButton.enabled = true | ||
83 | } | 82 | } | ||
84 | } | 83 | } | ||
85 | 84 | | |||
86 | Controls1.Button { | 85 | Button { | ||
87 | id: secondaryButton | 86 | id: secondaryButton | ||
88 | 87 | | |||
89 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | 88 | Layout.leftMargin: elisaTheme.layoutHorizontalMargin | ||
90 | Layout.alignment: Qt.AlignHCenter | 89 | Layout.alignment: Qt.AlignHCenter | ||
91 | Layout.maximumHeight: elisaTheme.delegateHeight | 90 | Layout.maximumHeight: elisaTheme.delegateHeight | ||
92 | 91 | | |||
93 | visible: text !== "" && topItem.height > height | 92 | visible: text !== "" && topItem.height > height | ||
94 | opacity: (topItem.height - height) / height | 93 | opacity: (topItem.height - height) / height | ||
Show All 11 Lines | |||||
106 | } | 105 | } | ||
107 | } | 106 | } | ||
108 | 107 | | |||
109 | Item { | 108 | Item { | ||
110 | Layout.fillWidth: true | 109 | Layout.fillWidth: true | ||
111 | } | 110 | } | ||
112 | } | 111 | } | ||
113 | 112 | | |||
114 | Controls1.ToolButton { | 113 | Action { | ||
114 | id: closeAction | ||||
115 | icon.name: 'dialog-close' | ||||
116 | onTriggered: close() | ||||
117 | } | ||||
118 | | ||||
119 | FlatButtonWithToolTip { | ||||
120 | action: closeAction | ||||
115 | anchors.top: parent.top | 121 | anchors.top: parent.top | ||
116 | anchors.right: parent.right | 122 | anchors.right: parent.right | ||
117 | 123 | | |||
118 | visible: topItem.height > height | 124 | visible: topItem.height > height | ||
119 | opacity: (topItem.height - height) / height | 125 | opacity: (topItem.height - height) / height | ||
120 | | ||||
121 | iconName: 'dialog-close' | | |||
122 | | ||||
123 | onClicked: close() | | |||
124 | } | 126 | } | ||
125 | } | 127 | } |