Use ForkAwesome consistently in Plasmoid as well

This commit is contained in:
Martchus 2021-10-15 22:18:30 +02:00
parent 7b6121cb05
commit 0651323da4
14 changed files with 110 additions and 59 deletions

View File

@ -48,6 +48,7 @@ else()
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${BUNDLED_QT_FORK_AWESOME_PATH}" OR IS_DIRECTORY "${BUNDLED_QT_FORK_AWESOME_PATH}")
add_subdirectory("${BUNDLED_QT_FORK_AWESOME_PATH}" qtforkawesome)
set(${NAMESPACE_PREFIX}qtforkawesome${CONFIGURATION_PACKAGE_SUFFIX_QTFORKAWESOME}_DIR "${CMAKE_CURRENT_BINARY_DIR}/qtforkawesome/qtforkawesome")
set(${NAMESPACE_PREFIX}qtquickforkawesome${CONFIGURATION_PACKAGE_SUFFIX_QTFORKAWESOME}_DIR "${CMAKE_CURRENT_BINARY_DIR}/qtforkawesome/qtquickforkawesome")
set(${NAMESPACE_PREFIX}qtforkawesomeiconengine${CONFIGURATION_PACKAGE_SUFFIX_QTFORKAWESOME}_DIR "${CMAKE_CURRENT_BINARY_DIR}/qtforkawesome/iconengineplugin")
else()
message(FATAL_ERROR "Specified directory for qtforkawesome sources \"${BUNDLED_QT_FORK_AWESOME_PATH}\" does not exist.")

View File

@ -22,6 +22,7 @@ set(PLASMOID_FILES
package/contents/ui/DetailItem.qml
package/contents/ui/ToolTipTrigger.qml
package/contents/ui/ToolTipView.qml
package/contents/ui/ToolButton.qml
package/contents/ui/TinyButton.qml
package/contents/ui/IconLabel.qml
package/contents/ui/StatisticsView.qml

View File

@ -11,6 +11,10 @@ set(TS_FILES ../translations/${META_PROJECT_NAME}_de_DE.ts ../translations/${MET
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.2.0 REQUIRED)
use_qt_utilities()
# find qtforkawesomequickimageprovider
find_package(${PACKAGE_NAMESPACE_PREFIX}qtquickforkawesome${CONFIGURATION_PACKAGE_SUFFIX_QTFORKAWESOME} 0.0.1 REQUIRED)
use_qt_quick_fork_awesome()
# check whether qtutilities supports DBus notifications
get_target_property(QT_UTILITIES_COMPILE_DEFINITIONS ${QT_UTILITIES_LIB} INTERFACE_COMPILE_DEFINITIONS)
list(FIND QT_UTILITIES_COMPILE_DEFINITIONS QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS QT_UTILITIES_SUPPORT_DBUS_NOTIFICATIONS)

View File

@ -20,6 +20,7 @@
#include "resources/qtconfig.h"
#include <qtforkawesome/utils.h>
#include <qtquickforkawesome/imageprovider.h>
#include <qtutilities/misc/desktoputils.h>
#include <qtutilities/misc/dialogutils.h>
@ -39,8 +40,6 @@
#include <QQmlEngine>
#include <QStringBuilder>
#include <iostream>
using namespace std;
using namespace Data;
using namespace Plasma;
@ -135,6 +134,15 @@ void SyncthingApplet::init()
m_initialized = true;
}
void SyncthingApplet::initEngine(QObject *object)
{
auto engine = qmlEngine(object);
if (!engine) {
return;
}
engine->addImageProvider(QStringLiteral("fa"), new QtForkAwesome::QuickImageProvider(IconManager::instance().forkAwesomeRenderer()));
}
QIcon SyncthingApplet::statusIcon() const
{
return m_statusInfo.statusIcon();

View File

@ -111,6 +111,7 @@ public:
public Q_SLOTS:
void init() override;
void initEngine(QObject *object);
void showSettingsDlg();
void showWebUI();
void showLog();

View File

@ -60,7 +60,7 @@ Item {
}
TinyButton {
id: resumePauseButton
icon.name: paused ? "media-playback-start" : "media-playback-pause"
icon.source: paused ? "image://fa/play" : "image://fa/pause"
tooltip: paused ? qsTr("Resume") : qsTr("Pause")
enabled: !isOwnDevice
onClicked: {

View File

@ -67,7 +67,7 @@ ColumnLayout {
}
TinyButton {
id: errorsButton
icon.name: "data-error"
icon.source: "image://fa/exclamation-triangle"
tooltip: qsTr("Show errors")
visible: pullErrorCount > 0
onClicked: {
@ -78,7 +78,7 @@ ColumnLayout {
}
TinyButton {
id: rescanButton
icon.name: "view-refresh"
icon.source: "image://fa/refresh"
tooltip: qsTr("Rescan")
enabled: !paused
onClicked: plasmoid.nativeInterface.connection.rescan(
@ -86,7 +86,7 @@ ColumnLayout {
}
TinyButton {
id: resumePauseButton
icon.name: paused ? "media-playback-start" : "media-playback-pause"
icon.source: paused ? "image://fa/play" : "image://fa/pause"
tooltip: paused ? qsTr("Resume") : qsTr("Pause")
onClicked: {
paused ? plasmoid.nativeInterface.connection.resumeDirectories(
@ -96,7 +96,7 @@ ColumnLayout {
}
TinyButton {
id: openButton
icon.name: "folder"
icon.source: "image://fa/folder"
tooltip: qsTr("Open in file browser")
onClicked: {
Qt.openUrlExternally(path)

View File

@ -63,7 +63,7 @@ Item {
}
TinyButton {
id: openButton
icon.name: "folder"
icon.source: "image://fa/folder"
tooltip: qsTr("Open in file browser")
enabled: path !== undefined
onClicked: {
@ -119,7 +119,7 @@ Item {
}
}
TinyButton {
icon.name: "folder"
icon.source: "image://fa/folder"
tooltip: qsTr("Open in file browser")
onClicked: {
Qt.openUrlExternally(path + "/..")

View File

@ -182,7 +182,7 @@ ColumnLayout {
id: toolBar
Layout.fillWidth: true
PlasmaComponents3.ToolButton {
ToolButton {
id: connectButton
states: [
State {
@ -190,7 +190,7 @@ ColumnLayout {
PropertyChanges {
target: connectButton
text: qsTr("Connect")
icon.name: "view-refresh"
icon.source: "image://fa/refresh"
visible: true
}
},
@ -206,7 +206,7 @@ ColumnLayout {
PropertyChanges {
target: connectButton
text: qsTr("Resume")
icon.name: "media-playback-start"
icon.source: "image://fa/play"
visible: true
}
},
@ -215,7 +215,7 @@ ColumnLayout {
PropertyChanges {
target: connectButton
text: qsTr("Pause")
icon.name: "media-playback-pause"
icon.source: "image://fa/pause"
visible: true
}
}
@ -256,7 +256,7 @@ ColumnLayout {
onActivated: connectButton.clicked()
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: startStopButton
states: [
State {
@ -265,7 +265,7 @@ ColumnLayout {
target: startStopButton
visible: true
text: qsTr("Stop")
icon.name: "process-stop"
icon.source: "image://fa/stop"
}
PropertyChanges {
target: startStopToolTip
@ -279,7 +279,7 @@ ColumnLayout {
target: startStopButton
visible: true
text: qsTr("Start")
icon.name: "system-run"
icon.source: "image://fa/play"
}
PropertyChanges {
target: startStopToolTip
@ -345,8 +345,8 @@ ColumnLayout {
}
}
}
PlasmaComponents3.ToolButton {
icon.name: "help-about"
ToolButton {
icon.source: "image://fa/info"
PlasmaComponents3.ToolTip {
text: qsTr("About Syncthing Tray")
}
@ -355,15 +355,9 @@ ColumnLayout {
plasmoid.expanded = false
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: showOwnIdButton
// use PlasmaCore.IconItem for the icon because I wouldn't know how to show the QIcon otherwise
contentItem: PlasmaCore.IconItem {
source: plasmoid.nativeInterface.loadForkAwesomeIcon("qrcode", 64)
}
// set preferred size so the tool button is displayed consistently with the previous one despite using PlasmaCore.IconItem
Layout.preferredWidth: settingsButton.width
Layout.preferredHeight: settingsButton.height
icon.source: "image://fa/qrcode"
onClicked: {
plasmoid.nativeInterface.showOwnDeviceId()
plasmoid.expanded = false
@ -376,9 +370,9 @@ ColumnLayout {
onActivated: showOwnIdButton.clicked()
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: showLogButton
icon.name: "text-x-generic"
icon.source: "image://fa/file-code-o"
onClicked: {
plasmoid.nativeInterface.showLog()
plasmoid.expanded = false
@ -391,9 +385,9 @@ ColumnLayout {
onActivated: showLogButton.clicked()
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: rescanAllDirsButton
icon.name: "folder-sync"
icon.source: "image://fa/search"
onClicked: plasmoid.nativeInterface.connection.rescanAllDirs()
PlasmaComponents3.ToolTip {
text: qsTr("Rescan all directories")
@ -403,9 +397,9 @@ ColumnLayout {
onActivated: rescanAllDirsButton.clicked()
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: settingsButton
icon.name: "preferences-other"
icon.source: "image://fa/cogs"
onClicked: {
plasmoid.nativeInterface.showSettingsDlg()
plasmoid.expanded = false
@ -418,15 +412,9 @@ ColumnLayout {
onActivated: settingsButton.clicked()
}
}
PlasmaComponents3.ToolButton {
ToolButton {
id: webUIButton
// use PlasmaCore.IconItem for the icon because I wouldn't know how to show the QIcon otherwise
contentItem: PlasmaCore.IconItem {
source: plasmoid.nativeInterface.loadForkAwesomeIcon("syncthing")
}
// set preferred size so the tool button is displayed consistently with the previous one despite using PlasmaCore.IconItem
Layout.preferredWidth: settingsButton.width
Layout.preferredHeight: settingsButton.height
icon.source: "image://fa/syncthing"
onClicked: {
plasmoid.nativeInterface.showWebUI()
plasmoid.expanded = false
@ -472,10 +460,12 @@ ColumnLayout {
rowSpacing: 1
columnSpacing: 4
PlasmaCore.IconItem {
Image {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
source: "globe"
height: 16
fillMode: Image.PreserveAspectFit
source: "image://fa/globe"
}
StatisticsView {
Layout.leftMargin: 4
@ -485,17 +475,18 @@ ColumnLayout {
IconLabel {
Layout.leftMargin: 10
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon(
"cloud-download")
iconSource: "image://fa/cloud-download"
iconOpacity: plasmoid.nativeInterface.hasIncomingTraffic ? 1.0 : 0.5
text: plasmoid.nativeInterface.incomingTraffic
tooltip: qsTr("Global incoming traffic")
}
PlasmaCore.IconItem {
Image {
Layout.preferredWidth: 16
Layout.preferredHeight: 16
source: "user-home-symbolic"
height: 16
fillMode: Image.PreserveAspectFit
source: "image://fa/home"
}
StatisticsView {
Layout.leftMargin: 4
@ -505,8 +496,7 @@ ColumnLayout {
IconLabel {
Layout.leftMargin: 10
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon(
"cloud-upload")
iconSource: "image://fa/cloud-upload"
iconOpacity: plasmoid.nativeInterface.hasOutgoingTraffic ? 1.0 : 0.5
text: plasmoid.nativeInterface.outgoingTraffic
tooltip: qsTr("Global outgoing traffic")
@ -540,22 +530,22 @@ ColumnLayout {
PlasmaComponents.TabButton {
id: dirsTabButton
iconSource: "folder-symbolic"
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("folder")
tab: dirsPage
}
PlasmaComponents.TabButton {
id: devsTabButton
iconSource: "network-server-symbolic"
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("sitemap")
tab: devicesPage
}
PlasmaComponents.TabButton {
id: downloadsTabButton
iconSource: "folder-download-symbolic"
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("download")
tab: downloadsPage
}
PlasmaComponents.TabButton {
id: recentChangesTabButton
iconSource: "document-open-recent-symbolic"
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("history")
tab: recentChangesPage
}
}

View File

@ -16,11 +16,12 @@ Item {
RowLayout {
id: layout
PlasmaCore.IconItem {
Image {
id: iconItem
Layout.preferredWidth: 16
Layout.preferredHeight: 16
opacity: 0.7
height: 16
fillMode: Image.PreserveAspectFit
}
PlasmaComponents3.Label {
id: label

View File

@ -7,17 +7,17 @@ RowLayout {
property string context: "?"
IconLabel {
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("file-o")
iconSource: "image://fa/file-o"
text: statistics.files !== undefined ? statistics.files : "?"
tooltip: context + qsTr(" files")
}
IconLabel {
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("folder-o")
iconSource: "image://fa/folder-o"
text: statistics.dirs !== undefined ? statistics.dirs : "?"
tooltip: context + qsTr(" directories")
}
IconLabel {
iconSource: plasmoid.nativeInterface.loadForkAwesomeIcon("hdd-o")
iconSource: "image://fa/hdd-o"
text: statistics.bytes !== undefined ? plasmoid.nativeInterface.formatFileSize(
statistics.bytes) : "?"
tooltip: context + qsTr(" size")

View File

@ -1,10 +1,22 @@
import QtQuick 2.8
import QtQuick.Layouts 1.1
import org.kde.plasma.components 3.0 as PlasmaComponents3
PlasmaComponents3.ToolButton {
id: root
property alias tooltip: tooltip.text
icon.width: units.iconSizes.small
icon.height: units.iconSizes.small
Layout.fillHeight: true
Layout.preferredWidth: units.iconSizes.smallMedium
Layout.preferredHeight: units.iconSizes.smallMedium
PlasmaComponents3.ToolTip {
id: tooltip
}
contentItem: Image {
source: root.icon.source
height: parent.height
fillMode: Image.PreserveAspectFit
}
}

View File

@ -0,0 +1,32 @@
import QtQuick 2.8
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents3
PlasmaComponents3.ToolButton {
id: root
Layout.fillHeight: true
Layout.preferredHeight: units.iconSizes.smallMedium
contentItem: Grid {
columns: 2
columnSpacing: label.visible ? units.smallSpacing : 0
verticalItemAlignment: Grid.AlignVCenter
PlasmaCore.ColorScope.inherit: true
Image {
source: root.icon.source
height: parent.height
fillMode: Image.PreserveAspectFit
}
PlasmaComponents3.Label {
id: label
visible: text.length > 0
text: root.text
font: root.parent.font
color: PlasmaCore.ColorScope.textColor
elide: Text.ElideRight
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}

View File

@ -62,6 +62,7 @@ Item {
}
Component.onCompleted: {
plasmoid.nativeInterface.initEngine(this)
plasmoid.removeAction("configure")
plasmoid.setAction(
"showWebUI", qsTr("Open Syncthing"),