some work towards encryption

This commit is contained in:
Blue 2023-11-04 22:12:15 -03:00
parent 297e08ba41
commit a7d1a28f29
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
21 changed files with 129 additions and 81 deletions

View file

@ -37,11 +37,11 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
m_ui->setupUi(this);
m_ui->roster->setModel(&rosterModel);
m_ui->roster->setContextMenuPolicy(Qt::CustomContextMenu);
if (QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1) {
if (QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
m_ui->roster->setColumnWidth(1, 52);
} else {
else
m_ui->roster->setColumnWidth(1, 26);
}
m_ui->roster->setIconSize(QSize(20, 20));
m_ui->roster->header()->setStretchLastSection(false);
m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch);
@ -69,24 +69,24 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
connect(m_ui->actionAboutSquawk, &QAction::triggered, this, &Squawk::onAboutSquawkCalled);
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
if (testAttribute(Qt::WA_TranslucentBackground)) {
if (testAttribute(Qt::WA_TranslucentBackground))
m_ui->roster->viewport()->setAutoFillBackground(false);
}
QSettings settings;
settings.beginGroup("ui");
settings.beginGroup("window");
if (settings.contains("geometry")) {
if (settings.contains("geometry"))
restoreGeometry(settings.value("geometry").toByteArray());
}
if (settings.contains("state")) {
if (settings.contains("state"))
restoreState(settings.value("state").toByteArray());
}
settings.endGroup();
if (settings.contains("splitter")) {
if (settings.contains("splitter"))
m_ui->splitter->restoreState(settings.value("splitter").toByteArray());
}
settings.endGroup();
onAccountsChanged();
@ -181,8 +181,10 @@ void Squawk::onJoinConferenceAccepted() {
void Squawk::closeEvent(QCloseEvent* event) {
if (accounts != nullptr)
accounts->close();
if (preferences != nullptr)
preferences->close();
if (about != nullptr)
about->close();
@ -221,9 +223,9 @@ void Squawk::stateChanged(Shared::Availability state) {
void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) {
if (item.isValid()) {
Models::Item* node = static_cast<Models::Item*>(item.internalPointer());
if (node->type == Models::Item::reference) {
if (node->type == Models::Item::reference)
node = static_cast<Models::Reference*>(node)->dereference();
}
Models::Contact* contact = nullptr;
Models::Room* room = nullptr;
switch (node->type) {
@ -258,9 +260,9 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
QModelIndex index = m_ui->roster->indexAt(point);
if (index.isValid()) {
Models::Item* item = static_cast<Models::Item*>(index.internalPointer());
if (item->type == Models::Item::reference) {
if (item->type == Models::Item::reference)
item = static_cast<Models::Reference*>(item)->dereference();
}
contextMenu->clear();
bool hasMenu = false;
bool active = item->getAccountConnectionState() == Shared::ConnectionState::connected;
@ -320,9 +322,9 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
QInputDialog* dialog = new QInputDialog(this);
connect(dialog, &QDialog::accepted, [this, dialog, cntName, id]() {
QString newName = dialog->textValue();
if (newName != cntName) {
if (newName != cntName)
emit renameContactRequest(id.account, id.name, newName);
}
dialog->deleteLater();
});
connect(dialog, &QDialog::rejected, dialog, &QObject::deleteLater);
@ -342,11 +344,10 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
gr->setChecked(rosterModel.groupHasContact(id.account, groupName, id.name));
gr->setEnabled(active);
connect(gr, &QAction::toggled, [this, groupName, id](bool checked) {
if (checked) {
if (checked)
emit addContactToGroupRequest(id.account, id.name, groupName);
} else {
else
emit removeContactFromGroupRequest(id.account, id.name, groupName);
}
});
}
QAction* newGroup = groupsMenu->addAction(Shared::icon("group-new"), tr("New group"));
@ -405,9 +406,8 @@ void Squawk::onRosterContextMenu(const QPoint& point) {
default:
break;
}
if (hasMenu) {
if (hasMenu)
contextMenu->popup(m_ui->roster->viewport()->mapToGlobal(point));
}
}
}
@ -515,9 +515,9 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
}
if (hasContext && QGuiApplication::mouseButtons() & Qt::RightButton) {
if (id != nullptr) {
if (id != nullptr)
delete id;
}
needToRestore = true;
restoreSelection = previous;
return;
@ -538,20 +538,19 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
}
Models::Account* acc = rosterModel.getAccount(id->account);
if (contact != nullptr) {
if (contact != nullptr)
currentConversation = new Chat(acc, contact);
} else if (room != nullptr) {
else if (room != nullptr)
currentConversation = new Room(acc, room);
}
if (!testAttribute(Qt::WA_TranslucentBackground)) {
if (!testAttribute(Qt::WA_TranslucentBackground))
currentConversation->setFeedFrames(true, false, true, true);
}
emit openedConversation();
if (res.size() > 0) {
if (res.size() > 0)
currentConversation->setPalResource(res);
}
m_ui->splitter->insertWidget(1, currentConversation);