4import QtQuick.Controls 2.0
6import "../../constants" 1.0
12 anchors.verticalCenter: parent.verticalCenter
15 background: Rectangle {
17 color: Num.sysPalette.base
22 text: control.textFromValue(control.value, control.locale)
23 anchors.verticalCenter: parent.verticalCenter
26 color: Num.sysPalette.text
27 horizontalAlignment:
Qt.AlignHCenter
28 verticalAlignment:
Qt.AlignVCenter
31 property int spacingg: 0
36 console.log(up.pressed)
40 up.indicator: Rectangle {
42 x: control.mirrored ? -spacingg : parent.width - width + spacingg
43 anchors.verticalCenter: parent.verticalCenter
46 color: up.pressed || !enabled ? Num.sysPalette.light : Num.sysPalette.base
47 border.color: up.pressed || !enabled ? Num.sysPalette.base : Num.sysPalette.light
53 font.pixelSize: control.font.pixelSize * 2
54 color: up.pressed || !enabled ? Num.sysPalette.dark : Num.sysPalette.
text
56 fontSizeMode: Text.Fit
57 horizontalAlignment: Text.AlignHCenter
58 verticalAlignment: Text.AlignVCenter
62 down.indicator: Rectangle {
64 x: control.mirrored ? parent.width - width + spacingg : -spacingg
65 anchors.verticalCenter: parent.verticalCenter
68 color: down.pressed || !enabled ? Num.sysPalette.light : Num.sysPalette.base
69 border.color: down.pressed || !enabled ? Num.sysPalette.base : Num.sysPalette.light
74 font.pixelSize: control.font.pixelSize * 2
75 color: down.pressed || !enabled ? Num.sysPalette.dark : Num.sysPalette.text
77 fontSizeMode: Text.Fit
78 horizontalAlignment: Text.AlignHCenter
79 verticalAlignment: Text.AlignVCenter
83 property bool daysOnly:
false
89 Component.onCompleted: {
93 property double secs_per_day: 86400.0
94 property double sidereal_year: 31558149.77
95 property double tropical_year: 31556925.19
97 property var timeString: []
98 property var timeScale: []
101 property int unitValue: 1
102 property int allunits: 8
103 property int dayunits: 5
104 property int minUnitValue
105 property int maxUnitValue
106 property var unitStep: []
108 function setDaysOnly() {
122 timeScale[10] = 60.0;
123 timeScale[11] = 120.0;
124 timeScale[12] = 300.0;
125 timeScale[13] = 600.0;
126 timeScale[14] = 900.0;
127 timeScale[15] = 1800.0;
128 timeScale[16] = 3600.0;
129 timeScale[17] = 7200.0;
130 timeScale[18] = 10800.0;
131 timeScale[19] = 21600.0;
132 timeScale[20] = 43200.0;
136 timeScale[i+1] = 86164.1;
137 timeScale[i+2] = secs_per_day;
138 timeScale[i+3] = 2.*secs_per_day;
139 timeScale[i+4] = 3.*secs_per_day;
140 timeScale[i+5] = 5.*secs_per_day;
141 timeScale[i+6] = 7.*secs_per_day;
142 timeScale[i+7] = 14.*secs_per_day;
143 timeScale[i+8] = 21.*secs_per_day;
145 timeScale[i+9] = sidereal_year/12.0;
146 timeScale[i+10] = sidereal_year/6.0;
147 timeScale[i+11] = 0.25*sidereal_year;
148 timeScale[i+12] = sidereal_year/3.0;
149 timeScale[i+13] = 0.5*sidereal_year;
150 timeScale[i+14] = 0.75*sidereal_year;
151 timeScale[i+15] = sidereal_year;
152 timeScale[i+16] = 2.0*sidereal_year;
153 timeScale[i+17] = 3.0*sidereal_year;
154 timeScale[i+18] = 5.0*sidereal_year;
155 timeScale[i+19] = 10.0*sidereal_year;
156 timeScale[i+20] = 25.0*sidereal_year;
157 timeScale[i+21] = 50.0*sidereal_year;
158 timeScale[i+22] = 100.0*sidereal_year;
162 timeString.push(
i18n(
"0 secs" ));
163 timeString.push(
i18n(
"0.1 secs" ));
164 timeString.push(
i18n(
"0.25 secs" ));
165 timeString.push(
i18n(
"0.5 secs" ));
166 timeString.push(
i18n(
"1 sec" ));
167 timeString.push(
i18n(
"2 secs" ));
168 timeString.push(
i18n(
"5 secs" ));
169 timeString.push(
i18n(
"10 secs" ));
170 timeString.push(
i18n(
"20 secs" ));
171 timeString.push(
i18n(
"30 secs" ));
172 timeString.push(
i18n(
"1 min" ));
173 timeString.push(
i18n(
"2 mins" ));
174 timeString.push(
i18n(
"5 mins" ));
175 timeString.push(
i18n(
"10 mins" ));
176 timeString.push(
i18n(
"15 mins" ));
177 timeString.push(
i18n(
"30 mins" ));
178 timeString.push(
i18n(
"1 hour" ));
179 timeString.push(
i18n(
"2 hrs" ));
180 timeString.push(
i18n(
"3 hrs" ));
181 timeString.push(
i18n(
"6 hrs" ));
182 timeString.push(
i18n(
"12 hrs" ));
184 timeString.push(
i18n(
"0 days" ));
186 timeString.push(
i18n(
"1 sid day" ));
187 timeString.push(
i18n(
"1 day" ));
188 timeString.push(
i18n(
"2 days" ));
189 timeString.push(
i18n(
"3 days" ));
190 timeString.push(
i18n(
"5 days" ));
191 timeString.push(
i18n(
"1 week" ));
192 timeString.push(
i18n(
"2 wks" ));
193 timeString.push(
i18n(
"3 wks" ));
194 timeString.push(
i18n(
"1 month" ));
195 timeString.push(
i18n(
"2 mths" ));
196 timeString.push(
i18n(
"3 mths" ));
197 timeString.push(
i18n(
"4 mths" ));
198 timeString.push(
i18n(
"6 mths" ));
199 timeString.push(
i18n(
"9 mths" ));
200 timeString.push(
i18n(
"1 year" ));
201 timeString.push(
i18n(
"2 yrs" ));
202 timeString.push(
i18n(
"3 yrs" ));
203 timeString.push(
i18n(
"5 yrs" ));
204 timeString.push(
i18n(
"10 yrs" ));
205 timeString.push(
i18n(
"25 yrs" ));
206 timeString.push(
i18n(
"50 yrs" ));
207 timeString.push(
i18n(
"100 yrs" ));
218 minUnitValue = 1-dayunits
219 maxUnitValue = dayunits-1
228 minUnitValue = 1-allunits
229 maxUnitValue = allunits-1
245 function increaseTimeUnit() {
246 if(unitValue < maxUnitValue) {
247 unitValue = unitValue + 1
248 value = getUnitValue()
252 function decreaseTimeUnit() {
253 if(unitValue > minUnitValue) {
254 unitValue = unitValue - 1
255 value = getUnitValue()
259 function getUnitValue() {
261 if ( unitValue >= 0 ) uval = unitStep[ unitValue ];
262 else uval = -1*unitStep[ Math.abs( unitValue ) ];
266 function unitValueFromNum( val ) {
267 if ( val >= 0 )
return unitStep[ val ];
268 else return -1*unitStep[ Math.abs( val ) ];
271 function getTimeScale() {
272 return value > 0 ? timeScale[ value ] : -1.*timeScale[ Math.abs(value) ];
275 function reportChange() {
276 console.log(
"Reporting new timestep value: " + getTimeScale())
280 textFromValue: function(value) {
282 var posval = Math.abs( value )
283 if ( posval > timeString.length - 1 ) posval = 4;
285 result = timeString[ posval ];
287 if ( value < 0 ) { result =
'-' + result; }
293 valueFromText: function(text) {
295 for (var i = 0; i < timeString.length; ++i) {
296 if (text === timeString[i])
return i
297 if (text.substring(1) === timeString[i])
return -1*i
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
void scaleChanged(float)
Emitted whenever TimeSpinBox in QML changes the scale.
QString i18n(const char *text, const TYPE &arg...)