mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Ground/OP-512- Autoconnect option, configured trough the options menu. Default is ON.
This commit is contained in:
parent
7f5c9b6c43
commit
1ffc0e3d56
@ -36,15 +36,13 @@
|
|||||||
|
|
||||||
#include "fancytabwidget.h"
|
#include "fancytabwidget.h"
|
||||||
#include "fancyactionbar.h"
|
#include "fancyactionbar.h"
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "qextserialport/src/qextserialenumerator.h"
|
#include "qextserialport/src/qextserialenumerator.h"
|
||||||
#include "qextserialport/src/qextserialport.h"
|
#include "qextserialport/src/qextserialport.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QTimer>
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
|
||||||
@ -52,9 +50,9 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, Internal:
|
|||||||
QWidget(mainWindow), // Pip
|
QWidget(mainWindow), // Pip
|
||||||
m_availableDevList(0),
|
m_availableDevList(0),
|
||||||
m_connectBtn(0),
|
m_connectBtn(0),
|
||||||
m_ioDev(NULL)
|
m_ioDev(NULL),m_mainWindow(mainWindow)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mainWindow);
|
// Q_UNUSED(mainWindow);
|
||||||
|
|
||||||
QVBoxLayout *top = new QVBoxLayout;
|
QVBoxLayout *top = new QVBoxLayout;
|
||||||
top->setSpacing(0);
|
top->setSpacing(0);
|
||||||
@ -344,7 +342,7 @@ void ConnectionManager::devChanged(IConnection *connection)
|
|||||||
|
|
||||||
//and add them back in the list
|
//and add them back in the list
|
||||||
QList <IConnection::device> availableDev = connection->availableDevices();
|
QList <IConnection::device> availableDev = connection->availableDevices();
|
||||||
foreach (IConnection::device dev, availableDev)
|
foreach (IConnection::device dev, availableDev)
|
||||||
{
|
{
|
||||||
QString cbName = connection->shortName() + ": " + dev.name;
|
QString cbName = connection->shortName() + ": " + dev.name;
|
||||||
QString disp = connection->shortName() + " : " + dev.displayName;
|
QString disp = connection->shortName() + " : " + dev.displayName;
|
||||||
@ -352,11 +350,26 @@ void ConnectionManager::devChanged(IConnection *connection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//add all the list again to the combobox
|
//add all the list again to the combobox
|
||||||
foreach (devListItem d, m_devList)
|
foreach (devListItem d, m_devList)
|
||||||
{
|
{
|
||||||
m_availableDevList->addItem(d.displayName);
|
m_availableDevList->addItem(d.displayName);
|
||||||
m_availableDevList->setItemData(m_availableDevList->count()-1,(const QString)d.devName,Qt::ToolTipRole);
|
m_availableDevList->setItemData(m_availableDevList->count()-1,(const QString)d.devName,Qt::ToolTipRole);
|
||||||
|
if(!m_ioDev && m_mainWindow->generalSettings()->autoConnect() && d.displayName.startsWith("USB"))
|
||||||
|
{
|
||||||
|
qDebug()<<"INSERTION"<<d.displayName;
|
||||||
|
m_availableDevList->setCurrentIndex(m_availableDevList->count()-1);
|
||||||
|
connectDevice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(m_ioDev)//if a device is connected make it the one selected on the dropbox
|
||||||
|
{
|
||||||
|
for(int x=0;x<m_availableDevList->count();++x)
|
||||||
|
{
|
||||||
|
if(m_connectionDevice.devName==m_availableDevList->itemData(x,Qt::ToolTipRole).toString())
|
||||||
|
m_availableDevList->setCurrentIndex(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//disable connection button if the liNameif (m_availableDevList->count() > 0)
|
//disable connection button if the liNameif (m_availableDevList->count() > 0)
|
||||||
if (m_availableDevList->count() > 0)
|
if (m_availableDevList->count() > 0)
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
#define CONNECTIONMANAGER_H
|
#define CONNECTIONMANAGER_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "generalsettings.h"
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
#include <QtCore/QIODevice>
|
#include <QtCore/QIODevice>
|
||||||
#include <QtCore/QLinkedList>
|
#include <QtCore/QLinkedList>
|
||||||
@ -108,6 +109,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool connectDevice();
|
bool connectDevice();
|
||||||
|
Internal::MainWindow *m_mainWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ using namespace Core::Internal;
|
|||||||
|
|
||||||
GeneralSettings::GeneralSettings():
|
GeneralSettings::GeneralSettings():
|
||||||
m_dialog(0),
|
m_dialog(0),
|
||||||
m_saveSettingsOnExit(true)
|
m_saveSettingsOnExit(true),
|
||||||
|
m_autoConnect(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
|
|||||||
|
|
||||||
fillLanguageBox();
|
fillLanguageBox();
|
||||||
m_page->checkBoxSaveOnExit->setChecked(m_saveSettingsOnExit);
|
m_page->checkBoxSaveOnExit->setChecked(m_saveSettingsOnExit);
|
||||||
|
m_page->checkAutoConnect->setChecked(m_autoConnect);
|
||||||
m_page->colorButton->setColor(StyleHelper::baseColor());
|
m_page->colorButton->setColor(StyleHelper::baseColor());
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings()));
|
m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings()));
|
||||||
@ -146,6 +147,7 @@ void GeneralSettings::apply()
|
|||||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||||
|
|
||||||
m_saveSettingsOnExit = m_page->checkBoxSaveOnExit->isChecked();
|
m_saveSettingsOnExit = m_page->checkBoxSaveOnExit->isChecked();
|
||||||
|
m_autoConnect = m_page->checkAutoConnect->isChecked();
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(),
|
ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(),
|
||||||
m_page->terminalEdit->text());
|
m_page->terminalEdit->text());
|
||||||
@ -163,6 +165,7 @@ void GeneralSettings::readSettings(QSettings* qs)
|
|||||||
qs->beginGroup(QLatin1String("General"));
|
qs->beginGroup(QLatin1String("General"));
|
||||||
m_language = qs->value(QLatin1String("OverrideLanguage"),QLocale::system().name()).toString();
|
m_language = qs->value(QLatin1String("OverrideLanguage"),QLocale::system().name()).toString();
|
||||||
m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"),m_saveSettingsOnExit).toBool();
|
m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"),m_saveSettingsOnExit).toBool();
|
||||||
|
m_autoConnect = qs->value(QLatin1String("AutoConnect"),m_autoConnect).toBool();
|
||||||
qs->endGroup();
|
qs->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -177,6 +180,7 @@ void GeneralSettings::saveSettings(QSettings* qs)
|
|||||||
qs->setValue(QLatin1String("OverrideLanguage"), m_language);
|
qs->setValue(QLatin1String("OverrideLanguage"), m_language);
|
||||||
|
|
||||||
qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
|
qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
|
||||||
|
qs->setValue(QLatin1String("AutoConnect"), m_autoConnect);
|
||||||
qs->endGroup();
|
qs->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,3 +245,8 @@ bool GeneralSettings::saveSettingsOnExit() const
|
|||||||
{
|
{
|
||||||
return m_saveSettingsOnExit;
|
return m_saveSettingsOnExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GeneralSettings::autoConnect() const
|
||||||
|
{
|
||||||
|
return m_autoConnect;
|
||||||
|
}
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
void finish();
|
void finish();
|
||||||
bool saveSettingsOnExit() const;
|
bool saveSettingsOnExit() const;
|
||||||
|
bool autoConnect() const;
|
||||||
void readSettings(QSettings* qs);
|
void readSettings(QSettings* qs);
|
||||||
void saveSettings(QSettings* qs);
|
void saveSettings(QSettings* qs);
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ private:
|
|||||||
Ui::GeneralSettings *m_page;
|
Ui::GeneralSettings *m_page;
|
||||||
QString m_language;
|
QString m_language;
|
||||||
bool m_saveSettingsOnExit;
|
bool m_saveSettingsOnExit;
|
||||||
|
bool m_autoConnect;
|
||||||
QPointer<QWidget> m_dialog;
|
QPointer<QWidget> m_dialog;
|
||||||
QList<QTextCodec *> m_codecs;
|
QList<QTextCodec *> m_codecs;
|
||||||
|
|
||||||
|
@ -241,6 +241,23 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="12" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>AutoConnect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="1">
|
||||||
|
<widget class="QCheckBox" name="checkAutoConnect">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -873,6 +873,11 @@ MimeDatabase *MainWindow::mimeDatabase() const
|
|||||||
return m_mimeDatabase;
|
return m_mimeDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeneralSettings * MainWindow::generalSettings() const
|
||||||
|
{
|
||||||
|
return m_generalSettings;
|
||||||
|
}
|
||||||
|
|
||||||
IContext *MainWindow::contextObject(QWidget *widget)
|
IContext *MainWindow::contextObject(QWidget *widget)
|
||||||
{
|
{
|
||||||
return m_contextWidgets.value(widget);
|
return m_contextWidgets.value(widget);
|
||||||
|
@ -111,7 +111,7 @@ public:
|
|||||||
Core::ThreadManager *threadManager() const;
|
Core::ThreadManager *threadManager() const;
|
||||||
Core::ModeManager *modeManager() const;
|
Core::ModeManager *modeManager() const;
|
||||||
Core::MimeDatabase *mimeDatabase() const;
|
Core::MimeDatabase *mimeDatabase() const;
|
||||||
|
Internal::GeneralSettings *generalSettings() const;
|
||||||
QSettings *settings(QSettings::Scope scope) const;
|
QSettings *settings(QSettings::Scope scope) const;
|
||||||
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
|
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
|
||||||
IContext * currentContextObject() const;
|
IContext * currentContextObject() const;
|
||||||
|
@ -177,6 +177,7 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G
|
|||||||
info.devicePath=deviceID;
|
info.devicePath=deviceID;
|
||||||
if( wParam == DBT_DEVICEARRIVAL )
|
if( wParam == DBT_DEVICEARRIVAL )
|
||||||
{
|
{
|
||||||
|
qDebug()<<"INSERTION";
|
||||||
if(infoFromHandle(guid,info,devInfo,i)==0)
|
if(infoFromHandle(guid,info,devInfo,i)==0)
|
||||||
break;
|
break;
|
||||||
knowndevices.append(info);
|
knowndevices.append(info);
|
||||||
@ -186,18 +187,21 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G
|
|||||||
}
|
}
|
||||||
else if( wParam == DBT_DEVICEREMOVECOMPLETE )
|
else if( wParam == DBT_DEVICEREMOVECOMPLETE )
|
||||||
{
|
{
|
||||||
|
bool found=false;
|
||||||
for(int x=0;x<knowndevices.count();++x)
|
for(int x=0;x<knowndevices.count();++x)
|
||||||
{
|
{
|
||||||
if(knowndevices[x].devicePath==deviceID)
|
if(knowndevices[x].devicePath==deviceID)
|
||||||
{
|
{
|
||||||
emit deviceRemoved(knowndevices[x]);
|
USBPortInfo temp=knowndevices.at(x);
|
||||||
//qDebug()<<"REMOVED"<<knowndevices[x].product;
|
emit deviceRemoved(temp);
|
||||||
knowndevices.removeAt(x);
|
found=true;
|
||||||
|
qDebug()<<"REMOVED"<<temp.product;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit deviceRemoved(info);
|
if(!found)
|
||||||
|
emit deviceRemoved(info);
|
||||||
|
qDebug()<<"REMOVED2";
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -224,7 +225,7 @@ UAVObjectField* UAVObject::getField(const QString& name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If this point is reached then the field was not found
|
// If this point is reached then the field was not found
|
||||||
Q_ASSERT_X(0,"UAVObject::getField",QString("Non existant field " + name + " requested. This indicates a bug. Make sure you also have null checking for non-debug code.").toAscii());
|
qWarning()<<"UAVObject::getField Non existant field "<<name<<" requested. This indicates a bug. Make sure you also have null checking for non-debug code.";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,9 +556,9 @@ UploaderGadgetWidget::~UploaderGadgetWidget()
|
|||||||
delete qw;
|
delete qw;
|
||||||
}
|
}
|
||||||
if (pd)
|
if (pd)
|
||||||
delete pd;
|
pd->deleteLater();;
|
||||||
if (t)
|
if (t)
|
||||||
delete t;
|
t->deleteLater();;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user