Advertisement
Guest User

Untitled

a guest
May 9th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.01 KB | None | 0 0
  1. import QtQuick 2.6
  2. import QtQuick.Layouts 1.1
  3. import QtQuick.Window 2.2
  4. import QtQuick.Controls 2.0
  5.  
  6. ApplicationWindow {
  7.     width: 400
  8.     height: 200
  9.     visible: true
  10.  
  11.     onActiveFocusItemChanged: print("activeFocusItem", activeFocusItem)
  12.  
  13.     header: ToolBar {
  14.         RowLayout {
  15.             focus: false
  16.             implicitWidth: children[0].implicitWidth
  17.             implicitHeight: children[0].implicitHeight
  18.  
  19.             ToolButton {
  20.                 text: qsTr("File")
  21.                 onClicked: {
  22.                     print("@@@@@@@@@ clicked menu toolbutton")
  23.                     fileMenu.open()
  24.                 }
  25.  
  26.                 Menu {
  27.                     id: fileMenu
  28.                     y: parent.height
  29.                     onClosed: print("@@@@@@@@@ closed menu")
  30.  
  31.                     MenuItem {
  32.                         text: qsTr("New")
  33.                     }
  34.                     MenuItem {
  35.                         text: qsTr("open")
  36.                     }
  37.                     MenuItem {
  38.                         text: qsTr("Close")
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.     }
  44.  
  45.     FocusScope {
  46.         id: focusScope
  47.         focus: true
  48.         anchors.fill: parent
  49.  
  50.         property bool toggled: false
  51.  
  52.         Keys.onPressed: {
  53.             if (event.modifiers === Qt.AltModifier) {
  54.                 focusScope.toggled = true;
  55.             }
  56.         }
  57.         Keys.onReleased: {
  58.             if ((event.modifiers === Qt.AltModifier || event.key === Qt.Key_Alt) && !event.isAutoRepeat) {
  59.                 focusScope.toggled = false;
  60.             }
  61.         }
  62.  
  63.         RowLayout {
  64.             anchors.centerIn: parent
  65.  
  66.             Button {
  67.                 id: penButton
  68.                 text: qsTr("Pen")
  69.                 highlighted: !focusScope.toggled
  70.             }
  71.             Button {
  72.                 id: eyedropperButton
  73.                 text: qsTr("Eyedropper")
  74.                 highlighted: focusScope.toggled
  75.             }
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement