summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-03-03 15:37:22 (GMT)
committerTobias Markmann <tm@ayena.de>2017-03-03 15:38:05 (GMT)
commit585e23d06c7754b4cdbf3cf0096fe5b4bba278d1 (patch)
tree288556fc8a89a71d8444f5a1b839dbe7da27f5a5 /Swift/QtUI
parentae0c4b8fe9a21f758f06461a52c3bb7a66be0c45 (diff)
downloadswift-585e23d06c7754b4cdbf3cf0096fe5b4bba278d1.zip
swift-585e23d06c7754b4cdbf3cf0096fe5b4bba278d1.tar.bz2
Allow pasting a newline separated list of JIDs in blocking dialog
Furthermore the dialog will alphabetically sort the list of blocked JIDs before showing it in the dialog. Test-Information: Tested on macOS 10.12.3 with Qt 5.7.1 that it sorts the list it receives from the server before presenting it in the UI. Successfully pasted a newline spereated list of JIDs in the dialog. Change-Id: I8fe6969821bccad0193180cee9433da43285aaef
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtBlockListEditorWindow.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/Swift/QtUI/QtBlockListEditorWindow.cpp b/Swift/QtUI/QtBlockListEditorWindow.cpp
index 30c939f..a6eca0e 100644
--- a/Swift/QtUI/QtBlockListEditorWindow.cpp
+++ b/Swift/QtUI/QtBlockListEditorWindow.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -14,6 +14,7 @@
#include <boost/bind.hpp>
+#include <QClipboard>
#include <QLineEdit>
#include <QMovie>
#include <QShortcut>
@@ -106,6 +107,25 @@ QtBlockListEditorWindow::QtBlockListEditorWindow() : QWidget(), ui(new Ui::QtBlo
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(freshBlockListTemplate) << "x");
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->blockListTreeWidget->addTopLevelItem(item);
+
+ // Allow pasting a newline seperated list of JIDs into the dialog.
+ auto pasteShortcut = new QShortcut(QKeySequence::Paste, this);
+ connect(pasteShortcut, &QShortcut::activated, [&](){
+ auto currentBlocklist = getCurrentBlockList();
+
+ auto clipboardText = QGuiApplication::clipboard()->text();
+ auto stringList = clipboardText.split("\n");
+ for (const auto& string : stringList) {
+ auto jid = JID(Q2PSTRING(string.trimmed()));
+ if (jid.isValid()) {
+ if (std::find(currentBlocklist.begin(), currentBlocklist.end(), jid) == currentBlocklist.end()) {
+ currentBlocklist.push_back(jid);
+ }
+ }
+ }
+ setCurrentBlockList(currentBlocklist);
+ });
+
}
QtBlockListEditorWindow::~QtBlockListEditorWindow() {
@@ -157,8 +177,14 @@ void QtBlockListEditorWindow::applyChanges() {
void QtBlockListEditorWindow::setCurrentBlockList(const std::vector<JID> &blockedJIDs) {
ui->blockListTreeWidget->clear();
+ QStringList blockedStrings;
for (const auto& jid : blockedJIDs) {
- QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(P2QSTRING(jid.toString())) << "");
+ blockedStrings << P2QSTRING(jid.toString());
+ }
+ blockedStrings.sort();
+
+ for (const auto& jid : blockedStrings) {
+ QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(jid) << "");
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui->blockListTreeWidget->addTopLevelItem(item);
}