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
a1de93c1
Commit
a1de93c1
authored
Jun 14, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace usage of QMessageBox with a QML window.
parent
d2ab2510
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
30 deletions
+93
-30
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
QGCApplication.cc
src/QGCApplication.cc
+30
-30
QGCApplication.h
src/QGCApplication.h
+4
-0
main.cc
src/main.cc
+4
-0
ExitWithErrorWindow.qml
src/ui/ExitWithErrorWindow.qml
+54
-0
No files found.
qgroundcontrol.qrc
View file @
a1de93c1
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
<file alias="DebugWindow.qml">src/ui/preferences/DebugWindow.qml</file>
<file alias="DebugWindow.qml">src/ui/preferences/DebugWindow.qml</file>
<file alias="ESP8266Component.qml">src/AutoPilotPlugins/Common/ESP8266Component.qml</file>
<file alias="ESP8266Component.qml">src/AutoPilotPlugins/Common/ESP8266Component.qml</file>
<file alias="ESP8266ComponentSummary.qml">src/AutoPilotPlugins/Common/ESP8266ComponentSummary.qml</file>
<file alias="ESP8266ComponentSummary.qml">src/AutoPilotPlugins/Common/ESP8266ComponentSummary.qml</file>
<file alias="ExitWithErrorWindow.qml">src/ui/ExitWithErrorWindow.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="FlightDisplayViewDummy.qml">src/FlightDisplay/FlightDisplayViewDummy.qml</file>
<file alias="FlightDisplayViewDummy.qml">src/FlightDisplay/FlightDisplayViewDummy.qml</file>
<file alias="FlightDisplayViewUVC.qml">src/FlightDisplay/FlightDisplayViewUVC.qml</file>
<file alias="FlightDisplayViewUVC.qml">src/FlightDisplay/FlightDisplayViewUVC.qml</file>
...
...
src/QGCApplication.cc
View file @
a1de93c1
...
@@ -26,11 +26,6 @@
...
@@ -26,11 +26,6 @@
#include <QStringListModel>
#include <QStringListModel>
#include <QRegularExpression>
#include <QRegularExpression>
#include <QFontDatabase>
#include <QFontDatabase>
#ifdef Q_OS_LINUX
#ifndef __mobile__
#include <QMessageBox>
#endif
#endif
#ifdef QGC_ENABLE_BLUETOOTH
#ifdef QGC_ENABLE_BLUETOOTH
#include <QBluetoothLocalDevice>
#include <QBluetoothLocalDevice>
...
@@ -164,42 +159,33 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
...
@@ -164,42 +159,33 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
,
_runningUnitTests
(
unitTesting
)
,
_runningUnitTests
(
unitTesting
)
{
{
_app
=
this
;
_app
=
this
;
// Setup for network proxy support
QNetworkProxyFactory
::
setUseSystemConfiguration
(
true
);
#ifdef Q_OS_LINUX
#ifdef Q_OS_LINUX
#ifndef __mobile__
#ifndef __mobile__
if
(
!
_runningUnitTests
)
{
if
(
!
_runningUnitTests
)
{
if
(
getuid
()
==
0
)
{
if
(
getuid
()
==
0
)
{
QMessageBox
msgBox
;
_exitWithError
(
QString
(
msgBox
.
setInformativeText
(
tr
(
"You are running %1 as root. "
tr
(
"You are running %1 as root. "
"You should not do this since it will cause other issues with %1. "
"You should not do this since it will cause other issues with %1."
"%1 will now exit. "
"%1 will now exit.<br/><br/>"
"If you are having serial port issues on Ubuntu, execute the following commands to fix most issues:
\n
"
"If you are having serial port issues on Ubuntu, execute the following commands to fix most issues:<br/>"
"sudo usermod -a -G dialout $USER
\n
"
"<pre>sudo usermod -a -G dialout $USER<br/>"
"sudo apt-get remove modemmanager"
).
arg
(
qgcApp
()
->
applicationName
()));
"sudo apt-get remove modemmanager</pre>"
).
arg
(
qgcApp
()
->
applicationName
())));
msgBox
.
setStandardButtons
(
QMessageBox
::
Ok
);
return
;
msgBox
.
setDefaultButton
(
QMessageBox
::
Ok
);
msgBox
.
exec
();
_exit
(
0
);
}
}
// Determine if we have the correct permissions to access USB serial devices
// Determine if we have the correct permissions to access USB serial devices
QFile
permFile
(
"/etc/group"
);
QFile
permFile
(
"/etc/group"
);
if
(
permFile
.
open
(
QIODevice
::
ReadOnly
))
{
if
(
permFile
.
open
(
QIODevice
::
ReadOnly
))
{
while
(
!
permFile
.
atEnd
())
{
while
(
!
permFile
.
atEnd
())
{
QString
line
=
permFile
.
readLine
();
QString
line
=
permFile
.
readLine
();
if
(
line
.
contains
(
"dialout"
)
&&
!
line
.
contains
(
getenv
(
"USER"
)))
{
if
(
line
.
contains
(
"dialout"
)
&&
!
line
.
contains
(
getenv
(
"USER"
)))
{
QMessageBox
msgBox
;
permFile
.
close
();
msgBox
.
setInformativeText
(
"The current user does not have the correct permissions to access serial devices. "
_exitWithError
(
QString
(
"You should also remove modemmanager since it also interferes. "
tr
(
"The current user does not have the correct permissions to access serial devices. "
"If you are using Ubuntu, execute the following commands to fix these issues:
\n
"
"You should also remove modemmanager since it also interferes.<br/><br/>"
"sudo usermod -a -G dialout $USER
\n
"
"If you are using Ubuntu, execute the following commands to fix these issues:<br/>"
"sudo apt-get remove modemmanager"
);
"<pre>sudo usermod -a -G dialout $USER<br/>"
msgBox
.
setStandardButtons
(
QMessageBox
::
Ok
);
"sudo apt-get remove modemmanager</pre>"
)));
msgBox
.
setDefaultButton
(
QMessageBox
::
Ok
);
return
;
msgBox
.
exec
();
break
;
}
}
}
}
permFile
.
close
();
permFile
.
close
();
...
@@ -208,6 +194,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
...
@@ -208,6 +194,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif
#endif
#endif
#endif
// Setup for network proxy support
QNetworkProxyFactory
::
setUseSystemConfiguration
(
true
);
// Parse command line options
// Parse command line options
bool
fClearSettingsOptions
=
false
;
// Clear stored settings
bool
fClearSettingsOptions
=
false
;
// Clear stored settings
...
@@ -348,6 +337,17 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
...
@@ -348,6 +337,17 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
_checkForNewVersion
();
_checkForNewVersion
();
}
}
void
QGCApplication
::
_exitWithError
(
QString
errorMessage
)
{
_error
=
true
;
QQmlApplicationEngine
*
pEngine
=
new
QQmlApplicationEngine
(
this
);
pEngine
->
addImportPath
(
"qrc:/qml"
);
pEngine
->
rootContext
()
->
setContextProperty
(
"errorMessage"
,
errorMessage
);
pEngine
->
load
(
QUrl
(
QStringLiteral
(
"qrc:/qml/ExitWithErrorWindow.qml"
)));
// Exit main application when last window is closed
connect
(
this
,
&
QGCApplication
::
lastWindowClosed
,
this
,
QGCApplication
::
quit
);
}
void
QGCApplication
::
setLanguage
()
void
QGCApplication
::
setLanguage
()
{
{
_locale
=
QLocale
::
system
();
_locale
=
QLocale
::
system
();
...
...
src/QGCApplication.h
View file @
a1de93c1
...
@@ -145,6 +145,8 @@ public:
...
@@ -145,6 +145,8 @@ public:
static
QGCApplication
*
_app
;
///< Our own singleton. Should be reference directly by qgcApp
static
QGCApplication
*
_app
;
///< Our own singleton. Should be reference directly by qgcApp
bool
isErrorState
()
{
return
_error
;
}
public:
public:
// Although public, these methods are internal and should only be called by UnitTest code
// Although public, these methods are internal and should only be called by UnitTest code
...
@@ -166,6 +168,7 @@ private slots:
...
@@ -166,6 +168,7 @@ private slots:
private:
private:
QObject
*
_rootQmlObject
();
QObject
*
_rootQmlObject
();
void
_checkForNewVersion
();
void
_checkForNewVersion
();
void
_exitWithError
(
QString
errorMessage
);
bool
_runningUnitTests
;
///< true: running unit tests, false: normal app
bool
_runningUnitTests
;
///< true: running unit tests, false: normal app
...
@@ -190,6 +193,7 @@ private:
...
@@ -190,6 +193,7 @@ private:
QTranslator
_QGCTranslator
;
QTranslator
_QGCTranslator
;
QTranslator
_QGCTranslatorQt
;
QTranslator
_QGCTranslatorQt
;
QLocale
_locale
;
QLocale
_locale
;
bool
_error
=
false
;
static
const
char
*
_settingsVersionKey
;
///< Settings key which hold settings version
static
const
char
*
_settingsVersionKey
;
///< Settings key which hold settings version
static
const
char
*
_deleteAllSettingsKey
;
///< If this settings key is set on boot, all settings will be deleted
static
const
char
*
_deleteAllSettingsKey
;
///< If this settings key is set on boot, all settings will be deleted
...
...
src/main.cc
View file @
a1de93c1
...
@@ -328,6 +328,10 @@ int main(int argc, char *argv[])
...
@@ -328,6 +328,10 @@ int main(int argc, char *argv[])
QCoreApplication
::
setAttribute
(
Qt
::
AA_UseHighDpiPixmaps
);
QCoreApplication
::
setAttribute
(
Qt
::
AA_UseHighDpiPixmaps
);
QGCApplication
*
app
=
new
QGCApplication
(
argc
,
argv
,
runUnitTests
);
QGCApplication
*
app
=
new
QGCApplication
(
argc
,
argv
,
runUnitTests
);
Q_CHECK_PTR
(
app
);
Q_CHECK_PTR
(
app
);
if
(
app
->
isErrorState
())
{
app
->
exec
();
return
-
1
;
}
#ifdef Q_OS_LINUX
#ifdef Q_OS_LINUX
QApplication
::
setWindowIcon
(
QIcon
(
":/res/resources/icons/qgroundcontrol.ico"
));
QApplication
::
setWindowIcon
(
QIcon
(
":/res/resources/icons/qgroundcontrol.ico"
));
...
...
src/ui/ExitWithErrorWindow.qml
0 → 100644
View file @
a1de93c1
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import
QtQuick
2.11
import
QtQuick
.
Controls
2.4
import
QtQuick
.
Dialogs
1.3
import
QtQuick
.
Layouts
1.11
import
QtQuick
.
Window
2.11
ApplicationWindow
{
id
:
errorWindow
minimumWidth
:
messageArea
.
width
+
60
minimumHeight
:
messageArea
.
height
+
60
width
:
messageArea
.
width
+
60
height
:
messageArea
.
height
+
60
visible
:
true
//-------------------------------------------------------------------------
//-- Main, full window background (Fly View)
background
:
Item
{
id
:
rootBackground
anchors.fill
:
parent
Rectangle
{
anchors.fill
:
parent
color
:
"
#000000
"
}
}
Column
{
id
:
messageArea
spacing
:
20
anchors.centerIn
:
parent
Label
{
width
:
600
text
:
errorMessage
color
:
"
#eecc44
"
wrapMode
:
Text
.
WordWrap
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Button
{
text
:
qsTr
(
"
Close
"
)
highlighted
:
true
onClicked
:
errorWindow
.
close
()
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
}
}
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