Merge branch 'edit'

This commit is contained in:
SET
2020-11-04 09:08:23 +01:00
9 changed files with 212 additions and 6 deletions

View File

@@ -20,6 +20,7 @@
#include "GpgMEWorker.h"
#include "GpgMECWorker.h"
#include "Tools.h"
#include "SensitiveTreeTableNodeText.h"
using namespace std;
@@ -267,7 +268,8 @@ void K7Main::DisplayKeys(const vector<GpgME::Key>& kList, const WString& grpLabe
}
}
keyNode->setColumnWidget(2, unique_ptr<WText> (lblOwnerTrust));
keyNode->setColumnWidget(3, cpp14::make_unique<WText> (k.primaryFingerprint()));
TreeTableNodeText * ttntFpr = new TreeTableNodeText(k.primaryFingerprint(), keyNode, 3);
keyNode->setColumnWidget(3, unique_ptr<TreeTableNodeText> (ttntFpr));
grpNode->addChildNode(unique_ptr<WTreeTableNode> (keyNode));
}
if (expand)
@@ -315,7 +317,8 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
{
UserID uid = k.userID(i);
WTreeTableNode * uidNode = new WTreeTableNode(uid.name());
uidNode->setColumnWidget(1, cpp14::make_unique<WText> (uid.email()));
TreeTableNodeText * ttntUidEmail = new TreeTableNodeText(uid.email(), uidNode, 1);
uidNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntUidEmail));
// Show key certify popup on double click
WText * lblUidValidity = new WText(UidValidities[uid.validity()]);
if (m_config->CanEditUidValidity()) {
@@ -323,7 +326,8 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
lblUidValidity->doubleClicked().connect(std::bind(&KeyEdit::OnUidValidityClicked, m_keyEdit, uidNode, privateKeys, WString(k.primaryFingerprint())));
}
uidNode->setColumnWidget(2, unique_ptr<WText> (lblUidValidity));
uidNode->setColumnWidget(3, cpp14::make_unique<WText> (uid.comment()));
TreeTableNodeText * ttntUidComment = new TreeTableNodeText(uid.comment(), uidNode, 3);
uidNode->setColumnWidget(3, unique_ptr<TreeTableNodeText> (ttntUidComment));
rootNode->addChildNode(unique_ptr<WTreeTableNode> (uidNode));
// uid.numSignatures() is always 0, even for signed keys !
for (uint s = 0; s < uid.numSignatures(); s++)
@@ -332,11 +336,13 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
const WString signer = WString(sig.signerName()) + _SPACE_
+ WString(sig.signerKeyID());
WTreeTableNode * sigNode = new WTreeTableNode(signer);
sigNode->setColumnWidget(1, cpp14::make_unique<WText> (sig.signerEmail()));
TreeTableNodeText * ttntEmail = new TreeTableNodeText(sig.signerEmail(), sigNode, 1);
sigNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntEmail));
WString exp = TR("Expiration") + _SPACE_ + _COLON_ + _SPACE_;
exp += sig.neverExpires() ? TR("Never") : MakeDateTimeLabel(sig.expirationTime());
sigNode->setColumnWidget(2, cpp14::make_unique<WText> (exp));
sigNode->setColumnWidget(3, cpp14::make_unique<WText> (sig.signerComment()));
TreeTableNodeText * ttntComment = new TreeTableNodeText(sig.signerComment(), sigNode, 3);
sigNode->setColumnWidget(3, unique_ptr<TreeTableNodeText> (ttntComment));
uidNode->addChild(unique_ptr<WTreeTableNode> (sigNode));
}
}
@@ -370,7 +376,8 @@ void K7Main::DisplaySubKeys(const WString& fullKeyID, bool secret)
{
Subkey sk = k.subkey(i);
WTreeTableNode * skNode = new WTreeTableNode(sk.keyID());
skNode->setColumnWidget(1, cpp14::make_unique<WText> (sk.fingerprint()));
TreeTableNodeText * ttntFpr = new TreeTableNodeText(sk.fingerprint(), skNode, 1);
skNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntFpr));
WString exp = sk.neverExpires() ? TR("Never") : MakeDateTimeLabel(sk.expirationTime());
skNode->setColumnWidget(2, cpp14::make_unique<WText> (exp));
WString usage = sk.canAuthenticate() ? WString("A") : WString::Empty;

View File

@@ -0,0 +1,90 @@
/*
* File: SensitiveTreeTableNodeText.cpp
* Author: SET - nmset@yandex.com
* License : LGPL v2.1
* Copyright SET - © 2019
*
* Created on November 3, 2020, 8:26 PM
*/
#include "SensitiveTreeTableNodeText.h"
#include <cstdlib>
using namespace std;
TreeTableNodeText::TreeTableNodeText(WTreeTableNode * node, uint colIndex)
: WText()
{
Init(node, colIndex);
}
TreeTableNodeText::~TreeTableNodeText()
{
}
TreeTableNodeText::TreeTableNodeText(const WString& text,
WTreeTableNode * node, uint colIndex)
: WText(text)
{
Init(node, colIndex);
}
TreeTableNodeText::TreeTableNodeText(const WString& text, TextFormat textFormat,
WTreeTableNode * node, uint colIndex)
: WText(text, textFormat)
{
Init(node, colIndex);
}
void TreeTableNodeText::Init(WTreeTableNode * node, uint colIndex)
{
m_node = node;
m_colIndex = colIndex;
m_lineEdit = NULL;
clicked().connect(this, &TreeTableNodeText::OnClick);
setToolTip(WString::tr("PrepareCopy"));
}
void TreeTableNodeText::OnClick()
{
m_lineEdit = new TreeTableNodeLineEdit(text(), m_node, m_colIndex);
m_lineEdit->setReadOnly(true);
m_lineEdit->blurred().connect(m_lineEdit, &TreeTableNodeLineEdit::OnBlurred);
m_lineEdit->setSelection(0, text().toUTF8().length());
m_node->setColumnWidget(m_colIndex, unique_ptr<WLineEdit> (m_lineEdit));
m_lineEdit->setFocus(true); // +++
}
///////////////////////////////////////////////////////////////////////////////
TreeTableNodeLineEdit::TreeTableNodeLineEdit(WTreeTableNode* node, uint colIndex)
: WLineEdit()
{
Init(node, colIndex);
}
TreeTableNodeLineEdit::~TreeTableNodeLineEdit()
{
}
TreeTableNodeLineEdit::TreeTableNodeLineEdit(const WString& content,
WTreeTableNode* node, uint colIndex)
: WLineEdit(content)
{
Init(node, colIndex);
}
void TreeTableNodeLineEdit::Init(WTreeTableNode* node, uint colIndex)
{
m_node = node;
m_colIndex = colIndex;
m_text = NULL;
clicked().connect(this, &TreeTableNodeLineEdit::OnBlurred);
}
void TreeTableNodeLineEdit::OnBlurred()
{
m_text = new TreeTableNodeText(text(), m_node, m_colIndex);
m_text->clicked().connect(m_text, &TreeTableNodeText::OnClick);
m_node->setColumnWidget(m_colIndex, unique_ptr<TreeTableNodeText> (m_text));
}

View File

@@ -0,0 +1,73 @@
/*
* File: SensitiveTreeTableNodeText.h
* Author: SET - nmset@yandex.com
* License : LGPL v2.1
* Copyright SET - © 2019
*
* Created on November 3, 2020, 8:26 PM
*/
#ifndef TREETABLENODETEXT_H
#define TREETABLENODETEXT_H
#include <Wt/WText.h>
#include <Wt/WTreeTableNode.h>
#include <Wt/WLineEdit.h>
using namespace Wt;
class TreeTableNodeText;
class TreeTableNodeLineEdit;
/**
* An extended WText in a WTreeTableNode.
* It is replaced by a TreeTableNodeLineEdit on click.
* \n This allows to copy the text to clipboard.
*/
class TreeTableNodeText : public WText
{
public:
TreeTableNodeText(WTreeTableNode * node, uint colIndex);
TreeTableNodeText(const WString& text,
WTreeTableNode * node, uint colIndex);
TreeTableNodeText(const WString& text, TextFormat textFormat,
WTreeTableNode * node, uint colIndex);
virtual ~TreeTableNodeText();
/**
* Creates a read-only TreeTableNodeLineEdit replacing this
* TreeTableNodeText.
*/
void OnClick();
private:
WTreeTableNode * m_node;
uint m_colIndex;
TreeTableNodeLineEdit * m_lineEdit;
void Init(WTreeTableNode * node, uint colIndex);
};
/**
* An extended WLineEdit replacing a WText in a WTreeTableNode.
* Switches back to a WTreeTableNodeText when it loses focus.
*/
class TreeTableNodeLineEdit : public WLineEdit
{
public:
TreeTableNodeLineEdit(WTreeTableNode * node, uint colIndex);
TreeTableNodeLineEdit(const WString& content,
WTreeTableNode * node, uint colIndex);
virtual ~TreeTableNodeLineEdit();
/**
* Creates back a TreeTableNodeText replacing this TreeTableNodeLineEdit.
*/
void OnBlurred();
private:
WTreeTableNode * m_node;
uint m_colIndex;
TreeTableNodeText * m_text;
void Init(WTreeTableNode * node, uint colIndex);
};
#endif /* TREETABLENODETEXT_H */

View File

@@ -79,4 +79,6 @@
<message id='Apply'>Apply</message>
<message id='CertificationSuccess'>Key succesfully certified</message>
<message id='CertificationFailure'>Key certification failed</message>
<message id='PrepareCopy'>Click to be able to copy next</message>
</messages>

View File

@@ -79,4 +79,6 @@
<message id='Apply'>Appliquer</message>
<message id='CertificationSuccess'>Succès de certification de la clé</message>
<message id='CertificationFailure'>Échec de certification de la clé</message>
<message id='PrepareCopy'>Cliquez pour pouvoir ensuite copier</message>
</messages>

View File

@@ -44,6 +44,7 @@ OBJECTFILES= \
${OBJECTDIR}/PopupCertifyUserId.o \
${OBJECTDIR}/PopupDeleter.o \
${OBJECTDIR}/PopupUploader.o \
${OBJECTDIR}/SensitiveTreeTableNodeText.o \
${OBJECTDIR}/Tools.o \
${OBJECTDIR}/TransientMessageWidget.o \
${OBJECTDIR}/main.o
@@ -118,6 +119,11 @@ ${OBJECTDIR}/PopupUploader.o: PopupUploader.cpp
${RM} "$@.d"
$(COMPILE.cc) -O2 -s -DLARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/Wt/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/PopupUploader.o PopupUploader.cpp
${OBJECTDIR}/SensitiveTreeTableNodeText.o: SensitiveTreeTableNodeText.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -O2 -s -DLARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -I/usr/local/Wt/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/SensitiveTreeTableNodeText.o SensitiveTreeTableNodeText.cpp
${OBJECTDIR}/Tools.o: Tools.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"

View File

@@ -44,6 +44,7 @@ OBJECTFILES= \
${OBJECTDIR}/PopupCertifyUserId.o \
${OBJECTDIR}/PopupDeleter.o \
${OBJECTDIR}/PopupUploader.o \
${OBJECTDIR}/SensitiveTreeTableNodeText.o \
${OBJECTDIR}/Tools.o \
${OBJECTDIR}/TransientMessageWidget.o \
${OBJECTDIR}/main.o
@@ -118,6 +119,11 @@ ${OBJECTDIR}/PopupUploader.o: PopupUploader.cpp
${RM} "$@.d"
$(COMPILE.cc) -g -DDEVTIME -I/usr/local/Wt-Debug/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/PopupUploader.o PopupUploader.cpp
${OBJECTDIR}/SensitiveTreeTableNodeText.o: SensitiveTreeTableNodeText.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -DDEVTIME -I/usr/local/Wt-Debug/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/SensitiveTreeTableNodeText.o SensitiveTreeTableNodeText.cpp
${OBJECTDIR}/Tools.o: Tools.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"

View File

@@ -44,6 +44,7 @@ OBJECTFILES= \
${OBJECTDIR}/PopupCertifyUserId.o \
${OBJECTDIR}/PopupDeleter.o \
${OBJECTDIR}/PopupUploader.o \
${OBJECTDIR}/SensitiveTreeTableNodeText.o \
${OBJECTDIR}/Tools.o \
${OBJECTDIR}/TransientMessageWidget.o \
${OBJECTDIR}/main.o
@@ -118,6 +119,11 @@ ${OBJECTDIR}/PopupUploader.o: PopupUploader.cpp
${RM} "$@.d"
$(COMPILE.cc) -O2 -s -I/usr/local/Wt/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/PopupUploader.o PopupUploader.cpp
${OBJECTDIR}/SensitiveTreeTableNodeText.o: SensitiveTreeTableNodeText.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -O2 -s -I/usr/local/Wt/include -I/usr/include/gpgme++ -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/SensitiveTreeTableNodeText.o SensitiveTreeTableNodeText.cpp
${OBJECTDIR}/Tools.o: Tools.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"

View File

@@ -13,6 +13,7 @@
<itemPath>PopupCertifyUserId.h</itemPath>
<itemPath>PopupDeleter.h</itemPath>
<itemPath>PopupUploader.h</itemPath>
<itemPath>SensitiveTreeTableNodeText.h</itemPath>
<itemPath>Tools.h</itemPath>
<itemPath>TransientMessageWidget.h</itemPath>
<itemPath>global.h</itemPath>
@@ -37,6 +38,7 @@
<itemPath>PopupCertifyUserId.cpp</itemPath>
<itemPath>PopupDeleter.cpp</itemPath>
<itemPath>PopupUploader.cpp</itemPath>
<itemPath>SensitiveTreeTableNodeText.cpp</itemPath>
<itemPath>Tools.cpp</itemPath>
<itemPath>TransientMessageWidget.cpp</itemPath>
<itemPath>main.cpp</itemPath>
@@ -131,6 +133,10 @@
</item>
<item path="PopupUploader.h" ex="false" tool="3" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.h" ex="false" tool="3" flavor2="0">
</item>
<item path="Tools.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="Tools.h" ex="false" tool="3" flavor2="0">
@@ -227,6 +233,10 @@
</item>
<item path="PopupUploader.h" ex="false" tool="3" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.h" ex="false" tool="3" flavor2="0">
</item>
<item path="Tools.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="Tools.h" ex="false" tool="3" flavor2="0">
@@ -327,6 +337,10 @@
</item>
<item path="PopupUploader.h" ex="false" tool="3" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="SensitiveTreeTableNodeText.h" ex="false" tool="3" flavor2="0">
</item>
<item path="Tools.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="Tools.h" ex="false" tool="3" flavor2="0">