Advertisement
Guest User

Untitled

a guest
May 4th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.72 KB | None | 0 0
  1. import QtQuick 2.1;
  2. import QtQuick.Window 2.1;
  3.  
  4. Window {
  5.     id: window;
  6.     width: 800;
  7.     height: 600;
  8.     visible: true;
  9.  
  10.     readonly property var centerLetterMove : { "0-left"    : ["a", "m", "y"],
  11.                                                "0-right"   : ["b", "n", "z"],
  12.                                                "60-left"   : ["c", "o", "."],
  13.                                                "60-right"  : ["d", "p", "?"],
  14.                                                "120-left"  : ["e", "q", "!"],
  15.                                                "120-right" : ["f", "r", ","],
  16.                                                "180-left"  : ["g", "s", ";"],
  17.                                                "180-right" : ["h", "t", ":"],
  18.                                                "240-left"  : ["i", "u", "'"],
  19.                                                "240-right" : ["j", "v", "("],
  20.                                                "300-left"  : ["k", "w", ")"],
  21.                                                "300-right" : ["l", "x", "$"],
  22.     };
  23.  
  24.     Rectangle {
  25.         id: centerDot;
  26.         color: "blue";
  27.         width: 50;
  28.         height: width;
  29.         radius: (width * 0.5);
  30.         opacity: 0.5;
  31.         anchors.centerIn: parent;
  32.     }
  33.     Repeater {
  34.         model: Object.keys (centerLetterMove);
  35.         delegate: Item {
  36.             id: branch;
  37.             anchors.centerIn: centerDot;
  38.  
  39.             readonly property string key      : modelData;
  40.             readonly property real   angle    : (parseInt (key.split ("-") [0].toString ()) * Math.PI / 180);
  41.             readonly property real   sin      : Math.sin (angle);
  42.             readonly property real   cos      : Math.cos (angle);
  43.             readonly property int    side     : (key.indexOf ("left") !== -1 ? -1 : 1);
  44.  
  45.             Repeater {
  46.                 model: centerLetterMove [key];
  47.                 delegate: Item {
  48.                     anchors {
  49.                         centerIn: parent;
  50.                         verticalCenterOffset:   (branch.sin * radius) + (charText.height * 0.4 * branch.side * branch.cos);
  51.                         horizontalCenterOffset: (branch.cos * radius) - (charText.height * 0.4 * branch.side * branch.sin);
  52.                     }
  53.  
  54.                     readonly property real radius : (centerDot.radius + (model.index + 1) * charText.height * 0.8);
  55.  
  56.                     Text {
  57.                         id: charText;
  58.                         text: modelData;
  59.                         font.pixelSize: 15;
  60.                         anchors.verticalCenter: parent.top;
  61.                         anchors.horizontalCenter: parent.left;
  62.                     }
  63.                 }
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement