<table><tr><td style="">broulik added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D10512" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>Cool!</p>

<p>Since this is all applet quick item stuff it will just work™ with applet within system tray?<br />
Would be nice to have some <tt style="background: #ebebeb; font-size: 13px;">qCInfo</tt> in there somewhere so we can better understand what it's doing, when it's increasing/decreasing the rating, when it's preloading it, etc.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10512#inline-49739" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">appletquickitem.cpp:47</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #74777d">//weight values for the logic for when or if to preload</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">int</span> <span class="n">s_defaultPreloadWeight</span> <span style="color: #aa2211">=</span> <span style="color: #601200">50</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">int</span> <span class="n">s_defaultLauncherPreloadWeight</span> <span style="color: #aa2211">=</span> <span style="color: #601200">100</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">imho using an <tt style="background: #ebebeb; font-size: 13px;">enum</tt> rather than a bunch of <tt style="background: #ebebeb; font-size: 13px;">static int</tt>s is nicer</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10512#inline-49738" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">appletquickitem.cpp:49</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">int</span> <span class="n">s_defaultLauncherPreloadWeight</span> <span style="color: #aa2211">=</span> <span style="color: #601200">100</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">int</span> <span class="n">s_defaultDatePreloadWeight</span> <span style="color: #aa2211">=</span> <span style="color: #601200">80</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span style="color: #aa4000">static</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">int</span> <span class="n">s_immediatePreloadWeight</span> <span style="color: #aa2211">=</span> <span style="color: #601200">70</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Are you sure we want to preload the calendar right away? This thing takes forever to open, wouldn't want to have that slow down plasma startup massively.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10512#inline-49736" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">appletquickitem.cpp:95</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #74777d">//default widgets to be barely preloaded</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">return</span> <span class="n">qBound</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span class="n">applet</span><span style="color: #aa2211">-></span><span class="n">config</span><span class="p">().</span><span class="n">readEntry</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"PreloadWeight"</span><span class="p">),</span> <span class="n">qMax</span><span class="p">(</span><span class="n">defaultWeight</span><span class="p">,</span> <span class="n">applet</span><span style="color: #aa2211">-></span><span class="n">pluginMetaData</span><span class="p">().</span><span class="n">rawData</span><span class="p">().</span><span class="n">value</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"X-Plasma-PreloadWeight"</span><span class="p">)).</span><span class="n">toInt</span><span class="p">())),</span> <span style="color: #601200">100</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"><span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Could this be split into multiple lines, it's quite hard to follow</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10512#inline-49741" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">appletquickitem.cpp:636</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span style="color: #74777d">//decrease weight until we open it again</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="n">applet</span><span class="p">()</span><span style="color: #aa2211">-></span><span class="n">config</span><span class="p">().</span><span class="n">writeEntry</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"PreloadWeight"</span><span class="p">),</span> <span class="n">qMax</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span class="n">preloadWeight</span> <span style="color: #aa2211">-</span> <span class="n">s_preloadWeightIncrement</span><span class="p">));</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">This should go into a function, there's like three places where a "random" <tt style="background: #ebebeb; font-size: 13px;">writeEntry</tt> is scattered around</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D10512#inline-49737" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">appletquickitem.cpp:642</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span style="color: #74777d">//spread the creation over a random delay between 2 and 10 seconds, to make it look plasma started before, and load everything in the background without big noticeable freezes</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">QTimer</span><span style="color: #aa2211">::</span><span class="n">singleShot</span><span class="p">(</span><span class="n">qrand</span><span class="p">()</span> <span style="color: #aa2211">%</span> <span class="p">((</span><span style="color: #601200">10000</span> <span style="color: #aa2211">+</span> <span style="color: #601200">1</span><span class="p">)</span> <span style="color: #aa2211">-</span> <span style="color: #601200">2000</span><span class="p">)</span> <span style="color: #aa2211">+</span> <span style="color: #601200">2000</span><span class="p">,</span> <span class="p">[</span><span style="color: #aa4000">this</span><span class="p">]()</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="n">d</span><span style="color: #aa2211">-></span><span class="n">createFullRepresentationItem</span><span class="p">();</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Add <tt style="background: #ebebeb; font-size: 13px;">this</tt> as context or else it would blow up when the applet is destroyed before the timer fires:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">QTimer::singleShot(qrand..., this, [this]() {</pre></div></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R242 Plasma Framework (Library)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D10512" rel="noreferrer">https://phabricator.kde.org/D10512</a></div></div><br /><div><strong>To: </strong>mart, Plasma<br /><strong>Cc: </strong>broulik, apol, ngraham, plasma-devel, Frameworks, michaelh, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, mart<br /></div>