Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 5.71 KB | None | 0 0
  1.         Rectangle {
  2.             id: navigationbar
  3.             width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
  4.             height: (parent.height > parent.width ? parent.height - (parent.height- 50) - parent.spacing : parent.height - (parent.height-50))
  5.             Rectangle {
  6.                 anchors.fill: parent
  7.                 gradient: Gradient {//...}
  8.                 border.width: 1.3
  9.  
  10.                 Image {
  11.                     id: settingsDate
  12.                     // ...
  13.                     MouseArea {
  14.                         id: mouseAreaSett
  15.                         anchors.fill: parent
  16.                         onClicked: {
  17.                             console.debug(aNewMonth)
  18.                             aNewMonth--;
  19.                             // increment the month
  20.                             calendar.selectedDate.setFullYear(aNewYear, aNewMonth, aNewDay);
  21.                             // this code not work
  22.                         }
  23.                     }
  24.  
  25.                 }
  26.  
  27.                 Image {
  28.                     id: prevDay
  29.                     // ...
  30.                     MouseArea {
  31.                         id: mouseAreaPrev
  32.                         anchors.fill: parent
  33.                         onClicked: {
  34.                             // prevDay actions ...
  35.                             calendar.selectedDate.setFullYear(aNewYear, aNewMonth, aNewDay);
  36.                             // nope
  37.                         }
  38.                     }
  39.  
  40.                 }
  41.  
  42.                 TextEdit {
  43.                     id: displayDate
  44.                     // ...
  45.                     MouseArea {
  46.                         id: mouseAreaDisp
  47.                         anchors.fill: parent
  48.                         onClicked: {
  49.                             var d = new Date();
  50.                             aNewDay = d.getDate();
  51.                             aNewMonth = d.getMonth();
  52.                             aNewYear = d.getFullYear();
  53.                             calendar.selectedDate.setFullYear(aNewYear, aNewMonth, aNewDay);
  54.                             // the calendar does not respond the choosen date
  55.                         }
  56.                     }
  57.  
  58.                 }
  59.  
  60.                 Image {
  61.                     id: nextDay
  62.                     // ...
  63.                     MouseArea {
  64.                         id: mouseAreaNext
  65.                         anchors.fill: parent
  66.                         onClicked: {
  67.                             aNewDay++
  68.                             // nextDay actions
  69.                             calendar.selectedDate.setFullYear(aNewYear, aNewMonth, aNewDay);
  70.                             calendar.update();
  71.                             // this does not work
  72.                         }
  73.                     }
  74.                 }
  75.  
  76.                 Image {
  77.                     id: plusMonth
  78.             // ...
  79.                     MouseArea {
  80.                         id: mouseAreaPlus
  81.                         anchors.fill: parent
  82.                         onClicked: {
  83.                             aNewMonth++;
  84.                             // plus month actions
  85.                             calendar.selectedDate.setFullYear(aNewYear, aNewMonth, aNewDay);
  86.                             // I don't know how to past the choosen date to calendar?
  87.                         }
  88.                     }
  89.                 }
  90.             }
  91.         Calendar {
  92.             id: calendar
  93.             width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
  94.             height: (parent.height > parent.width ? parent.height * 0.6 - parent.spacing : parent.height)
  95.             frameVisible: true
  96.             weekNumbersVisible: false
  97.             navigationBarVisible: false
  98.  
  99.             selectedDate: currentDate
  100.             focus: true
  101.             style: CalendarStyle {
  102.                 dayDelegate: Item {
  103.                     readonly property int dpi: Screen.pixelDensity*1.4
  104.                     readonly property color sameMonthDateTextColor: "#444"
  105.                     readonly property color selectedDateColor: Qt.platform.os === "osx" ? "#3778d0" : systemPalette.highlight
  106.                     readonly property color selectedDateTextColor: "white"
  107.                     readonly property color differentMonthDateTextColor: "#bbb000"
  108.                     readonly property color invalidDatecolor: "#dddddd"
  109.  
  110.                     Rectangle {
  111.                         id: selectedDayRect
  112.                         anchors.fill: parent
  113.                         border.color: "transparent"
  114.                         color: styleData.date !== undefined && styleData.selected ? selectedDateColor : "transparent"
  115.                         anchors.margins: styleData.selected ? -1 : 0
  116.                     }
  117.                     // code of my own imags, not relevant here ...
  118.                     Label {
  119.                         id: dayDelegateText
  120.                         text: styleData.date.getDate()
  121.                         anchors.top: parent.top
  122.                         anchors.right: parent.right
  123.                         anchors.margins: 0
  124.                         color: {
  125.                             var color = invalidDatecolor;
  126.                             if (styleData.valid) {
  127.                                 // Date is within the valid range.
  128.                                 color = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor;
  129.                                 if (styleData.selected) {
  130.                                     color = selectedDateTextColor;
  131.                                 }
  132.                             }
  133.                             color;
  134.                         }
  135.                     }
  136.                    
  137.                }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement