Skip to content

Commit

Permalink
Add clipboard copy buttons after advertisement & characteristic data
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Oct 13, 2024
1 parent dd51f7e commit 7050754
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
30 changes: 30 additions & 0 deletions qml/components/AdvertisementDataWidgetAdvanced.qml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Rectangle {
Flow {
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
spacing: 0

Repeater {
model: packet.advDataHex_list
Expand All @@ -223,6 +224,20 @@ Rectangle {
}
}
}

Item { width: 4; height: 4; } // spacer

SquareButtonSunken {
width: 26; height: 26;

tooltipText: qsTr("copy")
tooltipPosition: "right"
source: "qrc:/assets/icons/material-symbols/content_copy.svg"

onClicked: {
utilsClipboard.setText(packet.advDataHex)
}
}
}
}

Expand All @@ -249,6 +264,7 @@ Rectangle {
Flow {
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
spacing: 0

Repeater {
model: packet.advDataAscii_list
Expand All @@ -274,6 +290,20 @@ Rectangle {
}
}
}

Item { width: 4; height: 4; } // spacer

SquareButtonSunken {
width: 26; height: 26;

tooltipText: qsTr("copy")
tooltipPosition: "right"
source: "qrc:/assets/icons/material-symbols/content_copy.svg"

onClicked: {
utilsClipboard.setText(packet.advDataAscii)
}
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions qml/components/BleCharacteristicWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ Rectangle {
}
}
}

Item { width: 4; height: 4; } // spacer

SquareButtonSunken {
width: 26; height: 26;

tooltipText: qsTr("copy")
tooltipPosition: "right"
source: "qrc:/assets/icons/material-symbols/content_copy.svg"

onClicked: {
utilsClipboard.setText(modelData.valueHex)
}
}
}
}

Expand Down Expand Up @@ -269,6 +283,20 @@ Rectangle {
}
}
}

Item { width: 4; height: 4; } // spacer

SquareButtonSunken {
width: 26; height: 26;

tooltipText: qsTr("copy")
tooltipPosition: "right"
source: "qrc:/assets/icons/material-symbols/content_copy.svg"

onClicked: {
utilsClipboard.setText(modelData.valueAscii)
}
}
}
}
/*
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "utils_screen.h"
#include "utils_sysinfo.h"
#include "utils_language.h"
#include "utils_clipboard.h"
#if defined(Q_OS_MACOS)
#include "utils_os_macos_dock.h"
#endif
Expand Down Expand Up @@ -104,7 +105,8 @@ int main(int argc, char *argv[])
UtilsScreen *utilsScreen = UtilsScreen::getInstance();
UtilsSysInfo *utilsSysInfo = UtilsSysInfo::getInstance();
UtilsLanguage *utilsLanguage = UtilsLanguage::getInstance();
if (!utilsScreen || !utilsApp || !utilsLanguage)
UtilsClipboard *utilsClipboard = new UtilsClipboard();
if (!utilsScreen || !utilsApp|| !utilsLanguage || !utilsClipboard)
{
qWarning() << "Cannot init toolBLEx utils!";
return EXIT_FAILURE;
Expand Down Expand Up @@ -132,6 +134,7 @@ int main(int argc, char *argv[])
engine_context->setContextProperty("utilsScreen", utilsScreen);
engine_context->setContextProperty("utilsSysInfo", utilsSysInfo);
engine_context->setContextProperty("utilsLanguage", utilsLanguage);
engine_context->setContextProperty("utilsClipboard", utilsClipboard);

// Load the main view
engine.load(QUrl(QStringLiteral("qrc:/qml/DesktopApplication.qml")));
Expand Down

0 comments on commit 7050754

Please sign in to comment.