Commit 95f92dc3 authored by Don Gagne's avatar Don Gagne

Merge pull request #845 from Susurrus/joystick2

Second pass at moving joystick settings into general settings dialog window

This has been sitting for comment for a couple days. Code review is good and change makes sense. Merging.
parents 158bfc91 a30a180d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
JoystickWidget::JoystickWidget(JoystickInput* joystick, QWidget *parent) : JoystickWidget::JoystickWidget(JoystickInput* joystick, QWidget *parent) :
QDialog(parent), QWidget(parent),
joystick(joystick), joystick(joystick),
m_ui(new Ui::JoystickWidget) m_ui(new Ui::JoystickWidget)
{ {
......
...@@ -31,7 +31,7 @@ This file is part of the PIXHAWK project ...@@ -31,7 +31,7 @@ This file is part of the PIXHAWK project
#ifndef JOYSTICKWIDGET_H #ifndef JOYSTICKWIDGET_H
#define JOYSTICKWIDGET_H #define JOYSTICKWIDGET_H
#include <QDialog> #include <QWidget>
#include <QLabel> #include <QLabel>
#include <QMap> #include <QMap>
#include "JoystickInput.h" #include "JoystickInput.h"
...@@ -44,7 +44,7 @@ namespace Ui ...@@ -44,7 +44,7 @@ namespace Ui
class JoystickWidget; class JoystickWidget;
} }
class JoystickWidget : public QDialog class JoystickWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(JoystickWidget) Q_DISABLE_COPY(JoystickWidget)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>JoystickWidget</class> <class>JoystickWidget</class>
<widget class="QDialog" name="JoystickWidget"> <widget class="QWidget" name="JoystickWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<number>8</number> <number>8</number>
</property> </property>
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>8</number> <number>8</number>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Enable joysticks</string> <string>Enable controllers</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -174,53 +174,8 @@ ...@@ -174,53 +174,8 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QDialogButtonBox" name="dialogButtonsBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>dialogButtonsBox</sender>
<signal>accepted()</signal>
<receiver>JoystickWidget</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>263</x>
<y>438</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
...@@ -279,7 +279,6 @@ void MainWindow::init() ...@@ -279,7 +279,6 @@ void MainWindow::init()
// Connect user interface devices // Connect user interface devices
emit initStatusChanged(tr("Initializing joystick interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); emit initStatusChanged(tr("Initializing joystick interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
joystickWidget = 0;
joystick = new JoystickInput(); joystick = new JoystickInput();
#ifdef QGC_MOUSE_ENABLED_WIN #ifdef QGC_MOUSE_ENABLED_WIN
...@@ -1329,9 +1328,6 @@ void MainWindow::connectCommonActions() ...@@ -1329,9 +1328,6 @@ void MainWindow::connectCommonActions()
// so no ressources spend on this. // so no ressources spend on this.
ui.actionJoystickSettings->setVisible(true); ui.actionJoystickSettings->setVisible(true);
// Configuration
// Joystick
connect(ui.actionJoystickSettings, SIGNAL(triggered()), this, SLOT(configure()));
// Application Settings // Application Settings
connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings())); connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
...@@ -1380,22 +1376,9 @@ void MainWindow::showRoadMap() ...@@ -1380,22 +1376,9 @@ void MainWindow::showRoadMap()
} }
} }
void MainWindow::configure()
{
if (!joystickWidget)
{
if (!joystick->isRunning())
{
joystick->start();
}
joystickWidget = new JoystickWidget(joystick, this);
}
joystickWidget->show();
}
void MainWindow::showSettings() void MainWindow::showSettings()
{ {
QGCSettingsWidget* settings = new QGCSettingsWidget(this); QGCSettingsWidget* settings = new QGCSettingsWidget(joystick, this);
settings->show(); settings->show();
} }
......
...@@ -81,7 +81,6 @@ class QSplashScreen; ...@@ -81,7 +81,6 @@ class QSplashScreen;
class QGCStatusBar; class QGCStatusBar;
class Linecharts; class Linecharts;
class QGCDataPlot2D; class QGCDataPlot2D;
class JoystickWidget;
class MenuActionHelper; class MenuActionHelper;
class QGCUASFileViewMulti; class QGCUASFileViewMulti;
...@@ -202,7 +201,6 @@ public slots: ...@@ -202,7 +201,6 @@ public slots:
LinkInterface* addLink(); LinkInterface* addLink();
void addLink(LinkInterface* link); void addLink(LinkInterface* link);
bool configLink(LinkInterface *link); bool configLink(LinkInterface *link);
void configure();
/** @brief Simulate a link */ /** @brief Simulate a link */
void simulateLink(bool simulate); void simulateLink(bool simulate);
/** @brief Set the currently controlled UAS */ /** @brief Set the currently controlled UAS */
...@@ -459,10 +457,7 @@ protected: ...@@ -459,10 +457,7 @@ protected:
QPointer<QGCUASFileViewMulti> fileWidget; QPointer<QGCUASFileViewMulti> fileWidget;
// Popup widgets JoystickInput* joystick; ///< The joystick manager for QGC
JoystickWidget* joystickWidget;
JoystickInput* joystick;
#ifdef QGC_MOUSE_ENABLED_WIN #ifdef QGC_MOUSE_ENABLED_WIN
/** @brief 3d Mouse support (WIN only) */ /** @brief 3d Mouse support (WIN only) */
......
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
<addaction name="actionSimulate"/> <addaction name="actionSimulate"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMuteAudioOutput"/> <addaction name="actionMuteAudioOutput"/>
<addaction name="actionJoystickSettings"/>
<addaction name="actionSettings"/> <addaction name="actionSettings"/>
<addaction name="actionAdvanced_Mode"/> <addaction name="actionAdvanced_Mode"/>
<addaction name="separator"/> <addaction name="separator"/>
......
...@@ -5,14 +5,13 @@ ...@@ -5,14 +5,13 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_QGCSettingsWidget.h" #include "ui_QGCSettingsWidget.h"
#include "JoystickWidget.h"
#include "LinkManager.h" #include "LinkManager.h"
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
#include "MAVLinkSettingsWidget.h" #include "MAVLinkSettingsWidget.h"
#include "GAudioOutput.h" #include "GAudioOutput.h"
//, Qt::WindowFlags flags QGCSettingsWidget::QGCSettingsWidget(JoystickInput *joystick, QWidget *parent, Qt::WindowFlags flags) :
QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags), QDialog(parent, flags),
mainWindow((MainWindow*)parent), mainWindow((MainWindow*)parent),
ui(new Ui::QGCSettingsWidget) ui(new Ui::QGCSettingsWidget)
...@@ -24,6 +23,9 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : ...@@ -24,6 +23,9 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) :
position.moveCenter(QApplication::desktop()->availableGeometry().center()); position.moveCenter(QApplication::desktop()->availableGeometry().center());
move(position.topLeft()); move(position.topLeft());
// Add the joystick settings pane
ui->tabWidget->addTab(new JoystickWidget(joystick, this), "Controllers");
// Add all protocols // Add all protocols
QList<ProtocolInterface*> protocols = LinkManager::instance()->getProtocols(); QList<ProtocolInterface*> protocols = LinkManager::instance()->getProtocols();
foreach (ProtocolInterface* protocol, protocols) { foreach (ProtocolInterface* protocol, protocols) {
......
...@@ -14,7 +14,7 @@ class QGCSettingsWidget : public QDialog ...@@ -14,7 +14,7 @@ class QGCSettingsWidget : public QDialog
Q_OBJECT Q_OBJECT
public: public:
QGCSettingsWidget(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet); QGCSettingsWidget(JoystickInput *joystick, QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet);
~QGCSettingsWidget(); ~QGCSettingsWidget();
public slots: public slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment