From 43fcb9f71b19daed02f4e5b333e9ede767b2f8af Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 11 Sep 2021 02:20:38 +0200 Subject: [PATCH] Migrate to ForkAwesome * FontAwesome uses a propritary build system so let's move to its fork ForkAwesome similar to Syncthing * See https://github.com/syncthing/syncthing/pull/5237 * Bundle the font file instead of having the SVGs directly within Syncthing Tray's own repository --- CMakeLists.txt | 27 +++++++- README.md | 10 ++- fileitemactionplugin/syncthingdiractions.cpp | 2 +- .../syncthingfileitemactionstaticdata.cpp | 4 +- model/CMakeLists.txt | 4 ++ .../hicolor/scalable/fa-non-solid/file.svg | 1 - .../hicolor/scalable/fa-non-solid/folder.svg | 1 - .../hicolor/scalable/fa-non-solid/hdd.svg | 1 - .../icons/hicolor/scalable/fa/certificate.svg | 1 - .../icons/hicolor/scalable/fa/clock.svg | 1 - .../scalable/fa/cloud-download-alt.svg | 1 - .../hicolor/scalable/fa/cloud-upload-alt.svg | 1 - .../icons/hicolor/scalable/fa/cogs.svg | 1 - .../hicolor/scalable/fa/exchange-alt.svg | 1 - .../scalable/fa/exclamation-triangle.svg | 1 - .../icons/hicolor/scalable/fa/eye.svg | 1 - .../hicolor/scalable/fa/file-archive.svg | 1 - .../icons/hicolor/scalable/fa/folder-open.svg | 1 - .../icons/hicolor/scalable/fa/folder.svg | 1 - .../icons/hicolor/scalable/fa/globe.svg | 1 - .../icons/hicolor/scalable/fa/hashtag.svg | 1 - .../icons/hicolor/scalable/fa/home.svg | 1 - .../icons/hicolor/scalable/fa/link.svg | 1 - .../hicolor/scalable/fa/network-wired.svg | 1 - .../icons/hicolor/scalable/fa/redo.svg | 1 - .../icons/hicolor/scalable/fa/share-alt.svg | 1 - .../icons/hicolor/scalable/fa/tag.svg | 1 - model/resources/syncthingmodelicons.qrc | 22 ------- model/syncthingdevicemodel.cpp | 2 +- model/syncthingdirectorymodel.cpp | 2 +- model/syncthingicons.cpp | 63 +++++++------------ model/syncthingicons.h | 36 ++++++----- model/syncthingrecentchangesmodel.cpp | 4 +- plasmoid/lib/syncthingapplet.cpp | 20 ++++-- plasmoid/lib/syncthingapplet.h | 2 +- .../contents/ui/FullRepresentation.qml | 8 +-- .../package/contents/ui/StatisticsView.qml | 7 +-- tray/gui/traywidget.cpp | 17 ++--- 38 files changed, 121 insertions(+), 131 deletions(-) delete mode 100644 model/resources/icons/hicolor/scalable/fa-non-solid/file.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa-non-solid/folder.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa-non-solid/hdd.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/certificate.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/clock.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/cloud-download-alt.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/cloud-upload-alt.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/cogs.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/exchange-alt.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/exclamation-triangle.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/eye.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/file-archive.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/folder-open.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/folder.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/globe.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/hashtag.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/home.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/link.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/network-wired.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/redo.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/share-alt.svg delete mode 100644 model/resources/icons/hicolor/scalable/fa/tag.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index db8309d..1c8bb5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) # define metadata set(META_PROJECT_NAME syncthingtray) -set(META_PROJECT_TYPE application) set(META_APP_AUTHOR "Martchus") set(META_APP_AUTHOR_MAIL "martchus@gmx.net") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") @@ -11,7 +10,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer") set(META_GUI_OPTIONAL false) set(META_VERSION_MAJOR 1) set(META_VERSION_MINOR 1) -set(META_VERSION_PATCH 10) +set(META_VERSION_PATCH 11) set(META_VERSION_EXACT_SONAME ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) @@ -42,6 +41,30 @@ option(NO_PLASMOID "whether building the Plasma 5 plasmoid should be skipped" "$ set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities") set(CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES "${CONFIGURATION_PACKAGE_SUFFIX}" CACHE STRING "sets the suffix for qtutilities") +# allow building qtforkawesome as part of this project +set(BUNDLED_QT_FORK_AWESOME_PATH OFF CACHE PATH "specifies the (relative) path to the qtforkawesome sources for building it together with ${META_PROJECT_NAME}") +if(NOT BUNDLED_QT_FORK_AWESOME_PATH) + message(STATUS "Using system qtforkawesome") +else() + # check whether bundled c++utilities actually exists + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_QT_FORK_AWESOME_PATH}") + # treat the specified path as relative to the current source dir + set(qtforkawesome_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_QT_FORK_AWESOME_PATH}") + elseif(IS_DIRECTORY "${BUNDLED_QT_FORK_AWESOME_PATH}") + # treat the specified path as absolute + set(qtforkawesome_DIR "${BUNDLED_QT_FORK_AWESOME_PATH}") + else() + # consider the specified path invalid + set(qtforkawesome_DIR "") + endif() + if(qtforkawesome_DIR) + add_subdirectory("${BUNDLED_QT_FORK_AWESOME_PATH}" qtforkawesome_DIR) + list(APPEND CMAKE_MODULE_PATH "${CPP_UTILITIES_SOURCE_DIR}/cmake/modules") + else() + message(FATAL_ERROR "Specified directory for qtforkawesome sources \"${BUNDLED_CPP_UTILITIES_PATH}\" does not exist.") + endif() +endif() + # add subdirectories enable_testing() add_subdirectory(connector) diff --git a/README.md b/README.md index 753c6e5..3b1484a 100644 --- a/README.md +++ b/README.md @@ -244,8 +244,9 @@ See the release section on GitHub. by [perfect7gentleman's repository](https://github.com/perfect7gentleman/pg_overlay) ## Build instructions -The application depends on [c++utilities](https://github.com/Martchus/cpp-utilities) and -[qtutilities](https://github.com/Martchus/qtutilities) and is built the same way as these libraries. +The application depends on [c++utilities](https://github.com/Martchus/cpp-utilities), +[qtutilities](https://github.com/Martchus/qtutilities) and +[qtforkawesome](https://github.com/Martchus/qtforkawesome) and is built the same way as these libraries. For basic instructions checkout the README file of [c++utilities](https://github.com/Martchus/cpp-utilities). For building this straight, see the section below. There's also documentation about [various build variables](https://github.com/Martchus/cpp-utilities/blob/master/doc/buildvariables.md) which @@ -298,6 +299,8 @@ Building the testsuite requires CppUnit and Qt 5.8 or higher. cd $SOURCES git clone -c core.symlinks=true https://github.com/Martchus/cpp-utilities.git c++utilities git clone -c core.symlinks=true https://github.com/Martchus/qtutilities.git + git clone -c core.symlinks=true https://github.com/Martchus/qtforkawesome.git + git clone -c core.symlinks=true https://github.com/ForkAwesome/Fork-Awesome.git forkawesome git clone -c core.symlinks=true https://github.com/Martchus/syncthingtray.git git clone -c core.symlinks=true https://github.com/Martchus/subdirs.git ``` @@ -311,6 +314,9 @@ Building the testsuite requires CppUnit and Qt 5.8 or higher. cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="/install/prefix" \ + -DBUNDLED_QT_FORK_AWESOME_PATH="$SOURCES/qtforkawesome" \ + -DFORK_AWESOME_FONT_FILE="$SOURCES/forkawesome/fonts/forkawesome-webfont.woff2" \ + -DFORK_AWESOME_ICON_DEFINITIONS="$SOURCES/forkawesome/src/icons/icons.yml" \ $SOURCES/subdirs/syncthingtray ``` * Replace `/install/prefix` with the directory where you want to install. diff --git a/fileitemactionplugin/syncthingdiractions.cpp b/fileitemactionplugin/syncthingdiractions.cpp index 8e44a14..bf5a55b 100644 --- a/fileitemactionplugin/syncthingdiractions.cpp +++ b/fileitemactionplugin/syncthingdiractions.cpp @@ -12,7 +12,7 @@ SyncthingDirActions::SyncthingDirActions(const SyncthingDir &dir, const Syncthin : QObject(parent) , m_dirId(dir.id) { - const auto &icons = !data || !data->isUsingBrightCustomColors() ? fontAwesomeIconsForLightTheme() : fontAwesomeIconsForDarkTheme(); + const auto &icons = !data || !data->isUsingBrightCustomColors() ? forkAwesomeIconsForLightTheme() : forkAwesomeIconsForDarkTheme(); m_infoAction.setSeparator(true); m_infoAction.setIcon(icons.folder); m_globalStatusAction.setIcon(icons.globe); diff --git a/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp b/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp index d00d767..8a908ba 100644 --- a/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp +++ b/fileitemactionplugin/syncthingfileitemactionstaticdata.cpp @@ -105,8 +105,8 @@ void SyncthingFileItemActionStaticData::showAboutDialog() { auto *const aboutDialog = new AboutDialog(nullptr, QStringLiteral(APP_NAME), QStringLiteral(APP_AUTHOR "
Syncthing icons from Syncthing project
Using " - "icons from Font " - "Awesome (see their license)"), + "icons from Fork " + "Awesome (see their license)"), QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); aboutDialog->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); diff --git a/model/CMakeLists.txt b/model/CMakeLists.txt index 36c1f84..f248586 100644 --- a/model/CMakeLists.txt +++ b/model/CMakeLists.txt @@ -47,6 +47,10 @@ use_qt_utilities() find_package(syncthingconnector ${META_APP_VERSION} REQUIRED) use_syncthingconnector(VISIBILITY PUBLIC) +# find qtforkawesome +find_package(qtforkawesome 0.0.1 REQUIRED) +use_qt_fork_awesome(VISIBILITY PUBLIC) + # link also explicitly against the following Qt modules list(APPEND ADDITIONAL_QT_MODULES Network Gui Widgets Svg) diff --git a/model/resources/icons/hicolor/scalable/fa-non-solid/file.svg b/model/resources/icons/hicolor/scalable/fa-non-solid/file.svg deleted file mode 100644 index 9bc1513..0000000 --- a/model/resources/icons/hicolor/scalable/fa-non-solid/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa-non-solid/folder.svg b/model/resources/icons/hicolor/scalable/fa-non-solid/folder.svg deleted file mode 100644 index 7c9d6c4..0000000 --- a/model/resources/icons/hicolor/scalable/fa-non-solid/folder.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa-non-solid/hdd.svg b/model/resources/icons/hicolor/scalable/fa-non-solid/hdd.svg deleted file mode 100644 index dbf616f..0000000 --- a/model/resources/icons/hicolor/scalable/fa-non-solid/hdd.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/certificate.svg b/model/resources/icons/hicolor/scalable/fa/certificate.svg deleted file mode 100644 index c57ab13..0000000 --- a/model/resources/icons/hicolor/scalable/fa/certificate.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/clock.svg b/model/resources/icons/hicolor/scalable/fa/clock.svg deleted file mode 100644 index 6444d5b..0000000 --- a/model/resources/icons/hicolor/scalable/fa/clock.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/cloud-download-alt.svg b/model/resources/icons/hicolor/scalable/fa/cloud-download-alt.svg deleted file mode 100644 index 3cd62ac..0000000 --- a/model/resources/icons/hicolor/scalable/fa/cloud-download-alt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/cloud-upload-alt.svg b/model/resources/icons/hicolor/scalable/fa/cloud-upload-alt.svg deleted file mode 100644 index 8cf98e9..0000000 --- a/model/resources/icons/hicolor/scalable/fa/cloud-upload-alt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/cogs.svg b/model/resources/icons/hicolor/scalable/fa/cogs.svg deleted file mode 100644 index c016886..0000000 --- a/model/resources/icons/hicolor/scalable/fa/cogs.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/exchange-alt.svg b/model/resources/icons/hicolor/scalable/fa/exchange-alt.svg deleted file mode 100644 index b22538a..0000000 --- a/model/resources/icons/hicolor/scalable/fa/exchange-alt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/exclamation-triangle.svg b/model/resources/icons/hicolor/scalable/fa/exclamation-triangle.svg deleted file mode 100644 index 2ab5327..0000000 --- a/model/resources/icons/hicolor/scalable/fa/exclamation-triangle.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/eye.svg b/model/resources/icons/hicolor/scalable/fa/eye.svg deleted file mode 100644 index 477e9ed..0000000 --- a/model/resources/icons/hicolor/scalable/fa/eye.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/file-archive.svg b/model/resources/icons/hicolor/scalable/fa/file-archive.svg deleted file mode 100644 index 7c60e72..0000000 --- a/model/resources/icons/hicolor/scalable/fa/file-archive.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/folder-open.svg b/model/resources/icons/hicolor/scalable/fa/folder-open.svg deleted file mode 100644 index 57dcfa6..0000000 --- a/model/resources/icons/hicolor/scalable/fa/folder-open.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/folder.svg b/model/resources/icons/hicolor/scalable/fa/folder.svg deleted file mode 100644 index c960768..0000000 --- a/model/resources/icons/hicolor/scalable/fa/folder.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/globe.svg b/model/resources/icons/hicolor/scalable/fa/globe.svg deleted file mode 100644 index 93b6178..0000000 --- a/model/resources/icons/hicolor/scalable/fa/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/hashtag.svg b/model/resources/icons/hicolor/scalable/fa/hashtag.svg deleted file mode 100644 index 2a6094f..0000000 --- a/model/resources/icons/hicolor/scalable/fa/hashtag.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/home.svg b/model/resources/icons/hicolor/scalable/fa/home.svg deleted file mode 100644 index 27ee7ab..0000000 --- a/model/resources/icons/hicolor/scalable/fa/home.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/link.svg b/model/resources/icons/hicolor/scalable/fa/link.svg deleted file mode 100644 index 57caa9f..0000000 --- a/model/resources/icons/hicolor/scalable/fa/link.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/network-wired.svg b/model/resources/icons/hicolor/scalable/fa/network-wired.svg deleted file mode 100644 index 1be547c..0000000 --- a/model/resources/icons/hicolor/scalable/fa/network-wired.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/redo.svg b/model/resources/icons/hicolor/scalable/fa/redo.svg deleted file mode 100644 index c536b37..0000000 --- a/model/resources/icons/hicolor/scalable/fa/redo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/share-alt.svg b/model/resources/icons/hicolor/scalable/fa/share-alt.svg deleted file mode 100644 index 2f3151d..0000000 --- a/model/resources/icons/hicolor/scalable/fa/share-alt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/icons/hicolor/scalable/fa/tag.svg b/model/resources/icons/hicolor/scalable/fa/tag.svg deleted file mode 100644 index 6793a2e..0000000 --- a/model/resources/icons/hicolor/scalable/fa/tag.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/model/resources/syncthingmodelicons.qrc b/model/resources/syncthingmodelicons.qrc index 42e1fce..0a6c078 100644 --- a/model/resources/syncthingmodelicons.qrc +++ b/model/resources/syncthingmodelicons.qrc @@ -2,27 +2,5 @@ icons/hicolor/scalable/status/syncthing-default.svg icons/hicolor/scalable/mimetypes/text-x-generic.svg - icons/hicolor/scalable/fa/certificate.svg - icons/hicolor/scalable/fa/clock.svg - icons/hicolor/scalable/fa/cloud-download-alt.svg - icons/hicolor/scalable/fa/cloud-upload-alt.svg - icons/hicolor/scalable/fa/cogs.svg - icons/hicolor/scalable/fa/exchange-alt.svg - icons/hicolor/scalable/fa/exclamation-triangle.svg - icons/hicolor/scalable/fa/eye.svg - icons/hicolor/scalable/fa/file-archive.svg - icons/hicolor/scalable/fa/folder-open.svg - icons/hicolor/scalable/fa/folder.svg - icons/hicolor/scalable/fa/globe.svg - icons/hicolor/scalable/fa/hashtag.svg - icons/hicolor/scalable/fa/home.svg - icons/hicolor/scalable/fa/link.svg - icons/hicolor/scalable/fa/network-wired.svg - icons/hicolor/scalable/fa/redo.svg - icons/hicolor/scalable/fa/share-alt.svg - icons/hicolor/scalable/fa/tag.svg - icons/hicolor/scalable/fa-non-solid/file.svg - icons/hicolor/scalable/fa-non-solid/folder.svg - icons/hicolor/scalable/fa-non-solid/hdd.svg diff --git a/model/syncthingdevicemodel.cpp b/model/syncthingdevicemodel.cpp index 4236575..3a7cd90 100644 --- a/model/syncthingdevicemodel.cpp +++ b/model/syncthingdevicemodel.cpp @@ -169,7 +169,7 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const case DeviceDetailIcon: if (index.column() == 0) { // attribute icons - const auto &icons = m_brightColors ? fontAwesomeIconsForDarkTheme() : fontAwesomeIconsForLightTheme(); + const auto &icons = m_brightColors ? forkAwesomeIconsForDarkTheme() : forkAwesomeIconsForLightTheme(); switch (index.row()) { case 0: return icons.hashtag; diff --git a/model/syncthingdirectorymodel.cpp b/model/syncthingdirectorymodel.cpp index 51de6c3..cb86bf6 100644 --- a/model/syncthingdirectorymodel.cpp +++ b/model/syncthingdirectorymodel.cpp @@ -191,7 +191,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const case DirectoryDetailIcon: if (index.column() == 0) { // attribute icons - const auto &icons = m_brightColors ? fontAwesomeIconsForDarkTheme() : fontAwesomeIconsForLightTheme(); + const auto &icons = m_brightColors ? forkAwesomeIconsForDarkTheme() : forkAwesomeIconsForLightTheme(); switch (row) { case 0: return icons.hashtag; diff --git a/model/syncthingicons.cpp b/model/syncthingicons.cpp index e555c74..4cf17fe 100644 --- a/model/syncthingicons.cpp +++ b/model/syncthingicons.cpp @@ -165,25 +165,6 @@ QPixmap renderSvgImage(const QByteArray &contents, const QSize &size, int margin return Detail::renderSvgImage(contents, size, margin); } -/*! - * \brief Returns the font awesome icon with the specified \a iconName and \a color. - */ -QByteArray loadFontAwesomeIcon(const QString &iconName, const QColor &color, bool solid) -{ - auto result = QByteArray(); - auto icon = QFile(QString((solid ? QStringLiteral(":/icons/hicolor/scalable/fa/") : QStringLiteral(":/icons/hicolor/scalable/fa-non-solid/")) - % iconName % QStringLiteral(".svg"))); - if (!icon.open(QFile::ReadOnly)) { - return result; - } - result = icon.readAll(); - const auto pathBegin = result.indexOf(" 0) { - result.insert(pathBegin + 6, (QStringLiteral("fill=\"") % color.name(QColor::HexRgb) % QStringLiteral("\" ")).toUtf8()); - } - return result; -} - StatusIconSettings::StatusIconSettings() : defaultColor({ QStringLiteral("#26B6DB"), QStringLiteral("#0882C8"), QStringLiteral("#FFFFFF") }) , errorColor({ QStringLiteral("#DB3C26"), QStringLiteral("#C80828"), QStringLiteral("#FFFFFF") }) @@ -286,34 +267,34 @@ StatusIcons::StatusIcons(const StatusIconSettings &settings) { } -FontAwesomeIcons::FontAwesomeIcons(const QColor &color, const QSize &size, int margin) - : hashtag(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("hashtag"), color), size, margin)) - , folderOpen(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("folder-open"), color), size, margin)) - , globe(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("globe"), color), size, margin)) - , home(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("home"), color), size, margin)) - , shareAlt(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("share-alt"), color), size, margin)) - , refresh(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("redo"), color), size, margin)) - , clock(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("clock"), color), size, margin)) - , exchangeAlt(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("exchange-alt"), color), size, margin)) - , exclamationTriangle(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("exclamation-triangle"), color), size, margin)) - , cogs(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("cogs"), color), size, margin)) - , link(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("link"), color), size, margin)) - , eye(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("eye"), color), size, margin)) - , fileArchive(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("file-archive"), color), size, margin)) - , folder(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("folder"), color), size, margin)) - , certificate(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("certificate"), color), size, margin)) - , networkWired(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("network-wired"), color), size, margin)) - , cloudDownloadAlt(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("cloud-download-alt"), color), size, margin)) - , cloudUploadAlt(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("cloud-upload-alt"), color), size, margin)) - , tag(renderSvgImage(loadFontAwesomeIcon(QStringLiteral("tag"), color), size, margin)) +ForkAwesomeIcons::ForkAwesomeIcons(QtForkAwesome::Renderer &renderer, const QColor &color, const QSize &size) + : hashtag(renderer.pixmap(QtForkAwesome::Icon::Hashtag, size, color)) + , folderOpen(renderer.pixmap(QtForkAwesome::Icon::FolderOpen, size, color)) + , globe(renderer.pixmap(QtForkAwesome::Icon::Globe, size, color)) + , home(renderer.pixmap(QtForkAwesome::Icon::Home, size, color)) + , shareAlt(renderer.pixmap(QtForkAwesome::Icon::ShareAlt, size, color)) + , refresh(renderer.pixmap(QtForkAwesome::Icon::Refresh, size, color)) + , clock(renderer.pixmap(QtForkAwesome::Icon::ClockO, size, color)) + , exchangeAlt(renderer.pixmap(QtForkAwesome::Icon::Exchange, size, color)) + , exclamationTriangle(renderer.pixmap(QtForkAwesome::Icon::ExclamationTriangle, size, color)) + , cogs(renderer.pixmap(QtForkAwesome::Icon::Cogs, size, color)) + , link(renderer.pixmap(QtForkAwesome::Icon::Link, size, color)) + , eye(renderer.pixmap(QtForkAwesome::Icon::Eye, size, color)) + , fileArchive(renderer.pixmap(QtForkAwesome::Icon::FileArchiveO, size, color)) + , folder(renderer.pixmap(QtForkAwesome::Icon::Folder, size, color)) + , certificate(renderer.pixmap(QtForkAwesome::Icon::Certificate, size, color)) + , networkWired(renderer.pixmap(QtForkAwesome::Icon::Sitemap, size, color)) + , cloudDownloadAlt(renderer.pixmap(QtForkAwesome::Icon::CloudDownload, size, color)) + , cloudUploadAlt(renderer.pixmap(QtForkAwesome::Icon::CloudUpload, size, color)) + , tag(renderer.pixmap(QtForkAwesome::Icon::Tag, size, color)) { } IconManager::IconManager() : m_statusIcons() , m_trayIcons(m_statusIcons) - , m_fontAwesomeIconsForLightTheme(QColor(10, 10, 10), QSize(64, 64), 8) - , m_fontAwesomeIconsForDarkTheme(Qt::white, QSize(64, 64), 8) + , m_forkAwesomeIconsForLightTheme(m_forkAwesomeRenderer, QColor(10, 10, 10), QSize(64, 64)) + , m_fontAwesomeIconsForDarkTheme(m_forkAwesomeRenderer, Qt::white, QSize(64, 64)) { } diff --git a/model/syncthingicons.h b/model/syncthingicons.h index 3614663..9822424 100644 --- a/model/syncthingicons.h +++ b/model/syncthingicons.h @@ -3,6 +3,8 @@ #include "./global.h" +#include + #include #include @@ -58,7 +60,6 @@ LIB_SYNCTHING_MODEL_EXPORT QByteArray makeSyncthingIcon( StatusEmblem statusEmblem = StatusEmblem::None); LIB_SYNCTHING_MODEL_EXPORT QPixmap renderSvgImage(const QString &path, const QSize &size = QSize(32, 32), int margin = 0); LIB_SYNCTHING_MODEL_EXPORT QPixmap renderSvgImage(const QByteArray &contents, const QSize &size = QSize(32, 32), int margin = 0); -LIB_SYNCTHING_MODEL_EXPORT QByteArray loadFontAwesomeIcon(const QString &iconName, const QColor &color, bool solid = true); struct LIB_SYNCTHING_MODEL_EXPORT StatusIconSettings { struct DarkTheme { @@ -115,8 +116,8 @@ inline StatusIcons::StatusIcons() { } -struct LIB_SYNCTHING_MODEL_EXPORT FontAwesomeIcons { - FontAwesomeIcons(const QColor &color, const QSize &size, int margin); +struct LIB_SYNCTHING_MODEL_EXPORT ForkAwesomeIcons { + ForkAwesomeIcons(QtForkAwesome::Renderer &renderer, const QColor &color, const QSize &size); QIcon hashtag; QIcon folderOpen; QIcon globe; @@ -146,8 +147,9 @@ public: void applySettings(const StatusIconSettings *statusIconSettings = nullptr, const StatusIconSettings *trayIconSettings = nullptr); const StatusIcons &statusIcons() const; const StatusIcons &trayIcons() const; - const FontAwesomeIcons &fontAwesomeIconsForLightTheme() const; - const FontAwesomeIcons &fontAwesomeIconsForDarkTheme() const; + QtForkAwesome::Renderer &forkAwesomeRenderer(); + const ForkAwesomeIcons &forkAwesomeIconsForLightTheme() const; + const ForkAwesomeIcons &forkAwesomeIconsForDarkTheme() const; Q_SIGNALS: void statusIconsChanged(const StatusIcons &newStatusIcons, const StatusIcons &newTrayIcons); @@ -157,8 +159,9 @@ private: StatusIcons m_statusIcons; StatusIcons m_trayIcons; - FontAwesomeIcons m_fontAwesomeIconsForLightTheme; - FontAwesomeIcons m_fontAwesomeIconsForDarkTheme; + QtForkAwesome::Renderer m_forkAwesomeRenderer; + ForkAwesomeIcons m_forkAwesomeIconsForLightTheme; + ForkAwesomeIcons m_fontAwesomeIconsForDarkTheme; }; inline void IconManager::applySettings(const StatusIconSettings *statusIconSettings, const StatusIconSettings *trayIconSettings) @@ -186,12 +189,17 @@ inline const StatusIcons &IconManager::trayIcons() const return m_trayIcons; } -inline const FontAwesomeIcons &IconManager::fontAwesomeIconsForLightTheme() const +inline QtForkAwesome::Renderer &IconManager::forkAwesomeRenderer() { - return m_fontAwesomeIconsForLightTheme; + return m_forkAwesomeRenderer; } -inline const FontAwesomeIcons &IconManager::fontAwesomeIconsForDarkTheme() const +inline const ForkAwesomeIcons &IconManager::forkAwesomeIconsForLightTheme() const +{ + return m_forkAwesomeIconsForLightTheme; +} + +inline const ForkAwesomeIcons &IconManager::forkAwesomeIconsForDarkTheme() const { return m_fontAwesomeIconsForDarkTheme; } @@ -206,14 +214,14 @@ inline const StatusIcons &trayIcons() return IconManager::instance().trayIcons(); } -inline const FontAwesomeIcons &fontAwesomeIconsForLightTheme() +inline const ForkAwesomeIcons &forkAwesomeIconsForLightTheme() { - return IconManager::instance().fontAwesomeIconsForLightTheme(); + return IconManager::instance().forkAwesomeIconsForLightTheme(); } -inline const FontAwesomeIcons &fontAwesomeIconsForDarkTheme() +inline const ForkAwesomeIcons &forkAwesomeIconsForDarkTheme() { - return IconManager::instance().fontAwesomeIconsForDarkTheme(); + return IconManager::instance().forkAwesomeIconsForDarkTheme(); } } // namespace Data diff --git a/model/syncthingrecentchangesmodel.cpp b/model/syncthingrecentchangesmodel.cpp index 9692739..b75c58c 100644 --- a/model/syncthingrecentchangesmodel.cpp +++ b/model/syncthingrecentchangesmodel.cpp @@ -111,9 +111,9 @@ QVariant SyncthingRecentChangesModel::data(const QModelIndex &index, int role) c switch (index.column()) { case 0: if (change.fileChange.local) { - return m_brightColors ? fontAwesomeIconsForDarkTheme().home : fontAwesomeIconsForLightTheme().home; + return m_brightColors ? forkAwesomeIconsForDarkTheme().home : forkAwesomeIconsForLightTheme().home; } else { - return m_brightColors ? fontAwesomeIconsForDarkTheme().globe : fontAwesomeIconsForLightTheme().globe; + return m_brightColors ? forkAwesomeIconsForDarkTheme().globe : forkAwesomeIconsForLightTheme().globe; } } break; diff --git a/plasmoid/lib/syncthingapplet.cpp b/plasmoid/lib/syncthingapplet.cpp index 3c4a7de..a60b84c 100644 --- a/plasmoid/lib/syncthingapplet.cpp +++ b/plasmoid/lib/syncthingapplet.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -261,9 +262,20 @@ void SyncthingApplet::updateStatusIconAndTooltip() emit connectionStatusChanged(); } -QIcon SyncthingApplet::loadFontAwesomeIcon(const QString &name, bool solid) const +QIcon SyncthingApplet::loadForkAwesomeIcon(const QString &name) const { - return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, QGuiApplication::palette().color(QPalette::WindowText), solid), QSize(32, 32), 8); + using namespace QtForkAwesome; + static const auto mapping = QMap({ + { QStringLiteral("cloud-download"), Icon::CloudDownload }, + { QStringLiteral("cloud-upload"), Icon::CloudUpload }, + { QStringLiteral("file"), Icon::FileO }, + { QStringLiteral("folder"), Icon::FolderO }, + { QStringLiteral("hdd"), Icon::HddO }, + }); + const auto icon = mapping.find(name); + return icon != mapping.cend() + ? QIcon(IconManager::instance().forkAwesomeRenderer().pixmap(*icon, QSize(32, 32), QGuiApplication::palette().color(QPalette::WindowText))) + : QIcon(); } QString SyncthingApplet::formatFileSize(quint64 fileSizeInByte) const @@ -329,8 +341,8 @@ void SyncthingApplet::showAboutDialog() if (!m_aboutDlg) { m_aboutDlg = new AboutDialog(nullptr, QStringLiteral(APP_NAME), QStringLiteral("

Developed by " APP_AUTHOR "
Syncthing icons from Syncthing project
Using " - "icons from Font " - "Awesome (see their license)

"), + "icons from Fork " + "Awesome (see their license)

"), QStringLiteral(APP_VERSION), CppUtilities::applicationInfo.dependencyVersions, QStringLiteral(APP_URL), QStringLiteral(APP_DESCRIPTION), renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); m_aboutDlg->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); diff --git a/plasmoid/lib/syncthingapplet.h b/plasmoid/lib/syncthingapplet.h index 5e1b8f8..c4c6cac 100644 --- a/plasmoid/lib/syncthingapplet.h +++ b/plasmoid/lib/syncthingapplet.h @@ -119,7 +119,7 @@ public Q_SLOTS: void showDirectoryErrors(unsigned int directoryIndex); void copyToClipboard(const QString &text); void updateStatusIconAndTooltip(); - QIcon loadFontAwesomeIcon(const QString &name, bool solid = true) const; + QIcon loadForkAwesomeIcon(const QString &name) const; QString formatFileSize(quint64 fileSizeInByte) const; Q_SIGNALS: diff --git a/plasmoid/package/contents/ui/FullRepresentation.qml b/plasmoid/package/contents/ui/FullRepresentation.qml index a3d2902..d54f400 100644 --- a/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/plasmoid/package/contents/ui/FullRepresentation.qml @@ -479,8 +479,8 @@ ColumnLayout { IconLabel { Layout.leftMargin: 10 - iconSource: plasmoid.nativeInterface.loadFontAwesomeIcon( - "cloud-download-alt") + iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon( + "cloud-download") iconOpacity: plasmoid.nativeInterface.hasIncomingTraffic ? 1.0 : 0.5 text: plasmoid.nativeInterface.incomingTraffic tooltip: qsTr("Global incoming traffic") @@ -499,8 +499,8 @@ ColumnLayout { IconLabel { Layout.leftMargin: 10 - iconSource: plasmoid.nativeInterface.loadFontAwesomeIcon( - "cloud-upload-alt") + iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon( + "cloud-upload") iconOpacity: plasmoid.nativeInterface.hasOutgoingTraffic ? 1.0 : 0.5 text: plasmoid.nativeInterface.outgoingTraffic tooltip: qsTr("Global outgoing traffic") diff --git a/plasmoid/package/contents/ui/StatisticsView.qml b/plasmoid/package/contents/ui/StatisticsView.qml index 8dc3761..386c975 100644 --- a/plasmoid/package/contents/ui/StatisticsView.qml +++ b/plasmoid/package/contents/ui/StatisticsView.qml @@ -7,18 +7,17 @@ RowLayout { property string context: "?" IconLabel { - iconSource: plasmoid.nativeInterface.loadFontAwesomeIcon("file", false) + iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("file") text: statistics.files !== undefined ? statistics.files : "?" tooltip: context + qsTr(" files") } IconLabel { - iconSource: plasmoid.nativeInterface.loadFontAwesomeIcon("folder", - false) + iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("folder") text: statistics.dirs !== undefined ? statistics.dirs : "?" tooltip: context + qsTr(" directories") } IconLabel { - iconSource: plasmoid.nativeInterface.loadFontAwesomeIcon("hdd", false) + iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("hdd") text: statistics.bytes !== undefined ? plasmoid.nativeInterface.formatFileSize( statistics.bytes) : "?" tooltip: context + qsTr(" size") diff --git a/tray/gui/traywidget.cpp b/tray/gui/traywidget.cpp index 6cc7d49..3ecef1b 100644 --- a/tray/gui/traywidget.cpp +++ b/tray/gui/traywidget.cpp @@ -256,8 +256,8 @@ void TrayWidget::showAboutDialog() QStringLiteral( "

Developed by " APP_AUTHOR "
Fallback icons from KDE/Breeze project
Syncthing icons from Syncthing project
Using " - "icons from Font " - "Awesome (see their license)

"), + "icons from Fork " + "Awesome (see their license))

"), QString(), {}, QStringLiteral(APP_URL), QString(), renderSvgImage(makeSyncthingIcon(), QSize(128, 128)).toImage()); s_aboutDlg->setWindowTitle(tr("About") + QStringLiteral(" - " APP_NAME)); s_aboutDlg->setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg"))); @@ -630,18 +630,19 @@ void TrayWidget::updateTraffic() const auto colorActive = palette.color(QPalette::WindowText); const auto colorInactive = QColor((colorActive.red() + colorBackground.red()) / 2, (colorActive.green() + colorBackground.green()) / 2, (colorActive.blue() + colorBackground.blue()) / 2); - const auto renderIcon - = [&size](const QString &name, const QColor &color) { return Data::renderSvgImage(Data::loadFontAwesomeIcon(name, color), size); }; + const auto renderIcon = [&size](QtForkAwesome::Icon icon, const QColor &color) { + return IconManager::instance().forkAwesomeRenderer().pixmap(icon, size, color); + }; struct { QPixmap uploadIconActive; QPixmap uploadIconInactive; QPixmap downloadIconActive; QPixmap downloadIconInactive; } icons; - icons.uploadIconActive = renderIcon(QStringLiteral("cloud-upload-alt"), colorActive); - icons.uploadIconInactive = renderIcon(QStringLiteral("cloud-upload-alt"), colorInactive); - icons.downloadIconActive = renderIcon(QStringLiteral("cloud-download-alt"), colorActive); - icons.downloadIconInactive = renderIcon(QStringLiteral("cloud-download-alt"), colorInactive); + icons.uploadIconActive = renderIcon(QtForkAwesome::Icon::CloudUpload, colorActive); + icons.uploadIconInactive = renderIcon(QtForkAwesome::Icon::CloudUpload, colorInactive); + icons.downloadIconActive = renderIcon(QtForkAwesome::Icon::CloudDownload, colorActive); + icons.downloadIconInactive = renderIcon(QtForkAwesome::Icon::CloudDownload, colorInactive); return icons; }();