1
0
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:
zedamota 2011-05-31 15:29:53 +01:00
parent 7f5c9b6c43
commit 1ffc0e3d56
10 changed files with 72 additions and 19 deletions

View File

@ -36,15 +36,13 @@
#include "fancytabwidget.h"
#include "fancyactionbar.h"
#include "mainwindow.h"
#include "qextserialport/src/qextserialenumerator.h"
#include "qextserialport/src/qextserialport.h"
#include <QDebug>
#include <QLabel>
#include <QHBoxLayout>
#include <QComboBox>
#include <QTimer>
namespace Core {
@ -52,9 +50,9 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, Internal:
QWidget(mainWindow), // Pip
m_availableDevList(0),
m_connectBtn(0),
m_ioDev(NULL)
m_ioDev(NULL),m_mainWindow(mainWindow)
{
Q_UNUSED(mainWindow);
// Q_UNUSED(mainWindow);
QVBoxLayout *top = new QVBoxLayout;
top->setSpacing(0);
@ -344,7 +342,7 @@ void ConnectionManager::devChanged(IConnection *connection)
//and add them back in the list
QList <IConnection::device> availableDev = connection->availableDevices();
foreach (IConnection::device dev, availableDev)
foreach (IConnection::device dev, availableDev)
{
QString cbName = connection->shortName() + ": " + dev.name;
QString disp = connection->shortName() + " : " + dev.displayName;
@ -352,11 +350,26 @@ void ConnectionManager::devChanged(IConnection *connection)
}
//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->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)
if (m_availableDevList->count() > 0)

View File

@ -30,7 +30,8 @@
#define CONNECTIONMANAGER_H
#include <QWidget>
#include "mainwindow.h"
#include "generalsettings.h"
#include <QtCore/QVector>
#include <QtCore/QIODevice>
#include <QtCore/QLinkedList>
@ -108,6 +109,7 @@ protected:
private:
bool connectDevice();
Internal::MainWindow *m_mainWindow;
};

View File

@ -45,7 +45,8 @@ using namespace Core::Internal;
GeneralSettings::GeneralSettings():
m_dialog(0),
m_saveSettingsOnExit(true)
m_saveSettingsOnExit(true),
m_autoConnect(true)
{
}
@ -114,7 +115,7 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
fillLanguageBox();
m_page->checkBoxSaveOnExit->setChecked(m_saveSettingsOnExit);
m_page->checkAutoConnect->setChecked(m_autoConnect);
m_page->colorButton->setColor(StyleHelper::baseColor());
#ifdef Q_OS_UNIX
m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings()));
@ -146,6 +147,7 @@ void GeneralSettings::apply()
StyleHelper::setBaseColor(m_page->colorButton->color());
m_saveSettingsOnExit = m_page->checkBoxSaveOnExit->isChecked();
m_autoConnect = m_page->checkAutoConnect->isChecked();
#ifdef Q_OS_UNIX
ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(),
m_page->terminalEdit->text());
@ -163,6 +165,7 @@ void GeneralSettings::readSettings(QSettings* qs)
qs->beginGroup(QLatin1String("General"));
m_language = qs->value(QLatin1String("OverrideLanguage"),QLocale::system().name()).toString();
m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"),m_saveSettingsOnExit).toBool();
m_autoConnect = qs->value(QLatin1String("AutoConnect"),m_autoConnect).toBool();
qs->endGroup();
}
@ -177,6 +180,7 @@ void GeneralSettings::saveSettings(QSettings* qs)
qs->setValue(QLatin1String("OverrideLanguage"), m_language);
qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit);
qs->setValue(QLatin1String("AutoConnect"), m_autoConnect);
qs->endGroup();
}
@ -241,3 +245,8 @@ bool GeneralSettings::saveSettingsOnExit() const
{
return m_saveSettingsOnExit;
}
bool GeneralSettings::autoConnect() const
{
return m_autoConnect;
}

View File

@ -56,6 +56,7 @@ public:
void apply();
void finish();
bool saveSettingsOnExit() const;
bool autoConnect() const;
void readSettings(QSettings* qs);
void saveSettings(QSettings* qs);
@ -75,6 +76,7 @@ private:
Ui::GeneralSettings *m_page;
QString m_language;
bool m_saveSettingsOnExit;
bool m_autoConnect;
QPointer<QWidget> m_dialog;
QList<QTextCodec *> m_codecs;

View File

@ -241,6 +241,23 @@
</property>
</widget>
</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>
</widget>
</item>

View File

@ -873,6 +873,11 @@ MimeDatabase *MainWindow::mimeDatabase() const
return m_mimeDatabase;
}
GeneralSettings * MainWindow::generalSettings() const
{
return m_generalSettings;
}
IContext *MainWindow::contextObject(QWidget *widget)
{
return m_contextWidgets.value(widget);

View File

@ -111,7 +111,7 @@ public:
Core::ThreadManager *threadManager() const;
Core::ModeManager *modeManager() const;
Core::MimeDatabase *mimeDatabase() const;
Internal::GeneralSettings *generalSettings() const;
QSettings *settings(QSettings::Scope scope) const;
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
IContext * currentContextObject() const;

View File

@ -177,6 +177,7 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G
info.devicePath=deviceID;
if( wParam == DBT_DEVICEARRIVAL )
{
qDebug()<<"INSERTION";
if(infoFromHandle(guid,info,devInfo,i)==0)
break;
knowndevices.append(info);
@ -186,18 +187,21 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G
}
else if( wParam == DBT_DEVICEREMOVECOMPLETE )
{
bool found=false;
for(int x=0;x<knowndevices.count();++x)
{
if(knowndevices[x].devicePath==deviceID)
{
emit deviceRemoved(knowndevices[x]);
//qDebug()<<"REMOVED"<<knowndevices[x].product;
knowndevices.removeAt(x);
USBPortInfo temp=knowndevices.at(x);
emit deviceRemoved(temp);
found=true;
qDebug()<<"REMOVED"<<temp.product;
break;
}
}
emit deviceRemoved(info);
if(!found)
emit deviceRemoved(info);
qDebug()<<"REMOVED2";
}
break;

View File

@ -27,6 +27,7 @@
*/
#include "uavobject.h"
#include <QtEndian>
#include <QDebug>
/**
* Constructor
@ -224,7 +225,7 @@ UAVObjectField* UAVObject::getField(const QString& name)
}
}
// 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;
}

View File

@ -556,9 +556,9 @@ UploaderGadgetWidget::~UploaderGadgetWidget()
delete qw;
}
if (pd)
delete pd;
pd->deleteLater();;
if (t)
delete t;
t->deleteLater();;
}