Defaulted to qt6, fix some deprecations

This commit is contained in:
Blue 2025-02-20 21:37:38 +02:00
parent a8060b393c
commit 066ab487fc
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
7 changed files with 76 additions and 74 deletions

View File

@ -5,8 +5,9 @@
- messages to the mucs get sent once again
### 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
- look up for proper stanzaID
## Squawk 0.2.3 (February 04, 2024)
### Bug fixes

View File

@ -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
# Dependencies
## Qt
if (NOT DEFINED QT_VERSION_MAJOR)
find_package(QT NAMES Qt6 Qt5 CONFIG REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
else ()
find_package(Qt${QT_VERSION_MAJOR} CONFIG REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
## Qt, detect and prefer Qt6 if available
find_package(Qt6 QUIET CONFIG COMPONENTS Widgets DBus Gui Xml Network Core)
if (Qt6_FOUND)
set(QT_VERSION_MAJOR 6)
else()
find_package(Qt5 REQUIRED CONFIG COMPONENTS Widgets DBus Gui Xml Network Core)
set(QT_VERSION_MAJOR 5)
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})
## OMEMO

View File

@ -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_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`)
- `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

View File

@ -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 {
const QDateTime& time(source.stamp());
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);
initializeIDs(target, source);
QString messageId = target.getId();
if (messageId.size() == 0) {
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)
outgoing = target.getFromJid() == acc->getBareJid();
const QDateTime& time(source.stamp());
target.setOutgoing(outgoing);
if (time.isValid())
target.setTime(time);
@ -210,6 +199,37 @@ void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmp
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) {
qDebug() << reason;
qDebug() << "- from: " << msg.from();
@ -219,9 +239,6 @@ void Core::MessageHandler::logMessage(const QXmppMessage& msg, const QString& re
qDebug() << "- state: " << msg.state();
qDebug() << "- stamp: " << msg.stamp();
qDebug() << "- id: " << msg.id();
#if (QXMPP_VERSION) >= QT_VERSION_CHECK(1, 3, 0)
qDebug() << "- stanzaId: " << msg.stanzaId();
#endif
qDebug() << "- outOfBandUrl: " << msg.outOfBandUrl();
qDebug() << "==============================";
}

View File

@ -77,6 +77,7 @@ private:
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);
bool adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final);
void initializeIDs(Shared::Message& target, const QXmppMessage& source) const;
private:
Account* acc;

View File

@ -6,7 +6,7 @@ pkgdesc="An XMPP desktop messenger, written on pure c++ (qt)"
arch=('i686' 'x86_64')
url="https://git.macaw.me/blue/squawk"
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')
optdepends=('kwallet6: secure password storage (requires rebuild)'
'kconfig6: system themes support (requires rebuild)'

View File

@ -33,96 +33,78 @@ FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing):
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::~FlowLayout()
{
FlowLayout::~FlowLayout() {
QLayoutItem *item;
while ((item = takeAt(0))) {
while ((item = takeAt(0)))
delete item;
}
}
void FlowLayout::addItem(QLayoutItem *item)
{
void FlowLayout::addItem(QLayoutItem *item) {
itemList.append(item);
}
int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
int FlowLayout::horizontalSpacing() const {
if (m_hSpace >= 0)
return m_hSpace;
} else {
else
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
}
int FlowLayout::verticalSpacing() const
{
if (m_vSpace >= 0) {
int FlowLayout::verticalSpacing() const {
if (m_vSpace >= 0)
return m_vSpace;
} else {
else
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}
int FlowLayout::count() const
{
int FlowLayout::count() const {
return itemList.size();
}
QLayoutItem *FlowLayout::itemAt(int index) const
{
QLayoutItem *FlowLayout::itemAt(int index) const {
return itemList.value(index);
}
QLayoutItem *FlowLayout::takeAt(int index)
{
if (index >= 0 && index < itemList.size()) {
QLayoutItem *FlowLayout::takeAt(int index) {
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
}
return nullptr;
}
Qt::Orientations FlowLayout::expandingDirections() const
{
Qt::Orientations FlowLayout::expandingDirections() const {
return Qt::Orientations();
}
bool FlowLayout::hasHeightForWidth() const
{
bool FlowLayout::hasHeightForWidth() const {
return true;
}
int FlowLayout::heightForWidth(int width) const
{
int FlowLayout::heightForWidth(int width) const {
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
void FlowLayout::setGeometry(const QRect &rect)
{
void FlowLayout::setGeometry(const QRect &rect) {
QLayout::setGeometry(rect);
doLayout(rect, false);
}
QSize FlowLayout::sizeHint() const
{
QSize FlowLayout::sizeHint() const {
return minimumSize();
}
QSize FlowLayout::minimumSize() const
{
QSize FlowLayout::minimumSize() const {
QSize size;
for (const QLayoutItem *item : qAsConst(itemList)) {
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());
}
const QMargins margins = contentsMargins();
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
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;
getContentsMargins(&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 lineHeight = 0;
for (QLayoutItem *item : qAsConst(itemList)) {
for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1) {
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
}
int spaceY = verticalSpacing();
if (spaceY == -1) {
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
}
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
@ -148,9 +130,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
lineHeight = 0;
}
if (!testOnly) {
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
}
x = nextX;
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;
}
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const {
QObject *parent = this->parent();
if (!parent) {
return -1;