Here is a more decent patch (in the unified format) I redid the code after
update10 instead of trying to apply the patches, though I expect it all
came out more or less the same...
The patch can now also be found here:
https://github.com/Keeper-of-the-Keys/jolla-utils/tree/master/jolla-calendar
Just one thing, I'm not the biggest expert on patch, should I remove the
.orig/.update10 in the patch so that both pathes are the original file?
Thanks,
Eli
2014-11-16 15:45 GMT+02:00 E.S. Rosenberg <
[email protected]>:
> 2014-11-14 13:51 GMT+02:00 Pekka Vuorela <[email protected]>:
>
>> to, 2014-11-13 kello 23:43 +0200, E.S. Rosenberg kirjoitti:
>> > Well I solved it and now it's dependent on the locale (which by
>> > default is not set on Jolla) so:
>>
>> > 1. I am more then happy to submit my patches to Jolla, though you guys
>> > claim 'closed source' every file I edited had a BSD license at the
>> > top.
>>
>> I expect you have been checking Silica files. There the QML file side
>> does have BSD licenses on files. Rationale being to allow application
>> developers taking snippets of code when using provided elements directly
>> is not enough for some reason.
>>
>> I don't think we have a precedent of merging contributions there,
>> though. So while it's great you got it working how you like, it could be
>> easier for us (or me) right now to implement this separately.
>>
>> > 2. To actually make this work properly jolla one or all of the
>> > following environment variables need to be present LC_TIME, LC_ALL,
>> > LANG, by default LANG is present but for people like me who want
>> > language A but locale B for dates etc. so some way to set LC_* or at
>> > least LC_ALL would be cool.
>> > I tried adding to my .bashrc but that had no effect for launching from
>> > the launcher, from CLI it helpend of course.
>> >
>> > I assume I need to add it somewhere in dconf but I'm not knowledgeable
>> > enough about dconf for the moment...
>>
>> User session picks up the locale values (that is, LANG at the moment
>> set) from /var/lib/environment/nemo/locale.conf
>>
>> But having different locale categories working properly is not that
>> simple. String translations are also used for date/time patterns, Qt
>> knows only one system locale, etc.
>>
> Are you sure about this, as far as I can tell it's working fine, Qt is one
> of those frameworks that handles locales really well....
>
>>
>> Acknowledged that some people want this, though.
>>
>> > Should I publish the patches here or is that considered unacceptable
>> > behavior on this list?
>>
>> I see no reason not to.
>>
> So here are the patches, they will help you implement it.
>
> /usr/lib/qt5/qml/Sailfish/Silica/DatePickerDialog.qml -- haven't gone over
> the whole file.
> I am not 100% sure the DatePickerDialog.qml patch is needed for the
> calendar fix, but I guess for other uses....
> Modified start date of labels and added Qt.locale().firstDayOfWeek into
> the calculation.
>
> /usr/lib/qt5/qml/Sailfish/Silica/private/DatePicker.js -- this file does
> all the work
> removed variable _weekStartsOnMonday
> added variable _firstDayOfWeek
> added function _setFirstDayOfWeek(dayNo)
> modified function _getStartDateForMonthView(year, month) -- modified the
> math of the function so that it now always gives the right date (no matter
> what the firstDayOfWeeks' value is) and therefor the exception set for
> Monday was commented out.
>
> /usr/share/jolla-calendar/pages/MonthPage.qml -- the QML file that
> describes the jolla-calendar page that matters
> Modified start date of labels and added Qt.locale().firstDayOfWeek into
> the calculation.
>
> /usr/lib/qt5/qml/Sailfish/Silica/DatePicker.qml
> added property firstDayOfWeek which calls
> DatePicker.js._setFirstDayOfWeek() -- this was the only way I know at the
> moment to pass the information known to Qt.locale to the javascript, there
> may be better ways.
>
> As said everything was checked in locales with the 3 different week starts
> that exist according to wikipedia (sat, sun, mon), but it should work for
> any day so unless someone decides that s/he observes the calendar of
> Discworld (8 days/week) it should be fine.
>
> The order of the files in diff was "diff new orig".
>
> A mention of me in the source would be nice, but not mandatory.
> Hope this helps you implement it...
> Eli
>
>>
>>
>> _______________________________________________
>> SailfishOS.org Devel mailing list
>> To unsubscribe, please send a mail to
>> [email protected]
>>
>
>
--- /usr/lib/qt5/qml/Sailfish/Silica/private/DatePicker.js.update10 2014-12-28 18:09:01.990994576 +0200
+++ /usr/lib/qt5/qml/Sailfish/Silica/private/DatePicker.js 2014-12-28 18:19:19.529953760 +0200
@@ -36,7 +36,20 @@
// if this can change dynamically, needs to be a QML property instead
// and also should refer to some settings instead (theme?)
-var _weekStartsOnMonday = true
+//var _weekStartsOnMonday = true
+
+// Instead of (bool)_weekStartsOnMonday have an (int)_firstDayOfWeek, set through
+// _setFirstDayOfWeek which is called in QML which in turn is aware of locale settings.
+// To not harm default behvior (first day of week is Monday) the default value is 1.
+var _firstDayOfWeek = 1;
+
+function _setFirstDayOfWeek(dayNo) {
+ if(_firstDayOfWeek != dayNo && dayNo >= 0 && dayNo <= 6) {
+ _firstDayOfWeek = dayNo;
+ }
+ console.log('Set first day of week to ' + _firstDayOfWeek);
+ return _firstDayOfWeek;
+}
function _isLeapYear(year) {
return ((year % 4 == 0) && (year % 100 != 0))
@@ -63,16 +76,23 @@ function _maxDaysForMonth(month, year) {
// previous month
function _getStartDateForMonthView(year, month) {
var start = new Date(Date.UTC(year, month-1, 1))
- if (start.getDay() > 0) {
- start.setDate(start.getDate() - start.getDay())
- }
- if (_weekStartsOnMonday) {
- start.setDate(start.getDate() + 1)
- if (start.getDate() > 1 && start.getMonth()+1 === month) {
- // shifting forward to Monday skipped over the 1st of this month, go back a week
- // to the last Monday of last month
- start.setDate(start.getDate() - 7)
- }
+
+// Old Logic
+// if (start.getDay() > 0) {
+// start.setDate(start.getDate() - start.getDay())
+// }
+// if (_weekStartsOnMonday) {
+// start.setDate(start.getDate() + 1)
+// if (start.getDate() > 1 && start.getMonth()+1 === month) {
+// // shifting forward to Monday skipped over the 1st of this month, go back a week
+// // to the last Monday of last month
+// start.setDate(start.getDate() - 7)
+// }
+// }
+// New logic using offsets.
+ if (start.getDay() != _firstDayOfWeek) {
+ // Math used to offset (7 - (firstdayoffset - startDay))%7
+ start.setDate(start.getDate() - ((7 - (_firstDayOfWeek - start.getDay())) % 7))
}
return start
}
--- /usr/lib/qt5/qml/Sailfish/Silica/DatePicker.qml.update10 2014-12-28 18:11:20.989315939 +0200
+++ /usr/lib/qt5/qml/Sailfish/Silica/DatePicker.qml 2014-12-28 18:12:10.872544989 +0200
@@ -51,6 +51,7 @@ Item {
property date date: new Date()
property string dateText: Qt.formatDate(date)
property alias viewMoving: view.viewMovingImmediate
+ property int firstDayOfWeek: DatePickerScript._setFirstDayOfWeek(Qt.locale().firstDayOfWeek)
property Component modelComponent
property Component delegate: Component {
--- /usr/share/jolla-calendar/pages/MonthPage.qml.orig 2014-11-12 01:25:41.600602303 +0200
+++ /usr/share/jolla-calendar/pages/MonthPage.qml 2014-12-28 18:03:25.371797302 +0200
@@ -7,6 +7,8 @@ import "Util.js" as Util
Page {
id: root
+ property bool initialLoadDone
+
function addEvent() {
var now = new Date
var d = datePicker.date
@@ -71,8 +73,8 @@ Page {
delegate: Label {
y: 3
opacity: 0.6
- // 3 Jan 2000 was a Monday
- text: Qt.formatDateTime(new Date(2000, 0, 3 + index, 12), "ddd")
+ // 2 Jan 2000 was a Sunday
+ text: Qt.formatDateTime(new Date(2000, 0, 2 + Qt.locale().firstDayOfWeek + index, 12), "ddd")
color: Theme.highlightColor
width: parent.width / 7
font.pixelSize: Theme.fontSizeSmall
@@ -109,6 +111,11 @@ Page {
when: !datePicker.viewMoving
}
+ Connections {
+ target: !root.initialLoadDone ? agendaModel : null
+ onUpdated: root.initialLoadDone = true
+ }
+
VerticalScrollDecorator {}
Column {
width: view.width
@@ -245,7 +252,7 @@ Page {
Item {
width: parent.width
height: placeholderText.height + 2*Theme.paddingLarge
- visible: view.count === 0
+ visible: view.count === 0 && root.initialLoadDone
Label {
id: placeholderText
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to [email protected]