forked from blue/squawk
minor bugfix, start account editing feature
This commit is contained in:
parent
3c3e28b688
commit
16f96c4f2b
@ -259,17 +259,21 @@ void Core::Contact::flushMessagesToArchive(bool finished, const QString& firstId
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (archiveState) {
|
switch (archiveState) {
|
||||||
break;
|
|
||||||
case beginning:
|
case beginning:
|
||||||
if (finished) {
|
if (finished) {
|
||||||
archiveState = complete;
|
archiveState = complete;
|
||||||
|
archive->addElements(appendCache);
|
||||||
|
appendCache.clear();
|
||||||
nextRequest();
|
nextRequest();
|
||||||
} else {
|
} else {
|
||||||
emit needHistory("", lastId);
|
emit needHistory("", lastId);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case chunk:
|
case chunk:
|
||||||
if (finished) {
|
if (finished) {
|
||||||
archiveState = end;
|
archiveState = end;
|
||||||
|
archive->addElements(appendCache);
|
||||||
|
appendCache.clear();
|
||||||
nextRequest();
|
nextRequest();
|
||||||
} else {
|
} else {
|
||||||
emit needHistory("", lastId);
|
emit needHistory("", lastId);
|
||||||
|
@ -150,6 +150,19 @@ void Core::Squawk::onAccountConnectionStateChanged(int state)
|
|||||||
{
|
{
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit accountConnectionStateChanged(acc->getName(), state);
|
emit accountConnectionStateChanged(acc->getName(), state);
|
||||||
|
|
||||||
|
if (state == Shared::disconnected) {
|
||||||
|
bool equals = true;
|
||||||
|
for (Accounts::const_iterator itr = accounts.begin(), end = accounts.end(); itr != end; itr++) {
|
||||||
|
if ((*itr)->getState() != Shared::disconnected) {
|
||||||
|
equals = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (equals) {
|
||||||
|
state = Shared::offline;
|
||||||
|
emit stateChanged(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data)
|
||||||
|
@ -8,10 +8,6 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
|
|
||||||
# Find the QtWidgets library
|
# Find the QtWidgets library
|
||||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
find_package(Qt5Qml CONFIG REQUIRED)
|
|
||||||
find_package(Qt5QuickCompiler)
|
|
||||||
find_package(Qt5Quick CONFIG REQUIRED)
|
|
||||||
find_package(Qt5QuickWidgets CONFIG REQUIRED)
|
|
||||||
|
|
||||||
set(squawkUI_SRC
|
set(squawkUI_SRC
|
||||||
squawk.cpp
|
squawk.cpp
|
||||||
@ -32,9 +28,6 @@ add_library(squawkUI ${squawkUI_SRC})
|
|||||||
|
|
||||||
# Use the Widgets module from Qt 5.
|
# Use the Widgets module from Qt 5.
|
||||||
target_link_libraries(squawkUI Qt5::Widgets)
|
target_link_libraries(squawkUI Qt5::Widgets)
|
||||||
target_link_libraries(squawkUI Qt5::Quick)
|
|
||||||
target_link_libraries(squawkUI Qt5::Qml)
|
|
||||||
target_link_libraries(squawkUI Qt5::QuickWidgets)
|
|
||||||
|
|
||||||
# Install the executable
|
# Install the executable
|
||||||
install(TARGETS squawkUI DESTINATION lib)
|
install(TARGETS squawkUI DESTINATION lib)
|
||||||
|
@ -22,3 +22,17 @@ QMap<QString, QVariant> Account::value() const
|
|||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::lockId()
|
||||||
|
{
|
||||||
|
m_ui->name->setReadOnly(true);;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Account::setData(const QMap<QString, QVariant>& data)
|
||||||
|
{
|
||||||
|
m_ui->login->setText(data.value("login").toString());
|
||||||
|
m_ui->password->setText(data.value("password").toString());
|
||||||
|
m_ui->server->setText(data.value("server").toString());
|
||||||
|
m_ui->name->setText(data.value("name").toString());
|
||||||
|
m_ui->resource->setText(data.value("resource").toString());
|
||||||
|
}
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
~Account();
|
~Account();
|
||||||
|
|
||||||
QMap<QString, QVariant> value() const;
|
QMap<QString, QVariant> value() const;
|
||||||
|
void setData(const QMap<QString, QVariant>& data);
|
||||||
|
void lockId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::Account> m_ui;
|
QScopedPointer<Ui::Account> m_ui;
|
||||||
|
@ -3,13 +3,18 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Accounts::Accounts(Models::Accounts* model, QWidget *parent) :
|
Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) :
|
||||||
m_ui(new Ui::Accounts)
|
m_ui(new Ui::Accounts),
|
||||||
|
model(p_model),
|
||||||
|
editing(false)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
|
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
|
||||||
|
connect(m_ui->editButton, SIGNAL(clicked(bool)), this, SLOT(onEditButton(bool)));
|
||||||
m_ui->tableView->setModel(model);
|
m_ui->tableView->setModel(model);
|
||||||
|
connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||||
|
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Accounts::~Accounts() = default;
|
Accounts::~Accounts() = default;
|
||||||
@ -26,12 +31,49 @@ void Accounts::onAccountAccepted()
|
|||||||
{
|
{
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
QMap<QString, QVariant> map = acc->value();
|
QMap<QString, QVariant> map = acc->value();
|
||||||
|
if (editing) {
|
||||||
|
emit changeAccount(map);
|
||||||
|
} else {
|
||||||
emit newAccount(map);
|
emit newAccount(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accounts::onAccountRejected()
|
void Accounts::onAccountRejected()
|
||||||
{
|
{
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
acc->deleteLater();
|
acc->deleteLater();
|
||||||
|
editing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accounts::onEditButton(bool clicked)
|
||||||
|
{
|
||||||
|
Account* acc = new Account();
|
||||||
|
|
||||||
|
const Models::Account* mAcc = model->getAccount(m_ui->tableView->selectionModel()->selectedRows().at(0).row());
|
||||||
|
acc->setData({
|
||||||
|
{"login", mAcc->getLogin()},
|
||||||
|
{"password", mAcc->getPassword()},
|
||||||
|
{"server", mAcc->getServer()},
|
||||||
|
{"name", mAcc->getName()},
|
||||||
|
{"resource", mAcc->getResource()}
|
||||||
|
});
|
||||||
|
acc->lockId();
|
||||||
|
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
|
||||||
|
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
|
||||||
|
editing = true;
|
||||||
|
acc->exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accounts::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||||
|
{
|
||||||
|
const QItemSelection& selection = m_ui->tableView->selectionModel()->selection();
|
||||||
|
if (selection.size() == 0) {
|
||||||
|
m_ui->editButton->setEnabled(false);
|
||||||
|
} else if (selection.size() == 1) {
|
||||||
|
m_ui->editButton->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
m_ui->editButton->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QItemSelection>
|
||||||
|
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
#include "models/accounts.h"
|
#include "models/accounts.h"
|
||||||
@ -16,19 +17,24 @@ class Accounts : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Accounts(Models::Accounts* model, QWidget *parent = nullptr);
|
explicit Accounts(Models::Accounts* p_model, QWidget *parent = nullptr);
|
||||||
~Accounts() override;
|
~Accounts() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newAccount(const QMap<QString, QVariant>&);
|
void newAccount(const QMap<QString, QVariant>&);
|
||||||
|
void changeAccount(const QMap<QString, QVariant>&);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAddButton(bool clicked = 0);
|
void onAddButton(bool clicked = 0);
|
||||||
|
void onEditButton(bool clicked = 0);
|
||||||
void onAccountAccepted();
|
void onAccountAccepted();
|
||||||
void onAccountRejected();
|
void onAccountRejected();
|
||||||
|
void onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::Accounts> m_ui;
|
QScopedPointer<Ui::Accounts> m_ui;
|
||||||
|
Models::Accounts* model;
|
||||||
|
bool editing;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACCOUNTS_H
|
#endif // ACCOUNTS_H
|
||||||
|
@ -75,6 +75,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
|||||||
message->setAutoFillBackground(true);;
|
message->setAutoFillBackground(true);;
|
||||||
|
|
||||||
QLabel* body = new QLabel(msg.getBody());
|
QLabel* body = new QLabel(msg.getBody());
|
||||||
|
body->setTextInteractionFlags(body->textInteractionFlags() | Qt::TextSelectableByMouse);
|
||||||
QLabel* sender = new QLabel();
|
QLabel* sender = new QLabel();
|
||||||
QLabel* time = new QLabel(msg.getTime().toLocalTime().toString());
|
QLabel* time = new QLabel(msg.getTime().toLocalTime().toString());
|
||||||
QFont dFont = time->font();
|
QFont dFont = time->font();
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
#include <QtQuickWidgets/QQuickWidget>
|
|
||||||
|
|
||||||
class MessageLine : public QWidget
|
class MessageLine : public QWidget
|
||||||
{
|
{
|
||||||
@ -71,7 +70,6 @@ private:
|
|||||||
QString myName;
|
QString myName;
|
||||||
std::map<QString, QString> palNames;
|
std::map<QString, QString> palNames;
|
||||||
std::deque<QHBoxLayout*> views;
|
std::deque<QHBoxLayout*> views;
|
||||||
QQuickWidget busy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGELINE_H
|
#endif // MESSAGELINE_H
|
||||||
|
24
ui/squawk.ui
24
ui/squawk.ui
@ -76,16 +76,14 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="actionAccounts"/>
|
<addaction name="actionAccounts"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuSettings"/>
|
<widget class="QMenu" name="menuFile">
|
||||||
|
<property name="title">
|
||||||
|
<string>File</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
<addaction name="menuFile"/>
|
||||||
<attribute name="toolBarArea">
|
<addaction name="menuSettings"/>
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<addaction name="actionAccounts"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionAccounts">
|
<action name="actionAccounts">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@ -96,6 +94,14 @@
|
|||||||
<string>Accounts</string>
|
<string>Accounts</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionQuit">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="application-exit"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Quit</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
Reference in New Issue
Block a user