Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaf7c89
commit a9a57a6
Showing
12 changed files
with
173 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*************************************************************************** | ||
qgsgpstoolbar.cpp | ||
------------------- | ||
begin : October 2022 | ||
copyright : (C) 2022 Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgpstoolbar.h" | ||
#include "qgsappgpsconnection.h" | ||
#include "qgis.h" | ||
|
||
QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QWidget *parent ) | ||
: QToolBar( parent ) | ||
, mConnection( connection ) | ||
{ | ||
setObjectName( QStringLiteral( "mGpsToolBar" ) ); | ||
setWindowTitle( tr( "GPS Toolbar" ) ); | ||
setToolTip( tr( "GPS Toolbar" ) ); | ||
|
||
mConnectAction = new QAction( tr( "Connect" ), this ); | ||
mConnectAction->setCheckable( true ); | ||
addAction( mConnectAction ); | ||
|
||
connect( mConnection, &QgsAppGpsConnection::statusChanged, this, [ = ]( Qgis::GpsConnectionStatus status ) | ||
{ | ||
switch ( status ) | ||
{ | ||
case Qgis::GpsConnectionStatus::Disconnected: | ||
whileBlocking( mConnectAction )->setChecked( false ); | ||
mConnectAction->setText( tr( "Connect" ) ); | ||
mConnectAction->setEnabled( true ); | ||
break; | ||
case Qgis::GpsConnectionStatus::Connecting: | ||
whileBlocking( mConnectAction )->setChecked( true ); | ||
mConnectAction->setText( tr( "Connecting" ) ); | ||
mConnectAction->setEnabled( false ); | ||
break; | ||
case Qgis::GpsConnectionStatus::Connected: | ||
whileBlocking( mConnectAction )->setChecked( true ); | ||
mConnectAction->setText( tr( "Disconnect" ) ); | ||
mConnectAction->setEnabled( true ); | ||
break; | ||
} | ||
} ); | ||
|
||
connect( mConnectAction, &QAction::toggled, this, [ = ]( bool connect ) | ||
{ | ||
if ( connect ) | ||
mConnection->connectGps(); | ||
else | ||
mConnection->disconnectGps(); | ||
} ); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/*************************************************************************** | ||
qgsgpstoolbar.h | ||
------------------- | ||
begin : October 2022 | ||
copyright : (C) 2022 Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGPSTOOLBAR_H | ||
#define QGSGPSTOOLBAR_H | ||
|
||
#include <QToolBar> | ||
|
||
class QgsAppGpsConnection; | ||
|
||
class QgsGpsToolBar : public QToolBar | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
QgsGpsToolBar( QgsAppGpsConnection *connection, QWidget *parent = nullptr ); | ||
|
||
private: | ||
|
||
QgsAppGpsConnection *mConnection = nullptr; | ||
QAction *mConnectAction = nullptr; | ||
|
||
}; | ||
|
||
#endif // QGSGPSTOOLBAR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters