[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    D10297: Add new "Tools" button above System Monitor's process list
From:       Henrik Fehlauer <noreply () phabricator ! kde ! org>
Date:       2018-06-02 18:56:28
Message-ID: 20180602185628.1.C2F58696353ADA59 () phabricator ! kde ! org
[Download RAW message or body]

rkflx added a comment.


  Awesome, I did not expect that the fix for the shortcuts would be so simple. Thanks \
for your patience, we are nearly there…

INLINE COMMENTS

> ksysguardprocesslist.cpp:421-427
> +    //
> +    // This is one way of how to find out the two required parameters for the \
> globalShortcut method +    // (maybe there is a better one):
> +    //     auto list = \
> KGlobalAccel::getGlobalShortcutsByKey(QKeySequence(QStringLiteral("Alt+Space"))); + \
> //     foreach (auto item, list) { +    //         qDebug() << \
> item.componentUniqueName() << item.uniqueName(); +    //     }

Left-over debug code?

> ksysguardprocesslist.cpp:429
> +    auto runCommandShortcutList = \
> KGlobalAccel::self()->globalShortcut(QStringLiteral("krunner"), QStringLiteral("run \
> command")); +    QString runCommandShortcut = i18nc("a keyboard shortcut", "not \
> set"); +    if (runCommandShortcutList.size() > 0) {

Do you think it is really necessary to display `not set`? For me, an empty string \
would also work just fine, now that you are using `\t` instead of `(…)`.

Also I found a way to omit the string and `\t` entirely and let Qt do all the work:

  auto runCommandAction = new QAction(i18nc("@action:inmenu", "Run Command"), this);
  const auto runCommandShortcutList = \
KGlobalAccel::self()->globalShortcut(QStringLiteral("krunner"), QStringLiteral("run \
command"));  if (runCommandShortcutList.size() > 0) {
      runCommandAction->setShortcut(runCommandShortcutList[0]);
  }

REPOSITORY
  R111 KSysguard Library

REVISION DETAIL
  https://phabricator.kde.org/D10297

To: gregormi, #plasma, colomar, kossebau, broulik, mart, hein, rkflx
Cc: apol, anthonyfieroni, andreaska, rkflx, ngraham, plasma-devel, ragreen, Pitel, \
ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, mart


[Attachment #3 (unknown)]

<table><tr><td style="">rkflx 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/D10297">View Revision</a></tr></table><br \
/><div><div><p>Awesome, I did not expect that the fix for the shortcuts would be so \
simple. Thanks for your patience, we are nearly there…</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/D10297#inline-69168">View Inline</a><span \
style="color: #4b4d51; font-weight: \
bold;">ksysguardprocesslist.cpp:421-427</span></div> <div style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, 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">//</span> </div><div style="padding: 0 8px; margin: 0 4px; background: \
rgba(151, 234, 151, .6);">    <span style="color: #74777d">// This is one way of how \
to find out the two required parameters for the globalShortcut method</span> \
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, \
.6);">    <span style="color: #74777d">// (maybe there is a better one):</span> \
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, \
.6);">    <span style="color: #74777d">//     auto list = \
KGlobalAccel::getGlobalShortcutsByKey(QKeySequence(QStringLiteral(&quot;Alt+Space&quot;)));</span>
 </div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, \
.6);">    <span style="color: #74777d">//     foreach (auto item, list) {</span> \
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, \
.6);">    <span style="color: #74777d">//         qDebug() &lt;&lt; \
item.componentUniqueName() &lt;&lt; item.uniqueName();</span> </div><div \
style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span \
style="color: #74777d">//     }</span> </div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: \
8px;">Left-over debug code?</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/D10297#inline-69166">View Inline</a><span \
style="color: #4b4d51; font-weight: bold;">ksysguardprocesslist.cpp:429</span></div> \
<div style="font: 11px/15px &quot;Menlo&quot;, &quot;Consolas&quot;, \
&quot;Monaco&quot;, 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">auto</span> <span \
class="n">runCommandShortcutList</span> <span style="color: #aa2211">=</span> <span \
class="n">KGlobalAccel</span><span style="color: #aa2211">::</span><span \
class="n">self</span><span class="p">()</span><span style="color: \
#aa2211">-&gt;</span><span class="n">globalShortcut</span><span \
class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span \
style="color: #766510">&quot;krunner&quot;</span><span class="p">),</span> <span \
class="n">QStringLiteral</span><span class="p">(</span><span style="color: \
#766510">&quot;run command&quot;</span><span class="p">));</span> </div><div \
style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span \
class="n">QString</span> <span class="n">runCommandShortcut</span> <span \
style="color: #aa2211">=</span> <span class="n">i18nc</span><span \
class="p">(</span><span style="color: #766510">&quot;a keyboard \
shortcut&quot;</span><span class="p">,</span> <span style="color: #766510">&quot;not \
set&quot;</span><span class="p">);</span> </div><div style="padding: 0 8px; margin: 0 \
4px; background: rgba(151, 234, 151, .6);">    <span style="color: #aa4000">if</span> \
<span class="p">(</span><span class="n">runCommandShortcutList</span><span \
class="p">.</span><span class="n">size</span><span class="p">()</span> <span \
style="color: #aa2211">&gt;</span> <span style="color: #601200">0</span><span \
class="p">)</span> <span class="p">{</span> </div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Do \
you think it is really necessary to display <tt style="background: #ebebeb; \
font-size: 13px;">not set</tt>? For me, an empty string would also work just fine, \
now that you are using <tt style="background: #ebebeb; font-size: 13px;">\t</tt> \
instead of <tt style="background: #ebebeb; font-size: 13px;">(…)</tt>.</p>

<p style="padding: 0; margin: 8px;">Also I found a way to omit the string and <tt \
style="background: #ebebeb; font-size: 13px;">\t</tt> entirely and let Qt do all the \
work:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="c++" \
data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px \
&quot;Menlo&quot;, &quot;Consolas&quot;, &quot;Monaco&quot;, monospace; padding: \
12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><span style="color: \
#aa4000">auto</span> <span class="n">runCommandAction</span> <span style="color: \
#aa2211">=</span> <span style="color: #aa4000">new</span> <span \
class="n">QAction</span><span class="p">(</span><span class="n">i18nc</span><span \
class="p">(</span><span style="color: #766510">&quot;@action:inmenu&quot;</span><span \
class="p">,</span> <span style="color: #766510">&quot;Run Command&quot;</span><span \
class="p">),</span> <span style="color: #aa4000">this</span><span class="p">);</span> \
<span style="color: #aa4000">const</span> <span style="color: #aa4000">auto</span> \
<span class="n">runCommandShortcutList</span> <span style="color: #aa2211">=</span> \
<span class="n">KGlobalAccel</span><span style="color: #aa2211">::</span><span \
class="n">self</span><span class="p">()</span><span style="color: \
#aa2211">-&gt;</span><span class="n">globalShortcut</span><span \
class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span \
style="color: #766510">&quot;krunner&quot;</span><span class="p">),</span> <span \
class="n">QStringLiteral</span><span class="p">(</span><span style="color: \
#766510">&quot;run command&quot;</span><span class="p">));</span> <span style="color: \
#aa4000">if</span> <span class="p">(</span><span \
class="n">runCommandShortcutList</span><span class="p">.</span><span \
class="n">size</span><span class="p">()</span> <span style="color: \
#aa2211">&gt;</span> <span style="color: #601200">0</span><span class="p">)</span> \
<span class="p">{</span>  <span class="n">runCommandAction</span><span style="color: \
#aa2211">-&gt;</span><span class="n">setShortcut</span><span class="p">(</span><span \
class="n">runCommandShortcutList</span><span class="p">[</span><span style="color: \
#601200">0</span><span class="p">]);</span> <span \
class="p">}</span></pre></div></div></div></div></div></div><br \
/><div><strong>REPOSITORY</strong><div><div>R111 KSysguard \
Library</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a \
href="https://phabricator.kde.org/D10297">https://phabricator.kde.org/D10297</a></div></div><br \
/><div><strong>To: </strong>gregormi, Plasma, colomar, kossebau, broulik, mart, hein, \
rkflx<br /><strong>Cc: </strong>apol, anthonyfieroni, andreaska, rkflx, ngraham, \
plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, \
abetts, sebas, mart<br /></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic