Make NeoChat compile against libQuotient master and 0.6
Requires a few ugly ifdefs, but it will make developing against the master branch of libQuotient easier
This commit is contained in:
@@ -85,10 +85,6 @@ set_package_properties(Quotient PROPERTIES
|
|||||||
PURPOSE "Talk with matrix server"
|
PURPOSE "Talk with matrix server"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${Quotient_VERSION_MINOR} GREATER 6)
|
|
||||||
message(SEND_ERROR "NeoChat cannot be compiled against a 0.7 version of libQuotient. Use a 0.6 version instead")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(cmark)
|
find_package(cmark)
|
||||||
set_package_properties(cmark PROPERTIES
|
set_package_properties(cmark PROPERTIES
|
||||||
TYPE REQUIRED
|
TYPE REQUIRED
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ add_executable(neochat
|
|||||||
../res.qrc
|
../res.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(${Quotient_VERSION_MINOR} GREATER 6)
|
||||||
|
target_compile_definitions(neochat PRIVATE QUOTIENT_07)
|
||||||
|
endif()
|
||||||
|
|
||||||
ecm_add_app_icon(NEOCHAT_ICON ICONS ${CMAKE_SOURCE_DIR}/128-logo.png)
|
ecm_add_app_icon(NEOCHAT_ICON ICONS ${CMAKE_SOURCE_DIR}/128-logo.png)
|
||||||
|
|
||||||
target_sources(neochat PRIVATE ${NEOCHAT_ICON})
|
target_sources(neochat PRIVATE ${NEOCHAT_ICON})
|
||||||
|
|||||||
@@ -395,7 +395,11 @@ void Controller::playAudio(const QUrl &localFile)
|
|||||||
void Controller::changeAvatar(Connection *conn, const QUrl &localFile)
|
void Controller::changeAvatar(Connection *conn, const QUrl &localFile)
|
||||||
{
|
{
|
||||||
auto job = conn->uploadFile(localFile.toLocalFile());
|
auto job = conn->uploadFile(localFile.toLocalFile());
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
if(isJobPending(job)) {
|
||||||
|
#else
|
||||||
if (isJobRunning(job)) {
|
if (isJobRunning(job)) {
|
||||||
|
#endif
|
||||||
connect(job, &BaseJob::success, this, [conn, job] {
|
connect(job, &BaseJob::success, this, [conn, job] {
|
||||||
conn->callApi<SetAvatarUrlJob>(conn->userId(), job->contentUri());
|
conn->callApi<SetAvatarUrlJob>(conn->userId(), job->contentUri());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -392,7 +392,11 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
|||||||
}
|
}
|
||||||
if (e.avatarUrl().isEmpty()) {
|
if (e.avatarUrl().isEmpty()) {
|
||||||
text += i18nc("their refers to a singular user", "cleared their avatar");
|
text += i18nc("their refers to a singular user", "cleared their avatar");
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
} else if (!e.prevContent()->avatarUrl) {
|
||||||
|
#else
|
||||||
} else if (e.prevContent()->avatarUrl.isEmpty()) {
|
} else if (e.prevContent()->avatarUrl.isEmpty()) {
|
||||||
|
#endif
|
||||||
text += i18n("set an avatar");
|
text += i18n("set an avatar");
|
||||||
} else {
|
} else {
|
||||||
text += i18nc("their refers to a singular user", "updated their avatar");
|
text += i18nc("their refers to a singular user", "updated their avatar");
|
||||||
@@ -451,7 +455,11 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
|||||||
void NeoChatRoom::changeAvatar(const QUrl &localFile)
|
void NeoChatRoom::changeAvatar(const QUrl &localFile)
|
||||||
{
|
{
|
||||||
const auto job = connection()->uploadFile(localFile.toLocalFile());
|
const auto job = connection()->uploadFile(localFile.toLocalFile());
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
if(isJobPending(job)) {
|
||||||
|
#else
|
||||||
if (isJobRunning(job)) {
|
if (isJobRunning(job)) {
|
||||||
|
#endif
|
||||||
connect(job, &BaseJob::success, this, [this, job] {
|
connect(job, &BaseJob::success, this, [this, job] {
|
||||||
connection()->callApi<SetRoomStateWithKeyJob>(id(), "m.room.avatar", localUser()->id(), QJsonObject{{"url", job->contentUri()}});
|
connection()->callApi<SetRoomStateWithKeyJob>(id(), "m.room.avatar", localUser()->id(), QJsonObject{{"url", job->contentUri()}});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,7 +48,13 @@ void UserListModel::setRoom(Quotient::Room *room)
|
|||||||
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
||||||
}
|
}
|
||||||
for (User *user : qAsConst(m_users)) {
|
for (User *user : qAsConst(m_users)) {
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
connect(user, &User::defaultAvatarChanged, this, [=](){
|
||||||
|
avatarChanged(user, m_currentRoom);
|
||||||
|
});
|
||||||
|
#else
|
||||||
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);
|
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
||||||
setRoom(nullptr);
|
setRoom(nullptr);
|
||||||
@@ -147,7 +153,13 @@ void UserListModel::userAdded(Quotient::User *user)
|
|||||||
beginInsertRows(QModelIndex(), pos, pos);
|
beginInsertRows(QModelIndex(), pos, pos);
|
||||||
m_users.insert(pos, user);
|
m_users.insert(pos, user);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
|
connect(user, &User::defaultAvatarChanged, this, [=](){
|
||||||
|
avatarChanged(user, m_currentRoom);
|
||||||
|
});
|
||||||
|
#else
|
||||||
connect(user, &Quotient::User::avatarChanged, this, &UserListModel::avatarChanged);
|
connect(user, &Quotient::User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserListModel::userRemoved(Quotient::User *user)
|
void UserListModel::userRemoved(Quotient::User *user)
|
||||||
|
|||||||
Reference in New Issue
Block a user