Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/dde-dock/bluetooth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE

install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)
install(FILES "resources/dcc-bluetooth.dci" DESTINATION share/dde-dock/icons/dcc-setting)

dtk_add_config_meta_files(APPID org.deepin.dde.tray-loader FILES ../configs/org.deepin.dde.dock.plugin.bluetooth.json)
30 changes: 27 additions & 3 deletions plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,33 @@
#include <DPaletteHelper>
#include <DGuiApplicationHelper>

#include <QBoxLayout>

Check warning on line 22 in plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QStandardItemModel>

Check warning on line 23 in plugins/dde-dock/bluetooth/componments/bluetoothadapteritem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStandardItemModel> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace {

constexpr int DefaultScanIntervalSeconds = 5;

int scanIntervalMs()
{
bool ok = false;
int seconds = DConfigHelper::instance()->getConfig(
"org.deepin.dde.tray-loader",
"org.deepin.dde.dock.plugin.bluetooth",
QString(),
"scanInterval",
DefaultScanIntervalSeconds).toInt(&ok);

// DConfig does not enforce a range, and QTimer treats 0 as "fire
// immediately", which would restart discovery as soon as it finishes.
if (!ok || seconds <= 0)
seconds = DefaultScanIntervalSeconds;

return seconds * 1000;
}

} // namespace

BluetoothDeviceItem::BluetoothDeviceItem(QStyle *style, const Device *device, PluginListView *parent)
: m_style(style)
, m_device(device)
Expand Down Expand Up @@ -404,9 +428,9 @@

void BluetoothAdapterItem::initConnect()
{
m_scanTimer->setInterval(DConfigHelper::instance()->getConfig("org.deepin.dde.dock", "org.deepin.dde.dock.plugin.bluetooth", "", "scanInterval", 5).toInt() * 1000);
DConfigHelper::instance()->bind("org.deepin.dde.dock", "org.deepin.dde.dock.plugin.bluetooth", "", this, "scanInterval", [this] (const QString&, const QVariant&, QObject*) {
m_scanTimer->setInterval(DConfigHelper::instance()->getConfig("org.deepin.dde.dock", "org.deepin.dde.dock.plugin.bluetooth", "", "scanInterval", 5).toInt() * 1000);
m_scanTimer->setInterval(scanIntervalMs());
DConfigHelper::instance()->bind("org.deepin.dde.tray-loader", "org.deepin.dde.dock.plugin.bluetooth", "", this, "scanInterval", [this] (const QString&, const QVariant&, QObject*) {
m_scanTimer->setInterval(scanIntervalMs());
});
connect(m_scanTimer, &QTimer::timeout, this, [this] {
if (isVisible())
Expand Down
Loading