mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-430 show serial port description as tooltip in connection drop down
This commit is contained in:
parent
365f0ca3ad
commit
4a6573db1e
@ -40,6 +40,30 @@
|
|||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
QString DevListItem::getConName() const
|
||||||
|
{
|
||||||
|
if (connection == NULL) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return connection->shortName() + ": " + device.displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DevListItem::getConDescription() const
|
||||||
|
{
|
||||||
|
if (connection == NULL) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString description = device.displayName;
|
||||||
|
if (!device.description.isEmpty()) {
|
||||||
|
description += " - " + device.description;
|
||||||
|
}
|
||||||
|
// truncate description if too long
|
||||||
|
if (description.length() > 50) {
|
||||||
|
description = description.left(50) + "...";
|
||||||
|
}
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) :
|
ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) :
|
||||||
QWidget(mainWindow),
|
QWidget(mainWindow),
|
||||||
m_availableDevList(0),
|
m_availableDevList(0),
|
||||||
@ -458,7 +482,7 @@ void ConnectionManager::updateConnectionDropdown()
|
|||||||
// 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.getConName());
|
m_availableDevList->addItem(d.getConName());
|
||||||
m_availableDevList->setItemData(m_availableDevList->count() - 1, d.getConName(), Qt::ToolTipRole);
|
m_availableDevList->setItemData(m_availableDevList->count() - 1, d.getConDescription(), Qt::ToolTipRole);
|
||||||
if (!m_ioDev && d.getConName().startsWith("USB")) {
|
if (!m_ioDev && d.getConName().startsWith("USB")) {
|
||||||
if (m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) {
|
if (m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) {
|
||||||
m_availableDevList->setCurrentIndex(m_availableDevList->count() - 1);
|
m_availableDevList->setCurrentIndex(m_availableDevList->count() - 1);
|
||||||
|
@ -49,20 +49,16 @@ namespace Internal {
|
|||||||
class MainWindow;
|
class MainWindow;
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
class DevListItem {
|
class CORE_EXPORT DevListItem {
|
||||||
public:
|
public:
|
||||||
DevListItem(IConnection *c, IConnection::device d) :
|
DevListItem(IConnection *c, IConnection::device d) :
|
||||||
connection(c), device(d) {}
|
connection(c), device(d) {}
|
||||||
|
|
||||||
DevListItem() : connection(NULL) {}
|
DevListItem() : connection(NULL) {}
|
||||||
|
|
||||||
QString getConName()
|
QString getConName() const;
|
||||||
{
|
|
||||||
if (connection == NULL) {
|
QString getConDescription() const;
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return connection->shortName() + ": " + device.displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const DevListItem &rhs)
|
bool operator==(const DevListItem &rhs)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
struct device {
|
struct device {
|
||||||
QString name;
|
QString name;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
|
QString description;
|
||||||
bool operator==(device i)
|
bool operator==(device i)
|
||||||
{
|
{
|
||||||
return this->name == i.name;
|
return this->name == i.name;
|
||||||
|
@ -145,9 +145,7 @@ QList <Core::IConnection::device> SerialConnection::availableDevices()
|
|||||||
|
|
||||||
d.name = port.portName();
|
d.name = port.portName();
|
||||||
d.displayName = port.portName();
|
d.displayName = port.portName();
|
||||||
if (!port.description().isEmpty()) {
|
d.description = port.description();
|
||||||
d.displayName += " - " + port.description();
|
|
||||||
}
|
|
||||||
|
|
||||||
list.append(d);
|
list.append(d);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user