Skip to content

Commit

Permalink
Redraw torrent status icons (#278)
Browse files Browse the repository at this point in the history
Also fix hidpi issues with them by using SVG and QIcon instead of QPixmap.
  • Loading branch information
equeim committed Mar 23, 2023
1 parent 3f8aaf4 commit 35ecbf8
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Copyright: 2015-2022 Alexey Rochev
2018 Carlos Gonzalez
License: GPL-3.0-or-later

Files: data/icons/status/*.png
Files: data/icons/status/*.svg
Copyright: 2009 Mateusz Tobola
Copyright: 2023 Alexey Rochev
License: GPL-2.0-or-later

Files: data/icons/hicolor/*/apps/org.equeim.Tremotesf.png data/icons/hicolor/scalable/apps/org.equeim.Tremotesf.svg src/tremotesf/tremotesf.ico
Expand Down
Binary file removed data/icons/status/active.png
Binary file not shown.
18 changes: 18 additions & 0 deletions data/icons/status/active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/checking.png
Binary file not shown.
15 changes: 15 additions & 0 deletions data/icons/status/checking.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/downloading.png
Binary file not shown.
12 changes: 12 additions & 0 deletions data/icons/status/downloading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/errored.png
Binary file not shown.
13 changes: 13 additions & 0 deletions data/icons/status/errored.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/paused.png
Binary file not shown.
13 changes: 13 additions & 0 deletions data/icons/status/paused.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/queued.png
Binary file not shown.
18 changes: 18 additions & 0 deletions data/icons/status/queued.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/seeding.png
Binary file not shown.
12 changes: 12 additions & 0 deletions data/icons/status/seeding.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/stalled-downloading.png
Binary file not shown.
14 changes: 14 additions & 0 deletions data/icons/status/stalled-downloading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/icons/status/stalled-seeding.png
Binary file not shown.
14 changes: 14 additions & 0 deletions data/icons/status/stalled-seeding.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions data/icons/status/status.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ SPDX-License-Identifier: CC0-1.0

<RCC>
<qresource prefix="/">
<file>active.png</file>
<file>checking.png</file>
<file>downloading.png</file>
<file>errored.png</file>
<file>paused.png</file>
<file>queued.png</file>
<file>seeding.png</file>
<file>stalled-downloading.png</file>
<file>stalled-seeding.png</file>
<file>active.svg</file>
<file>checking.svg</file>
<file>downloading.svg</file>
<file>errored.svg</file>
<file>paused.svg</file>
<file>queued.svg</file>
<file>seeding.svg</file>
<file>stalled-downloading.svg</file>
<file>stalled-seeding.svg</file>
</qresource>
</RCC>
18 changes: 9 additions & 9 deletions src/tremotesf/desktoputils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ namespace tremotesf::desktoputils {
QString statusIconPath(StatusIcon icon) {
switch (icon) {
case ActiveIcon:
return ":/active.png"_l1;
return ":/active.svg"_l1;
case CheckingIcon:
return ":/checking.png"_l1;
return ":/checking.svg"_l1;
case DownloadingIcon:
return ":/downloading.png"_l1;
return ":/downloading.svg"_l1;
case ErroredIcon:
return ":/errored.png"_l1;
return ":/errored.svg"_l1;
case PausedIcon:
return ":/paused.png"_l1;
return ":/paused.svg"_l1;
case QueuedIcon:
return ":/queued.png"_l1;
return ":/queued.svg"_l1;
case SeedingIcon:
return ":/seeding.png"_l1;
return ":/seeding.svg"_l1;
case StalledDownloadingIcon:
return ":/stalled-downloading.png"_l1;
return ":/stalled-downloading.svg"_l1;
case StalledSeedingIcon:
return ":/stalled-seeding.png"_l1;
return ":/stalled-seeding.svg"_l1;
}

return {};
Expand Down
18 changes: 9 additions & 9 deletions src/tremotesf/ui/screens/mainwindow/torrentsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <limits>

#include <QCoreApplication>
#include <QIcon>
#include <QMetaEnum>
#include <QPixmap>

#include "libtremotesf/stdutils.h"
#include "libtremotesf/torrent.h"
Expand Down Expand Up @@ -36,27 +36,27 @@ namespace tremotesf {
if (static_cast<Column>(index.column()) == Column::Name) {
using namespace desktoputils;
if (torrent->data().error != TorrentData::Error::None) {
return QPixmap(statusIconPath(ErroredIcon));
return QIcon(statusIconPath(ErroredIcon));
}
switch (torrent->data().status) {
case TorrentData::Status::Paused:
return QPixmap(statusIconPath(PausedIcon));
return QIcon(statusIconPath(PausedIcon));
case TorrentData::Status::Seeding:
if (torrent->data().isSeedingStalled()) {
return QPixmap(statusIconPath(StalledSeedingIcon));
return QIcon(statusIconPath(StalledSeedingIcon));
}
return QPixmap(statusIconPath(SeedingIcon));
return QIcon(statusIconPath(SeedingIcon));
case TorrentData::Status::Downloading:
if (torrent->data().isDownloadingStalled()) {
return QPixmap(statusIconPath(StalledDownloadingIcon));
return QIcon(statusIconPath(StalledDownloadingIcon));
}
return QPixmap(statusIconPath(DownloadingIcon));
return QIcon(statusIconPath(DownloadingIcon));
case TorrentData::Status::QueuedForDownloading:
case TorrentData::Status::QueuedForSeeding:
return QPixmap(statusIconPath(QueuedIcon));
return QIcon(statusIconPath(QueuedIcon));
case TorrentData::Status::Checking:
case TorrentData::Status::QueuedForChecking:
return QPixmap(statusIconPath(CheckingIcon));
return QIcon(statusIconPath(CheckingIcon));
}
}
break;
Expand Down

0 comments on commit 35ecbf8

Please sign in to comment.