diff options
-rw-r--r-- | mobile-widgets/qml/About.qml | 9 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 12 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 | ||||
-rw-r--r-- | qt-models/messagehandlermodel.cpp | 9 | ||||
-rw-r--r-- | qt-models/messagehandlermodel.h | 1 |
5 files changed, 32 insertions, 0 deletions
diff --git a/mobile-widgets/qml/About.qml b/mobile-widgets/qml/About.qml index 212ff5c6b..6d3bb28a3 100644 --- a/mobile-widgets/qml/About.qml +++ b/mobile-widgets/qml/About.qml @@ -56,5 +56,14 @@ Kirigami.ScrollablePage { anchors.horizontalCenter: parent.Center horizontalAlignment: Text.AlignHCenter } + SsrfButton { + id: copyAppLogToClipboard + Layout.alignment: Qt.AlignHCenter + text: qsTr("Copy app log to clipboard") + onClicked: { + manager.copyAppLogToClipboard() + rootItem.returnTopPage() + } + } } } diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index fba9efb92..2b2d4cbbe 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -12,12 +12,14 @@ #include <QElapsedTimer> #include <QTimer> #include <QDateTime> +#include <QClipboard> #include <QBluetoothLocalDevice> #include "qt-models/divelistmodel.h" #include "qt-models/gpslistmodel.h" #include "qt-models/completionmodels.h" +#include "qt-models/messagehandlermodel.h" #include "core/divelist.h" #include "core/device.h" #include "core/pref.h" @@ -332,6 +334,16 @@ void QMLManager::cancelCredentialsPinSetup() setShowPin(false); } +void QMLManager::copyAppLogToClipboard() +{ + /* + * The user clicked the button, so copy the log file + * to the clipboard for easy access + */ + QString copyString = MessageHandlerModel::self()->logAsString(); + QApplication::clipboard()->setText(copyString, QClipboard::Clipboard); +} + void QMLManager::finishSetup() { // Initialize cloud credentials. diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index b158e43ee..1a7166b65 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -178,6 +178,7 @@ public slots: void clearGpsData(); void clearCredentials(); void cancelCredentialsPinSetup(); + void copyAppLogToClipboard(); void finishSetup(); void openLocalThenRemote(QString url); void mergeLocalRepo(); diff --git a/qt-models/messagehandlermodel.cpp b/qt-models/messagehandlermodel.cpp index be077a1a3..78497f5bc 100644 --- a/qt-models/messagehandlermodel.cpp +++ b/qt-models/messagehandlermodel.cpp @@ -51,6 +51,15 @@ void MessageHandlerModel::addLog(QtMsgType type, const QString& message) #endif } +const QString MessageHandlerModel::logAsString() +{ + QString copyString; + + // Loop through m_data and build big string to be put on the clipboard + for(const MessageData &data: m_data) + copyString += data.message + "\n"; + return copyString; +} QVariant MessageHandlerModel::data(const QModelIndex& idx, int role) const { switch(role) { diff --git a/qt-models/messagehandlermodel.h b/qt-models/messagehandlermodel.h index b59a4eca3..3addee95f 100644 --- a/qt-models/messagehandlermodel.h +++ b/qt-models/messagehandlermodel.h @@ -14,6 +14,7 @@ public: QVariant data(const QModelIndex& idx, int role) const override; QHash<int, QByteArray> roleNames() const override; void addLog(QtMsgType type, const QString& message); + const QString logAsString(); /* call this to clear the debug data */ Q_INVOKABLE void reset(); |