Advertisement
Guest User

styles

a guest
Dec 7th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 0.94 KB | None | 0 0
  1. //controls/Action.decl
  2. Action : Object {
  3.     property bool checkable;
  4.     property bool checked;
  5.     property bool enabled;
  6. }
  7.  
  8. //Global
  9. ButtonStyle : Item {
  10.     id : defaultButtonStyle;
  11.  
  12.     Rectangle {
  13.         anchors.fill: defaultButtonStyle.parent;
  14.  
  15.         color: defaultButtonStyle.parent.Button.checked ? "#000000" : "#FFFFFF";
  16.     }
  17. }
  18.  
  19. //controls/Button.decl
  20. Button : Item {
  21.     id: root;
  22.  
  23.     property alias checkable: action.checkable;
  24.     property alias checked: action.checked;
  25.     property ButtonStylePtr style;
  26.  
  27.     Action {
  28.         id: action;
  29.  
  30.         enabled: root.enabled;
  31.     }
  32.  
  33.     onSelectPressed: {
  34.         if (enabled) {
  35.             if (checkable)
  36.                 checked = !checked;
  37.         }
  38.     }
  39.  
  40.     onCompleted: {
  41.         if (!style)
  42.             self->style = Globals()->defaultButtonStyle;
  43.     }
  44. }
  45.  
  46. //myapp/styles/ButtonStyles.decl
  47. CustomButtonStyle : ButtonStyle {
  48. }
  49.  
  50. //myapp/MyApp.decl
  51.  
  52. CustomButtonStyle {
  53.     id: customButtonStyle;
  54. }
  55.  
  56. Button {
  57.     id: myAppButton;
  58.  
  59.     style: customButtonStyle;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement