forked from blue/squawk
Defaulted to qt6, fix some deprecations
This commit is contained in:
parent
a8060b393c
commit
066ab487fc
@ -5,8 +5,9 @@
|
|||||||
- messages to the mucs get sent once again
|
- messages to the mucs get sent once again
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- it's possible to build against Qt 6 now
|
- it's possible to build against Qt 6 now, Qt6 is the default
|
||||||
- got rid of deprecated SimpleCrypt library
|
- got rid of deprecated SimpleCrypt library
|
||||||
|
- look up for proper stanzaID
|
||||||
|
|
||||||
## Squawk 0.2.3 (February 04, 2024)
|
## Squawk 0.2.3 (February 04, 2024)
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
@ -36,15 +36,18 @@ option(WITH_KCONFIG "Build KConfig support module" ON)
|
|||||||
option(WITH_OMEMO "Build OMEMO support module" OFF) #it should be off by default untill I sort the problems out
|
option(WITH_OMEMO "Build OMEMO support module" OFF) #it should be off by default untill I sort the problems out
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
## Qt
|
## Qt, detect and prefer Qt6 if available
|
||||||
if (NOT DEFINED QT_VERSION_MAJOR)
|
find_package(Qt6 QUIET CONFIG COMPONENTS Widgets DBus Gui Xml Network Core)
|
||||||
find_package(QT NAMES Qt6 Qt5 CONFIG REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
|
if (Qt6_FOUND)
|
||||||
else ()
|
set(QT_VERSION_MAJOR 6)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
|
else()
|
||||||
|
find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus Gui Xml Network Core)
|
||||||
|
set(QT_VERSION_MAJOR 5)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Boost COMPONENTS)
|
message(STATUS "Building against Qt${QT_VERSION_MAJOR}")
|
||||||
|
|
||||||
|
find_package(Boost COMPONENTS)
|
||||||
target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS})
|
target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
## OMEMO
|
## OMEMO
|
||||||
|
@ -108,7 +108,7 @@ Here is the list of keys you can pass to configuration phase of `cmake ..`:
|
|||||||
- `WITH_KIO` - `True` builds the `KIO` capability module if `KIO` is installed and if not goes to `False`. `False` disables `KIO` support (default is `True`)
|
- `WITH_KIO` - `True` builds the `KIO` capability module if `KIO` is installed and if not goes to `False`. `False` disables `KIO` support (default is `True`)
|
||||||
- `WITH_KCONFIG` - `True` builds the `KConfig` and `KConfigWidgets` capability module if such packages are installed and if not goes to `False`. `False` disables `KConfig` and `KConfigWidgets` support (default is `True`)
|
- `WITH_KCONFIG` - `True` builds the `KConfig` and `KConfigWidgets` capability module if such packages are installed and if not goes to `False`. `False` disables `KConfig` and `KConfigWidgets` support (default is `True`)
|
||||||
- `WITH_OMEMO` - `True` builds the OMEMO encryption, requires `qxmpp` of version >= 1.5.0 built with OMEMO support. `False` disables OMEMO support (default is `False`)
|
- `WITH_OMEMO` - `True` builds the OMEMO encryption, requires `qxmpp` of version >= 1.5.0 built with OMEMO support. `False` disables OMEMO support (default is `False`)
|
||||||
- `QT_VERSION_MAJOR` - `6` builds against Qt 6, `5` builds against Qt 6, corresponding version of lmdbal and qxmpp should be installed. By default it picks your system default Qt
|
- `QT_VERSION_MAJOR` - `6` builds against Qt 6, `5` builds against Qt 6, corresponding version of lmdbal and qxmpp should be installed (default is `6`)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -164,19 +164,7 @@ bool Core::MessageHandler::handleGroupMessage(const QXmppMessage& msg, bool outg
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing, bool forwarded, bool guessing) const {
|
void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing, bool forwarded, bool guessing) const {
|
||||||
const QDateTime& time(source.stamp());
|
initializeIDs(target, source);
|
||||||
QString id;
|
|
||||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
|
||||||
id = source.originId();
|
|
||||||
if (id.size() == 0)
|
|
||||||
id = source.id();
|
|
||||||
|
|
||||||
target.setStanzaId(source.stanzaId());
|
|
||||||
qDebug() << "initializing message with originId:" << source.originId() << ", id:" << source.id() << ", stansaId:" << source.stanzaId();
|
|
||||||
#else
|
|
||||||
id = source.id();
|
|
||||||
#endif
|
|
||||||
target.setId(id);
|
|
||||||
QString messageId = target.getId();
|
QString messageId = target.getId();
|
||||||
if (messageId.size() == 0) {
|
if (messageId.size() == 0) {
|
||||||
target.generateRandomId(); //TODO out of desperation, I need at least a random ID
|
target.generateRandomId(); //TODO out of desperation, I need at least a random ID
|
||||||
@ -197,6 +185,7 @@ void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmp
|
|||||||
if (guessing)
|
if (guessing)
|
||||||
outgoing = target.getFromJid() == acc->getBareJid();
|
outgoing = target.getFromJid() == acc->getBareJid();
|
||||||
|
|
||||||
|
const QDateTime& time(source.stamp());
|
||||||
target.setOutgoing(outgoing);
|
target.setOutgoing(outgoing);
|
||||||
if (time.isValid())
|
if (time.isValid())
|
||||||
target.setTime(time);
|
target.setTime(time);
|
||||||
@ -210,6 +199,37 @@ void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmp
|
|||||||
target.setOutOfBandUrl(oob);
|
target.setOutOfBandUrl(oob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::MessageHandler::initializeIDs(Shared::Message& target, const QXmppMessage& source) const {
|
||||||
|
QString id;
|
||||||
|
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
||||||
|
id = source.originId();
|
||||||
|
if (id.size() == 0)
|
||||||
|
id = source.id();
|
||||||
|
|
||||||
|
QString stanzaID;
|
||||||
|
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 5, 0)
|
||||||
|
// here I'm looking preferably for id generated by myself, but if there isn't - any is better than nothing
|
||||||
|
QVector<QXmppStanzaId> sIDs = source.stanzaIds();
|
||||||
|
for (const QXmppStanzaId& sID : sIDs) {
|
||||||
|
bool match = sID.by == acc->getBareJid();
|
||||||
|
if (stanzaID.isEmpty() || match)
|
||||||
|
stanzaID = sID.id;
|
||||||
|
|
||||||
|
if (match)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
stanzaID = source.stanzaId();
|
||||||
|
#endif
|
||||||
|
target.setStanzaId(stanzaID);
|
||||||
|
qDebug() << "initializing message with originId:" << source.originId() << ", id:" << source.id() << ", stanzaId:" << stanzaID;
|
||||||
|
#else
|
||||||
|
id = source.id();
|
||||||
|
#endif
|
||||||
|
target.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& reason) {
|
void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& reason) {
|
||||||
qDebug() << reason;
|
qDebug() << reason;
|
||||||
qDebug() << "- from: " << msg.from();
|
qDebug() << "- from: " << msg.from();
|
||||||
@ -219,9 +239,6 @@ void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& re
|
|||||||
qDebug() << "- state: " << msg.state();
|
qDebug() << "- state: " << msg.state();
|
||||||
qDebug() << "- stamp: " << msg.stamp();
|
qDebug() << "- stamp: " << msg.stamp();
|
||||||
qDebug() << "- id: " << msg.id();
|
qDebug() << "- id: " << msg.id();
|
||||||
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
|
|
||||||
qDebug() << "- stanzaId: " << msg.stanzaId();
|
|
||||||
#endif
|
|
||||||
qDebug() << "- outOfBandUrl: " << msg.outOfBandUrl();
|
qDebug() << "- outOfBandUrl: " << msg.outOfBandUrl();
|
||||||
qDebug() << "==============================";
|
qDebug() << "==============================";
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ private:
|
|||||||
bool handlePendingMessageError(const QString& id, const QString& errorText);
|
bool handlePendingMessageError(const QString& id, const QString& errorText);
|
||||||
std::pair<Shared::Message::State, QString> scheduleSending(const Shared::Message& message, const QDateTime& sendTime, const QString& originalId);
|
std::pair<Shared::Message::State, QString> scheduleSending(const Shared::Message& message, const QDateTime& sendTime, const QString& originalId);
|
||||||
bool adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final);
|
bool adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final);
|
||||||
|
void initializeIDs(Shared::Message& target, const QXmppMessage& source) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Account* acc;
|
Account* acc;
|
||||||
|
@ -6,7 +6,7 @@ pkgdesc="An XMPP desktop messenger, written on pure c++ (qt)"
|
|||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
url="https://git.macaw.me/blue/squawk"
|
url="https://git.macaw.me/blue/squawk"
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
depends=('hicolor-icon-theme' 'desktop-file-utils' 'lmdbal-qt6' 'qxmpp-qt6')
|
depends=('hicolor-icon-theme' 'desktop-file-utils' 'lmdbal-qt6' 'qxmpp')
|
||||||
makedepends=('cmake>=3.3' 'imagemagick' 'qt6-tools' 'boost')
|
makedepends=('cmake>=3.3' 'imagemagick' 'qt6-tools' 'boost')
|
||||||
optdepends=('kwallet6: secure password storage (requires rebuild)'
|
optdepends=('kwallet6: secure password storage (requires rebuild)'
|
||||||
'kconfig6: system themes support (requires rebuild)'
|
'kconfig6: system themes support (requires rebuild)'
|
||||||
|
@ -33,96 +33,78 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing):
|
|||||||
setContentsMargins(margin, margin, margin, margin);
|
setContentsMargins(margin, margin, margin, margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowLayout::~FlowLayout()
|
FlowLayout::~FlowLayout() {
|
||||||
{
|
|
||||||
QLayoutItem *item;
|
QLayoutItem *item;
|
||||||
while ((item = takeAt(0))) {
|
while ((item = takeAt(0)))
|
||||||
delete item;
|
delete item;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlowLayout::addItem(QLayoutItem *item)
|
void FlowLayout::addItem(QLayoutItem *item) {
|
||||||
{
|
|
||||||
itemList.append(item);
|
itemList.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::horizontalSpacing() const
|
int FlowLayout::horizontalSpacing() const {
|
||||||
{
|
if (m_hSpace >= 0)
|
||||||
if (m_hSpace >= 0) {
|
|
||||||
return m_hSpace;
|
return m_hSpace;
|
||||||
} else {
|
else
|
||||||
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::verticalSpacing() const
|
int FlowLayout::verticalSpacing() const {
|
||||||
{
|
if (m_vSpace >= 0)
|
||||||
if (m_vSpace >= 0) {
|
|
||||||
return m_vSpace;
|
return m_vSpace;
|
||||||
} else {
|
else
|
||||||
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::count() const
|
int FlowLayout::count() const {
|
||||||
{
|
|
||||||
return itemList.size();
|
return itemList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayoutItem *FlowLayout::itemAt(int index) const
|
QLayoutItem *FlowLayout::itemAt(int index) const {
|
||||||
{
|
|
||||||
return itemList.value(index);
|
return itemList.value(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayoutItem *FlowLayout::takeAt(int index)
|
QLayoutItem *FlowLayout::takeAt(int index) {
|
||||||
{
|
if (index >= 0 && index < itemList.size())
|
||||||
if (index >= 0 && index < itemList.size()) {
|
|
||||||
return itemList.takeAt(index);
|
return itemList.takeAt(index);
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Orientations FlowLayout::expandingDirections() const
|
Qt::Orientations FlowLayout::expandingDirections() const {
|
||||||
{
|
|
||||||
return Qt::Orientations();
|
return Qt::Orientations();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlowLayout::hasHeightForWidth() const
|
bool FlowLayout::hasHeightForWidth() const {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::heightForWidth(int width) const
|
int FlowLayout::heightForWidth(int width) const {
|
||||||
{
|
|
||||||
int height = doLayout(QRect(0, 0, width, 0), true);
|
int height = doLayout(QRect(0, 0, width, 0), true);
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlowLayout::setGeometry(const QRect &rect)
|
void FlowLayout::setGeometry(const QRect &rect) {
|
||||||
{
|
|
||||||
QLayout::setGeometry(rect);
|
QLayout::setGeometry(rect);
|
||||||
doLayout(rect, false);
|
doLayout(rect, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize FlowLayout::sizeHint() const
|
QSize FlowLayout::sizeHint() const {
|
||||||
{
|
|
||||||
return minimumSize();
|
return minimumSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize FlowLayout::minimumSize() const
|
QSize FlowLayout::minimumSize() const {
|
||||||
{
|
|
||||||
QSize size;
|
QSize size;
|
||||||
for (const QLayoutItem *item : qAsConst(itemList)) {
|
for (const QLayoutItem *item : std::as_const(itemList))
|
||||||
size = size.expandedTo(item->minimumSize());
|
size = size.expandedTo(item->minimumSize());
|
||||||
}
|
|
||||||
|
|
||||||
const QMargins margins = contentsMargins();
|
const QMargins margins = contentsMargins();
|
||||||
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
|
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const {
|
||||||
{
|
|
||||||
int left, top, right, bottom;
|
int left, top, right, bottom;
|
||||||
getContentsMargins(&left, &top, &right, &bottom);
|
getContentsMargins(&left, &top, &right, &bottom);
|
||||||
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
|
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
|
||||||
@ -130,16 +112,16 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
|||||||
int y = effectiveRect.y();
|
int y = effectiveRect.y();
|
||||||
int lineHeight = 0;
|
int lineHeight = 0;
|
||||||
|
|
||||||
for (QLayoutItem *item : qAsConst(itemList)) {
|
for (QLayoutItem *item : std::as_const(itemList)) {
|
||||||
const QWidget *wid = item->widget();
|
const QWidget *wid = item->widget();
|
||||||
int spaceX = horizontalSpacing();
|
int spaceX = horizontalSpacing();
|
||||||
if (spaceX == -1) {
|
if (spaceX == -1)
|
||||||
spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
|
spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
|
||||||
}
|
|
||||||
int spaceY = verticalSpacing();
|
int spaceY = verticalSpacing();
|
||||||
if (spaceY == -1) {
|
if (spaceY == -1)
|
||||||
spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
|
spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
|
||||||
}
|
|
||||||
int nextX = x + item->sizeHint().width() + spaceX;
|
int nextX = x + item->sizeHint().width() + spaceX;
|
||||||
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
|
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
|
||||||
x = effectiveRect.x();
|
x = effectiveRect.x();
|
||||||
@ -148,9 +130,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
|||||||
lineHeight = 0;
|
lineHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!testOnly) {
|
if (!testOnly)
|
||||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||||
}
|
|
||||||
|
|
||||||
x = nextX;
|
x = nextX;
|
||||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||||
@ -158,8 +139,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
|||||||
return y + lineHeight - rect.y() + bottom;
|
return y + lineHeight - rect.y() + bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const {
|
||||||
{
|
|
||||||
QObject *parent = this->parent();
|
QObject *parent = this->parent();
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user