From a181020b193f0ae44c49a1ac095713cd2fa10213 Mon Sep 17 00:00:00 2001 From: jan Iversen Date: Wed, 16 May 2018 16:50:17 +0200 Subject: mobile: add "Copy log to clipboard" button on iOS it is practically impossible to copy the App log to e.g. a mail! in iOS 11 the log file is stored within the subsurface container and you first need to copy (actually using the clipboard) out from there to the "normal" document shared space, before it can be used. At least iOS users (and I believe Android users) are not really used to work with files, so the process is not easy to document in an understandable way. The alternative is to provide a button, which simply puts the log on the general clipboard, allowing it to be pasted in a multitud of applications. Signed-off-by: Jan Iversen --- qt-models/messagehandlermodel.cpp | 9 +++++++++ qt-models/messagehandlermodel.h | 1 + 2 files changed, 10 insertions(+) (limited to 'qt-models') 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 roleNames() const override; void addLog(QtMsgType type, const QString& message); + const QString logAsString(); /* call this to clear the debug data */ Q_INVOKABLE void reset(); -- cgit v1.2.3-70-g09d2