TabContainer.qml 1.3 KB
Newer Older
1
import QtQuick 2.7
2
import QtQuick.Controls 2.2
3
import QtQuick.Layouts 1.3
4

5
import Common 1.0
6
import Common.Styles 1.0
7
import Utils 1.0
8 9 10 11 12 13 14 15 16

// =============================================================================

Rectangle {
  default property alias _content: content.data

  anchors.fill: parent
  color: TabContainerStyle.color

17 18 19
  ColumnLayout {
    anchors.fill: parent
    spacing: 0
20

21 22 23 24
    Flickable {
      ScrollBar.vertical: ForceScrollBar {
        id: scrollBar
      }
25

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
      Layout.fillHeight: true
      Layout.fillWidth: true

      boundsBehavior: Flickable.StopAtBounds
      clip: true

      contentHeight: Utils.ensureArray(_content).reduce(function (acc, item) { return item.height }, 0, []) +
        TabContainerStyle.topMargin + TabContainerStyle.bottomMargin
      contentWidth: width

      Item {
        id: content

        anchors {
          left: parent.left
          leftMargin: TabContainerStyle.leftMargin
          right: parent.right
          rightMargin: TabContainerStyle.rightMargin
          top: parent.top
          topMargin: TabContainerStyle.topMargin
        }
      }
    }

    Rectangle {
      Layout.fillWidth: true
      Layout.preferredHeight: TabContainerStyle.separator.height

      color: TabContainerStyle.separator.color
      visible: scrollBar.visible
56 57 58
    }
  }
}