blob: 514b2d6d9324ed62a98247503403c7458bd65a34 (
plain)
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
|
// Copyright 2005-2021 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 "Tokens.h"
#include "Database.h"
#include "ServerHandler.h"
// We define a global macro called 'g'. This can lead to issues when included code uses 'g' as a type or parameter name
// (like protobuf 3.7 does). As such, for now, we have to make this our last include.
#include "Global.h"
Tokens::Tokens(QWidget *p) : QDialog(p) {
setupUi(this);
qlwTokens->setAccessibleName(tr("Tokens"));
qbaDigest = g.sh->qbaDigest;
QStringList tokens = g.db->getTokens(qbaDigest);
tokens.sort();
foreach (const QString &qs, tokens) {
QListWidgetItem *qlwi = new QListWidgetItem(qs);
qlwi->setFlags(qlwi->flags() | Qt::ItemIsEditable);
qlwTokens->addItem(qlwi);
}
}
void Tokens::accept() {
QStringList qsl;
QList< QListWidgetItem * > items = qlwTokens->findItems(QString(), Qt::MatchStartsWith);
foreach (QListWidgetItem *qlwi, items) {
const QString &text = qlwi->text().trimmed();
if (!text.isEmpty())
qsl << text;
}
g.db->setTokens(qbaDigest, qsl);
g.sh->setTokens(qsl);
QDialog::accept();
}
void Tokens::on_qpbAdd_clicked() {
QListWidgetItem *qlwi = new QListWidgetItem(tr("Empty Token"));
qlwi->setFlags(qlwi->flags() | Qt::ItemIsEditable);
qlwTokens->addItem(qlwi);
qlwTokens->editItem(qlwi);
}
void Tokens::on_qpbRemove_clicked() {
foreach (QListWidgetItem *qlwi, qlwTokens->selectedItems())
delete qlwi;
}
|