Skip to main content
<div id="tree_path"> &lt;span class=&quot;pjs-branch-select&quot;&gt;&lt;i class=&#039;octicon octicon-git-branch&#039;&gt;&lt;/i&gt;&lt;div class=&quot;form-group field select&quot;&gt; &lt;label for=&quot;id_sel_branch&quot;&gt;&lt;/label&gt; &lt;select name=&quot;sel_branch&quot; id=&quot;id_sel_branch&quot; class=&quot;form-control&quot; aria-describedby=&quot;sel_branch_tip&quot;&gt; &lt;option value=&quot;https://kirgroup.com/projects/fabrixxm/harbour-friendly/tree/feature/notifications/qml/harbour-friendly.qml&quot; &gt;feature/notifications&lt;/option&gt;&lt;option value=&quot;https://kirgroup.com/projects/fabrixxm/harbour-friendly/tree/master/qml/harbour-friendly.qml&quot; selected=&quot;selected&quot;&gt;master&lt;/option&gt;&lt;option value=&quot;https://kirgroup.com/projects/fabrixxm/harbour-friendly/tree/pms/qml/harbour-friendly.qml&quot; &gt;pms&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/span&gt; - <a class="pjs-bc-first " href="https://kirgroup.com/projects/fabrixxm/harbour-friendly">harbour-friendly</a> / <a class=" " href="https://kirgroup.com/projects/fabrixxm/harbour-friendly/qml">qml</a> / <a class=" pjs-bc-last" href="https://kirgroup.com/projects/fabrixxm/harbour-friendly/qml/harbour-friendly.qml">harbour-friendly.qml</a> </div>
<div id='L1' class='linehi'><a name='L1' href='#L1' class='linenumber'>1</a>import QtQuick 2.0</div> <div id='L2' class='linehi'><a name='L2' href='#L2' class='linenumber'>2</a>import Sailfish.Silica 1.0</div> <div id='L3' class='linehi'><a name='L3' href='#L3' class='linenumber'>3</a>import org.nemomobile.notifications 1.0</div> <div id='L4' class='linehi'><a name='L4' href='#L4' class='linenumber'>4</a></div> <div id='L5' class='linehi'><a name='L5' href='#L5' class='linenumber'>5</a>import &quot;../core/qml/models&quot;</div> <div id='L6' class='linehi'><a name='L6' href='#L6' class='linenumber'>6</a>import &quot;./pages&quot;</div> <div id='L7' class='linehi'><a name='L7' href='#L7' class='linenumber'>7</a>import &quot;./models&quot;</div> <div id='L8' class='linehi'><a name='L8' href='#L8' class='linenumber'>8</a></div> <div id='L9' class='linehi'><a name='L9' href='#L9' class='linenumber'>9</a>ApplicationWindow</div> <div id='L10' class='linehi'><a name='L10' href='#L10' class='linenumber'>10</a>{</div> <div id='L11' class='linehi'><a name='L11' href='#L11' class='linenumber'>11</a> HarbourSettingsModel { id: settingsSchema }</div> <div id='L12' class='linehi'><a name='L12' href='#L12' class='linenumber'>12</a></div> <div id='L13' class='linehi'><a name='L13' href='#L13' class='linenumber'>13</a> NetworkModel { id: networkModel }</div> <div id='L14' class='linehi'><a name='L14' href='#L14' class='linenumber'>14</a></div> <div id='L15' class='linehi'><a name='L15' href='#L15' class='linenumber'>15</a> FriendsModel { id: friendsModel }</div> <div id='L16' class='linehi'><a name='L16' href='#L16' class='linenumber'>16</a></div> <div id='L17' class='linehi'><a name='L17' href='#L17' class='linenumber'>17</a> PMListModel { id: pmListModel }</div> <div id='L18' class='linehi'><a name='L18' href='#L18' class='linenumber'>18</a></div> <div id='L19' class='linehi'><a name='L19' href='#L19' class='linenumber'>19</a> Notification {</div> <div id='L20' class='linehi'><a name='L20' href='#L20' class='linenumber'>20</a> id: applicationNotification</div> <div id='L21' class='linehi'><a name='L21' href='#L21' class='linenumber'>21</a> category: &quot;x-nemo.messaging.im.preview&quot;</div> <div id='L22' class='linehi'><a name='L22' href='#L22' class='linenumber'>22</a> appName: &quot;Friendly&quot;</div> <div id='L23' class='linehi'><a name='L23' href='#L23' class='linenumber'>23</a> appIcon: &quot;harbour-friendly&quot;</div> <div id='L24' class='linehi'><a name='L24' href='#L24' class='linenumber'>24</a></div> <div id='L25' class='linehi'><a name='L25' href='#L25' class='linenumber'>25</a> onClosed: {</div> <div id='L26' class='linehi'><a name='L26' href='#L26' class='linenumber'>26</a> if (reason == 2) { // Notification.DismissedByUser</div> <div id='L27' class='linehi'><a name='L27' href='#L27' class='linenumber'>27</a> activate();</div> <div id='L28' class='linehi'><a name='L28' href='#L28' class='linenumber'>28</a> pageStack.push(Qt.resolvedUrl(&quot;NotificationsPage.qml&quot;));</div> <div id='L29' class='linehi'><a name='L29' href='#L29' class='linenumber'>29</a> }</div> <div id='L30' class='linehi'><a name='L30' href='#L30' class='linenumber'>30</a> }</div> <div id='L31' class='linehi'><a name='L31' href='#L31' class='linenumber'>31</a> onClicked : { }</div> <div id='L32' class='linehi'><a name='L32' href='#L32' class='linenumber'>32</a> }</div> <div id='L33' class='linehi'><a name='L33' href='#L33' class='linenumber'>33</a></div> <div id='L34' class='linehi'><a name='L34' href='#L34' class='linenumber'>34</a></div> <div id='L35' class='linehi'><a name='L35' href='#L35' class='linenumber'>35</a> PingModel {</div> <div id='L36' class='linehi'><a name='L36' href='#L36' class='linenumber'>36</a> id: pingModel</div> <div id='L37' class='linehi'><a name='L37' href='#L37' class='linenumber'>37</a></div> <div id='L38' class='linehi'><a name='L38' href='#L38' class='linenumber'>38</a> onNotification: {</div> <div id='L39' class='linehi'><a name='L39' href='#L39' class='linenumber'>39</a> // (array notificationlist)</div> <div id='L40' class='linehi'><a name='L40' href='#L40' class='linenumber'>40</a> // (n.id, n.name, n.date_rel, n.timestamp, n.photo, n.note)</div> <div id='L41' class='linehi'><a name='L41' href='#L41' class='linenumber'>41</a></div> <div id='L42' class='linehi'><a name='L42' href='#L42' class='linenumber'>42</a> console.log(&quot;pingModel.onNotification&quot;, notificationlist.length);</div> <div id='L43' class='linehi'><a name='L43' href='#L43' class='linenumber'>43</a></div> <div id='L44' class='linehi'><a name='L44' href='#L44' class='linenumber'>44</a> if (notificationlist.length === 0) return</div> <div id='L45' class='linehi'><a name='L45' href='#L45' class='linenumber'>45</a></div> <div id='L46' class='linehi'><a name='L46' href='#L46' class='linenumber'>46</a> var notificationbody = qsTr(&quot;%1 new notifications&quot;).arg(notificationlist.length);</div> <div id='L47' class='linehi'><a name='L47' href='#L47' class='linenumber'>47</a></div> <div id='L48' class='linehi'><a name='L48' href='#L48' class='linenumber'>48</a> if (notificationlist.length === 1 ) {</div> <div id='L49' class='linehi'><a name='L49' href='#L49' class='linenumber'>49</a> notificationbody = notificationlist[0].note;</div> <div id='L50' class='linehi'><a name='L50' href='#L50' class='linenumber'>50</a> }</div> <div id='L51' class='linehi'><a name='L51' href='#L51' class='linenumber'>51</a></div> <div id='L52' class='linehi'><a name='L52' href='#L52' class='linenumber'>52</a> // messaggio popup, suono, non in elenco, sparisce quando scade</div> <div id='L53' class='linehi'><a name='L53' href='#L53' class='linenumber'>53</a> applicationNotification.category = &quot;x-nemo.messaging.im.preview&quot;;</div> <div id='L54' class='linehi'><a name='L54' href='#L54' class='linenumber'>54</a> applicationNotification.replacesId = 0;</div> <div id='L55' class='linehi'><a name='L55' href='#L55' class='linenumber'>55</a> applicationNotification.summary = &quot;&quot;;</div> <div id='L56' class='linehi'><a name='L56' href='#L56' class='linenumber'>56</a> applicationNotification.body = &quot;&quot;;</div> <div id='L57' class='linehi'><a name='L57' href='#L57' class='linenumber'>57</a> applicationNotification.previewSummary = &quot;Friendica&quot;</div> <div id='L58' class='linehi'><a name='L58' href='#L58' class='linenumber'>58</a> applicationNotification.previewBody = notificationbody</div> <div id='L59' class='linehi'><a name='L59' href='#L59' class='linenumber'>59</a> applicationNotification.itemCount = notificationlist.length;</div> <div id='L60' class='linehi'><a name='L60' href='#L60' class='linenumber'>60</a> applicationNotification.timestamp = new Date();</div> <div id='L61' class='linehi'><a name='L61' href='#L61' class='linenumber'>61</a> applicationNotification.publish();</div> <div id='L62' class='linehi'><a name='L62' href='#L62' class='linenumber'>62</a></div> <div id='L63' class='linehi'><a name='L63' href='#L63' class='linenumber'>63</a></div> <div id='L64' class='linehi'><a name='L64' href='#L64' class='linenumber'>64</a> for (var k=0; k&lt;notificationlist.length; k++) {</div> <div id='L65' class='linehi'><a name='L65' href='#L65' class='linenumber'>65</a> var n = notificationlist[k];</div> <div id='L66' class='linehi'><a name='L66' href='#L66' class='linenumber'>66</a></div> <div id='L67' class='linehi'><a name='L67' href='#L67' class='linenumber'>67</a></div> <div id='L68' class='linehi'><a name='L68' href='#L68' class='linenumber'>68</a> applicationNotification.category = &quot;x-nemo.messaging.im&quot;;</div> <div id='L69' class='linehi'><a name='L69' href='#L69' class='linenumber'>69</a> applicationNotification.replacesId = 0;</div> <div id='L70' class='linehi'><a name='L70' href='#L70' class='linenumber'>70</a> applicationNotification.summary = n.note</div> <div id='L71' class='linehi'><a name='L71' href='#L71' class='linenumber'>71</a> applicationNotification.body = &quot;&quot;</div> <div id='L72' class='linehi'><a name='L72' href='#L72' class='linenumber'>72</a> applicationNotification.previewSummary = &quot;&quot;</div> <div id='L73' class='linehi'><a name='L73' href='#L73' class='linenumber'>73</a> applicationNotification.previewBody = &quot;&quot;</div> <div id='L74' class='linehi'><a name='L74' href='#L74' class='linenumber'>74</a> applicationNotification.itemCount = 1</div> <div id='L75' class='linehi'><a name='L75' href='#L75' class='linenumber'>75</a> applicationNotification.timestamp = new Date(n.timestamp * 1000);</div> <div id='L76' class='linehi'><a name='L76' href='#L76' class='linenumber'>76</a> applicationNotification.publish();</div> <div id='L77' class='linehi'><a name='L77' href='#L77' class='linenumber'>77</a> }</div> <div id='L78' class='linehi'><a name='L78' href='#L78' class='linenumber'>78</a></div> <div id='L79' class='linehi'><a name='L79' href='#L79' class='linenumber'>79</a></div> <div id='L80' class='linehi'><a name='L80' href='#L80' class='linenumber'>80</a> }</div> <div id='L81' class='linehi'><a name='L81' href='#L81' class='linenumber'>81</a> }</div> <div id='L82' class='linehi'><a name='L82' href='#L82' class='linenumber'>82</a></div> <div id='L83' class='linehi'><a name='L83' href='#L83' class='linenumber'>83</a></div> <div id='L84' class='linehi'><a name='L84' href='#L84' class='linenumber'>84</a> Timer {</div> <div id='L85' class='linehi'><a name='L85' href='#L85' class='linenumber'>85</a> id: pingModelTimer</div> <div id='L86' class='linehi'><a name='L86' href='#L86' class='linenumber'>86</a> repeat: true</div> <div id='L87' class='linehi'><a name='L87' href='#L87' class='linenumber'>87</a> interval: (cover.status === Cover.Active ? settings.data.tPingUpdate : settings.data.tCoverUpdates) * 1000</div> <div id='L88' class='linehi'><a name='L88' href='#L88' class='linenumber'>88</a> running: true</div> <div id='L89' class='linehi'><a name='L89' href='#L89' class='linenumber'>89</a> onTriggered: {</div> <div id='L90' class='linehi'><a name='L90' href='#L90' class='linenumber'>90</a> pingModel.reload();</div> <div id='L91' class='linehi'><a name='L91' href='#L91' class='linenumber'>91</a> }</div> <div id='L92' class='linehi'><a name='L92' href='#L92' class='linenumber'>92</a> }</div> <div id='L93' class='linehi'><a name='L93' href='#L93' class='linenumber'>93</a></div> <div id='L94' class='linehi'><a name='L94' href='#L94' class='linenumber'>94</a> Component.onCompleted: {</div> <div id='L95' class='linehi'><a name='L95' href='#L95' class='linenumber'>95</a></div> <div id='L96' class='linehi'><a name='L96' href='#L96' class='linenumber'>96</a> /**</div> <div id='L97' class='linehi'><a name='L97' href='#L97' class='linenumber'>97</a> * Looks like QML creates elements from bottom-up, then calls onCompleted().</div> <div id='L98' class='linehi'><a name='L98' href='#L98' class='linenumber'>98</a> * like:</div> <div id='L99' class='linehi'><a name='L99' href='#L99' class='linenumber'>99</a> * ApplicationWindow &lt;- NetworkPage &lt;- NetworkModel</div> <div id='L100' class='linehi'><a name='L100' href='#L100' class='linenumber'>100</a> *</div> <div id='L101' class='linehi'><a name='L101' href='#L101' class='linenumber'>101</a> * Every object under the one wich sets 'settings.data' will</div> <div id='L102' class='linehi'><a name='L102' href='#L102' class='linenumber'>102</a> * see 'null' as 'settings.data' in its 'Component.onCompleted'.</div> <div id='L103' class='linehi'><a name='L103' href='#L103' class='linenumber'>103</a> * To be sure that everiting works, any other components must</div> <div id='L104' class='linehi'><a name='L104' href='#L104' class='linenumber'>104</a> * use settings.data in 'Component.onCompleted' wrapped in an handler for</div> <div id='L105' class='linehi'><a name='L105' href='#L105' class='linenumber'>105</a> * 'settings.settingsChanged' event, expecially if it want to set an handler</div> <div id='L106' class='linehi'><a name='L106' href='#L106' class='linenumber'>106</a> * listening for any data value change.</div> <div id='L107' class='linehi'><a name='L107' href='#L107' class='linenumber'>107</a> *</div> <div id='L108' class='linehi'><a name='L108' href='#L108' class='linenumber'>108</a> **/</div> <div id='L109' class='linehi'><a name='L109' href='#L109' class='linenumber'>109</a></div> <div id='L110' class='linehi'><a name='L110' href='#L110' class='linenumber'>110</a></div> <div id='L111' class='linehi'><a name='L111' href='#L111' class='linenumber'>111</a> //reload models on settings changed</div> <div id='L112' class='linehi'><a name='L112' href='#L112' class='linenumber'>112</a> settings.settingsChanged.connect( function() {</div> <div id='L113' class='linehi'><a name='L113' href='#L113' class='linenumber'>113</a> if (settings.data._valid) {</div> <div id='L114' class='linehi'><a name='L114' href='#L114' class='linenumber'>114</a> pingModel.reload();</div> <div id='L115' class='linehi'><a name='L115' href='#L115' class='linenumber'>115</a> networkModel.reload();</div> <div id='L116' class='linehi'><a name='L116' href='#L116' class='linenumber'>116</a> friendsModel.reload();</div> <div id='L117' class='linehi'><a name='L117' href='#L117' class='linenumber'>117</a> }</div> <div id='L118' class='linehi'><a name='L118' href='#L118' class='linenumber'>118</a> });</div> <div id='L119' class='linehi'><a name='L119' href='#L119' class='linenumber'>119</a></div> <div id='L120' class='linehi'><a name='L120' href='#L120' class='linenumber'>120</a> settings.data = settingsSchema;</div> <div id='L121' class='linehi'><a name='L121' href='#L121' class='linenumber'>121</a> var r = settings.readSettings();</div> <div id='L122' class='linehi'><a name='L122' href='#L122' class='linenumber'>122</a> console.log(&quot;readSettings&quot;, r);</div> <div id='L123' class='linehi'><a name='L123' href='#L123' class='linenumber'>123</a></div> <div id='L124' class='linehi'><a name='L124' href='#L124' class='linenumber'>124</a> }</div> <div id='L125' class='linehi'><a name='L125' href='#L125' class='linenumber'>125</a></div> <div id='L126' class='linehi'><a name='L126' href='#L126' class='linenumber'>126</a> id: applicationWindow</div> <div id='L127' class='linehi'><a name='L127' href='#L127' class='linenumber'>127</a> initialPage: Component { NetworkPage { } }</div> <div id='L128' class='linehi'><a name='L128' href='#L128' class='linenumber'>128</a> cover: Qt.resolvedUrl(&quot;cover/CoverPage.qml&quot;)</div> <div id='L129' class='linehi'><a name='L129' href='#L129' class='linenumber'>129</a> allowedOrientations: Orientation.All</div> <div id='L130' class='linehi'><a name='L130' href='#L130' class='linenumber'>130</a> _defaultPageOrientations: Orientation.All</div> <div id='L131' class='linehi'><a name='L131' href='#L131' class='linenumber'>131</a>}</div> <div id='L132' class='linehi'><a name='L132' href='#L132' class='linenumber'>132</a></div> <div id='L133' class='linehi'><a name='L133' href='#L133' class='linenumber'>133</a></div> <div id='L134' class='linehi'><a name='L134' href='#L134' class='linenumber'>134</a></div>