File: about.py

package info (click to toggle)
git-cola 4.16.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: python: 37,972; sh: 298; makefile: 223; xml: 106; tcl: 62
file content (529 lines) | stat: -rw-r--r-- 20,476 bytes parent folder | download
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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
import platform
import webbrowser
import os
import sys

import qtpy
from qtpy import QtCore
from qtpy.QtCore import Qt
from qtpy import QtGui
from qtpy import QtWidgets

from ..i18n import N_
from .. import resources
from .. import hotkeys
from .. import icons
from .. import qtutils
from .. import utils
from .. import version
from . import defs


def about_dialog(context):
    """Launches the Help -> About dialog"""
    view = AboutView(context, qtutils.active_window())
    view.show()
    return view


class ExpandingTabBar(QtWidgets.QTabBar):
    """A TabBar with tabs that expand to fill the empty space

    The setExpanding(True) method does not work in practice because
    it respects the OS style.  We override the style by implementing
    tabSizeHint() so that we can specify the size explicitly.
    """

    def tabSizeHint(self, tab_index):
        width = self.parent().width() // max(2, self.count()) - 1
        size = super().tabSizeHint(tab_index)
        size.setWidth(width)
        return size


class ExpandingTabWidget(QtWidgets.QTabWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTabBar(ExpandingTabBar(self))

    def resizeEvent(self, event):
        """Forward resize events to the ExpandingTabBar"""
        # Qt does not resize the tab bar when the dialog is resized
        # so manually forward resize events to the tab bar.
        width = event.size().width()
        height = self.tabBar().height()
        self.tabBar().resize(width, height)
        return super().resizeEvent(event)


class AboutView(QtWidgets.QDialog):
    """Provides the git-cola 'About' dialog"""

    def __init__(self, context, parent=None):
        QtWidgets.QDialog.__init__(self, parent)

        self.context = context
        self.setWindowTitle(N_('About git-cola'))
        self.setWindowModality(Qt.WindowModal)

        # Top-most large icon
        self.logo_label = qtutils.pixmap_label(icons.cola(), defs.huge_icon)
        self.logo_label.setAlignment(Qt.AlignCenter)

        self.logo_text_label = qtutils.label(text='Git Cola')
        self.logo_text_label.setAlignment(Qt.AlignLeft | Qt.AlignCenter)

        font = self.logo_text_label.font()
        font.setPointSize(defs.logo_text)
        self.logo_text_label.setFont(font)

        self.text = qtutils.textbrowser(text=copyright_text())
        self.version = qtutils.textbrowser(text=version_text(context))
        self.authors = qtutils.textbrowser(text=authors_text())
        self.translators = qtutils.textbrowser(text=translators_text())

        self.tabs = ExpandingTabWidget()
        self.tabs.addTab(self.text, N_('About'))
        self.tabs.addTab(self.version, N_('Version'))
        self.tabs.addTab(self.authors, N_('Authors'))
        self.tabs.addTab(self.translators, N_('Translators'))

        self.close_button = qtutils.close_button()
        self.close_button.setDefault(True)

        self.logo_layout = qtutils.hbox(
            defs.no_margin,
            defs.button_spacing,
            self.logo_label,
            self.logo_text_label,
            qtutils.STRETCH,
        )

        self.button_layout = qtutils.hbox(
            defs.spacing, defs.margin, qtutils.STRETCH, self.close_button
        )

        self.main_layout = qtutils.vbox(
            defs.no_margin,
            defs.spacing,
            self.logo_layout,
            self.tabs,
            self.button_layout,
        )
        self.setLayout(self.main_layout)

        qtutils.connect_button(self.close_button, self.accept)

        self.resize(defs.scale(600), defs.scale(720))


def copyright_text():
    return """
Git Cola: The highly caffeinated Git GUI

Copyright (C) 2007-2024 David Aguilar and contributors

This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the
GNU General Public License along with this program.
If not, see http://www.gnu.org/licenses/.

"""


def version_text(context):
    git_version = version.git_version(context)
    cola_version = version.version()
    python_path = sys.executable
    python_version = sys.version
    qt_version = qtpy.QT_VERSION
    qtpy_version = qtpy.__version__
    pyqt_api_name = qtpy.API_NAME
    if (
        getattr(qtpy, 'PYQT6', False)
        or getattr(qtpy, 'PYQT5', False)
        or getattr(qtpy, 'PYQT4', False)
    ):
        pyqt_api_version = qtpy.PYQT_VERSION
    elif qtpy.PYSIDE:
        pyqt_api_version = qtpy.PYSIDE_VERSION
    else:
        pyqt_api_version = 'unknown'

    platform_version = platform.platform()

    scope = dict(
        cola_version=cola_version,
        git_version=git_version,
        platform_version=platform_version,
        pyqt_api_name=pyqt_api_name,
        pyqt_api_version=pyqt_api_version,
        python_path=python_path,
        python_version=python_version,
        qt_version=qt_version,
        qtpy_version=qtpy_version,
    )

    return (
        N_(
            """
        <br>
            Git Cola version %(cola_version)s
        <ul>
            <li> %(platform_version)s
            <li> Python (%(python_path)s) %(python_version)s
            <li> Git %(git_version)s
            <li> Qt %(qt_version)s
            <li> QtPy %(qtpy_version)s
            <li> %(pyqt_api_name)s %(pyqt_api_version)s
        </ul>
    """
        )
        % scope
    )


def mailto(email, text, palette):
    return qtutils.link('mailto:%s' % email, text, palette) + '<br>'


def render_authors(authors):
    """Render a list of author details into rich text html"""
    for x in authors:
        x.setdefault('email', '')

    entries = [
        (
            """
        <p>
            <strong>%(name)s</strong><br>
            <em>%(title)s</em><br>
            %(email)s
        </p>
    """
            % author
        )
        for author in authors
    ]

    return ''.join(entries)


def contributors_text(authors, prelude='', epilogue=''):
    author_text = render_authors(authors)
    scope = dict(author_text=author_text, epilogue=epilogue, prelude=prelude)

    return (
        """
        %(prelude)s
        %(author_text)s
        %(epilogue)s
    """
        % scope
    )


def authors_text():
    palette = QtGui.QPalette()
    contact = N_('Email contributor')
    authors = (
        # The names listed here are listed in the same order as
        # `git shortlog --summary --numbered --no-merges`
        # Please submit a pull request if you would like to include your
        # email address in the about screen.
        # See the `generate-about` script in the "todo" branch.
        # vim :read! ./todo/generate-about
        dict(
            name='David Aguilar',
            title=N_('Maintainer (since 2007) and developer'),
            email=mailto('davvid@gmail.com', contact, palette),
        ),
        dict(name='Daniel Harding', title=N_('Developer')),
        dict(name='Efimov Vasily', title=N_('Developer')),
        dict(
            name='V字龍(Vdragon)',
            title=N_('Developer'),
            email=mailto('Vdragon.Taiwan@gmail.com', contact, palette),
        ),
        dict(name='Kurt McKee', title=N_('Developer')),
        dict(name='Guillaume de Bure', title=N_('Developer')),
        dict(name='Javier Rodriguez Cuevas', title=N_('Developer')),
        dict(name='Uri Okrent', title=N_('Developer')),
        dict(name='Alex Chernetz', title=N_('Developer')),
        dict(name='xhl', title=N_('Developer')),
        dict(name='Ville Skyttä', title=N_('Developer')),
        dict(name='Thomas Kluyver', title=N_('Developer')),
        dict(name='Andreas Sommer', title=N_('Developer')),
        dict(name='nakanoi', title=N_('Developer')),
        dict(name='Szymon Judasz', title=N_('Developer')),
        dict(name='Minarto Margoliono', title=N_('Developer')),
        dict(name='Stanislaw Halik', title=N_('Developer')),
        dict(name='jm4R', title=N_('Developer')),
        dict(name='Igor Galarraga', title=N_('Developer')),
        dict(name='Luke Horwell', title=N_('Developer')),
        dict(name='Virgil Dupras', title=N_('Developer')),
        dict(name='Barry Roberts', title=N_('Developer')),
        dict(name='wsdfhjxc', title=N_('Developer')),
        dict(name='Guo Yunhe', title=N_('Developer')),
        dict(name='malpas', title=N_('Developer')),
        dict(name='林博仁(Buo-ren Lin)', title=N_('Developer')),
        dict(name='Matthias Mailänder', title=N_('Developer')),
        dict(name='cclauss', title=N_('Developer')),
        dict(name='Benjamin Somers', title=N_('Developer')),
        dict(name='Max Harmathy', title=N_('Developer')),
        dict(name='Stefan Naewe', title=N_('Developer')),
        dict(name='Victor Nepveu', title=N_('Developer')),
        dict(name='Benedict Lee', title=N_('Developer')),
        dict(name='Filip Danilović', title=N_('Developer')),
        dict(name='Nanda Lopes', title=N_('Developer')),
        dict(name='NotSqrt', title=N_('Developer')),
        dict(name='Pavel Rehak', title=N_('Developer')),
        dict(name='Steffen Prohaska', title=N_('Developer')),
        dict(name='Thomas Kiley', title=N_('Developer')),
        dict(name='Tim Brown', title=N_('Developer')),
        dict(name='Chris Stefano', title=N_('Developer')),
        dict(name='Floris Lambrechts', title=N_('Developer')),
        dict(name='Martin Gysel', title=N_('Developer')),
        dict(name='Michael Geddes', title=N_('Developer')),
        dict(name='Rustam Safin', title=N_('Developer')),
        dict(name='abid1998', title=N_('Developer')),
        dict(name='Alex Gulyás', title=N_('Developer')),
        dict(name='David Martínez Martí', title=N_('Developer')),
        dict(name='Hualiang Xie', title=N_('Developer')),
        dict(name='Justin Lecher', title=N_('Developer')),
        dict(name='Kai Krakow', title=N_('Developer')),
        dict(name='Karl Bielefeldt', title=N_('Developer')),
        dict(name='Marco Costalba', title=N_('Developer')),
        dict(name='Michael Baumgartner', title=N_('Developer')),
        dict(name='Michael Homer', title=N_('Developer')),
        dict(name='Mithil Poojary', title=N_('Developer')),
        dict(name='Sven Claussner', title=N_('Developer')),
        dict(name='Victor Gambier', title=N_('Developer')),
        dict(name='bsomers', title=N_('Developer')),
        dict(name='mmargoliono', title=N_('Developer')),
        dict(name='v.paritskiy', title=N_('Developer')),
        dict(name='vanderkoort', title=N_('Developer')),
        dict(name='wm4', title=N_('Developer')),
        dict(name='0xflotus', title=N_('Developer')),
        dict(name='AJ Bagwell', title=N_('Developer')),
        dict(name='Adrien be', title=N_('Developer')),
        dict(name='Alexander Preißner', title=N_('Developer')),
        dict(name='Andrej', title=N_('Developer')),
        dict(name='Arthur Coelho', title=N_('Developer')),
        dict(name='Audrius Karabanovas', title=N_('Developer')),
        dict(name='Axel Heider', title=N_('Developer')),
        dict(name='Barrett Lowe', title=N_('Developer')),
        dict(name='Ben Boeckel', title=N_('Developer')),
        dict(name='Bob van der Linden', title=N_('Developer')),
        dict(name='Boerje Sewing', title=N_('Developer')),
        dict(name='Boris W', title=N_('Developer')),
        dict(name='Bruno Cabral', title=N_('Developer')),
        dict(name='Charles', title=N_('Developer')),
        dict(name='Christoph Erhardt', title=N_('Developer')),
        dict(name='Clément Pit--Claudel', title=N_('Developer')),
        dict(name='Daniel Haskin', title=N_('Developer')),
        dict(name='Daniel King', title=N_('Developer')),
        dict(name='Daniel Pavel', title=N_('Developer')),
        dict(name='DasaniT', title=N_('Developer')),
        dict(name='Dave Cottlehuber', title=N_('Developer')),
        dict(name='David Schwörer', title=N_('Developer')),
        dict(name='David Zumbrunnen', title=N_('Developer')),
        dict(name='George Vasilakos', title=N_('Developer')),
        dict(name='Ilya Tumaykin', title=N_('Developer')),
        dict(name='Iulian Udrea', title=N_('Developer')),
        dict(name='Jake Biesinger', title=N_('Developer')),
        dict(name='Jakub Szymański', title=N_('Developer')),
        dict(name='Jamie Pate', title=N_('Developer')),
        dict(name='Jean-Francois Dagenais', title=N_('Developer')),
        dict(name='Joachim Lusiardi', title=N_('Developer')),
        dict(name='Karthik Manamcheri', title=N_('Developer')),
        dict(name='Kelvie Wong', title=N_('Developer')),
        dict(name='Klaas Neirinck', title=N_('Developer')),
        dict(name='Kyle', title=N_('Developer')),
        dict(name='Laszlo Boszormenyi (GCS)', title=N_('Developer')),
        dict(name='Maciej Filipiak', title=N_('Developer')),
        dict(name='Maicon D. Filippsen', title=N_('Developer')),
        dict(name='Markus Heidelberg', title=N_('Developer')),
        dict(name='Matthew E. Levine', title=N_('Developer')),
        dict(name='Md. Mahbub Alam', title=N_('Developer')),
        dict(name='Mikhail Terekhov', title=N_('Developer')),
        dict(name='Niel Buys', title=N_('Developer')),
        dict(name='Ori shalhon', title=N_('Developer')),
        dict(name='Paul Hildebrandt', title=N_('Developer')),
        dict(name='Paul Weingardt', title=N_('Developer')),
        dict(name='Paulo Fidalgo', title=N_('Developer')),
        dict(name='Petr Gladkikh', title=N_('Developer')),
        dict(name='Philip Stark', title=N_('Developer')),
        dict(name='Radek Postołowicz', title=N_('Developer')),
        dict(name='Rainer Müller', title=N_('Developer')),
        dict(name='Ricardo J. Barberis', title=N_('Developer')),
        dict(name='Rolando Espinoza', title=N_('Developer')),
        dict(name="Samsul Ma'arif", title=N_('Developer')),
        dict(name='Sebastian Brass', title=N_('Developer')),
        dict(name='Sergei Dyshel', title=N_('Developer')),
        dict(name='Simon Peeters', title=N_('Developer')),
        dict(name='Stephen', title=N_('Developer')),
        dict(name='Tim Gates', title=N_('Developer')),
        dict(name='Vaibhav Sagar', title=N_('Developer')),
        dict(name='Ved Vyas', title=N_('Developer')),
        dict(name='VishnuSanal', title=N_('Developer')),
        dict(name='Voicu Hodrea', title=N_('Developer')),
        dict(name='WNguyen14', title=N_('Developer')),
        dict(name='Wesley Wong', title=N_('Developer')),
        dict(name='Wolfgang Ocker', title=N_('Developer')),
        dict(name='Zhang Han', title=N_('Developer')),
        dict(name='beauxq', title=N_('Developer')),
        dict(name='bensmrs', title=N_('Developer')),
        dict(name='lcjh', title=N_('Developer')),
        dict(name='lefairy', title=N_('Developer')),
        dict(name='melkecelioglu', title=N_('Developer')),
        dict(name='ochristi', title=N_('Developer')),
        dict(name='yael levi', title=N_('Developer')),
        dict(name='Łukasz Wojniłowicz', title=N_('Developer')),
    )
    bug_url = 'https://github.com/git-cola/git-cola/issues'
    bug_link = qtutils.link(bug_url, bug_url)
    scope = dict(bug_link=bug_link)
    prelude = (
        N_(
            """
        <br>
        Please use %(bug_link)s to report issues.
        <br>
    """
        )
        % scope
    )

    return contributors_text(authors, prelude=prelude)


def translators_text():
    palette = QtGui.QPalette()
    contact = N_('Email contributor')

    translators = (
        # See the `generate-about` script in the "todo" branch.
        # vim :read! ./todo/generate-about --translators
        dict(
            name='V字龍(Vdragon)',
            title=N_('Traditional Chinese (Taiwan) translation'),
            email=mailto('Vdragon.Taiwan@gmail.com', contact, palette),
        ),
        dict(name='Pavel Rehak', title=N_('Czech translation')),
        dict(name='Victorhck', title=N_('Spanish translation')),
        dict(name='Vitor Lobo', title=N_('Brazilian translation')),
        dict(name='Zhang Han', title=N_('Simplified Chinese translation')),
        dict(name='Łukasz Wojniłowicz', title=N_('Polish translation')),
        dict(name='Igor Kopach', title=N_('Ukrainian translation')),
        dict(name='Gyuris Gellért', title=N_('Hungarian translation')),
        dict(name='fu7mu4', title=N_('Japanese translation')),
        dict(name='Barış ÇELİK', title=N_('Turkish translation')),
        dict(name='Guo Yunhe', title=N_('Simplified Chinese translation')),
        dict(name='Luke Horwell', title=N_('Translation')),
        dict(name='Minarto Margoliono', title=N_('Indonesian translation')),
        dict(name='Rafael Nascimento', title=N_('Brazilian translation')),
        dict(name='Rafael Reuber', title=N_('Brazilian translation')),
        dict(name='Shun Sakai', title=N_('Japanese translation')),
        dict(name='Sven Claussner', title=N_('German translation')),
        dict(name='Vaiz', title=N_('Russian translation')),
        dict(name='adlgrbz', title=N_('Turkish translation')),
        dict(name='Balázs Meskó', title=N_('Translation')),
        dict(name='Joachim Lusiardi', title=N_('German translation')),
        dict(name='Kai Krakow', title=N_('German translation')),
        dict(name='Louis Rousseau', title=N_('French translation')),
        dict(name='Mickael Albertus', title=N_('French translation')),
        dict(
            name='Peter Dave Hello',
            title=N_('Traditional Chinese (Taiwan) translation'),
        ),
        dict(name='Pilar Molina Lopez', title=N_('Spanish translation')),
        dict(name='Sabri Ünal', title=N_('Turkish translation')),
        dict(name="Samsul Ma'arif", title=N_('Indonesian translation')),
        dict(name='YAMAMOTO Kenyu', title=N_('Translation')),
        dict(name='Zeioth', title=N_('Spanish translation')),
        dict(name='balping', title=N_('Hungarian translation')),
        dict(name='p-bo', title=N_('Czech translation')),
        dict(
            name='林博仁(Buo-ren Lin)',
            title=N_('Traditional Chinese (Taiwan) translation'),
        ),
    )

    bug_url = 'https://github.com/git-cola/git-cola/issues'
    bug_link = qtutils.link(bug_url, bug_url)
    scope = dict(bug_link=bug_link)

    prelude = (
        N_(
            """
        <br>
            Git Cola has been translated into different languages thanks
            to the help of the individuals listed below.

        <br>
        <p>
            Translation is approximate.  If you find a mistake,
            please let us know by opening an issue on Github:
        </p>

        <p>
            %(bug_link)s
        </p>

        <br>
        <p>
            We invite you to participate in translation by adding or updating
            a translation and opening a pull request.
        </p>

        <br>

    """
        )
        % scope
    )
    return contributors_text(translators, prelude=prelude)


def show_shortcuts():
    hotkeys_html = resources.data_path(N_('hotkeys.html'))
    if utils.is_win32():
        hotkeys_url = 'file:///' + hotkeys_html.replace('\\', '/')
    else:
        hotkeys_url = 'file://' + hotkeys_html
    if not os.path.isfile(hotkeys_html):
        hotkeys_url = 'https://git-cola.gitlab.io/share/doc/git-cola/hotkeys.html'
    try:
        from qtpy import QtWebEngineWidgets
    except (ImportError, qtpy.PythonQtError):
        # Redhat disabled QtWebKit in their Qt build but don't punish the users
        webbrowser.open_new_tab(hotkeys_url)
        return

    parent = qtutils.active_window()
    widget = QtWidgets.QDialog(parent)
    widget.setWindowModality(Qt.WindowModal)
    widget.setWindowTitle(N_('Shortcuts'))

    web = QtWebEngineWidgets.QWebEngineView()
    web.setUrl(QtCore.QUrl(hotkeys_url))

    layout = qtutils.hbox(defs.no_margin, defs.spacing, web)
    widget.setLayout(layout)
    widget.resize(800, min(parent.height(), 600))
    qtutils.add_action(
        widget, N_('Close'), widget.accept, hotkeys.QUESTION, *hotkeys.ACCEPT
    )
    widget.show()
    widget.exec_()