/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ import QtQuick 2.11 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.11 import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 // Tool Strip not tested for mobile devices! Rectangle { id: _root color: qgcPal.window width: toolStripGrid.width + (toolStripGrid.anchors.margins * 2) height: toolStripGrid.height + (toolStripGrid.anchors.margins * 2) radius: _radius border.width: 1 border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35) property string title: "Title" property alias model: repeater.model property var showAlternateIcon ///< List of bool values, one for each button in strip - true: show alternate icon, false: show normal icon property var rotateImage ///< List of bool values, one for each button in strip - true: animation rotation, false: static image property var animateImage ///< List of bool values, one for each button in strip - true: animate image, false: static image property var buttonEnabled ///< List of bool values, one for each button in strip - true: button enabled, false: button disabled property var buttonVisible ///< List of bool values, one for each button in strip - true: button visible, false: button invisible property var maxHeight /// legacy parameter, does not have any impact property bool horizontal: false /// toolstrip horizontal or vertical ? property bool enableSwitchButton: false /// enable horizontal vertical button ? signal clicked(int index, bool checked) readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _buttonSpacing: ScreenTools.defaultFontPixelHeight / 4 readonly property real _buttonWidthHeight: ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 6 Component.onCompleted: toolStripGrid.horizontal = _root.horizontal onHorizontalChanged: toolStripGrid.horizontal = _root.horizontal QGCPalette { id: qgcPal } ExclusiveGroup { id: dropButtonsExclusiveGroup } function uncheckAll() { dropButtonsExclusiveGroup.current = null // Signal all toggles as off for (var i=0; i vertical Rectangle { id: switchButtonRect height: enableSwitchButton ? _buttonWidthHeight : 0 width: enableSwitchButton ? _buttonWidthHeight : 0 color: _showHighlight ? _switchButtonPal.buttonHighlight : _switchButtonPal.window visible: enableSwitchButton radius: ScreenTools.defaultFontPixelWidth/2 clip: true property bool _hovered: false property bool _showHighlight: (enableSwitchButton && _hovered) QGCPalette { id: _switchButtonPal; colorGroupEnabled: enableSwitchButton } Column { anchors.horizontalCenter: parent.horizontalCenter QGCColoredImage { id: switchButtonImage height: _buttonWidthHeight-switchButtonLabel.height width: _buttonWidthHeight-switchButtonLabel.height source: "/res/clockwise-arrow.svg" anchors.horizontalCenter: parent.horizontalCenter sourceSize.height: _buttonWidthHeight-switchButtonLabel.height sourceSize.width: _buttonWidthHeight-switchButtonLabel.height fillMode: Image.PreserveAspectCrop mipmap: true smooth: true color: switchButtonRect._showHighlight ? _switchButtonPal.buttonHighlightText : _switchButtonPal.text } QGCLabel { id: switchButtonLabel anchors.horizontalCenter: parent.horizontalCenter font.pointSize: ScreenTools.smallFontPointSize text: toolStripGrid.horizontal ? "Vert" : "Hor" color: switchButtonRect._showHighlight ? _switchButtonPal.buttonHighlightText : _switchButtonPal.text enabled: enableSwitchButton } } QGCMouseArea { anchors.fill: parent visible: enableSwitchButton hoverEnabled: true preventStealing: true onContainsMouseChanged: switchButtonRect._hovered = containsMouse onContainsPressChanged: switchButtonRect._hovered = containsPress onClicked: { dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if if (toolStripGrid.horizontal === true) { toolStripGrid.horizontal = false } else { toolStripGrid.horizontal = true } } } } // switchButton Rectangle } // GridLayout DropPanel { id: dropPanel toolStrip: _root } }