Commit Graph

793 Commits

Author SHA1 Message Date
Charles Kerr 9d313a8816
sonarcloud warnings 9 (#1511)
* refactor: const correctness 

* refactor: fix some implicit conversions

* refactor: make local pointers const if their objects are not modified

* refactor: do not cast away const in torrent-cell-renderer

* refactor: remove call to deprecated gtk_icon_size_lookup_for_settings

* refactor: member functions that do not mutate their objects should be declared const

* chore: do not end comments with a semicolon
2020-11-08 21:31:02 -06:00
Charles Kerr 6b0408b320
refactor: fix more sonarcloud warnings (#1509)
* chore: simplify loop logic

* refactor: simplify isValidUtf8()

* refactor: use std::make_unique in Application::Application

* refactor: avoid raw pointers in DetailsDialog

* refactor: simplify DetailsDialog::refreshPref()

* refactor: make Application methods const

* refactor: reduce cognitive complexity of buildTrackerSummary()
2020-11-08 13:54:40 -06:00
Charles Kerr 7f147c65fb
refactor: fix more sonarcloud warnings (#1508)
* refactor: const correctness

* refactor: use getpwuid_r instead of getpwuid

* chore: simplify dict walking loop logic

* refactor: remove dead store assignment in announcer

* refactor: use std::make_shared
2020-11-05 16:46:21 -06:00
Mike Gelfand a6798adf2c Sync existing translations with Transifex 2020-11-03 20:26:30 +03:00
Charles Kerr 0bfbc3eba7
Sonarcloud warnings 4 (#1499)
* chore: fix some sonarcloud html warnings (e.g. deprecated attribute use)

* chore: uppercase literal suffixes

* chore: remove redundant casts

* chore: remove commented-out code

* chore: use qInfo() instead of std::cerr
2020-11-02 09:16:12 -06:00
Charles Kerr 73fdd722a7
Sonarcloud warnings 3 (#1498)
* chore: use ClassName:: for calling static methods

* chore: prefer to initialize member data in the class initializer
2020-11-01 19:13:32 -06:00
Charles Kerr 19e52d8b9a
chore: sonarcloud warnings 2 (#1496)
* fix "merge nested if" sonarcloud warnings

* fix explicit constructor warnings in qt client
2020-11-01 15:47:57 -06:00
Charles Kerr 973e63d897
refactor: use qt5's connect api (#1491)
* refactor: use qt5's connect syntax everywhere

https://wiki.qt.io/New_Signal_Slot_Syntax
2020-10-31 13:56:12 -05:00
Mike Gelfand 7cbfaf9d59 Fix qt/IconCache includes 2020-10-14 13:18:14 +03:00
Charles Kerr f59118d1fe
feat: add torrent-get 'primary-mime-type' to RPC. (#1464)
* feat: add torrent-get 'primary-mime-type' to RPC.

This is a cheap way for RPC clients to know what type of content is in a
torrent. This info can be used to display the torrent, e.g. by using an
icon that corresponds to the mime type.

* use size_t for content byte count

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit boolean expressions

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* use uint64_t for content byte counts

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* avoid unnecessary logic branches

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit cast

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* refactor: add an autogenerated mime-type.h header

* chore: maybe fix the win32 FTBFS

* chore: add mime-types.[ch] to xcode

* Squashed commit of the following:

commit 4c7153fa48
Author: Mike Gelfand <mikedld@users.noreply.github.com>
Date:   Tue Oct 13 03:15:19 2020 +0300

    Remove autotools-based build system (#1465)

    * Support .git files (e.g. for worktrees, submodules)
    * Fix symlinks in source tarball, switch to TXZ, adjust non-release name
    * Remove autotools stuff

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2020-10-13 10:33:56 -05:00
Mike Gelfand 4c7153fa48
Remove autotools-based build system (#1465)
* Support .git files (e.g. for worktrees, submodules)
* Fix symlinks in source tarball, switch to TXZ, adjust non-release name
* Remove autotools stuff
2020-10-13 03:15:19 +03:00
Mike Gelfand 32add75f0e Add new translations from Transifex (95% and higher)
Qt client: Arabic, Hebrew, Hindi, Croatian, Chinese (Taiwan).
2020-10-03 15:38:00 +03:00
Mike Gelfand 3a4cc558b6 Sync existing translations with Transifex 2020-10-03 15:36:23 +03:00
Charles Kerr 92fc42ceb5
Scrape www subdomain for favicon (#1451)
* fix: scrape other subdomains for favicon
2020-09-17 00:38:13 -05:00
Charles Kerr c2fb393390
chore: fix clang-tidy-11 warnings (#1436)
* refactor: mark subclass' destructors as override.

* refactor: use QUrl to parse announce URL strings.

The prompt for this was to work around a clang-tidy issue where
"char* host = nullptr;" triggers a "don't use varargs" warning,
but on the other hand it's also terser / cleaner.

* refactor: make the TorrentDelegate brushes const.

* refactor: s/auto/auto const*/ where appropriate

* chore: add some nonconst global warning exemptions

* chore: turn off warnings in GTest

* refactor: just disable the clang-tidy warning.

Apparently a std::array<T>::iterator is a T* on clang, since clang-tidy's
readability warning says we should use 'auto*' instead of 'auto'. However
adding that annotation fails on MSVC, where the is apparently _not_ a raw
pointer.

Since there's not a way to satisfy both of them at the same time, disable
the warning.
2020-09-09 09:24:39 -05:00
Charles Kerr bda60c5a18
feat: add 'TR_RPC_VERBOSE' env variable in Qt app. (#1435)
When set, this will log the RPC messages sent between the GUI and the
backend. This replaces the old `#ifdef DEBUG_HTTP` as something that can
be enabled without needing to recompile.
2020-09-08 17:20:46 -05:00
Charles Kerr 542feef77d
refactor: make torrents' mime icons lazy-loaded. (#1433)
* refactor: make torrents' mime icons lazy-loaded.

Another "small wins" patch, this time on CPU: icon loading is expensive,
so calculating them for every torrent all at once on startup isn't the
smartest way to do it.
2020-09-08 11:51:33 -05:00
Mike Gelfand 138ee3d7a0 Fix ICC build error due to template argument type reduction failure 2020-09-08 18:53:39 +03:00
Charles Kerr b156f55dca
refactor: use a vector for FavIcon cache keys (#1432)
* refactor: use a vector for FavIcon cache keys

Third of three PRs focused on small memory wins in transmission-qt.
This one saves 1-2 M off RES in my 15K torrent testbed. Not a major
improvement, but nice enough.

Previously we held the torrent's tracker keys in an unordered_set.
That container type is overkill for this field: the list is usually
short and almost never changes, so we don't need fast insertion time.
We can keep the same log N lookup by using a sorted vector and avoid
the excess container size & memory allocations of an unordered_set.
2020-09-08 08:58:14 -05:00
Charles Kerr b3c3168f16
refactor: intern repeated strings e.g. downloadDir (#1430)
* refactor: intern repeated strings e.g. downloadDir

Add an app-wide interned QString cache for commonly-repeated
strings. Currently used for download_dir, announce_url, comment,
creator, error_string.
2020-09-07 22:52:29 -05:00
Charles Kerr 9f7c865454
refactor: don't store torrent hashes in QStrings (#1428)
* refactor: keep torrent hash in std::array<char,20>

This replaces the hashString QString allocation with a compile-time
array that's included in sizeof the Torrent struct that owns it.
2020-09-07 16:19:10 -05:00
Charles Kerr 90ce7efc09
fixup: qt client nicer torrent add handling (#1427)
* refactor: omit unnecessary #include

* refactor: make the onDuplicatesTimer slot private.

* feat: show dupe torrents in dialog's detailText

* fix: a stupid bug that I introduced.
2020-09-07 10:20:48 -05:00
Charles Kerr fdaad67def fixup! refactor: make variant_headers reusable to qt app. (#1369) 2020-09-07 00:33:46 -05:00
Charles Kerr 6b89ee7903 fixup! refactor: make variant_headers reusable to qt app. (#1369) 2020-09-06 22:12:55 -05:00
Charles Kerr 4d7950dcb9 fixup! refactor: speed up FaviconCache::add() again. (#1402) 2020-09-02 19:33:45 -05:00
Charles Kerr 0bd915c34c fixup! refactor: speed up FaviconCache::add() again. (#1402) 2020-09-02 19:28:36 -05:00
Charles Kerr 848125d6d8 fixup! feat: nicer add-torrent workflow in the qt client. (#1410) 2020-09-02 09:25:45 -05:00
Charles Kerr cf9b81eb7d
feat: nicer add-torrent workflow in the qt client. (#1410)
* If you accidentally try to add a lot of duplicates -- for example, by
  starting up with a lot of duplicate torrents in the watchdir -- then
  coalesce all of them into a single error dialog instead of spamming
  the desktop with a different dialog for every duplicate.

* Make the duplicate torrent dialog's error message slightly terser to
  make it accommodate a long list of torrents: omit the ".torrent" file
  suffixes and show an abbreviated form of the existing torrent's hash.

* Support searching by torrent hash in the filterbar's text entry.
  This is useful when copy/pasting the hash from the duplicate torrent
  error dialog and is also consistent with the GTK client behavior.

* Copy the GTK client's behavior of appending ".added" to the end of
  .torrent files after they've been added to the session.
2020-08-26 20:42:41 -05:00
Charles Kerr 1bb9e2eef2
refactor: speed up FaviconCache::add() again. (#1402)
* refactor: speed up FaviconCache::add() again.

Another iteration on FaviconCache::add() since it's still showing up so
high in my perf tests. add()'s url argument is now a QString instead of
a QUrl, and the class has a private unordered_map that maps QString urls
into Keys. Basically, QUrl generation is so expensive that it's worth
caching the result to avoid constructing the intermediate QUrl object.

Also, ensure that the network reply's `deleteLater()` method is called
so that they don't leak, and add 'svg' to the icon list since it's now
supported on all major browsers.
2020-08-26 14:00:39 -05:00
Charles Kerr b8a02fdfb3 fixup! refactor: remove exit-time destructors from transmission-qt (#1395) 2020-08-16 20:43:14 -05:00
Charles Kerr 68920f5fa6
refactor: remove exit-time destructors from transmission-qt (#1395)
* refactor: remove exit-time destructors from transmission-qt
2020-08-15 10:42:51 -05:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Charles Kerr 49400ab443
fix: qt client memory leaks (#1378)
* fix: don't leak the qt client's QFileSystemWatcher

* fix: don't leak the Qt client's ListViewProxyStyle
2020-07-29 18:21:11 -05:00
Charles Kerr 77ced2b7c8
Fix Ubuntu 18.04 Qt FTBFS (#1377)
* fix: avoid qt5_add_translation options on old qt5

Check the Qt5Linguist version before passing 'OPTIONS -silent' to
qt5_add_translation(). 'OPTIONS' arg support was merged 2018-01-12
https://codereview.qt.nokia.com/gitweb?p=qt%2Fqttools.git;a=commit;h=9f3dba2ea3978936565aa5e7893415a8a765268e
and made it into the 5.11 release on 2018-05-22.

* fix: ftbfs include <cassert> before using assert()
2020-07-29 14:53:55 -05:00
Charles Kerr 8f12792186
fix: ensure details dialog is updated on selection (#1376)
* fix: ensure details dialog is updated on selection
2020-07-29 11:56:23 -05:00
Charles Kerr 9da4abb003
feat: add 'transfer.complete' notification hint (#1374)
Described at https://developer.gnome.org/notification-spec/#categories ,
this is for a file transfer or download complete notification.
2020-07-28 16:51:01 -05:00
Charles Kerr 910944733e
refactor: reuse one QRequestHeader across requests (#1373)
Minor optimization: since we don't actually change our request headers
very often, we can lazy-build the request once and reuse that instead of
having to rebuild it each time.
2020-07-28 10:56:40 -05:00
Charles Kerr 0b042d85dd
fix: type deduction error introduced in 00be8d0 (#1372)
Explicitly delete the implied function to ensure we don't get bitten by
this again in the future.

Mark the string_views constexpr where possible so that we can avoid some
strlen() calls at runtime.
2020-07-27 18:34:40 -05:00
Charles Kerr 00be8d00d7
refactor: make variant_headers reusable to qt app. (#1369)
* refactor: make variant_headers reusable to qt app.

Torrent.cc's `change()` template methods are generically useful to deal
with tr_variant wrangling, but previously were only used in Torrent.cc.
This PR moves them into a new API `VariantHelpers.h` for use by Prefs,
Session, TorrentModel, etc.
2020-07-26 23:30:58 -05:00
Charles Kerr 7e1da2d8fe
refactor: only update favicon when tracker changes (#1336)
* refactor: make Favicon's Key a semi-opaque type and update a Torrent's icon only when the announce_url changes.
2020-06-24 13:28:54 -05:00
Charles Kerr 33a421e97f
refactor: only update filterbar comboboxes when necessary (#1335)
* refactor: Torrent::update() returns a delta bitset

Setting up for followup PRs where, instead of doing expensive work every
time there is a change, we can be more fine-grained and do the work only
if the relevant Torrent properties changed.

* chore: make uncrustify happy

* refactor: update filterbar counts more selectively

Only rebuild the activity and tracker combobox models when the model's
size changes or when the relevant Torrent properties change.

Previously, rebuild would happen on any Torrent property change even if
the properties were unrelated to activity or trackers.

* chore: remove redundant "private:" key
2020-06-23 18:54:08 -05:00
Charles Kerr f37253a3ab
feat: Torrent::update() returns a bitset of changed properties (#1334)
* refactor: Torrent::update() returns a delta bitset

Setting up for followup PRs where, instead of doing expensive work every
time there is a change, we can be more fine-grained and do the work only
if the relevant Torrent properties changed.

* chore: make uncrustify happy

* chore: fix #includes
2020-06-23 16:11:16 -05:00
Charles Kerr 83e4e4ca55
refactor: faster action sensitivity updates (#1333)
* refactor: faster action sensitivity updates

Currently we walk through every row in the model and pump its TorrentRole data, which can be expensive for long lists. However since we're only interested in the selected rows, let's save some traversal overhead by getting that list directly and walking it instead.
2020-06-23 12:16:07 -05:00
Charles Kerr 8fcfc1e4ae
feat: add 'edit-date' support to qt client (#1322)
edit-date got added to the backend in 3.00, but I never finished adding
it properly to the Qt client. This PR rectifies that. When a torrent is
edited, the Application and DetailsDialogs will re-query the backend to
update the torrent properties that are needed.
2020-06-18 15:34:11 -05:00
Charles Kerr fcda077cdd
chore: remove extraneous/default class destructors (#1317)
* chore: remove extraneous/default class destructors

* fixup! chore: remove extraneous/default class destructors
2020-06-15 09:30:29 -05:00
Charles Kerr 51573a3c1e
chore: clang-tidy cleanups (#1287)
* chore: fix syntax error in clang-tidy config file
2020-06-05 14:02:11 -05:00
Charles Kerr 1f28470cf4
chore: prefer QStringLiteral (#1284)
Further reading:
* https://forum.qt.io/topic/78540/qstringliteral-vs-qlatin1string/2
* https://woboq.com/blog/qstringliteral.html
* https://www.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral

tl;dr: QLatin1Literal uses less memory than QStringLiteral; however,
since most Qt APIs require a QString argument, there's extra runtime
cost of converting QLatin1Strings to QStrings. QStringLiteral uses a
little more memory but constructs its QStrings at compile time.

ok, the `prefer-qstringliteral` branch is getting out of control: the
secondary goal of fixing a .clang-tidy issue is causing more diffs
than the primary goal. So, I'm breaking it into two separate PRs.
2020-05-29 12:40:07 -05:00
Charles Kerr 070a7f2ffc
refactor: use snake_case field naming in qt client (#1262)
* refactor: use snake_case field naming in qt client

* fix: some missed symbols

* chore: make uncrustify happy

* fixup! refactor: use snake_case field naming in qt client
2020-05-27 16:53:12 -05:00
Charles Kerr d43aeb6a5c
chore: add clang-tidy checks to Qt client (#1236)
* chore: add clang-tidy integration for Qt client
2020-05-19 20:32:51 -05:00
Charles Kerr 6aa559f12f
refactor: remove QVariants from torrent (#1234)
* chore: remove qvariants from torrent class

* chore: remove unused Q_DECLARE macro calls

* refactor: remove unused includes from Torrent.h

* chore: make clang-tidy and linter happy

* refactor: rename 'setValue()' to 'change()'

* refactor: make tr_variant function paramters const

* chore: remove devel scaffolding

* refactor: rename peer_limit_ to peerLimit_

* refactor: do not use bitwise logic on booleans
2020-05-19 18:42:17 -05:00