-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/AnnaAK/trikRuntime
- Loading branch information
Showing
10 changed files
with
140 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Copyright 2016 Anna Kudryashova | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. */ | ||
|
||
#include "gamepadIndicator.h" | ||
|
||
#include "trikKernel/paths.h" | ||
|
||
using namespace trikGui; | ||
|
||
GamepadIndicator::GamepadIndicator(Controller &controller, QWidget *parent) | ||
: QLabel(parent) | ||
, mController(controller) | ||
{ | ||
connect(&mController, SIGNAL(gamepadDisconnected()), this, SLOT(setOff())); | ||
connect(&mController, SIGNAL(gamepadConnected()), this, SLOT(setOn())); | ||
|
||
updateStatus(); | ||
connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | ||
mUpdateTimer.start(7000); | ||
} | ||
|
||
void GamepadIndicator::setOn() | ||
{ | ||
QPixmap icon("://resources/gamepad_on.png"); | ||
setPixmap(icon); | ||
show(); | ||
} | ||
|
||
void GamepadIndicator::setOff() | ||
{ | ||
hide(); | ||
} | ||
|
||
void GamepadIndicator::connected(bool connected) | ||
{ | ||
connected ? setOn() : setOff(); | ||
} | ||
|
||
void GamepadIndicator::updateStatus() | ||
{ | ||
connected(mController.gamepadConnectionStatus()); | ||
} | ||
|
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,56 @@ | ||
/* Copyright 2016 Anna Kudryashova | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. */ | ||
|
||
#pragma once | ||
|
||
#include <QtCore/qglobal.h> | ||
|
||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) | ||
#include <QtGui/QLabel> | ||
#else | ||
#include <QtWidgets/QLabel> | ||
#endif | ||
|
||
#include <controller.h> | ||
#include <trikNetwork/gamepadInterface.h> | ||
|
||
namespace trikGui { | ||
|
||
/// A label that shows gamepad connection status. | ||
class GamepadIndicator : public QLabel | ||
{ | ||
Q_OBJECT | ||
public: | ||
/// @param controller is used to get the current gamepad info | ||
explicit GamepadIndicator(Controller &controller, QWidget *parent = 0); | ||
|
||
public slots: | ||
/// Updates the status to 'connect'. | ||
void setOn(); | ||
|
||
/// Updates the status to 'disconnect'. | ||
void setOff(); | ||
|
||
/// Requests connection info from the controller and updates the status. | ||
void updateStatus(); | ||
|
||
/// Updates the status according to connected parameters. | ||
void connected(bool connected); | ||
|
||
private: | ||
QTimer mUpdateTimer; | ||
Controller &mController; | ||
}; | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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