mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Only show PipX config gadget when the PipX is connected.
This commit is contained in:
parent
0bc3c5061f
commit
6f9c6ae86d
@ -90,9 +90,6 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
qwd = new ConfigTxPIDWidget(this);
|
qwd = new ConfigTxPIDWidget(this);
|
||||||
ftw->insertTab(ConfigGadgetWidget::txpid, qwd, QIcon(":/configgadget/images/txpid.png"), QString("TxPID"));
|
ftw->insertTab(ConfigGadgetWidget::txpid, qwd, QIcon(":/configgadget/images/txpid.png"), QString("TxPID"));
|
||||||
|
|
||||||
qwd = new ConfigPipXtremeWidget(this);
|
|
||||||
ftw->insertTab(ConfigGadgetWidget::pipxtreme, qwd, QIcon(":/configgadget/images/PipXtreme.png"), QString("PipXtreme"));
|
|
||||||
|
|
||||||
// *********************
|
// *********************
|
||||||
// Listen to autopilot connection events
|
// Listen to autopilot connection events
|
||||||
|
|
||||||
@ -108,6 +105,19 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
help = 0;
|
help = 0;
|
||||||
connect(ftw,SIGNAL(currentAboutToShow(int,bool*)),this,SLOT(tabAboutToChange(int,bool*)));//,Qt::BlockingQueuedConnection);
|
connect(ftw,SIGNAL(currentAboutToShow(int,bool*)),this,SLOT(tabAboutToChange(int,bool*)));//,Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
|
// Connect to the PipXStatus object updates
|
||||||
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
|
pipxStatusObj = dynamic_cast<UAVDataObject*>(objManager->getObject("PipXStatus"));
|
||||||
|
if (pipxStatusObj != NULL ) {
|
||||||
|
connect(pipxStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updatePipXStatus(UAVObject*)));
|
||||||
|
} else {
|
||||||
|
qDebug() << "Error: Object is unknown (PipXStatus).";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the timer that is used to timeout the connection to the PipX.
|
||||||
|
pipxTimeout = new QTimer(this);
|
||||||
|
connect(pipxTimeout, SIGNAL(timeout()),this,SLOT(onPipxtremeDisconnect()));
|
||||||
|
pipxConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigGadgetWidget::~ConfigGadgetWidget()
|
ConfigGadgetWidget::~ConfigGadgetWidget()
|
||||||
@ -203,5 +213,27 @@ void ConfigGadgetWidget::tabAboutToChange(int i,bool * proceed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Called by updates to @PipXStatus
|
||||||
|
*/
|
||||||
|
void ConfigGadgetWidget::updatePipXStatus(UAVObject *object)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Restart the disconnection timer.
|
||||||
|
pipxTimeout->start(5000);
|
||||||
|
if (!pipxConnected)
|
||||||
|
{
|
||||||
|
qDebug()<<"ConfigGadgetWidget onPipxtremeConnect";
|
||||||
|
QWidget *qwd = new ConfigPipXtremeWidget(this);
|
||||||
|
ftw->insertTab(ConfigGadgetWidget::pipxtreme, qwd, QIcon(":/configgadget/images/PipXtreme.png"), QString("PipXtreme"));
|
||||||
|
ftw->setCurrentIndex(ConfigGadgetWidget::pipxtreme);
|
||||||
|
pipxConnected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigGadgetWidget::onPipxtremeDisconnect() {
|
||||||
|
qDebug()<<"ConfigGadgetWidget onPipxtremeDisconnect";
|
||||||
|
pipxTimeout->stop();
|
||||||
|
ftw->removeTab(ConfigGadgetWidget::pipxtreme);
|
||||||
|
pipxConnected = false;
|
||||||
|
}
|
||||||
|
@ -56,14 +56,25 @@ public slots:
|
|||||||
void onAutopilotConnect();
|
void onAutopilotConnect();
|
||||||
void onAutopilotDisconnect();
|
void onAutopilotDisconnect();
|
||||||
void tabAboutToChange(int i,bool *);
|
void tabAboutToChange(int i,bool *);
|
||||||
|
void updatePipXStatus(UAVObject *object);
|
||||||
|
void onPipxtremeDisconnect();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void autopilotConnected();
|
void autopilotConnected();
|
||||||
void autopilotDisconnected();
|
void autopilotDisconnected();
|
||||||
|
void pipxtremeConnect();
|
||||||
|
void pipxtremeDisconnect();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent * event);
|
void resizeEvent(QResizeEvent * event);
|
||||||
MyTabbedStackWidget *ftw;
|
MyTabbedStackWidget *ftw;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UAVDataObject* pipxStatusObj;
|
||||||
|
|
||||||
|
// A timer that timesout the connction to the PipX.
|
||||||
|
QTimer *pipxTimeout;
|
||||||
|
bool pipxConnected;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGGADGETWIDGET_H
|
#endif // CONFIGGADGETWIDGET_H
|
||||||
|
@ -86,10 +86,6 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
|
|||||||
connect(m_pipx->PairSelect3, SIGNAL(toggled(bool)), this, SLOT(pair3Toggled(bool)));
|
connect(m_pipx->PairSelect3, SIGNAL(toggled(bool)), this, SLOT(pair3Toggled(bool)));
|
||||||
connect(m_pipx->PairSelect4, SIGNAL(toggled(bool)), this, SLOT(pair4Toggled(bool)));
|
connect(m_pipx->PairSelect4, SIGNAL(toggled(bool)), this, SLOT(pair4Toggled(bool)));
|
||||||
|
|
||||||
// Create the timer that is used to timeout the connection to the PipX.
|
|
||||||
timeOut = new QTimer(this);
|
|
||||||
connect(timeOut, SIGNAL(timeout()),this,SLOT(disconnected()));
|
|
||||||
|
|
||||||
//Add scroll bar when necessary
|
//Add scroll bar when necessary
|
||||||
QScrollArea *scroll = new QScrollArea;
|
QScrollArea *scroll = new QScrollArea;
|
||||||
scroll->setWidget(m_pipx->frame_3);
|
scroll->setWidget(m_pipx->frame_3);
|
||||||
@ -97,10 +93,9 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget
|
|||||||
|
|
||||||
// Request and update of the setting object.
|
// Request and update of the setting object.
|
||||||
settingsUpdated = false;
|
settingsUpdated = false;
|
||||||
pipxSettingsObj->requestUpdate();
|
//pipxSettingsObj->requestUpdate();
|
||||||
|
|
||||||
disableMouseWheelEvents();
|
disableMouseWheelEvents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigPipXtremeWidget::~ConfigPipXtremeWidget()
|
ConfigPipXtremeWidget::~ConfigPipXtremeWidget()
|
||||||
@ -145,9 +140,6 @@ void ConfigPipXtremeWidget::saveSettings()
|
|||||||
void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
|
void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Restart the disconnection timer.
|
|
||||||
timeOut->start(10000);
|
|
||||||
|
|
||||||
// Request and update of the setting object if we haven't received it yet.
|
// Request and update of the setting object if we haven't received it yet.
|
||||||
if (!settingsUpdated)
|
if (!settingsUpdated)
|
||||||
pipxSettingsObj->requestUpdate();
|
pipxSettingsObj->requestUpdate();
|
||||||
@ -266,16 +258,22 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
|
|||||||
\brief Called by updates to @PipXSettings
|
\brief Called by updates to @PipXSettings
|
||||||
*/
|
*/
|
||||||
void ConfigPipXtremeWidget::updateSettings(UAVObject *object)
|
void ConfigPipXtremeWidget::updateSettings(UAVObject *object)
|
||||||
|
{
|
||||||
|
if (!settingsUpdated)
|
||||||
{
|
{
|
||||||
settingsUpdated = true;
|
settingsUpdated = true;
|
||||||
enableControls(true);
|
enableControls(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigPipXtremeWidget::disconnected()
|
void ConfigPipXtremeWidget::disconnected()
|
||||||
|
{
|
||||||
|
if (settingsUpdated)
|
||||||
{
|
{
|
||||||
settingsUpdated = false;
|
settingsUpdated = false;
|
||||||
enableControls(false);
|
enableControls(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx)
|
void ConfigPipXtremeWidget::pairIDToggled(bool checked, quint8 idx)
|
||||||
{
|
{
|
||||||
|
@ -53,9 +53,6 @@ private:
|
|||||||
|
|
||||||
bool settingsUpdated;
|
bool settingsUpdated;
|
||||||
|
|
||||||
// A timer that timesout the connction to the PipX.
|
|
||||||
QTimer *timeOut;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshValues();
|
void refreshValues();
|
||||||
void applySettings();
|
void applySettings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user