Advertisement
Guest User

Untitled

a guest
May 27th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 3.22 KB | None | 0 0
  1.     TabView {
  2.         id: tabs
  3.         width: browserWindow.width / 1.8
  4.         function createEmptyTab(profile) {
  5.             var tab = addTab("new tab", tabComponent);
  6.             // We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately.
  7.             tab.active = true;
  8.             tab.title = Qt.binding(function() { return tab.item.title });
  9.             tab.item.profile = profile;
  10.             return tab;
  11.  
  12.         }
  13.  
  14.         anchors.top: parent.top
  15.         anchors.bottom: devToolsView.bottom
  16.         anchors.left: parent.left
  17.         anchors.right: parent.right
  18.         Component.onCompleted: createEmptyTab(defaultProfile)
  19.  
  20.         // Add custom tab view style so we can customize the tabs to include a close button
  21.         style: TabViewStyle {
  22.             id: whiteTabs
  23.             property color frameColor: "#999"
  24.             property color fillColor: "#eee"
  25.             property color nonSelectedColor: "#ddd"
  26.             frameOverlap: 1
  27.             frame: Rectangle {
  28.                 color: "#fff"
  29.                 border.color: frameColor
  30.             }
  31.             tab: Rectangle {
  32.                 id: tabRectangle
  33.                 width: 600
  34.                 height: 23
  35.                 color: styleData.selected ? '#C4C4C4' : '#DDDDDD'
  36.                 radius: 4
  37.                 clip: true
  38.  
  39.                 implicitWidth: Math.max(50, 100)
  40.                 implicitHeight: Math.max(text.height + 10, 20)
  41.  
  42.                 Text {
  43.                     id: text
  44.                     anchors.left: parent.left
  45.                     anchors.verticalCenter: parent.verticalCenter
  46.                     height: 15
  47.                     anchors.leftMargin: 26
  48.                     anchors.topMargin: 26
  49.                     text: styleData.title
  50.                     elide: Text.ElideRight
  51.                     color: styleData.selected ? "black" : frameColor
  52.                 }
  53.                 Button {
  54.                     anchors.right: parent.right
  55.                     anchors.verticalCenter: parent.verticalCenter
  56.                     anchors.rightMargin: 1
  57.                     height: 12
  58.                     iconSource: "icons/close.svg"
  59.                     style: ButtonStyle {
  60.                         background: Rectangle {
  61.                             implicitWidth: 30
  62.                             implicitHeight: 35
  63.                             color: control.hovered ? "#ccc" : tabRectangle.color
  64.  
  65.                         }}
  66.                     onClicked: tabs.removeTab(styleData.index);
  67.                 }
  68.  
  69.                 Button {
  70.                     anchors.left: parent.left
  71.                     anchors.verticalCenter: parent.verticalCenter
  72.                     anchors.rightMargin: 10
  73.                     height: 15
  74.                     iconSource: "icons/add.svg"
  75.                     style: ButtonStyle {
  76.                         background: Rectangle {
  77.                             implicitWidth: 10
  78.                             implicitHeight: 10
  79.                             color: control.hovered ? "#ccc" : tabRectangle.color
  80.                         }}
  81.                     onClicked: tabs.createEmptyTab(styleData.index);
  82.                 }
  83.             }
  84.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement