Commit 5fc494bc authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Add support for groups of keys to SignEncryptWidget

GnuPG-bug-id: 5175, 5241, 5249
parent 810d9223
Pipeline #48183 failed with stage
in 12 minutes and 7 seconds
......@@ -11,6 +11,7 @@ endif()
option(FORCE_DISABLE_KCMUTILS "Force building Kleopatra without KCMUtils. Doing this will disable configuration KCM Plugins. [default=OFF]" OFF)
option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
option(ENABLE_GROUP_SUPPORT "Enable experimental support for groups of keys [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set(KF5_MIN_VERSION "5.78.0")
......@@ -145,6 +146,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
add_definitions(-DQT_NO_EMIT)
if(ENABLE_GROUP_SUPPORT)
message(STATUS "Enabling experimental group support")
add_definitions(-DGROUP_SUPPORT)
endif()
kde_enable_exceptions()
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" FALSE)
......
......@@ -23,6 +23,7 @@
#include <Libkleo/DefaultKeyFilter>
#include <Libkleo/KeyCache>
#include <Libkleo/KeyGroup>
#include <Libkleo/KeyListModel>
#include <Libkleo/KeySelectionCombo>
#include <Libkleo/KeyListSortFilterProxyModel>
......@@ -94,7 +95,11 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
QVBoxLayout *lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
mModel->useKeyCache(true, false);
#ifdef GROUP_SUPPORT
mModel->useKeyCache(true, KeyList::IncludeGroups);
#else
mModel->useKeyCache(true, KeyList::AllKeys);
#endif
/* The signature selection */
QHBoxLayout *sigLay = new QHBoxLayout;
......@@ -302,7 +307,7 @@ void SignEncryptWidget::recipientsChanged()
{
bool oneEmpty = false;
for (const CertificateLineEdit *w : qAsConst(mRecpWidgets)) {
if (w->key().isNull()) {
if (w->key().isNull() && w->group().isNull()) {
oneEmpty = true;
break;
}
......@@ -338,8 +343,12 @@ QVector <Key> SignEncryptWidget::recipients() const
break;
}
const Key k = w->key();
const KeyGroup g = w->group();
if (!k.isNull()) {
ret << k;
} else if (!g.isNull()) {
const auto keys = g.keys();
std::copy(keys.begin(), keys.end(), std::back_inserter(ret));
}
}
const Key k = selfKey();
......@@ -510,7 +519,7 @@ void SignEncryptWidget::setProtocol(GpgME::Protocol proto)
bool SignEncryptWidget::validate()
{
for (const auto edit: qAsConst(mRecpWidgets)) {
if (!edit->isEmpty() && edit->key().isNull()) {
if (!edit->isEmpty() && edit->key().isNull() && edit->group().isNull()) {
KMessageBox::error(this, i18nc("%1 is user input that could not be found",
"Could not find a key for '%1'", edit->text().toHtmlEscaped()),
i18n("Failed to find recipient"), KMessageBox::Notify);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment