This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
mumblepahelper.cpp
228 lines (194 loc) · 6.67 KB
/
mumblepahelper.cpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// Copyright 2005-2018 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "mumblepahelper.h"
#include "ui_mumblepahelper.h"
MumblePAHelper::MumblePAHelper(QWidget *parent) :
QMainWindow(parent) {
plugins = new Plugins(this);
plugins->setObjectName(QString::fromUtf8("plugins"));
setupUi(this);
installEventFilter(this);
QMainWindow::statusBar()->showMessage(tr("Not linked to plugin"));
plugins->rescanPlugins();
}
MumblePAHelper::~MumblePAHelper() {
if (plugins)
delete plugins;
}
// We use an event filter to prevent the status bar message
// from being cleared when moving the cursor over a menu option.
// This happens because the menu sends a signal to the status bar
// containing the option's tip, which is empty.
bool MumblePAHelper::eventFilter(QObject *object, QEvent *event) {
if (event->type() == QEvent::StatusTip) {
return true;
} else {
return QObject::eventFilter(object, event);
}
}
void MumblePAHelper::on_plugins_Fetched() {
QReadLocker lock(&plugins->qrwlPlugins);
// Output avatar posititon
qdsbAPX->setValue(plugins->fPosition[0]);
qdsbAPY->setValue(plugins->fPosition[1]);
qdsbAPZ->setValue(plugins->fPosition[2]);
qdsbAFX->setValue(plugins->fFront[0]);
qdsbAFY->setValue(plugins->fFront[1]);
qdsbAFZ->setValue(plugins->fFront[2]);
qdsbATX->setValue(plugins->fTop[0]);
qdsbATY->setValue(plugins->fTop[1]);
qdsbATZ->setValue(plugins->fTop[2]);
// Output camera position
qdsbCPX->setValue(plugins->fCameraPosition[0]);
qdsbCPY->setValue(plugins->fCameraPosition[1]);
qdsbCPZ->setValue(plugins->fCameraPosition[2]);
qdsbCFX->setValue(plugins->fCameraFront[0]);
qdsbCFY->setValue(plugins->fCameraFront[1]);
qdsbCFZ->setValue(plugins->fCameraFront[2]);
qdsbCTX->setValue(plugins->fCameraTop[0]);
qdsbCTY->setValue(plugins->fCameraTop[1]);
qdsbCTZ->setValue(plugins->fCameraTop[2]);
}
void MumblePAHelper::on_plugins_IdentityChanged(const QString identity) {
// Output identity
qpteIdentity->setPlainText(identity);
}
void MumblePAHelper::on_plugins_ContextChanged(const QString context) {
// Output context
qpteContext->setPlainText(context);
}
void MumblePAHelper::on_plugins_LinkLost(const PluginInfo *pi) {
QMainWindow::statusBar()->showMessage(tr("Lost link to plugin %1").arg(pi->shortname));
// Reset avatar posititon
qdsbAPX->setValue(0);
qdsbAPY->setValue(0);
qdsbAPZ->setValue(0);
qdsbAFX->setValue(0);
qdsbAFY->setValue(0);
qdsbAFZ->setValue(0);
qdsbATX->setValue(0);
qdsbATY->setValue(0);
qdsbATZ->setValue(0);
// Reset camera position
qdsbCPX->setValue(0);
qdsbCPY->setValue(0);
qdsbCPZ->setValue(0);
qdsbCFX->setValue(0);
qdsbCFY->setValue(0);
qdsbCFZ->setValue(0);
qdsbCTX->setValue(0);
qdsbCTY->setValue(0);
qdsbCTZ->setValue(0);
}
void MumblePAHelper::on_plugins_Linked(const PluginInfo *pi) {
QMainWindow::statusBar()->showMessage(tr("Linked to plugin %1").arg(pi->shortname));
}
void MumblePAHelper::on_plugins_PluginList(const QList<PluginInfo*> plist) {
qlwPlugins->clear();
qlPluginInfo->setText(tr("No plugin selected"));
QReadLocker lock(&plugins->qrwlPlugins);
foreach (PluginInfo *pi, plist) {
QListWidgetItem *item = new QListWidgetItem(pi->shortname);
item->setData(Qt::UserRole, pi->filename);
qlwPlugins->addItem(item);
}
}
void MumblePAHelper::on_qpbAbout_clicked(bool) {
QListWidgetItem *item = qlwPlugins->currentItem();
if (item) {
QString filename = item->data(Qt::UserRole).toString();
QReadLocker lock(&plugins->qrwlPlugins);
foreach (PluginInfo *pi, plugins->qlPlugins) {
if (pi->filename == filename) {
lock.unlock();
if (pi->p->about) {
pi->p->about(0);
} else {
QMessageBox::information(this, QLatin1String("MumblePAHelper"), tr("Plugin has no about function."), QMessageBox::Ok, QMessageBox::NoButton);
}
break;
}
}
}
}
void MumblePAHelper::on_qpbConfig_clicked(bool) {
QListWidgetItem *item = qlwPlugins->currentItem();
if (item) {
QString filename = item->data(Qt::UserRole).toString();
QReadLocker lock(&plugins->qrwlPlugins);
foreach (PluginInfo *pi, plugins->qlPlugins) {
if (pi->filename == filename) {
lock.unlock();
if (pi->p->config)
pi->p->config(0);
else {
QMessageBox::information(this, QLatin1String("MumblePAHelper"), tr("Plugin has no configure function."), QMessageBox::Ok, QMessageBox::NoButton);
}
break;
}
}
}
}
void MumblePAHelper::on_qlwPlugins_currentItemChanged(QListWidgetItem *item, QListWidgetItem*) {
if(item == NULL) {
qlPluginInfo->setText(tr("No plugin selected"));
return;
}
QString filename = item->data(Qt::UserRole).toString();
QReadLocker lock(&plugins->qrwlPlugins);
bool bFound = false;
foreach (PluginInfo *pi, plugins->qlPlugins) {
if (pi->filename == filename) {
qlPluginInfo->setText(tr("Filename: %1\nShortname: %2\nDescription: %3").arg(pi->filename, pi->shortname, pi->description));
bFound = true;
break;
}
if (!bFound){
qlPluginInfo->setText(tr("No plugin selected"));
}
}
}
void MumblePAHelper::on_action_Unlink_triggered(bool) {
plugins->bUnlink = true;
}
void MumblePAHelper::on_action_Quit_triggered(bool) {
close();
}
void MumblePAHelper::on_action_Rescan_triggered(bool) {
plugins->rescanPlugins();
}
void MumblePAHelper::on_action_SetSystemPluginsLocation_triggered(bool) {
QString systemPluginsLocation = QFileDialog::getExistingDirectory(this, tr("Set system plugins directory"), plugins->qsSystemPlugins, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (systemPluginsLocation != NULL)
plugins->qsSystemPlugins = systemPluginsLocation;
plugins->rescanPlugins();
}
void MumblePAHelper::on_action_SetUserPluginsLocation_triggered(bool) {
QString userPluginsLocation = QFileDialog::getExistingDirectory(this, tr("Set user plugins directory"), plugins->qsUserPlugins, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (userPluginsLocation != NULL)
plugins->qsUserPlugins = userPluginsLocation;
plugins->rescanPlugins();
}
void MumblePAHelper::on_qcbCurrentDirectoryPlugins_stateChanged() {
if (qcbCurrentDirectoryPlugins->isChecked())
plugins->bUseCurrentDirPlugins = true;
else
plugins->bUseCurrentDirPlugins = false;
plugins->rescanPlugins();
}
void MumblePAHelper::on_qcbSystemPlugins_stateChanged() {
if (qcbSystemPlugins->isChecked())
plugins->bUseSystemPlugins = true;
else
plugins->bUseSystemPlugins = false;
plugins->rescanPlugins();
}
void MumblePAHelper::on_qcbUserPlugins_stateChanged() {
if (qcbUserPlugins->isChecked())
plugins->bUseUserPlugins = true;
else
plugins->bUseUserPlugins = false;
plugins->rescanPlugins();
}