Advertisement
Guest User

Untitled

a guest
Sep 11th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.0;
  2.  
  3. Item {
  4.     id: button;
  5.     width:  Math.max (label.contentWidth  + 20, 120);
  6.     height: Math.max (label.contentHeight + 20, 40);
  7.  
  8.     property int   roundness : Math.floor (height / 2);
  9.     property color baseColor : "green";
  10.     property alias value     : label.text;
  11.     property alias pressed   : clicker.pressed;
  12.  
  13.     signal clicked ();
  14.  
  15.     Rectangle {
  16.         id: rectAura;
  17.         color: "gray";
  18.         opacity: 0.15;
  19.         antialiasing: true;
  20.         radius: (button.roundness - anchors.margins);
  21.         anchors {
  22.             fill: parent;
  23.             margins: -4;
  24.         }
  25.     }
  26.     Rectangle {
  27.         id: rectShadow;
  28.         color: "black";
  29.         opacity: 0.85;
  30.         antialiasing: true;
  31.         radius: (button.roundness - anchors.margins);
  32.         anchors {
  33.             fill: parent;
  34.             topMargin: (button.pressed ? 0 : +1);
  35.             bottomMargin: (button.pressed ? 0 : -1);
  36.         }
  37.     }
  38.     Rectangle {
  39.         id: rectColor;
  40.         radius: button.roundness;
  41.         antialiasing: true;
  42.         border {
  43.             width: 2;
  44.             color: Qt.darker (button.baseColor, 1.65);
  45.         }
  46.         gradient: Gradient {
  47.             GradientStop { position: (button.pressed ? 1.0 : 0.0); color: Qt.lighter (button.baseColor, 1.45); }
  48.             GradientStop { position: (button.pressed ? 0.0 : 1.0); color: Qt.darker  (button.baseColor, 1.45); }
  49.         }
  50.         anchors {
  51.             fill: parent;
  52.             topMargin: (button.pressed ? +1 : 0);
  53.             bottomMargin: (button.pressed ? -1 : 0);
  54.         }
  55.  
  56.         Rectangle {
  57.             id: rectTangoHighlight;
  58.             color: "transparent";
  59.             opacity: 0.35;
  60.             antialiasing: true;
  61.             radius: (parent.radius - anchors.margins);
  62.             border {
  63.                 width: 1;
  64.                 color: "white";
  65.             }
  66.             anchors {
  67.                 fill: parent;
  68.                 margins: parent.border.width;
  69.             }
  70.         }
  71.         Text {
  72.             id: label;
  73.             text: qsTr ("Nice button !");
  74.             renderType: Text.QtRendering;
  75.             color: "white";
  76.             font {
  77.                 bold: true;
  78.                 pixelSize: 16;
  79.                 family: "Calibri";
  80.             }
  81.             anchors.centerIn: parent;
  82.  
  83.             Text {
  84.                 id: textShadow;
  85.                 z: -1;
  86.                 color: "black";
  87.                 opacity: 0.65;
  88.                 text: parent.text;
  89.                 font: parent.font;
  90.                 visible: (offset !== 0);
  91.                 anchors {
  92.                     fill: parent;
  93.                     topMargin: offset;
  94.                     leftMargin: offset;
  95.                     rightMargin: -offset;
  96.                     bottomMargin: -offset;
  97.                 }
  98.  
  99.                 property int offset : 1;
  100.             }
  101.         }
  102.     }
  103.     MouseArea {
  104.         id: clicker;
  105.         anchors.fill: parent;
  106.         onClicked: { button.clicked (); }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement