Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
bc19757e
Commit
bc19757e
authored
Apr 05, 2016
by
Nate Weibley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file save support for logs
parent
9ceca7fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
9 deletions
+95
-9
QGCApplication.cc
src/QGCApplication.cc
+2
-1
AppMessages.cc
src/QmlControls/AppMessages.cc
+33
-4
AppMessages.h
src/QmlControls/AppMessages.h
+22
-2
AppMessages.qml
src/QmlControls/AppMessages.qml
+37
-1
MainWindow.cc
src/ui/MainWindow.cc
+1
-1
No files found.
src/QGCApplication.cc
View file @
bc19757e
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <QPainter>
#include <QPainter>
#include <QStyleFactory>
#include <QStyleFactory>
#include <QAction>
#include <QAction>
#include <QStringListModel>
#ifdef QGC_ENABLE_BLUETOOTH
#ifdef QGC_ENABLE_BLUETOOTH
#include <QBluetoothLocalDevice>
#include <QBluetoothLocalDevice>
...
@@ -485,7 +486,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
...
@@ -485,7 +486,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
_qmlAppEngine
=
new
QQmlApplicationEngine
(
this
);
_qmlAppEngine
=
new
QQmlApplicationEngine
(
this
);
_qmlAppEngine
->
addImportPath
(
"qrc:/qml"
);
_qmlAppEngine
->
addImportPath
(
"qrc:/qml"
);
_qmlAppEngine
->
rootContext
()
->
setContextProperty
(
"joystickManager"
,
toolbox
()
->
joystickManager
());
_qmlAppEngine
->
rootContext
()
->
setContextProperty
(
"joystickManager"
,
toolbox
()
->
joystickManager
());
_qmlAppEngine
->
rootContext
()
->
setContextProperty
(
"debugMessageModel"
,
&
AppMessages
::
getModel
());
_qmlAppEngine
->
rootContext
()
->
setContextProperty
(
"debugMessageModel"
,
AppMessages
::
getModel
());
_qmlAppEngine
->
load
(
QUrl
(
QStringLiteral
(
"qrc:/qml/MainWindowNative.qml"
)));
_qmlAppEngine
->
load
(
QUrl
(
QStringLiteral
(
"qrc:/qml/MainWindowNative.qml"
)));
#else
#else
// Start the user interface
// Start the user interface
...
...
src/QmlControls/AppMessages.cc
View file @
bc19757e
...
@@ -22,11 +22,14 @@ This file is part of the QGROUNDCONTROL project
...
@@ -22,11 +22,14 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/
======================================================================*/
#include "AppMessages.h"
#include "AppMessages.h"
#include <QFile>
#include <QStringListModel>
#include <QStringListModel>
#include <iostream>
#include <QtConcurrent>
#include <QTextStream>
AppLogModel
AppLogModel
::
instance
;
static
QtMessageHandler
old_handler
;
static
QtMessageHandler
old_handler
;
static
QStringListModel
debug_strings
;
static
AppLogModel
&
debug_strings
=
AppLogModel
::
getModel
()
;
static
void
msgHandler
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
)
static
void
msgHandler
(
QtMsgType
type
,
const
QMessageLogContext
&
context
,
const
QString
&
msg
)
{
{
...
@@ -51,7 +54,33 @@ void AppMessages::installHandler()
...
@@ -51,7 +54,33 @@ void AppMessages::installHandler()
old_handler
=
qInstallMessageHandler
(
msgHandler
);
old_handler
=
qInstallMessageHandler
(
msgHandler
);
}
}
QStringListModel
&
AppMessages
::
getModel
()
AppLogModel
*
AppMessages
::
getModel
()
{
{
return
debug_strings
;
return
&
AppLogModel
::
getModel
();
}
AppLogModel
&
AppLogModel
::
getModel
()
{
return
instance
;
}
AppLogModel
::
AppLogModel
()
:
QStringListModel
()
{
}
void
AppLogModel
::
writeMessages
(
const
QUrl
dest_file
)
{
const
QString
writebuffer
(
stringList
().
join
(
'\n'
).
append
(
'\n'
));
QtConcurrent
::
run
([
dest_file
,
writebuffer
]
{
emit
instance
.
writeStarted
();
bool
success
=
false
;
QFile
file
(
dest_file
.
toLocalFile
());
if
(
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
QTextStream
out
(
&
file
);
out
<<
writebuffer
;
success
=
out
.
status
()
==
QTextStream
::
Ok
;
}
emit
instance
.
writeFinished
(
success
);
});
}
}
src/QmlControls/AppMessages.h
View file @
bc19757e
...
@@ -23,11 +23,31 @@ This file is part of the QGROUNDCONTROL project
...
@@ -23,11 +23,31 @@ This file is part of the QGROUNDCONTROL project
#pragma once
#pragma once
class
QStringListModel
;
#include <QObject>
#include <QStringListModel>
#include <QUrl>
class
AppLogModel
:
public
QStringListModel
{
Q_OBJECT
public:
static
AppLogModel
&
getModel
();
Q_INVOKABLE
void
writeMessages
(
const
QUrl
dest_file
);
signals:
void
writeStarted
();
void
writeFinished
(
bool
success
);
private:
AppLogModel
();
static
AppLogModel
instance
;
};
class
AppMessages
class
AppMessages
{
{
public:
public:
static
void
installHandler
();
static
void
installHandler
();
static
QStringListModel
&
getModel
();
static
AppLogModel
*
getModel
();
};
};
src/QmlControls/AppMessages.qml
View file @
bc19757e
...
@@ -93,8 +93,44 @@ QGCView {
...
@@ -93,8 +93,44 @@ QGCView {
delegate
:
delegateItem
delegate
:
delegateItem
}
}
FileDialog
{
id
:
writeDialog
folder
:
shortcuts
.
home
nameFilters
:
[
"
Log files (*.txt)
"
,
"
All Files (*)
"
]
selectExisting
:
false
title
:
"
Select log save file
"
onAccepted
:
{
debugMessageModel
.
writeMessages
(
fileUrl
);
visible
=
false
;
}
onRejected
:
visible
=
false
}
Connections
{
target
:
debugMessageModel
onWriteStarted
:
writeButton
.
enabled
=
false
;
onWriteFinished
:
writeButton
.
enabled
=
true
;
}
QGCButton
{
id
:
writeButton
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
onClicked
:
writeDialog
.
visible
=
true
text
:
"
Save App Log
"
}
BusyIndicator
{
id
:
writeBusy
anchors.bottom
:
writeButton
.
bottom
anchors.left
:
writeButton
.
right
height
:
writeButton
.
height
visible
:
!
writeButton
.
enabled
}
QGCButton
{
QGCButton
{
id
:
followTail
id
:
followTail
anchors.bottom
:
parent
.
bottom
anchors.bottom
:
parent
.
bottom
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
anchors.margins
:
ScreenTools
.
defaultFontPixelWidth
...
...
src/ui/MainWindow.cc
View file @
bc19757e
...
@@ -165,7 +165,7 @@ MainWindow::MainWindow()
...
@@ -165,7 +165,7 @@ MainWindow::MainWindow()
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
_mainQmlWidgetHolder
->
setContextPropertyObject
(
"controller"
,
this
);
_mainQmlWidgetHolder
->
setContextPropertyObject
(
"controller"
,
this
);
_mainQmlWidgetHolder
->
setContextPropertyObject
(
"debugMessageModel"
,
&
AppMessages
::
getModel
());
_mainQmlWidgetHolder
->
setContextPropertyObject
(
"debugMessageModel"
,
AppMessages
::
getModel
());
_mainQmlWidgetHolder
->
setSource
(
QUrl
::
fromUserInput
(
"qrc:qml/MainWindowHybrid.qml"
));
_mainQmlWidgetHolder
->
setSource
(
QUrl
::
fromUserInput
(
"qrc:qml/MainWindowHybrid.qml"
));
// Image provider
// Image provider
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment