mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
Minor UI updates
This commit is contained in:
parent
4034ed39c4
commit
a0b8dfcfc1
@ -80,6 +80,7 @@ Control {
|
||||
opacity: enabled ? 1 : 0.5
|
||||
icon.color: Cpp_ThemeManager.text
|
||||
icon.source: "qrc:/icons/refresh.svg"
|
||||
enabled: !Cpp_IO_Bluetooth.isScanning
|
||||
onClicked: Cpp_IO_Bluetooth.beginScanning()
|
||||
}
|
||||
}
|
||||
@ -114,6 +115,7 @@ Control {
|
||||
//
|
||||
RowLayout {
|
||||
spacing: app.spacing
|
||||
visible: _deviceCombo.currentIndex >= 1
|
||||
|
||||
Label {
|
||||
id: rssiLabel
|
||||
@ -163,6 +165,30 @@ Control {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Not at BLE device warning
|
||||
//
|
||||
RowLayout {
|
||||
spacing: app.spacing
|
||||
visible: opacity > 0
|
||||
opacity: Cpp_IO_Bluetooth.isScanning ? 1 : 0
|
||||
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
|
||||
BusyIndicator {
|
||||
width: 16
|
||||
height: 16
|
||||
Layout.minimumWidth: 16
|
||||
Layout.minimumHeight: 16
|
||||
running: Cpp_IO_Bluetooth.isScanning
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Scanning....")
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Spacer
|
||||
//
|
||||
|
@ -32,6 +32,12 @@ IO::DataSources::Bluetooth::Bluetooth()
|
||||
&IO::DataSources::Bluetooth::deviceUpdated);
|
||||
connect(&m_discovery, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this,
|
||||
&IO::DataSources::Bluetooth::deviceDiscovered);
|
||||
connect(&m_discovery, &QBluetoothDeviceDiscoveryAgent::canceled, this,
|
||||
&IO::DataSources::Bluetooth::scanningChanged);
|
||||
connect(&m_discovery, &QBluetoothDeviceDiscoveryAgent::finished, this,
|
||||
&IO::DataSources::Bluetooth::scanningChanged);
|
||||
connect(&m_discovery, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this,
|
||||
SLOT(onErrorOcurred(QBluetoothDeviceDiscoveryAgent::Error)));
|
||||
|
||||
// Start the device discovery process
|
||||
QTimer::singleShot(1000, this, &IO::DataSources::Bluetooth::beginScanning);
|
||||
@ -67,6 +73,15 @@ bool IO::DataSources::Bluetooth::supported() const
|
||||
return m_supported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns @c true if the bluetooth discovery service is searching
|
||||
* for devices
|
||||
*/
|
||||
bool IO::DataSources::Bluetooth::isScanning() const
|
||||
{
|
||||
return m_discovery.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the currently selected device
|
||||
*/
|
||||
@ -113,6 +128,7 @@ void IO::DataSources::Bluetooth::beginScanning()
|
||||
// Update UI
|
||||
Q_EMIT rssiChanged();
|
||||
Q_EMIT devicesChanged();
|
||||
Q_EMIT scanningChanged();
|
||||
Q_EMIT servicesChanged();
|
||||
Q_EMIT supportedChanged();
|
||||
Q_EMIT currentDeviceChanged();
|
||||
@ -226,6 +242,15 @@ void IO::DataSources::Bluetooth::deviceUpdated(const QBluetoothDeviceInfo &info,
|
||||
refreshDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the device discovery error that have occurred
|
||||
*/
|
||||
void IO::DataSources::Bluetooth::onErrorOcurred(
|
||||
QBluetoothDeviceDiscoveryAgent::Error error)
|
||||
{
|
||||
qDebug() << error << m_discovery.errorString();
|
||||
}
|
||||
|
||||
#ifdef SERIAL_STUDIO_INCLUDE_MOC
|
||||
# include "moc_Bluetooth.cpp"
|
||||
#endif
|
||||
|
@ -58,11 +58,15 @@ class Bluetooth : public QObject
|
||||
Q_PROPERTY(bool supported
|
||||
READ supported
|
||||
NOTIFY supportedChanged)
|
||||
Q_PROPERTY(bool isScanning
|
||||
READ isScanning
|
||||
NOTIFY scanningChanged)
|
||||
// clang-format on
|
||||
|
||||
Q_SIGNALS:
|
||||
void rssiChanged();
|
||||
void devicesChanged();
|
||||
void scanningChanged();
|
||||
void servicesChanged();
|
||||
void supportedChanged();
|
||||
void currentDeviceChanged();
|
||||
@ -81,6 +85,7 @@ public:
|
||||
|
||||
QString rssi() const;
|
||||
bool supported() const;
|
||||
bool isScanning() const;
|
||||
int currentDevice() const;
|
||||
QStringList devices() const;
|
||||
QStringList services() const;
|
||||
@ -94,6 +99,7 @@ private Q_SLOTS:
|
||||
void deviceDiscovered(const QBluetoothDeviceInfo &info);
|
||||
void deviceUpdated(const QBluetoothDeviceInfo &info,
|
||||
QBluetoothDeviceInfo::Fields updatedFields);
|
||||
void onErrorOcurred(QBluetoothDeviceDiscoveryAgent::Error error);
|
||||
|
||||
private:
|
||||
QString m_rssi;
|
||||
|
Loading…
x
Reference in New Issue
Block a user