forked from qt-creator/qt-creator
Add some listing of serial devices with friendly names.
This doesn't update at all yet, so you'll need to recreate the run configuration or restart creator.
This commit is contained in:
@@ -8,14 +8,16 @@ SUPPORT_QT_S60 = $$(QTCREATOR_WITH_S60)
|
|||||||
$$PWD/winscwtoolchain.cpp \
|
$$PWD/winscwtoolchain.cpp \
|
||||||
$$PWD/gccetoolchain.cpp \
|
$$PWD/gccetoolchain.cpp \
|
||||||
$$PWD/s60emulatorrunconfiguration.cpp \
|
$$PWD/s60emulatorrunconfiguration.cpp \
|
||||||
$$PWD/s60devicerunconfiguration.cpp
|
$$PWD/s60devicerunconfiguration.cpp \
|
||||||
|
$$PWD/serialdevicelister.cpp
|
||||||
HEADERS += $$PWD/s60devices.h \
|
HEADERS += $$PWD/s60devices.h \
|
||||||
$$PWD/s60devicespreferencepane.h \
|
$$PWD/s60devicespreferencepane.h \
|
||||||
$$PWD/s60manager.h \
|
$$PWD/s60manager.h \
|
||||||
$$PWD/winscwtoolchain.h \
|
$$PWD/winscwtoolchain.h \
|
||||||
$$PWD/gccetoolchain.h \
|
$$PWD/gccetoolchain.h \
|
||||||
$$PWD/s60emulatorrunconfiguration.h \
|
$$PWD/s60emulatorrunconfiguration.h \
|
||||||
$$PWD/s60devicerunconfiguration.h
|
$$PWD/s60devicerunconfiguration.h \
|
||||||
|
$$PWD/serialdevicelister.h
|
||||||
FORMS += $$PWD/s60devicespreferencepane.ui
|
FORMS += $$PWD/s60devicespreferencepane.ui
|
||||||
OTHER_FILES += $$PWD/qt-s60-todo.txt
|
OTHER_FILES += $$PWD/qt-s60-todo.txt
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "profilereader.h"
|
#include "profilereader.h"
|
||||||
#include "s60manager.h"
|
#include "s60manager.h"
|
||||||
#include "s60devices.h"
|
#include "s60devices.h"
|
||||||
|
#include "serialdevicelister.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
@@ -264,11 +265,20 @@ S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget(S60DeviceRunCon
|
|||||||
m_sisxFileLabel = new QLabel(m_runConfiguration->basePackageFilePath() + ".sisx");
|
m_sisxFileLabel = new QLabel(m_runConfiguration->basePackageFilePath() + ".sisx");
|
||||||
formLayout->addRow(tr("Install File:"), m_sisxFileLabel);
|
formLayout->addRow(tr("Install File:"), m_sisxFileLabel);
|
||||||
|
|
||||||
QComboBox *serialPorts = new QComboBox;
|
QString runConfigurationPortName = m_runConfiguration->serialPortName();
|
||||||
serialPorts->addItems(QStringList() << "COM1" << "COM2" << "COM3" << "COM4" << "COM5" << "COM6" << "COM7" << "COM8" << "COM9");
|
QList<SerialDeviceLister::SerialDevice> serialDevices = SerialDeviceLister().serialDevices();
|
||||||
serialPorts->setCurrentIndex(m_runConfiguration->serialPortName().mid(3).toInt()-1);
|
m_serialPorts = new QComboBox;
|
||||||
connect(serialPorts, SIGNAL(activated(QString)), this, SLOT(setSerialPort(QString)));
|
for (int i = 0; i < serialDevices.size(); ++i) {
|
||||||
formLayout->addRow(tr("Device on Serial Port:"), serialPorts);
|
const SerialDeviceLister::SerialDevice &device = serialDevices.at(i);
|
||||||
|
m_serialPorts->addItem(device.friendlyName, device.portName);
|
||||||
|
if (device.portName == runConfigurationPortName)
|
||||||
|
m_serialPorts->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
QString selectedPortName = m_serialPorts->itemData(m_serialPorts->currentIndex()).toString();
|
||||||
|
if (m_serialPorts->count() > 0 && runConfigurationPortName != selectedPortName)
|
||||||
|
m_runConfiguration->setSerialPortName(selectedPortName);
|
||||||
|
connect(m_serialPorts, SIGNAL(activated(int)), this, SLOT(setSerialPort(int)));
|
||||||
|
formLayout->addRow(tr("Device on Serial Port:"), m_serialPorts);
|
||||||
|
|
||||||
QWidget *signatureWidget = new QWidget();
|
QWidget *signatureWidget = new QWidget();
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
@@ -331,9 +341,9 @@ void S60DeviceRunConfigurationWidget::updateTargetInformation()
|
|||||||
m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + ".sisx");
|
m_sisxFileLabel->setText(m_runConfiguration->basePackageFilePath() + ".sisx");
|
||||||
}
|
}
|
||||||
|
|
||||||
void S60DeviceRunConfigurationWidget::setSerialPort(const QString &portName)
|
void S60DeviceRunConfigurationWidget::setSerialPort(int index)
|
||||||
{
|
{
|
||||||
m_runConfiguration->setSerialPortName(portName.trimmed());
|
m_runConfiguration->setSerialPortName(m_serialPorts->itemData(index).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle)
|
void S60DeviceRunConfigurationWidget::selfSignToggled(bool toggle)
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QLineEdit>
|
#include <QtGui/QLineEdit>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -100,7 +101,7 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void nameEdited(const QString &text);
|
void nameEdited(const QString &text);
|
||||||
void updateTargetInformation();
|
void updateTargetInformation();
|
||||||
void setSerialPort(const QString &portName);
|
void setSerialPort(int index);
|
||||||
void selfSignToggled(bool toggle);
|
void selfSignToggled(bool toggle);
|
||||||
void customSignatureToggled(bool toggle);
|
void customSignatureToggled(bool toggle);
|
||||||
void signaturePathChanged(const QString &path);
|
void signaturePathChanged(const QString &path);
|
||||||
@@ -108,6 +109,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
S60DeviceRunConfiguration *m_runConfiguration;
|
S60DeviceRunConfiguration *m_runConfiguration;
|
||||||
|
QComboBox *m_serialPorts;
|
||||||
QLineEdit *m_nameLineEdit;
|
QLineEdit *m_nameLineEdit;
|
||||||
QLabel *m_sisxFileLabel;
|
QLabel *m_sisxFileLabel;
|
||||||
};
|
};
|
||||||
|
63
src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp
Normal file
63
src/plugins/qt4projectmanager/qt-s60/serialdevicelister.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://www.qtsoftware.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "serialdevicelister.h"
|
||||||
|
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
using namespace Qt4ProjectManager::Internal;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const char * const REGKEY_CURRENT_CONTROL_SET = "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet";
|
||||||
|
const char * const USBSER = "Services/usbser/Enum";
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialDeviceLister::SerialDeviceLister()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<SerialDeviceLister::SerialDevice> SerialDeviceLister::serialDevices() const
|
||||||
|
{
|
||||||
|
QList<SerialDeviceLister::SerialDevice> devices;
|
||||||
|
QSettings registry(REGKEY_CURRENT_CONTROL_SET, QSettings::NativeFormat);
|
||||||
|
int count = registry.value(QString::fromLatin1("%1/Count").arg(USBSER)).toInt();
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
QString driver = registry.value(QString::fromLatin1("%1/%2").arg(USBSER).arg(i)).toString();
|
||||||
|
if (driver.contains("JAVACOMM")) {
|
||||||
|
driver.replace('\\', '/');
|
||||||
|
SerialDeviceLister::SerialDevice device;
|
||||||
|
device.friendlyName = registry.value(QString::fromLatin1("Enum/%1/FriendlyName").arg(driver)).toString();
|
||||||
|
device.portName = registry.value(QString::fromLatin1("Enum/%1/Device Parameters/PortName").arg(driver)).toString();
|
||||||
|
devices.append(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
57
src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h
Normal file
57
src/plugins/qt4projectmanager/qt-s60/serialdevicelister.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://www.qtsoftware.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SERIALDEVICELISTER_H
|
||||||
|
#define SERIALDEVICELISTER_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class SerialDeviceLister : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
struct SerialDevice {
|
||||||
|
QString portName;
|
||||||
|
QString friendlyName;
|
||||||
|
};
|
||||||
|
|
||||||
|
SerialDeviceLister();
|
||||||
|
QList<SerialDevice> serialDevices() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Qt4ProjectManager
|
||||||
|
|
||||||
|
#endif // SERIALDEVICELISTER_H
|
Reference in New Issue
Block a user