Use ForkAwesome icons more consistently in tray widget

Mixing ForkAwesome icons too much with the regular icon theme doesn't look
good (depending on the theme) so let's prefer ForkAwesome icons within the
tray widget which already uses ForkAwesome in some places like certain
buttons and models. This makes it also look more in-line with Syncthing's
web UI. For context menus and dialogs let's prefer system icons because
there are hardly any ForkAwesome icons used/required so far and it is maybe
nicer to be in-line with the system here.
This commit is contained in:
Martchus 2021-10-15 00:23:22 +02:00
parent d3c878359a
commit 7b6121cb05
9 changed files with 43 additions and 86 deletions

View File

@ -2,6 +2,10 @@
#include <syncthingconnector/syncthingconnection.h>
#include <syncthingmodel/syncthingdevicemodel.h>
#include <syncthingmodel/syncthingicons.h>
#include <qtforkawesome/renderer.h>
#include <qtforkawesome/icon.h>
#include <QApplication>
#include <QBrush>
@ -23,12 +27,6 @@ inline int centerObj(int avail, int size)
DevButtonsItemDelegate::DevButtonsItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, m_pauseIcon(
QIcon::fromTheme(QStringLiteral("media-playback-pause"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-pause.svg")))
.pixmap(QSize(16, 16)))
, m_resumeIcon(
QIcon::fromTheme(QStringLiteral("media-playback-start"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-start.svg")))
.pixmap(QSize(16, 16)))
{
}
@ -59,8 +57,7 @@ void DevButtonsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
return;
}
const int buttonY = option.rect.y() + centerObj(option.rect.height(), 16);
painter->drawPixmap(
option.rect.right() - 16, buttonY, 16, 16, index.data(SyncthingDeviceModel::DevicePaused).toBool() ? m_resumeIcon : m_pauseIcon);
IconManager::instance().forkAwesomeRenderer().render(index.data(SyncthingDeviceModel::DevicePaused).toBool() ? QtForkAwesome::Icon::Play : QtForkAwesome::Icon::Pause, painter, QRect(option.rect.right() - 16, buttonY, 16, 16), QGuiApplication::palette().color(QPalette::Text));
}
}
} // namespace QtGui

View File

@ -1,7 +1,6 @@
#ifndef DEVBUTTONSITEMDELEGATE_H
#define DEVBUTTONSITEMDELEGATE_H
#include <QPixmap>
#include <QStyleOptionViewItem>
#include <QStyledItemDelegate>
@ -13,10 +12,6 @@ public:
DevButtonsItemDelegate(QObject *parent);
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
private:
const QPixmap m_pauseIcon;
const QPixmap m_resumeIcon;
};
} // namespace QtGui

View File

@ -1,6 +1,10 @@
#include "./dirbuttonsitemdelegate.h"
#include <syncthingmodel/syncthingdirectorymodel.h>
#include <syncthingmodel/syncthingicons.h>
#include <qtforkawesome/renderer.h>
#include <qtforkawesome/icon.h>
#include <QApplication>
#include <QBrush>
@ -22,16 +26,6 @@ inline int centerObj(int avail, int size)
DirButtonsItemDelegate::DirButtonsItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, m_refreshIcon(QIcon::fromTheme(QStringLiteral("view-refresh"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/view-refresh.svg")))
.pixmap(QSize(16, 16)))
, m_folderIcon(QIcon::fromTheme(QStringLiteral("folder-open"), QIcon(QStringLiteral(":/icons/hicolor/scalable/places/folder-open.svg")))
.pixmap(QSize(16, 16)))
, m_pauseIcon(
QIcon::fromTheme(QStringLiteral("media-playback-pause"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-pause.svg")))
.pixmap(QSize(16, 16)))
, m_resumeIcon(
QIcon::fromTheme(QStringLiteral("media-playback-start"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-start.svg")))
.pixmap(QSize(16, 16)))
{
}
@ -49,7 +43,7 @@ void DirButtonsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter);
// draw text
QRectF textRect = option.rect;
auto textRect = QRectF(option.rect);
textRect.setWidth(textRect.width() - 58);
QTextOption textOption;
textOption.setAlignment(opt.displayAlignment);
@ -60,11 +54,13 @@ void DirButtonsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
// draw buttons
const int buttonY = option.rect.y() + centerObj(option.rect.height(), 16);
const bool dirPaused = index.data(SyncthingDirectoryModel::DirectoryPaused).toBool();
const auto iconColor = QGuiApplication::palette().color(QPalette::Text);
auto &forkAwesomeRenderer = IconManager::instance().forkAwesomeRenderer();
if (!dirPaused) {
painter->drawPixmap(option.rect.right() - 52, buttonY, 16, 16, m_refreshIcon);
forkAwesomeRenderer.render(QtForkAwesome::Icon::Refresh, painter, QRect(option.rect.right() - 52, buttonY, 16, 16), iconColor);
}
painter->drawPixmap(option.rect.right() - 34, buttonY, 16, 16, dirPaused ? m_resumeIcon : m_pauseIcon);
painter->drawPixmap(option.rect.right() - 16, buttonY, 16, 16, m_folderIcon);
forkAwesomeRenderer.render(dirPaused ? QtForkAwesome::Icon::Play : QtForkAwesome::Icon::Pause, painter, QRect(option.rect.right() - 34, buttonY, 16, 16), iconColor);
forkAwesomeRenderer.render(QtForkAwesome::Icon::Folder, painter, QRect(option.rect.right() - 16, buttonY, 16, 16), iconColor);
}
}
} // namespace QtGui

View File

@ -1,7 +1,6 @@
#ifndef DIRBUTTONSITEMDELEGATE_H
#define DIRBUTTONSITEMDELEGATE_H
#include <QPixmap>
#include <QStyledItemDelegate>
namespace QtGui {
@ -12,12 +11,6 @@ public:
DirButtonsItemDelegate(QObject *parent);
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
private:
const QPixmap m_refreshIcon;
const QPixmap m_folderIcon;
const QPixmap m_pauseIcon;
const QPixmap m_resumeIcon;
};
} // namespace QtGui

View File

@ -1,6 +1,10 @@
#include "./downloaditemdelegate.h"
#include <syncthingmodel/syncthingdownloadmodel.h>
#include <syncthingmodel/syncthingicons.h>
#include <qtforkawesome/renderer.h>
#include <qtforkawesome/icon.h>
#include <QApplication>
#include <QBrush>
@ -26,8 +30,6 @@ inline int centerObj(int avail, int size)
DownloadItemDelegate::DownloadItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, m_folderIcon(QIcon::fromTheme(QStringLiteral("folder-open"), QIcon(QStringLiteral(":/icons/hicolor/scalable/places/folder-open.svg")))
.pixmap(QSize(16, 16)))
{
}
@ -81,7 +83,7 @@ void DownloadItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
if (!index.parent().isValid()) {
buttonY += centerObj(progressBarOption.rect.height(), 16);
}
painter->drawPixmap(option.rect.right() - 16, buttonY, 16, 16, m_folderIcon);
IconManager::instance().forkAwesomeRenderer().render(QtForkAwesome::Icon::Folder, painter, QRect(option.rect.right() - 16, buttonY, 16, 16), QGuiApplication::palette().color(QPalette::Text));
// draw file icon
if (index.parent().isValid()) {

View File

@ -13,9 +13,6 @@ public:
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
const QPixmap m_folderIcon;
};
} // namespace QtGui

View File

@ -49,7 +49,7 @@ TrayIcon::TrayIcon(const QString &connectionConfig, QObject *parent)
// set context menu
#ifndef SYNCTHINGTRAY_UNIFY_TRAY_MENUS
connect(m_contextMenu.addAction(QIcon(QStringLiteral(":/icons/hicolor/scalable/status/syncthing-default.svg")), tr("Open Syncthing")),
connect(m_contextMenu.addAction(QIcon(QStringLiteral("syncthing.fa")), tr("Open Syncthing")),
&QAction::triggered, &widget, &TrayWidget::showWebUi);
connect(m_contextMenu.addAction(
QIcon::fromTheme(QStringLiteral("preferences-other"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/preferences-other.svg"))),
@ -59,8 +59,7 @@ TrayIcon::TrayIcon(const QString &connectionConfig, QObject *parent)
QIcon::fromTheme(QStringLiteral("folder-sync"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/folder-sync.svg"))),
tr("Rescan all")),
&QAction::triggered, &widget.connection(), &SyncthingConnection::rescanAllDirs);
connect(m_contextMenu.addAction(
QIcon::fromTheme(QStringLiteral("text-x-generic"), QIcon(QStringLiteral(":/icons/hicolor/scalable/mimetypes/text-x-generic.svg"))),
connect(m_contextMenu.addAction(QIcon(QStringLiteral("file-code-o.fa")),
tr("Log")),
&QAction::triggered, &widget, &TrayWidget::showLog);
m_errorsAction = m_contextMenu.addAction(

View File

@ -122,20 +122,17 @@ TrayWidget::TrayWidget(TrayMenu *parent)
cornerFrameLayout->addWidget(viewIdButton);
auto *restartButton = new QPushButton(m_cornerFrame);
restartButton->setToolTip(tr("Restart Syncthing"));
restartButton->setIcon(
QIcon::fromTheme(QStringLiteral("system-reboot"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/view-refresh.svg"))));
restartButton->setIcon(QIcon(QStringLiteral("power-off.fa")));
restartButton->setFlat(true);
cornerFrameLayout->addWidget(restartButton);
auto *showLogButton = new QPushButton(m_cornerFrame);
showLogButton->setToolTip(tr("Show Syncthing log"));
showLogButton->setIcon(
QIcon::fromTheme(QStringLiteral("text-x-generic"), QIcon(QStringLiteral(":/icons/hicolor/scalable/mimetypes/text-x-generic.svg"))));
showLogButton->setIcon(QIcon(QStringLiteral("file-code-o.fa")));
showLogButton->setFlat(true);
cornerFrameLayout->addWidget(showLogButton);
auto *scanAllButton = new QPushButton(m_cornerFrame);
scanAllButton->setToolTip(tr("Rescan all directories"));
scanAllButton->setIcon(
QIcon::fromTheme(QStringLiteral("folder-sync"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/folder-sync.svg"))));
scanAllButton->setIcon(QIcon(QStringLiteral("search.fa")));
scanAllButton->setFlat(true);
cornerFrameLayout->addWidget(scanAllButton);
m_ui->tabWidget->setCornerWidget(m_cornerFrame, Qt::BottomRightCorner);
@ -154,10 +151,8 @@ TrayWidget::TrayWidget(TrayMenu *parent)
// setup other widgets
m_ui->notificationsPushButton->setHidden(true);
m_ui->globalTextLabel->setPixmap(
QIcon::fromTheme(QStringLiteral("globe"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/globe.svg"))).pixmap(16));
m_ui->localTextLabel->setPixmap(
QIcon::fromTheme(QStringLiteral("user-home"), QIcon(QStringLiteral(":/icons/hicolor/scalable/places/user-home.svg"))).pixmap(16));
m_ui->globalTextLabel->setPixmap(QIcon(QStringLiteral("globe.fa")).pixmap(16));
m_ui->localTextLabel->setPixmap(QIcon(QStringLiteral("home.fa")).pixmap(16));
updateTraffic();
// add actions from right-click menu if it is not available
@ -395,8 +390,7 @@ void TrayWidget::handleStatusChanged(SyncthingStatus status)
case SyncthingStatus::Disconnected:
m_ui->statusPushButton->setText(tr("Connect"));
m_ui->statusPushButton->setToolTip(tr("Not connected to Syncthing, click to connect"));
m_ui->statusPushButton->setIcon(
QIcon::fromTheme(QStringLiteral("view-refresh"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/view-refresh.svg"))));
m_ui->statusPushButton->setIcon(QIcon(QStringLiteral("refresh.fa")));
m_ui->statusPushButton->setHidden(false);
updateTraffic(); // ensure previous traffic statistics are no longer shown
break;
@ -409,15 +403,13 @@ void TrayWidget::handleStatusChanged(SyncthingStatus status)
case SyncthingStatus::RemoteNotInSync:
m_ui->statusPushButton->setText(tr("Pause"));
m_ui->statusPushButton->setToolTip(tr("Syncthing is running, click to pause all devices"));
m_ui->statusPushButton->setIcon(QIcon::fromTheme(
QStringLiteral("media-playback-pause"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-pause.svg"))));
m_ui->statusPushButton->setIcon(QIcon(QStringLiteral("pause.fa")));
m_ui->statusPushButton->setHidden(false);
break;
case SyncthingStatus::Paused:
m_ui->statusPushButton->setText(tr("Continue"));
m_ui->statusPushButton->setToolTip(tr("At least one device is paused, click to resume"));
m_ui->statusPushButton->setIcon(QIcon::fromTheme(
QStringLiteral("media-playback-start"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/media-playback-start.svg"))));
m_ui->statusPushButton->setIcon(QIcon(QStringLiteral("play.fa")));
m_ui->statusPushButton->setHidden(false);
break;
default:;
@ -736,13 +728,11 @@ Settings::Launcher::LauncherStatus TrayWidget::applyLauncherSettings(bool reconn
if (launcherStatus.running) {
m_ui->startStopPushButton->setText(tr("Stop"));
m_ui->startStopPushButton->setToolTip(tr("Stop Syncthing instance launched via tray icon"));
m_ui->startStopPushButton->setIcon(
QIcon::fromTheme(QStringLiteral("process-stop"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/process-stop.svg"))));
m_ui->startStopPushButton->setIcon(QIcon(QStringLiteral("stop.fa")));
} else {
m_ui->startStopPushButton->setText(tr("Start"));
m_ui->startStopPushButton->setToolTip(tr("Start Syncthing with the built-in launcher configured in the settings"));
m_ui->startStopPushButton->setIcon(
QIcon::fromTheme(QStringLiteral("system-run"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/system-run.svg"))));
m_ui->startStopPushButton->setIcon(QIcon(QStringLiteral("play.fa")));
}
return launcherStatus;
}
@ -780,15 +770,13 @@ Settings::Systemd::ServiceStatus TrayWidget::applySystemdSettings(bool reconnect
m_ui->startStopPushButton->setToolTip(
(serviceStatus.userService ? QStringLiteral("systemctl --user stop ") : QStringLiteral("systemctl stop "))
+ systemdSettings.syncthingUnit);
m_ui->startStopPushButton->setIcon(
QIcon::fromTheme(QStringLiteral("process-stop"), QIcon(QStringLiteral(":/icons/hicolor/scalable/actions/process-stop.svg"))));
m_ui->startStopPushButton->setIcon(QIcon(QStringLiteral("stop.fa")));
} else {
m_ui->startStopPushButton->setText(tr("Start"));
m_ui->startStopPushButton->setToolTip(
(serviceStatus.userService ? QStringLiteral("systemctl --user start ") : QStringLiteral("systemctl start "))
+ systemdSettings.syncthingUnit);
m_ui->startStopPushButton->setIcon(
QIcon::fromTheme(QStringLiteral("system-run"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/system-run.svg"))));
m_ui->startStopPushButton->setIcon(QIcon(QStringLiteral("play.fa")));
}
return serviceStatus;
}

View File

@ -58,8 +58,7 @@
<string>Connect</string>
</property>
<property name="icon">
<iconset theme="view-refresh" resource="../../widgets/resources/syncthingwidgetsicons.qrc">
<normaloff>:/icons/hicolor/scalable/actions/view-refresh.svg</normaloff>:/icons/hicolor/scalable/actions/view-refresh.svg</iconset>
<iconset>refresh.fa</iconset>
</property>
<property name="flat">
<bool>true</bool>
@ -72,8 +71,7 @@
<string>Start</string>
</property>
<property name="icon">
<iconset theme="system-run" resource="../../widgets/resources/syncthingwidgetsicons.qrc">
<normaloff>:/icons/hicolor/scalable/apps/system-run.svg</normaloff>:/icons/hicolor/scalable/apps/system-run.svg</iconset>
<iconset>play.fa</iconset>
</property>
<property name="flat">
<bool>true</bool>
@ -99,8 +97,7 @@
<string>About</string>
</property>
<property name="icon">
<iconset theme="help-about" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/actions/help-about.svg</normaloff>:/icons/hicolor/scalable/actions/help-about.svg</iconset>
<iconset>info.fa</iconset>
</property>
<property name="flat">
<bool>true</bool>
@ -113,8 +110,7 @@
<string>Settings</string>
</property>
<property name="icon">
<iconset theme="preferences-other" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/actions/application-menu.svg</normaloff>:/icons/hicolor/scalable/actions/application-menu.svg</iconset>
<iconset>cogs.fa</iconset>
</property>
<property name="flat">
<bool>true</bool>
@ -145,8 +141,7 @@
</sizepolicy>
</property>
<property name="icon">
<iconset theme="network-connect" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/actions/network-connect.svg</normaloff>:/icons/hicolor/scalable/actions/network-connect.svg</iconset>
<iconset>plug.fa</iconset>
</property>
<property name="flat">
<bool>true</bool>
@ -383,8 +378,7 @@ For &lt;i&gt;all&lt;/i&gt; notifications, checkout the log</string>
</property>
<widget class="QWidget" name="dirsTab">
<attribute name="icon">
<iconset theme="folder" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/places/folder.svg</normaloff>:/icons/hicolor/scalable/places/folder.svg</iconset>
<iconset>folder.fa</iconset>
</attribute>
<attribute name="title">
<string>Directories</string>
@ -416,8 +410,7 @@ For &lt;i&gt;all&lt;/i&gt; notifications, checkout the log</string>
</widget>
<widget class="QWidget" name="devsTab">
<attribute name="icon">
<iconset theme="network-server" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/places/network-workgroup.svg</normaloff>:/icons/hicolor/scalable/places/network-workgroup.svg</iconset>
<iconset>sitemap.fa</iconset>
</attribute>
<attribute name="title">
<string>Devices</string>
@ -449,8 +442,7 @@ For &lt;i&gt;all&lt;/i&gt; notifications, checkout the log</string>
</widget>
<widget class="QWidget" name="downloadsTab">
<attribute name="icon">
<iconset theme="folder-download" resource="../resources/syncthingtrayicons.qrc">
<normaloff>:/icons/hicolor/scalable/places/folder-download.svg</normaloff>:/icons/hicolor/scalable/places/folder-download.svg</iconset>
<iconset>download.fa</iconset>
</attribute>
<attribute name="title">
<string>Downloads</string>
@ -478,9 +470,7 @@ For &lt;i&gt;all&lt;/i&gt; notifications, checkout the log</string>
</widget>
<widget class="QWidget" name="recentChangesTab">
<attribute name="icon">
<iconset theme="document-open-recent-symbolic">
<normaloff>.</normaloff>
<normalon>:/icons/hicolor/scalable/actions/appointment-new.svg</normalon>.</iconset>
<iconset>history.fa</iconset>
</attribute>
<attribute name="title">
<string>Recent changes</string>