Advertisement
Guest User

Untitled

a guest
Oct 25th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 6.27 KB | None | 0 0
  1. import QtQuick 2.6
  2.  
  3. Rectangle {
  4.     id: painel
  5.     visible: true
  6.     width: 800
  7.     height: 600
  8.     color: "darkBlue"
  9.  
  10.     property int margins: 10
  11.  
  12.     property int senhaAtual: 1
  13.     property int numGuiches: 10
  14.  
  15.     function chamaSenha() {
  16.         senhaAtual++
  17.         var guicheAtual = Math.round(Math.random() * numGuiches)
  18.  
  19.         senha.text = "A" + ("000" + senhaAtual).slice(-3)
  20.         guiche.text = guicheAtual
  21.  
  22.         modeloAnteriores.append({senha: senha.text, guiche: guiche.text})
  23.  
  24.         // remove any exceeding items
  25.         if (modeloAnteriores.count > 9) {
  26.             modeloAnteriores.remove(0, 1)
  27.         }
  28.     }
  29.  
  30.     Rectangle {
  31.         id: painelSenha
  32.  
  33.         anchors {
  34.             top: parent.top
  35.             left: parent.left
  36.             bottom: parent.verticalCenter
  37.             bottomMargin: 5
  38.             right: parent.horizontalCenter
  39.             margins: painel.margins
  40.         }
  41.         color: "orange"
  42.  
  43.         Column {
  44.             anchors.fill: parent
  45.             spacing: painel.margins
  46.  
  47.             Text {
  48.                 color: "darkBlue"
  49.                 font.pointSize: 40
  50.                 text: "SENHA"
  51.                 horizontalAlignment: Text.AlignHCenter
  52.                 anchors {
  53.                     left: parent.left
  54.                     right: parent.right
  55.                 }
  56.             }
  57.  
  58.             Text {
  59.                 id: senha
  60.                 color: "darkBlue"
  61.                 font.pointSize: 100
  62.                 text: "A001"
  63.                 horizontalAlignment: Text.AlignHCenter
  64.                 anchors {
  65.                     left: parent.left
  66.                     right: parent.right
  67.                 }
  68.             }
  69.         }
  70.     }
  71.  
  72.     Rectangle {
  73.         id: painelGuiche
  74.  
  75.         anchors {
  76.             top: parent.verticalCenter
  77.             topMargin: margins / 2
  78.             left: parent.left
  79.             leftMargin: margins / 2
  80.             bottom: parent.bottom
  81.             right: parent.horizontalCenter
  82.             margins: painel.margins
  83.         }
  84.         color: "orange"
  85.  
  86.         Column {
  87.             anchors.fill: parent
  88.             spacing: painel.margins
  89.  
  90.             Text {
  91.                 color: "darkBlue"
  92.                 font.pointSize: 40
  93.                 text: "GUICHÊ"
  94.                 horizontalAlignment: Text.AlignHCenter
  95.                 anchors {
  96.                     left: parent.left
  97.                     right: parent.right
  98.                 }
  99.             }
  100.  
  101.             Text {
  102.                 id: guiche
  103.                 color: "darkBlue"
  104.                 font.pointSize: 100
  105.                 text: "1"
  106.                 horizontalAlignment: Text.AlignHCenter
  107.                 anchors {
  108.                     left: parent.left
  109.                     right: parent.right
  110.                 }
  111.             }
  112.         }
  113.     }
  114.  
  115.     ListModel {
  116.         id: modeloAnteriores
  117.         ListElement { senha: "A001"; guiche: "1" }
  118.     }
  119.  
  120.     Rectangle {
  121.         id: painelAnteriores
  122.  
  123.         property int fontSize: 30
  124.  
  125.         anchors {
  126.             top: parent.top
  127.             left: parent.horizontalCenter
  128.             bottom: parent.bottom
  129.             right: parent.right
  130.             margins: painel.margins
  131.         }
  132.         color: "orange"
  133.  
  134.         Column {
  135.             id: viewAnteriores
  136.             anchors.fill: parent
  137.  
  138.             // cabeçalho
  139.             Item {
  140.                 anchors {
  141.                     left: parent.left
  142.                     right: parent.right
  143.                 }
  144.                 height: childrenRect.height
  145.  
  146.                 Text {
  147.                     anchors {
  148.                         left: parent.left
  149.                         top: parent.top
  150.                     }
  151.                     width: parent.width / 2
  152.                     text: "SENHA"
  153.                     color: "darkBlue"
  154.                     font.pointSize: painelAnteriores.fontSize
  155.                     horizontalAlignment: Text.AlignHCenter
  156.                 }
  157.  
  158.                 Text {
  159.                     anchors {
  160.                         right: parent.right
  161.                         top: parent.top
  162.                     }
  163.                     width: parent.width / 2
  164.                     text: "GUICHÊ"
  165.                     color: "darkBlue"
  166.                     font.pointSize: painelAnteriores.fontSize
  167.                     horizontalAlignment: Text.AlignHCenter
  168.                 }
  169.             }
  170.  
  171.             Repeater {
  172.                 model: modeloAnteriores
  173.  
  174.                 Item {
  175.                     anchors {
  176.                         left: parent.left
  177.                         right: parent.right
  178.                     }
  179.                     height: childrenRect.height
  180.  
  181.                     Text {
  182.                         anchors {
  183.                             left: parent.left
  184.                             top: parent.top
  185.                         }
  186.                         width: parent.width / 2
  187.                         text: model.senha
  188.                         color: "darkBlue"
  189.                         font.pointSize: painelAnteriores.fontSize
  190.                         horizontalAlignment: Text.AlignHCenter
  191.                     }
  192.  
  193.                     Text {
  194.                         anchors {
  195.                             right: parent.right
  196.                             top: parent.top
  197.                         }
  198.                         width: parent.width / 2
  199.                         text: model.guiche
  200.                         color: "darkBlue"
  201.                         font.pointSize: painelAnteriores.fontSize
  202.                         horizontalAlignment: Text.AlignHCenter
  203.                     }
  204.                 }
  205.             }
  206.         }
  207.  
  208.         // desenha uma linha dividindo os textos
  209.         Rectangle {
  210.             color: "darkBlue"
  211.             width: painel.margins
  212.             anchors {
  213.                 top: parent.top
  214.                 bottom: parent.bottom
  215.                 horizontalCenter: parent.horizontalCenter
  216.             }
  217.         }
  218.     }
  219.  
  220.     // um botão jaguara só pra chamar próxima senha
  221.     Rectangle {
  222.         radius: width / 2
  223.         width: 100
  224.         height: width
  225.  
  226.         color: "red"
  227.         anchors.centerIn: parent
  228.  
  229.         MouseArea {
  230.             anchors.fill: parent
  231.             onClicked: chamaSenha()
  232.         }
  233.     }
  234.  
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement