-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBluetooth.cxx
More file actions
91 lines (68 loc) · 2.37 KB
/
Bluetooth.cxx
File metadata and controls
91 lines (68 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
This file is part of liquidshell.
SPDX-FileCopyrightText: 2017 - 2024 Martin Koller <martin@kollix.at>
SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <Bluetooth.hxx>
#include <QIcon>
#include <BluezQt/Adapter>
#include <BluezQt/InitManagerJob>
#include <KLocalizedString>
#include <KIconLoader>
#include <KPluginMetaData>
//--------------------------------------------------------------------------------
Bluetooth::Bluetooth(QWidget *parent)
: SysTrayItem(parent)
{
manager = new BluezQt::Manager(this);
job = manager->init();
job->start();
connect(job, &BluezQt::InitManagerJob::result, this, &Bluetooth::changed);
connect(manager, &BluezQt::Manager::adapterAdded, this, &Bluetooth::changed);
connect(manager, &BluezQt::Manager::adapterRemoved, this, &Bluetooth::changed);
connect(manager, &BluezQt::Manager::allAdaptersRemoved, this, &Bluetooth::changed);
connect(manager, &BluezQt::Manager::bluetoothOperationalChanged, this, &Bluetooth::changed);
connect(manager, &BluezQt::Manager::operationalChanged, this, &Bluetooth::changed);
connect(KIconLoader::global(), &KIconLoader::iconLoaderSettingsChanged, this, &Bluetooth::changed);
}
//--------------------------------------------------------------------------------
Bluetooth::~Bluetooth()
{
if ( job )
job->kill();
}
//--------------------------------------------------------------------------------
void Bluetooth::changed()
{
job = nullptr;
if ( manager->adapters().isEmpty() || !manager->isOperational() )
{
hide(); // no BT
return;
}
show();
if ( manager->isBluetoothOperational() )
{
setPixmap(QIcon::fromTheme("preferences-system-bluetooth.png").pixmap(size()));
setToolTip(i18n("Bluetooth is operational"));
}
else
{
setPixmap(QIcon::fromTheme("preferences-system-bluetooth-inactive.png").pixmap(size()));
setToolTip(i18n("Bluetooth is not operational"));
}
}
//--------------------------------------------------------------------------------
QWidget *Bluetooth::getDetailsList()
{
if ( !dialog )
{
dialog = new KCMultiDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->addModule(KPluginMetaData("plasma/kcms/systemsettings/kcm_bluetooth"));
dialog->adjustSize();
dialog->setWindowTitle(i18n("Bluetooth"));
}
return dialog;
}
//--------------------------------------------------------------------------------