forked from blue/squawk
some further work on omemo, far from done yet
This commit is contained in:
parent
6f32e99593
commit
77dd28b600
18 changed files with 161 additions and 43 deletions
|
@ -20,7 +20,7 @@
|
|||
#include <random>
|
||||
constexpr uint8_t fingerprintLength = 32;
|
||||
|
||||
Omemo::Omemo(QWidget* parent):
|
||||
UI::Omemo::Omemo(QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::Omemo()),
|
||||
keysDelegate(),
|
||||
|
@ -31,8 +31,6 @@ Omemo::Omemo(QWidget* parent):
|
|||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
generateMockData();
|
||||
|
||||
m_ui->keysView->setItemDelegate(&keysDelegate);
|
||||
m_ui->keysView->setModel(&keysModel);
|
||||
m_ui->unusedKeysView->setItemDelegate(&unusedKeysDelegate);
|
||||
|
@ -42,12 +40,12 @@ Omemo::Omemo(QWidget* parent):
|
|||
connect(m_ui->keysView, &QWidget::customContextMenuRequested, this, &Omemo::onActiveKeysContextMenu);
|
||||
}
|
||||
|
||||
Omemo::~Omemo()
|
||||
UI::Omemo::~Omemo()
|
||||
{
|
||||
contextMenu->deleteLater();
|
||||
}
|
||||
|
||||
void Omemo::generateMockData() {
|
||||
void UI::Omemo::generateMockData() {
|
||||
std::random_device rd;
|
||||
std::uniform_int_distribution<char> dist(CHAR_MIN, CHAR_MAX);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
|
@ -67,7 +65,19 @@ void Omemo::generateMockData() {
|
|||
}
|
||||
}
|
||||
|
||||
void Omemo::onActiveKeysContextMenu(const QPoint& pos) {
|
||||
void UI::Omemo::setData(const std::list<Shared::KeyInfo>& keys) {
|
||||
keysModel.clear();
|
||||
unusedKeysModel.clear();
|
||||
for (const Shared::KeyInfo& key : keys) {
|
||||
keysModel.addKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
const QString UI::Omemo::title() const {
|
||||
return m_ui->OMEMOHeading->text();}
|
||||
|
||||
|
||||
void UI::Omemo::onActiveKeysContextMenu(const QPoint& pos) {
|
||||
contextMenu->clear();
|
||||
QModelIndex index = m_ui->keysView->indexAt(pos);
|
||||
if (index.isValid()) {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#ifndef VCARD_OMEMO_H
|
||||
#define VCARD_OMEMO_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
#include <QMenu>
|
||||
|
@ -24,7 +26,9 @@
|
|||
#include "ui/models/info/omemo/keys.h"
|
||||
#include "keydelegate.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/keyinfo.h"
|
||||
|
||||
namespace UI {
|
||||
namespace Ui
|
||||
{
|
||||
class Omemo;
|
||||
|
@ -36,6 +40,9 @@ public:
|
|||
Omemo(QWidget* parent = nullptr);
|
||||
~Omemo();
|
||||
|
||||
void setData(const std::list<Shared::KeyInfo>& keys);
|
||||
const QString title() const;
|
||||
|
||||
private slots:
|
||||
void onActiveKeysContextMenu(const QPoint& pos);
|
||||
|
||||
|
@ -50,5 +57,5 @@ private:
|
|||
Models::Keys unusedKeysModel;
|
||||
QMenu* contextMenu;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // VCARD_OMEMO_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Omemo</class>
|
||||
<widget class="QWidget" name="Omemo">
|
||||
<class>UI::Omemo</class>
|
||||
<widget class="QWidget" name="UI::Omemo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue