Browse Source

add menu more button to quick module

pull/2/head
Skycoder42 7 years ago
parent
commit
06c2c258ea
  1. 12
      examples/mvvmdatasyncquick/DataSyncSampleQuick/SampleView.qml
  2. 11
      examples/mvvmquick/SampleQuick/SampleView.qml
  3. 3
      examples/mvvmquick/SampleQuick/TabView.qml
  4. 21
      src/imports/mvvmdatasyncquick/DataSyncView.qml
  5. 1
      src/imports/mvvmdatasyncquick/qtmvvmdatasyncquick_plugin.qrc
  6. 37
      src/imports/mvvmquick/MenuButton.qml
  7. 0
      src/imports/mvvmquick/icons/ic_more_vert_white_24px.svg
  8. 1
      src/imports/mvvmquick/mvvmquick.pro
  9. 1
      src/imports/mvvmquick/qmldir
  10. 1
      src/imports/mvvmquick/qtmvvmquick_plugin.qrc

12
examples/mvvmdatasyncquick/DataSyncSampleQuick/SampleView.qml

@ -10,17 +10,9 @@ Page {
property SampleViewModel viewModel: null property SampleViewModel viewModel: null
readonly property bool presentAsRoot: true readonly property bool presentAsRoot: true
header: ToolBar { header: ContrastToolBar {
height: 56 ToolBarLabel {
Label {
anchors.fill: parent anchors.fill: parent
font.pointSize: 16
font.bold: true
elide: Label.ElideRight
horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignVCenter
leftPadding: 10
text: qsTr("Datasync Sample") text: qsTr("Datasync Sample")
} }
} }

11
examples/mvvmquick/SampleQuick/SampleView.qml

@ -15,8 +15,9 @@ Page {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
ToolButton { ActionButton {
text: "≣" text: "≣"
display: AbstractButton.TextOnly
onClicked: QuickPresenter.toggleDrawer() onClicked: QuickPresenter.toggleDrawer()
} }
@ -25,12 +26,7 @@ Page {
Layout.fillWidth: true Layout.fillWidth: true
} }
ToolButton { MenuButton {
text: "⋮"
onClicked: moreMenu.open()
Menu {
id: moreMenu
MenuItem { MenuItem {
text: qsTr("Another Input") text: qsTr("Another Input")
onTriggered: viewModel.getInput() onTriggered: viewModel.getInput()
@ -49,7 +45,6 @@ Page {
} }
} }
} }
}
PresenterProgress {} PresenterProgress {}

3
examples/mvvmquick/SampleQuick/TabView.qml

@ -18,8 +18,9 @@ Page {
columnSpacing: 0 columnSpacing: 0
columns: 2 columns: 2
ToolButton { ActionButton {
text: "≣" text: "≣"
display: AbstractButton.TextOnly
onClicked: QuickPresenter.toggleDrawer() onClicked: QuickPresenter.toggleDrawer()
} }

21
src/imports/mvvmdatasyncquick/DataSyncView.qml

@ -41,21 +41,8 @@ Page {
onClicked: viewModel.showDeviceInfo() onClicked: viewModel.showDeviceInfo()
} }
ActionButton { MenuButton {
id: _moreButton id: _moreButton
icon.source: "image://svg/de/skycoder42/qtmvvm/quick/icons/ic_more_vert"
text: qsTr("More…")
checkable: true
checked: _moreMenu.visible
MouseArea { //used to catch mouse events to prevent flickering
visible: _moreMenu.visible
anchors.fill: parent
}
Menu {
id: _moreMenu
visible: _moreButton.checked
MenuItem { MenuItem {
text: qsTr("Update exchange key") text: qsTr("Update exchange key")
@ -81,12 +68,6 @@ Page {
onClicked: viewModel.performReset() onClicked: viewModel.performReset()
} }
} }
Component.onCompleted: {
if(QuickPresenter.currentStyle !== "Material")
_moreMenu.y = Qt.binding(function(){return _moreButton.height});
}
}
} }
} }

1
src/imports/mvvmdatasyncquick/qtmvvmdatasyncquick_plugin.qrc

@ -2,7 +2,6 @@
<qresource prefix="/de/skycoder42/qtmvvm/quick/icons"> <qresource prefix="/de/skycoder42/qtmvvm/quick/icons">
<file alias="ic_sync.svg">icons/ic_sync_white_24px.svg</file> <file alias="ic_sync.svg">icons/ic_sync_white_24px.svg</file>
<file alias="ic_fingerprint.svg">icons/ic_fingerprint_white_24px.svg</file> <file alias="ic_fingerprint.svg">icons/ic_fingerprint_white_24px.svg</file>
<file alias="ic_more_vert.svg">icons/ic_more_vert_white_24px.svg</file>
<file alias="ic_delete_forever.svg">icons/ic_delete_forever_white_24px.svg</file> <file alias="ic_delete_forever.svg">icons/ic_delete_forever_white_24px.svg</file>
<file alias="ic_add.svg">icons/ic_add_white_24px.svg</file> <file alias="ic_add.svg">icons/ic_add_white_24px.svg</file>
<file alias="ic_export.svg">icons/ic_call_made_white_24px.svg</file> <file alias="ic_export.svg">icons/ic_call_made_white_24px.svg</file>

37
src/imports/mvvmquick/MenuButton.qml

@ -0,0 +1,37 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import de.skycoder42.QtMvvm.Quick 1.0
ActionButton {
id: _menuButton
icon.name: "view-more-symbolic"
icon.source: "image://svg/de/skycoder42/qtmvvm/quick/icons/ic_more_vert"
text: qsTr("More…")
checkable: true
checked: _moreMenu.visible
property alias moreMenu: _moreMenu
default property alias menuContent: _moreMenu.contentData
MouseArea { //used to catch mouse events to prevent flickering
visible: _moreMenu.visible
anchors.fill: parent
}
Menu {
id: _moreMenu
visible: _menuButton.checked
}
Component.onCompleted: {
if(QuickPresenter.currentStyle !== "Material") {
_moreMenu.y = Qt.binding(function(){
return _menuButton.height + Math.max(0, (parent.height - _menuButton.height)/2);
});
} else {
_moreMenu.y = Qt.binding(function(){
return Math.min(0, (_menuButton.height - parent.height)/2);
});
}
}
}

0
src/imports/mvvmdatasyncquick/icons/ic_more_vert_white_24px.svg → src/imports/mvvmquick/icons/ic_more_vert_white_24px.svg

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 309 B

1
src/imports/mvvmquick/mvvmquick.pro

@ -36,6 +36,7 @@ QML_FILES += \
ToolBarLabel.qml \ ToolBarLabel.qml \
ActionButton.qml \ ActionButton.qml \
RoundActionButton.qml \ RoundActionButton.qml \
MenuButton.qml \
MsgBoxBase.qml \ MsgBoxBase.qml \
MsgBox.qml \ MsgBox.qml \
InputDialog.qml \ InputDialog.qml \

1
src/imports/mvvmquick/qmldir

@ -21,6 +21,7 @@ ContrastToolBar 1.0 ContrastToolBar.qml
ToolBarLabel 1.0 ToolBarLabel.qml ToolBarLabel 1.0 ToolBarLabel.qml
ActionButton 1.0 ActionButton.qml ActionButton 1.0 ActionButton.qml
RoundActionButton 1.0 RoundActionButton.qml RoundActionButton 1.0 RoundActionButton.qml
MenuButton 1.0 MenuButton.qml
PresenterProgress 1.0 PresenterProgress.qml PresenterProgress 1.0 PresenterProgress.qml
PresentingStackView 1.0 PresentingStackView.qml PresentingStackView 1.0 PresentingStackView.qml

1
src/imports/mvvmquick/qtmvvmquick_plugin.qrc

@ -8,6 +8,7 @@
<file alias="ic_search.svg">icons/ic_search_white_24px.svg</file> <file alias="ic_search.svg">icons/ic_search_white_24px.svg</file>
<file alias="ic_settings_backup_restore.svg">icons/ic_settings_backup_restore_white_24px.svg</file> <file alias="ic_settings_backup_restore.svg">icons/ic_settings_backup_restore_white_24px.svg</file>
<file alias="ic_chevron_right.svg">icons/ic_chevron_right_white_24px.svg</file> <file alias="ic_chevron_right.svg">icons/ic_chevron_right_white_24px.svg</file>
<file alias="ic_more_vert.svg">icons/ic_more_vert_white_24px.svg</file>
</qresource> </qresource>
<qresource prefix="/de/skycoder42/qtmvvm/quick/qml"> <qresource prefix="/de/skycoder42/qtmvvm/quick/qml">
<file>FileDialog.qml</file> <file>FileDialog.qml</file>

Loading…
Cancel
Save