From ba2ec69285951beba16c248e35b617ecc0a845da Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 27 Sep 2016 11:19:00 +0200 Subject: [PATCH] feat(app): new menu component --- tests/imgs/contacts_list.svg | 15 ++++ tests/imgs/home.svg | 17 ++++ tests/imgs/right_arrow.svg | 15 ++++ tests/linphone.pro | 1 - tests/resources.qrc | 5 +- tests/ui/modules/Linphone/Menu.qml | 85 ++++++++++++++++++++ tests/ui/modules/Linphone/Misc/MenuEntry.qml | 39 --------- tests/ui/modules/Linphone/qmldir | 4 +- tests/ui/views/MainWindow/MainWindow.qml | 23 +++--- 9 files changed, 151 insertions(+), 53 deletions(-) create mode 100644 tests/imgs/contacts_list.svg create mode 100644 tests/imgs/home.svg create mode 100644 tests/imgs/right_arrow.svg create mode 100644 tests/ui/modules/Linphone/Menu.qml delete mode 100644 tests/ui/modules/Linphone/Misc/MenuEntry.qml diff --git a/tests/imgs/contacts_list.svg b/tests/imgs/contacts_list.svg new file mode 100644 index 000000000..529c9cda9 --- /dev/null +++ b/tests/imgs/contacts_list.svg @@ -0,0 +1,15 @@ + + + + footer_contacts + Created with Sketch. + + + + + + + + + + diff --git a/tests/imgs/home.svg b/tests/imgs/home.svg new file mode 100644 index 000000000..3907176c7 --- /dev/null +++ b/tests/imgs/home.svg @@ -0,0 +1,17 @@ + + + + menu + Created with Sketch. + + + + + + + + + + + + diff --git a/tests/imgs/right_arrow.svg b/tests/imgs/right_arrow.svg new file mode 100644 index 000000000..68a9ded59 --- /dev/null +++ b/tests/imgs/right_arrow.svg @@ -0,0 +1,15 @@ + + + + arrow_hangup + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/tests/linphone.pro b/tests/linphone.pro index 22dbf6a7e..063e22312 100644 --- a/tests/linphone.pro +++ b/tests/linphone.pro @@ -33,7 +33,6 @@ lupdate_only{ ui/modules/Linphone/Dialog/*.qml \ ui/modules/Linphone/Form/*.qml \ ui/modules/Linphone/Image/*.qml \ - ui/modules/Linphone/Misc/*.qml \ ui/modules/Linphone/Popup/*.qml \ ui/modules/Linphone/Select/*.qml \ ui/modules/Linphone/Styles/*.qml \ diff --git a/tests/resources.qrc b/tests/resources.qrc index 0f3011265..8c97b4edf 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -6,10 +6,12 @@ imgs/chat.svg imgs/collapse.svg imgs/conference.svg + imgs/contacts_list.svg imgs/contact.svg imgs/delete.svg imgs/hangup.svg imgs/history.svg + imgs/home.svg imgs/incoming_call.svg imgs/led_absent.svg imgs/led_connected.svg @@ -18,6 +20,7 @@ imgs/linphone.png imgs/lost_incoming_call.svg imgs/lost_outgoing_call.svg + imgs/right_arrow.svg imgs/valid.svg languages/en.qm languages/fr.qm @@ -47,7 +50,7 @@ ui/modules/Linphone/Form/TransparentComboBox.qml ui/modules/Linphone/Image/Icon.qml ui/modules/Linphone/InvertedMouseArea.qml - ui/modules/Linphone/Misc/MenuEntry.qml + ui/modules/Linphone/Menu.qml ui/modules/Linphone/Popup/DropDownMenu.qml ui/modules/Linphone/Popup/PopupShadow.qml ui/modules/Linphone/qmldir diff --git a/tests/ui/modules/Linphone/Menu.qml b/tests/ui/modules/Linphone/Menu.qml new file mode 100644 index 000000000..eda31fb49 --- /dev/null +++ b/tests/ui/modules/Linphone/Menu.qml @@ -0,0 +1,85 @@ +import QtQuick 2.7 +import QtQuick.Layouts 1.3 + +import Linphone 1.0 + +// =================================================================== +// Responsive flat menu with visual indicators. +// =================================================================== + +ColumnLayout { + id: item + + property int entryHeight + property int entryWidth + property variant entries + + property int _selectedEntry: 0 + + signal entrySelected (int entry) + + spacing: 2 + + Repeater { + model: entries + + Rectangle { + color: _selectedEntry === index + ? '#434343' + : (mouseArea.pressed + ? '#FE5E00' + : (mouseArea.containsMouse + ? '#707070' + : '#8E8E8E' + ) + ) + height: item.entryHeight + width: item.entryWidth + + RowLayout { + anchors.left: parent.left + anchors.leftMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 20 + anchors.verticalCenter: parent.verticalCenter + spacing: 18 + + Icon { + Layout.preferredHeight: 24 + Layout.preferredWidth: 24 + icon: modelData.icon + } + + Text { + Layout.fillWidth: true + color: '#FFFFFF' + font.pointSize: 13 + height: parent.height + text: modelData.entryName + verticalAlignment: Text.AlignVCenter + } + + Icon { + Layout.alignment: Qt.AlignRight + Layout.preferredHeight: 12 + Layout.preferredWidth: 12 + icon: _selectedEntry === index ? 'right_arrow' : '' + } + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + + onClicked: { + if (_selectedEntry !== index) { + _selectedEntry = index + entrySelected(index) + } + } + } + } + } +} diff --git a/tests/ui/modules/Linphone/Misc/MenuEntry.qml b/tests/ui/modules/Linphone/Misc/MenuEntry.qml deleted file mode 100644 index a97240029..000000000 --- a/tests/ui/modules/Linphone/Misc/MenuEntry.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 2.7 - -Rectangle { - property alias entryName: text.text - property bool isSelected - - color: isSelected ? '#434343' : '#8E8E8E' - - Row { - anchors.fill: parent - anchors.leftMargin: 10 - anchors.rightMargin: 10 - spacing: 10 - - Image { - fillMode: Image.PreserveAspectFit - height: parent.height - width: 30 - } - - Text { - color: '#FFFFFF' - font.pointSize: 13 - height: parent.height - id: text - verticalAlignment: Text.AlignVCenter - } - - Image { - fillMode: Image.PreserveAspectFit - height: parent.height - } - } - - MouseArea { - anchors.fill: parent - onClicked: { } // TODO. - } -} diff --git a/tests/ui/modules/Linphone/qmldir b/tests/ui/modules/Linphone/qmldir index a763ced38..e6ab51e54 100644 --- a/tests/ui/modules/Linphone/qmldir +++ b/tests/ui/modules/Linphone/qmldir @@ -40,8 +40,8 @@ Icon 1.0 Image/Icon.qml # InvertedMouseArea InvertedMouseArea 1.0 InvertedMouseArea.qml -# Misc -MenuEntry 1.0 Misc/MenuEntry.qml +# Menu +Menu 1.0 Menu.qml # Popup DropDownMenu 1.0 Popup/DropDownMenu.qml diff --git a/tests/ui/views/MainWindow/MainWindow.qml b/tests/ui/views/MainWindow/MainWindow.qml index c82d88930..bbfaf106d 100644 --- a/tests/ui/views/MainWindow/MainWindow.qml +++ b/tests/ui/views/MainWindow/MainWindow.qml @@ -93,18 +93,21 @@ ApplicationWindow { Layout.preferredWidth: 250 spacing: 0 - MenuEntry { - Layout.fillWidth: true - Layout.preferredHeight: 50 - entryName: qsTr('homeEntry') - } + Menu { + entryHeight: 50 + entryWidth: parent.width - Item { Layout.preferredHeight: 2 } + entries: [{ + entryName: qsTr('homeEntry'), + icon: 'home' + }, { + entryName: qsTr('contactsEntry'), + icon: 'contacts_list' + }] - MenuEntry { - Layout.fillWidth: true - Layout.preferredHeight: 50 - entryName: qsTr('contactsEntry') + onEntrySelected: { + console.log('entry', entry) + } } // History.