/usr/share/doc/copyq/html/source-code-overview.html is in copyq-doc 3.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Source Code Overview — CopyQ documentation</title>
<link rel="shortcut icon" href="_static/icon_32x32.png"/>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="CopyQ documentation" href="index.html"/>
<link rel="next" title="Translations" href="translations.html"/>
<link rel="prev" title="Fixing Bugs and Adding Features" href="fixing-bugs.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> CopyQ
<img src="_static/icon_64x64.png" class="logo" />
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">The Basics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="basic-usage.html">Basic Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="tabs-and-items.html">Tabs and Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="keyboard.html">Keyboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="images.html">Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="tags.html">Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ - Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced Topics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="command-line.html">Command Line</a></li>
<li class="toctree-l1"><a class="reference internal" href="sessions.html">Sessions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pin-items.html">Pin Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="password-protection.html">Password Protection</a></li>
<li class="toctree-l1"><a class="reference internal" href="synchronize.html">Synchronize with Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-commands-and-adding-functionality.html">Writing Commands and Adding Functionality</a></li>
<li class="toctree-l1"><a class="reference internal" href="scripting.html">Scripting</a></li>
<li class="toctree-l1"><a class="reference internal" href="command-examples.html">Command Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="backup.html">Backup</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-raw-data.html">Writing Raw Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="scripting-api.html">Scripting API</a></li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="build-source-code.html">Build from Source Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="fixing-bugs.html">Fixing Bugs and Adding Features</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Source Code Overview</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#applications-frameworks-and-libraries">Applications, Frameworks and Libraries</a></li>
<li class="toctree-l2"><a class="reference internal" href="#application-processes">Application Processes</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#main-gui-application">Main GUI Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="#clipboard-monitor">Clipboard Monitor</a></li>
<li class="toctree-l3"><a class="reference internal" href="#clients-and-scripting">Clients and Scripting</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#platform-dependent-code">Platform-dependent Code</a></li>
<li class="toctree-l2"><a class="reference internal" href="#plugins">Plugins</a></li>
<li class="toctree-l2"><a class="reference internal" href="#continuous-integration-ci">Continuous Integration (CI)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="translations.html">Translations</a></li>
<li class="toctree-l1"><a class="reference internal" href="text-encoding.html">Text Encoding</a></li>
<li class="toctree-l1"><a class="reference internal" href="customize-and-build-the-windows-installer.html">Customize and Build the Windows Installer</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">CopyQ</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Source Code Overview</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/source-code-overview.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="source-code-overview">
<h1>Source Code Overview<a class="headerlink" href="#source-code-overview" title="Permalink to this headline">¶</a></h1>
<p>This page describes application processes and source code.</p>
<div class="section" id="applications-frameworks-and-libraries">
<h2>Applications, Frameworks and Libraries<a class="headerlink" href="#applications-frameworks-and-libraries" title="Permalink to this headline">¶</a></h2>
<p>The application is written in C++11 and uses Qt framework.</p>
<p>Source code can be build either with CMake (preferred) or QMake.</p>
<p>Most icons in the application are taken from theme by default (which
currently works only on Linux) with fallback to built-in icons provided
by <a class="reference external" href="http://fontawesome.io/">FontAwesome</a>.</p>
<p>Application logo was created in <a class="reference external" href="https://www.blender.org/">Blender</a>
(scene source is
<a class="reference external" href="https://github.com/hluk/CopyQ/blob/master/src/images/logo.blend">here</a>).</p>
<p>The logo is used for bigger application icon. Smaller icons were created
in <a class="reference external" href="https://inkscape.org/">Inkscape</a> (icon source is
<a class="reference external" href="https://github.com/hluk/CopyQ/blob/master/src/images/icon.svg">here</a>).</p>
</div>
<div class="section" id="application-processes">
<h2>Application Processes<a class="headerlink" href="#application-processes" title="Permalink to this headline">¶</a></h2>
<p>There are these system processes:</p>
<ul class="simple">
<li>main GUI application,</li>
<li>clipboard monitor (started from main application),</li>
<li>multiple clients (run scripts in main application).</li>
</ul>
<div class="section" id="main-gui-application">
<h3>Main GUI Application<a class="headerlink" href="#main-gui-application" title="Permalink to this headline">¶</a></h3>
<p>The main GUI application (or server) can be executed by running
<code class="docutils literal"><span class="pre">copyq</span></code> binary without attributes (session name can be optionally
specified on command line).</p>
<p>It creates local server allowing communication with clipboard monitor
process and other client processes.</p>
<p>Each user can run multiple main application processes each with unique
session name (default name is empty).</p>
</div>
<div class="section" id="clipboard-monitor">
<h3>Clipboard Monitor<a class="headerlink" href="#clipboard-monitor" title="Permalink to this headline">¶</a></h3>
<p>Clipboard monitoring happens in separate process because otherwise it
would block GUI (in Qt clipboard needs to be accessed in main GUI
thread). The process is allowed to crash or loop indefinitely due to
bugs on some platforms.</p>
<p>Setting and retrieving clipboard can still happen in GUI thread (copying
and pasting in various GUI widgets) but it’s preferred to send and
receive clipboard data using monitor process.</p>
<p>The monitor process is launched as soon as GUI application starts and is
restarted whenever it doesn’t respond to keep-alive requests.</p>
</div>
<div class="section" id="clients-and-scripting">
<h3>Clients and Scripting<a class="headerlink" href="#clients-and-scripting" title="Permalink to this headline">¶</a></h3>
<p>Scripting language is <a class="reference external" href="https://doc.qt.io/qt-5/qtscript-index.html">Qt
Script</a> (mostly same
syntax and functions as JavaScript).</p>
<p>API is described in <a class="reference internal" href="scripting-api.html#scripting-api"><span class="std std-ref">Scripting API</span></a>.</p>
<p>A script can be started by passing arguments to <code class="docutils literal"><span class="pre">copyq</span></code>. This tells
the server (main GUI application) to run the script.</p>
<p>After script finishes, the server sends back output of last command and
exit code (non-zero if script crashes).</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">eval</span> <span class="s1">'read(0,1,2)'</span> <span class="c1"># prints first three items in list</span>
copyq <span class="nb">eval</span> <span class="s1">'fail()'</span> <span class="c1"># exit code will be non-zero</span>
</pre></div>
</div>
<p>While script is running, it can send print requests to client.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">eval</span> <span class="s1">'print("Hello, "); print("World!\n")'</span>
</pre></div>
</div>
<p>Scripts can ask for stdin from client.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">eval</span> <span class="s1">'var client_stdin = input()'</span>
</pre></div>
</div>
<p>The script run in current directory of client process.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">eval</span> <span class="s1">'Dir().absolutePath()'</span>
copyq <span class="nb">eval</span> <span class="s1">'execute("ls", "-l").stdout'</span>
</pre></div>
</div>
<p>Single function call where all arguments are numbers or strings can be
executed by passing function name and function arguments on command
line. Following commands are equal.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">eval</span> <span class="s1">'copy("Hello, World!")'</span>
copyq copy <span class="s2">"Hello, World!"</span>
</pre></div>
</div>
<p>Getting application version or help mustn’t require the server to be
running.</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span>copyq <span class="nb">help</span>
copyq version
</pre></div>
</div>
<p>Scripts run in separate thread and communicate with main thread by
calling methods on an object of <code class="docutils literal"><span class="pre">ScriptableProxy</span></code> class. If called
from non-main thread, these methods invoke a slot on an <code class="docutils literal"><span class="pre">QObject</span></code> in
main thread and pass it a function object which simply calls the method
again.</p>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="kt">bool</span> <span class="n">ScriptableProxy</span><span class="o">::</span><span class="n">loadTab</span><span class="p">(</span><span class="k">const</span> <span class="n">QString</span> <span class="o">&</span><span class="n">tabName</span><span class="p">)</span>
<span class="p">{</span>
<span class="c1">// This section is wrapped in an macro so to remove duplicate code.</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">m_inMainThread</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Callable object just wraps the lambda so it's possible to send it to a slot.</span>
<span class="k">auto</span> <span class="n">callable</span> <span class="o">=</span> <span class="n">createCallable</span><span class="p">([</span><span class="o">&</span><span class="p">]{</span> <span class="k">return</span> <span class="n">loadTab</span><span class="p">(</span><span class="n">tabName</span><span class="p">);</span> <span class="p">});</span>
<span class="n">m_inMainThread</span> <span class="o">=</span> <span class="nb">true</span><span class="p">;</span>
<span class="n">QMetaObject</span><span class="o">::</span><span class="n">invokeMethod</span><span class="p">(</span><span class="n">m_wnd</span><span class="p">,</span> <span class="s">"invoke"</span><span class="p">,</span> <span class="n">Qt</span><span class="o">::</span><span class="n">BlockingQueuedConnection</span><span class="p">,</span> <span class="n">Q_ARG</span><span class="p">(</span><span class="n">Callable</span><span class="o">*</span><span class="p">,</span> <span class="o">&</span><span class="n">callable</span><span class="p">));</span>
<span class="n">m_inMainThread</span> <span class="o">=</span> <span class="nb">false</span><span class="p">;</span>
<span class="k">return</span> <span class="n">callable</span><span class="p">.</span><span class="n">result</span><span class="p">();</span>
<span class="p">}</span>
<span class="c1">// Now it's possible to call method on an object in main thread.</span>
<span class="k">return</span> <span class="n">m_wnd</span><span class="o">-></span><span class="n">loadTab</span><span class="p">(</span><span class="n">tabName</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="platform-dependent-code">
<h2>Platform-dependent Code<a class="headerlink" href="#platform-dependent-code" title="Permalink to this headline">¶</a></h2>
<p>Code for various platforms is stored in
<a class="reference external" href="https://github.com/hluk/CopyQ/tree/master/src/platform">src/platform</a>.</p>
<p>This leverages amount of <code class="docutils literal"><span class="pre">#if</span></code>s and similar preprocessor directives
in common code.</p>
<p>Each supported platform implements
<a class="reference external" href="https://github.com/hluk/CopyQ/blob/master/src/platform/platformnativeinterface.h">PlatformNativeInterface</a>
and <code class="docutils literal"><span class="pre">createPlatformNativeInterface()</span></code>.</p>
<p>The implementations can contain:</p>
<ul class="simple">
<li>creating Qt application objects,</li>
<li>clipboard handling (for clipboard monitor),</li>
<li>focusing window and getting window titles,</li>
<li>getting system paths,</li>
<li>setting “autostart” option,</li>
<li>handling global shortcuts (<strong>note:</strong> this part is in
<a class="reference external" href="https://github.com/hluk/CopyQ/tree/master/qxt">qxt/</a>).</li>
</ul>
<p>For unsupported platforms there is <a class="reference external" href="https://github.com/hluk/CopyQ/tree/master/src/platform/dummy">simple
implementation</a>
to get started.</p>
</div>
<div class="section" id="plugins">
<h2>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h2>
<p>Plugins are built as dynamic libraries which are loaded from runtime
plugin directory (platform-dependent) after application start.</p>
<p>Code is stored in
<a class="reference external" href="https://github.com/hluk/CopyQ/tree/master/plugins">plugins</a>.</p>
<p>Plugins implement interfaces from
<a class="reference external" href="https://github.com/hluk/CopyQ/tree/master/src/item/itemwidget.h">src/item/itemwidget.h</a>.</p>
<p>To create new plugin just duplicate and rewrite an existing plugin. You
can build the plugin with <code class="docutils literal"><span class="pre">make</span> <span class="pre">{PLUGIN_NAME}</span></code>.</p>
</div>
<div class="section" id="continuous-integration-ci">
<h2>Continuous Integration (CI)<a class="headerlink" href="#continuous-integration-ci" title="Permalink to this headline">¶</a></h2>
<p>The application binaries and packages are built and tested on multiple
CI servers.</p>
<ul class="simple">
<li><dl class="first docutils">
<dt><a class="reference external" href="https://travis-ci.org/hluk/CopyQ">Travis CI</a></dt>
<dd><ul class="first last">
<li>Builds packages for OS X.</li>
<li>Builds and runs tests for Linux binaries with Qt 4.</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://gitlab.com/CopyQ/CopyQ/builds">GitLab CI</a></dt>
<dd><ul class="first last">
<li>Builds and runs tests for Ubuntu 16.04 binaries with Qt 5.</li>
<li>Screenshots are taken while GUI tests are running. These are
available if a test fails.</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://ci.appveyor.com/project/hluk/copyq">AppVeyor</a></dt>
<dd><ul class="first last">
<li>Builds installers and portable packages for Windows with Qt 5.</li>
<li>Provides downloads for recent commits.</li>
<li>Release build are based on gcc-compiled binaries (Visual Studio
builds are also available).</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://build.opensuse.org/project/show/home:lukho:copyq">OBS Linux Packages</a></dt>
<dd><ul class="first last">
<li>Builds release packages for various Linux distributions.</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://build.opensuse.org/project/show/home:lukho:copyq-beta">Beta OBS Linux Packages</a></dt>
<dd><ul class="first last">
<li>Builds beta and unstable packages for various Linux distributions.</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://coveralls.io/github/hluk/CopyQ">Coveralls</a></dt>
<dd><ul class="first last">
<li>Contains coverage report from tests run with Travis CI.</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="translations.html" class="btn btn-neutral float-right" title="Translations" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="fixing-bugs.html" class="btn btn-neutral" title="Fixing Bugs and Adding Features" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, Lukas Holecek.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|