feat(omemo): basic UI

This commit is contained in:
vae 2021-05-15 12:28:43 +03:00
parent bb2ce750c8
commit 08fe37bfb2
Signed by: vae
GPG Key ID: A9A33351400E00E5
9 changed files with 220 additions and 15 deletions

View File

@ -1,5 +1,8 @@
target_sources(squawk PRIVATE target_sources(squawk PRIVATE
omemodevices.cpp contactsettings.cpp
omemodevices.h contactsettings.h
omemodevices.ui contactsettings.ui
) omemodevices.cpp
omemodevices.h
omemodevices.ui
)

View File

@ -0,0 +1,23 @@
/*
* Created by victoria on 2021-05-15.
*/
#include "contactsettings.h"
#include "ui_contactsettings.h"
#include "omemodevices.h"
ContactSettings::ContactSettings(QWidget *parent)
: QDialog(parent), m_ui(new Ui::ContactSettings()) {
m_ui->setupUi(this);
connect(m_ui->devicesButton, &QPushButton::clicked, this, &ContactSettings::openDeviceList);
}
ContactSettings::~ContactSettings() {}
void ContactSettings::openDeviceList() {
auto devices = new OMEMODevices(this);
devices->setAttribute(Qt::WA_DeleteOnClose);
devices->show();
}

View File

@ -0,0 +1,24 @@
/*
* Created by victoria on 2021-05-15.
*/
#pragma once
#include <QDialog>
namespace Ui {
class ContactSettings;
}
class ContactSettings : public QDialog {
Q_OBJECT
public:
explicit ContactSettings(QWidget *parent = nullptr);
~ContactSettings() override;
private slots:
void openDeviceList();
private:
QScopedPointer<Ui::ContactSettings> m_ui;
};

144
ui/omemo/contactsettings.ui Normal file
View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ContactSettings</class>
<widget class="QDialog" name="ContactSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Contact Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Settings for foo@example.com</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="useOmemoCheckBox">
<property name="text">
<string>Use OMEMO</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="devicesButton">
<property name="text">
<string>Devices...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ContactSettings</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ContactSettings</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -6,8 +6,8 @@
#include "ui_omemodevices.h" #include "ui_omemodevices.h"
OMEMODevices::OMEMODevices(QWidget *parent) OMEMODevices::OMEMODevices(QWidget *parent)
: QDialog(parent), m_ui(new Ui::OMEMODevices()) { : QDialog(parent), m_ui(new Ui::OMEMODevices()) {
m_ui->setupUi(this); m_ui->setupUi(this);
} }
OMEMODevices::~OMEMODevices() {} OMEMODevices::~OMEMODevices() {}

View File

@ -7,15 +7,15 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui {
class OMEMODevices; class OMEMODevices;
} }
class OMEMODevices : public QDialog { class OMEMODevices : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit OMEMODevices(QWidget *parent = nullptr); explicit OMEMODevices(QWidget *parent = nullptr);
~OMEMODevices() override; ~OMEMODevices() override;
private: private:
QScopedPointer<Ui::OMEMODevices> m_ui; QScopedPointer<Ui::OMEMODevices> m_ui;
}; };

View File

@ -27,6 +27,7 @@
#include <unistd.h> #include <unistd.h>
#include <QAbstractTextDocumentLayout> #include <QAbstractTextDocumentLayout>
#include <QCoreApplication> #include <QCoreApplication>
#include <ui/omemo/contactsettings.h>
Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el, const QString pJid, const QString pRes, QWidget* parent): Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el, const QString pJid, const QString pRes, QWidget* parent):
QWidget(parent), QWidget(parent),
@ -80,7 +81,8 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
connect(m_ui->clearButton, &QPushButton::clicked, this, &Conversation::onClearButton); connect(m_ui->clearButton, &QPushButton::clicked, this, &Conversation::onClearButton);
connect(m_ui->messageEditor->document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged, connect(m_ui->messageEditor->document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged,
this, &Conversation::onTextEditDocSizeChanged); this, &Conversation::onTextEditDocSizeChanged);
connect(m_ui->encryptionButton, &QToolButton::clicked, this, &Conversation::openEncryptionSettings);
m_ui->messageEditor->installEventFilter(&ker); m_ui->messageEditor->installEventFilter(&ker);
@ -433,3 +435,10 @@ void Conversation::onFeedContext(const QPoint& pos)
} }
} }
} }
void Conversation::openEncryptionSettings() {
auto cs = new ContactSettings(this);
cs->setAttribute(Qt::WA_DeleteOnClose);
cs->show();
}

View File

@ -107,6 +107,7 @@ protected slots:
void onFeedMessage(const Shared::Message& msg); void onFeedMessage(const Shared::Message& msg);
void positionShadow(); void positionShadow();
void onFeedContext(const QPoint &pos); void onFeedContext(const QPoint &pos);
void openEncryptionSettings();
public: public:
const bool isMuc; const bool isMuc;

View File

@ -293,14 +293,15 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="encryptionButton"> <widget class="QToolButton" name="encryptionButton">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="security-low"/> <iconset theme="security-low">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="flat"> <property name="autoRaise">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>