mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 06:08:48 +03:00
commit
ea5f6ca0f4
19 changed files with 138 additions and 107 deletions
|
@ -18,8 +18,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
|
||||||
option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
|
option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
|
||||||
include("cmake/HunterGate.cmake")
|
include("cmake/HunterGate.cmake")
|
||||||
HunterGate(
|
HunterGate(
|
||||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.260.tar.gz"
|
URL "https://github.com/cpp-pm/hunter/archive/v0.23.288.tar.gz"
|
||||||
SHA1 "13775235910a3fa85644568d1c5be8271de72e1c"
|
SHA1 "6c9b2bc606d86ae31f96a62fc68f0a593024815b"
|
||||||
)
|
)
|
||||||
|
|
||||||
option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED})
|
option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED})
|
||||||
|
@ -579,6 +579,7 @@ endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_executable (nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
|
add_executable (nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
|
||||||
|
target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601)
|
||||||
else()
|
else()
|
||||||
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
|
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -2,45 +2,65 @@
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Debug",
|
"name": "Debug",
|
||||||
"generator": "Visual Studio 15 2017 Win64",
|
"generator": "Visual Studio 16 2019 Win64",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"buildRoot": "${workspaceRoot}\\build-vc\\${name}",
|
"buildRoot": "${workspaceRoot}\\build-vc\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "CMAKE_TOOLCHAIN_FILE",
|
"name": "HUNTER_ENABLED",
|
||||||
"value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here
|
"value": "OFF",
|
||||||
|
"type": "BOOL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BUILD_SHARED_LIBS",
|
||||||
|
"value": "ON",
|
||||||
|
"type": "BOOL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CMAKE_INSTALL_PREFIX",
|
"name": "CMAKE_INSTALL_PREFIX",
|
||||||
"value": "${workspaceRoot}/.deps"
|
"value": "${workspaceRoot}/.deps",
|
||||||
|
"type": "STRING"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Qt5_DIR",
|
"name": "Qt5_DIR",
|
||||||
"value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here
|
"value": "C:\\Qt\\5.12.5\\msvc2017_64\\lib\\cmake\\Qt5", // <-- change qt location here
|
||||||
|
"type": "STRING"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"cmakeToolchain": "${workspaceRoot}\\toolchain.cmake",
|
||||||
|
"inheritEnvironments": [ "msvc_x64" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Release",
|
"name": "Release",
|
||||||
"generator": "Visual Studio 15 2017 Win64",
|
"generator": "Visual Studio 16 2019 Win64",
|
||||||
"configurationType": "Release",
|
"configurationType": "Release",
|
||||||
"buildRoot": "${workspaceRoot}\\build-vc\\${name}",
|
"buildRoot": "${workspaceRoot}\\build-vc\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "CMAKE_TOOLCHAIN_FILE",
|
"name": "HUNTER_ENABLED",
|
||||||
"value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here
|
"value": "ON",
|
||||||
|
"type": "BOOL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BUILD_SHARED_LIBS",
|
||||||
|
"value": "OFF",
|
||||||
|
"type": "BOOL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CMAKE_INSTALL_PREFIX",
|
"name": "CMAKE_INSTALL_PREFIX",
|
||||||
"value": "${workspaceRoot}/.deps"
|
"value": "${workspaceRoot}/.deps",
|
||||||
|
"type": "STRING"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Qt5_DIR",
|
"name": "Qt5_DIR",
|
||||||
"value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here
|
"value": "C:\\Qt\\5.12.5\\msvc2017_64\\lib\\cmake\\Qt5", // <-- change qt location here
|
||||||
|
"type": "STRING"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmakeToolchain": "${workspaceRoot}\\toolchain.cmake",
|
||||||
|
"inheritEnvironments": [ "msvc_x64" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
}
|
12
appveyor.yml
12
appveyor.yml
|
@ -3,7 +3,7 @@
|
||||||
version: 0.7.2-{build}
|
version: 0.7.2-{build}
|
||||||
|
|
||||||
configuration: Release
|
configuration: Release
|
||||||
image: Visual Studio 2017
|
image: Visual Studio 2019
|
||||||
platform: x64
|
platform: x64
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
@ -22,9 +22,9 @@ build:
|
||||||
verbosity: minimal
|
verbosity: minimal
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- set QT_DIR=C:\Qt\5.13\msvc2017_64
|
- set QT_DIR=C:\Qt\5.15\msvc2019_64
|
||||||
- set PATH=%PATH%;%QT_DIR%\bin
|
- set PATH=C:\Strawberry\perl\bin;%PATH%;%QT_DIR%\bin
|
||||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
# VERSION format: branch-master/branch-1.2
|
# VERSION format: branch-master/branch-1.2
|
||||||
|
@ -46,8 +46,8 @@ build_script:
|
||||||
- echo %DATE%
|
- echo %DATE%
|
||||||
|
|
||||||
# Build nheko
|
# Build nheko
|
||||||
#- cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild
|
#- cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild
|
||||||
- cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild
|
- cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild
|
||||||
-DHUNTER_ROOT="C:\hunter"
|
-DHUNTER_ROOT="C:\hunter"
|
||||||
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF
|
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF
|
||||||
-DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
-DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
||||||
|
|
|
@ -81,7 +81,7 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca
|
||||||
cache::saveImage(cacheKey.toStdString(), res);
|
cache::saveImage(cacheKey.toStdString(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit proxy->avatarDownloaded(QByteArray(res.data(), res.size()));
|
emit proxy->avatarDownloaded(QByteArray(res.data(), (int)res.size()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ BlurhashResponse::run()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage image(decoded.image.data(), decoded.width, decoded.height, QImage::Format_RGB32);
|
QImage image(
|
||||||
|
decoded.image.data(), (int)decoded.width, (int)decoded.height, QImage::Format_RGB32);
|
||||||
|
|
||||||
m_image = image.copy();
|
m_image = image.copy();
|
||||||
emit finished();
|
emit finished();
|
||||||
|
|
|
@ -685,7 +685,7 @@ Cache::image(lmdb::txn &txn, const std::string &url) const
|
||||||
if (!res)
|
if (!res)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
||||||
return QByteArray(image.data(), image.size());
|
return QByteArray(image.data(), (int)image.size());
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &e) {
|
||||||
nhlog::db()->critical("image: {}, {}", e.what(), url);
|
nhlog::db()->critical("image: {}, {}", e.what(), url);
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ Cache::image(const QString &url) const
|
||||||
if (!res)
|
if (!res)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
||||||
return QByteArray(image.data(), image.size());
|
return QByteArray(image.data(), (int)image.size());
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &e) {
|
||||||
nhlog::db()->critical("image: {} {}", e.what(), url.toStdString());
|
nhlog::db()->critical("image: {} {}", e.what(), url.toStdString());
|
||||||
}
|
}
|
||||||
|
@ -1267,9 +1267,10 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
updatedInfo.tags = tmp.tags;
|
updatedInfo.tags = tmp.tags;
|
||||||
} catch (const json::exception &e) {
|
} catch (const json::exception &e) {
|
||||||
nhlog::db()->warn(
|
nhlog::db()->warn(
|
||||||
"failed to parse room info: room_id ({}), {}",
|
"failed to parse room info: room_id ({}), {}: {}",
|
||||||
room.first,
|
room.first,
|
||||||
std::string(data.data(), data.size()));
|
std::string(data.data(), data.size()),
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1468,9 +1469,10 @@ Cache::singleRoomInfo(const std::string &room_id)
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
} catch (const json::exception &e) {
|
} catch (const json::exception &e) {
|
||||||
nhlog::db()->warn("failed to parse room info: room_id ({}), {}",
|
nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}",
|
||||||
room_id,
|
room_id,
|
||||||
std::string(data.data(), data.size()));
|
std::string(data.data(), data.size()),
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1502,9 +1504,10 @@ Cache::getRoomInfo(const std::vector<std::string> &rooms)
|
||||||
|
|
||||||
room_info.emplace(QString::fromStdString(room), std::move(tmp));
|
room_info.emplace(QString::fromStdString(room), std::move(tmp));
|
||||||
} catch (const json::exception &e) {
|
} catch (const json::exception &e) {
|
||||||
nhlog::db()->warn("failed to parse room info: room_id ({}), {}",
|
nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}",
|
||||||
room,
|
room,
|
||||||
std::string(data.data(), data.size()));
|
std::string(data.data(), data.size()),
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check if the room is an invite.
|
// Check if the room is an invite.
|
||||||
|
@ -1517,10 +1520,11 @@ Cache::getRoomInfo(const std::vector<std::string> &rooms)
|
||||||
room_info.emplace(QString::fromStdString(room),
|
room_info.emplace(QString::fromStdString(room),
|
||||||
std::move(tmp));
|
std::move(tmp));
|
||||||
} catch (const json::exception &e) {
|
} catch (const json::exception &e) {
|
||||||
nhlog::db()->warn(
|
nhlog::db()->warn("failed to parse room info for invite: "
|
||||||
"failed to parse room info for invite: room_id ({}), {}",
|
"room_id ({}), {}: {}",
|
||||||
room,
|
room,
|
||||||
std::string(data.data(), data.size()));
|
std::string(data.data(), data.size()),
|
||||||
|
e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2054,7 +2058,7 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cursor = lmdb::cursor::open(txn, membersdb);
|
auto cursor = lmdb::cursor::open(txn, membersdb);
|
||||||
const int total = membersdb.size(txn);
|
const auto total = membersdb.size(txn);
|
||||||
|
|
||||||
std::size_t ii = 0;
|
std::size_t ii = 0;
|
||||||
std::string user_id;
|
std::string user_id;
|
||||||
|
@ -2337,7 +2341,7 @@ Cache::getRoomAvatar(const std::string &room_id)
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
return QImage::fromData(QByteArray(response.data(), response.size()));
|
return QImage::fromData(QByteArray(response.data(), (int)response.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
|
|
|
@ -61,7 +61,7 @@ struct RoomInfo
|
||||||
//! Whether or not the room is an invite.
|
//! Whether or not the room is an invite.
|
||||||
bool is_invite = false;
|
bool is_invite = false;
|
||||||
//! Total number of members in the room.
|
//! Total number of members in the room.
|
||||||
int16_t member_count = 0;
|
size_t member_count = 0;
|
||||||
//! Who can access to the room.
|
//! Who can access to the room.
|
||||||
mtx::events::state::JoinRule join_rule = mtx::events::state::JoinRule::Public;
|
mtx::events::state::JoinRule join_rule = mtx::events::state::JoinRule::Public;
|
||||||
bool guest_access = false;
|
bool guest_access = false;
|
||||||
|
|
|
@ -439,7 +439,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http::client()->set_user(parse<User>(userid.toStdString()));
|
http::client()->set_user(parse<User>(userid.toStdString()));
|
||||||
} catch (const std::invalid_argument &e) {
|
} catch (const std::invalid_argument &) {
|
||||||
nhlog::ui()->critical("bootstrapped with invalid user_id: {}",
|
nhlog::ui()->critical("bootstrapped with invalid user_id: {}",
|
||||||
userid.toStdString());
|
userid.toStdString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,8 @@ CommunitiesList::setTagsForRoom(const QString &room_id, const std::vector<std::s
|
||||||
}
|
}
|
||||||
// insert or remove the room from the tag as appropriate
|
// insert or remove the room from the tag as appropriate
|
||||||
std::string current_tag =
|
std::string current_tag =
|
||||||
it->first.right(it->first.size() - strlen("tag:")).toStdString();
|
it->first.right(static_cast<int>(it->first.size() - strlen("tag:")))
|
||||||
|
.toStdString();
|
||||||
if (std::find(tags.begin(), tags.end(), current_tag) != tags.end()) {
|
if (std::find(tags.begin(), tags.end(), current_tag) != tags.end()) {
|
||||||
// the room has this tag
|
// the room has this tag
|
||||||
it->second->addRoom(room_id);
|
it->second->addRoom(room_id);
|
||||||
|
@ -246,7 +247,7 @@ CommunitiesList::fetchCommunityAvatar(const QString &id, const QString &avatarUr
|
||||||
|
|
||||||
cache::saveImage(opts.mxc_url, res);
|
cache::saveImage(opts.mxc_url, res);
|
||||||
|
|
||||||
auto data = QByteArray(res.data(), res.size());
|
auto data = QByteArray(res.data(), (int)res.size());
|
||||||
|
|
||||||
QPixmap pix;
|
QPixmap pix;
|
||||||
pix.loadFromData(data);
|
pix.loadFromData(data);
|
||||||
|
|
|
@ -117,7 +117,7 @@ CommunitiesListItem::resolveName() const
|
||||||
if (!name_.isEmpty())
|
if (!name_.isEmpty())
|
||||||
return name_;
|
return name_;
|
||||||
if (groupId_.startsWith("tag:"))
|
if (groupId_.startsWith("tag:"))
|
||||||
return groupId_.right(groupId_.size() - strlen("tag:"));
|
return groupId_.right(static_cast<int>(groupId_.size() - strlen("tag:")));
|
||||||
if (!groupId_.startsWith("+"))
|
if (!groupId_.startsWith("+"))
|
||||||
return QString("Group"); // Group with no name or id.
|
return QString("Group"); // Group with no name or id.
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ CommunitiesListItem::updateTooltip()
|
||||||
if (groupId_ == "world")
|
if (groupId_ == "world")
|
||||||
setToolTip(tr("All rooms"));
|
setToolTip(tr("All rooms"));
|
||||||
else if (is_tag()) {
|
else if (is_tag()) {
|
||||||
QString tag = groupId_.right(groupId_.size() - strlen("tag:"));
|
QString tag = groupId_.right(static_cast<int>(groupId_.size() - strlen("tag:")));
|
||||||
if (tag == "m.favourite")
|
if (tag == "m.favourite")
|
||||||
setToolTip(tr("Favourite rooms"));
|
setToolTip(tr("Favourite rooms"));
|
||||||
else if (tag == "m.lowpriority")
|
else if (tag == "m.lowpriority")
|
||||||
|
|
|
@ -225,7 +225,7 @@ LoginPage::onMatrixIdEntered()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
user = parse<User>(matrixid_input_->text().toStdString());
|
user = parse<User>(matrixid_input_->text().toStdString());
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &) {
|
||||||
showError(error_matrixid_label_,
|
showError(error_matrixid_label_,
|
||||||
"You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
"You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
return;
|
return;
|
||||||
|
@ -389,7 +389,7 @@ LoginPage::onLoginButtonClicked()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
user = parse<User>(matrixid_input_->text().toStdString());
|
user = parse<User>(matrixid_input_->text().toStdString());
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &) {
|
||||||
showError(error_matrixid_label_,
|
showError(error_matrixid_label_,
|
||||||
"You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
"You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -164,7 +164,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
try {
|
try {
|
||||||
using namespace mtx::identifiers;
|
using namespace mtx::identifiers;
|
||||||
http::client()->set_user(parse<User>(user_id.toStdString()));
|
http::client()->set_user(parse<User>(user_id.toStdString()));
|
||||||
} catch (const std::invalid_argument &e) {
|
} catch (const std::invalid_argument &) {
|
||||||
nhlog::ui()->critical("bootstrapped with invalid user_id: {}",
|
nhlog::ui()->critical("bootstrapped with invalid user_id: {}",
|
||||||
user_id.toStdString());
|
user_id.toStdString());
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ MainWindow::openReadReceiptsDialog(const QString &event_id)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dialog->addUsers(cache::readReceipts(event_id, room_id));
|
dialog->addUsers(cache::readReceipts(event_id, room_id));
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &) {
|
||||||
nhlog::db()->warn("failed to retrieve read receipts for {} {}",
|
nhlog::db()->warn("failed to retrieve read receipts for {} {}",
|
||||||
event_id.toStdString(),
|
event_id.toStdString(),
|
||||||
chat_page_->currentRoom().toStdString());
|
chat_page_->currentRoom().toStdString());
|
||||||
|
|
|
@ -48,7 +48,7 @@ MxcImageResponse::run()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = QByteArray(res.data(), res.size());
|
auto data = QByteArray(res.data(), (int)res.size());
|
||||||
cache::saveImage(fileName, data);
|
cache::saveImage(fileName, data);
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(&data);
|
||||||
if (!m_image.isNull()) {
|
if (!m_image.isNull()) {
|
||||||
|
@ -92,7 +92,7 @@ MxcImageResponse::run()
|
||||||
temp = mtx::crypto::to_string(
|
temp = mtx::crypto::to_string(
|
||||||
mtx::crypto::decrypt_file(temp, m_encryptionInfo.value()));
|
mtx::crypto::decrypt_file(temp, m_encryptionInfo.value()));
|
||||||
|
|
||||||
auto data = QByteArray(temp.data(), temp.size());
|
auto data = QByteArray(temp.data(), (int)temp.size());
|
||||||
cache::saveImage(m_id, data);
|
cache::saveImage(m_id, data);
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(&data);
|
||||||
m_image.setText("original filename",
|
m_image.setText("original filename",
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||||
{
|
{
|
||||||
(void)parent;
|
(void)parent;
|
||||||
return roomMembers_.size();
|
return (int)roomMembers_.size();
|
||||||
}
|
}
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
|
|
|
@ -244,20 +244,20 @@ utils::humanReadableFileSize(uint64_t bytes)
|
||||||
int
|
int
|
||||||
utils::levenshtein_distance(const std::string &s1, const std::string &s2)
|
utils::levenshtein_distance(const std::string &s1, const std::string &s2)
|
||||||
{
|
{
|
||||||
const int nlen = s1.size();
|
const auto nlen = s1.size();
|
||||||
const int hlen = s2.size();
|
const auto hlen = s2.size();
|
||||||
|
|
||||||
if (hlen == 0)
|
if (hlen == 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (nlen == 1)
|
if (nlen == 1)
|
||||||
return s2.find(s1);
|
return (int)s2.find(s1);
|
||||||
|
|
||||||
std::vector<int> row1(hlen + 1, 0);
|
std::vector<int> row1(hlen + 1, 0);
|
||||||
|
|
||||||
for (int i = 0; i < nlen; ++i) {
|
for (size_t i = 0; i < nlen; ++i) {
|
||||||
std::vector<int> row2(1, i + 1);
|
std::vector<int> row2(1, (int)i + 1);
|
||||||
|
|
||||||
for (int j = 0; j < hlen; ++j) {
|
for (size_t j = 0; j < hlen; ++j) {
|
||||||
const int cost = s1[i] != s2[j];
|
const int cost = s1[i] != s2[j];
|
||||||
row2.push_back(
|
row2.push_back(
|
||||||
std::min(row1[j + 1] + 1, std::min(row2[j] + 1, row1[j] + cost)));
|
std::min(row1[j + 1] + 1, std::min(row2[j] + 1, row1[j] + cost)));
|
||||||
|
@ -381,15 +381,16 @@ utils::escapeBlacklistedHtml(const QString &rawStr)
|
||||||
"caption", "/caption", "pre", "/pre", "span", "/span", "img", "/img"};
|
"caption", "/caption", "pre", "/pre", "span", "/span", "img", "/img"};
|
||||||
QByteArray data = rawStr.toUtf8();
|
QByteArray data = rawStr.toUtf8();
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
const size_t length = data.size();
|
const int length = data.size();
|
||||||
buffer.reserve(length);
|
buffer.reserve(length);
|
||||||
bool escapingTag = false;
|
bool escapingTag = false;
|
||||||
for (size_t pos = 0; pos != length; ++pos) {
|
for (int pos = 0; pos != length; ++pos) {
|
||||||
switch (data.at(pos)) {
|
switch (data.at(pos)) {
|
||||||
case '<': {
|
case '<': {
|
||||||
bool oneTagMatched = false;
|
bool oneTagMatched = false;
|
||||||
size_t endPos = std::min(static_cast<size_t>(data.indexOf('>', pos)),
|
const int endPos =
|
||||||
static_cast<size_t>(data.indexOf(' ', pos)));
|
static_cast<int>(std::min(static_cast<size_t>(data.indexOf('>', pos)),
|
||||||
|
static_cast<size_t>(data.indexOf(' ', pos))));
|
||||||
|
|
||||||
auto mid = data.mid(pos + 1, endPos - pos - 1);
|
auto mid = data.mid(pos + 1, endPos - pos - 1);
|
||||||
for (const auto &tag : allowedTags) {
|
for (const auto &tag : allowedTags) {
|
||||||
|
@ -543,7 +544,7 @@ utils::generateContrastingHexColor(const QString &input, const QString &backgrou
|
||||||
// Create a color for the input
|
// Create a color for the input
|
||||||
auto hash = hashQString(input);
|
auto hash = hashQString(input);
|
||||||
// create a hue value based on the hash of the input.
|
// create a hue value based on the hash of the input.
|
||||||
auto userHue = static_cast<int>(qAbs(hash % 360));
|
auto userHue = static_cast<int>(hash % 360);
|
||||||
// start with moderate saturation and lightness values.
|
// start with moderate saturation and lightness values.
|
||||||
auto sat = 220;
|
auto sat = 220;
|
||||||
auto lightness = 125;
|
auto lightness = 125;
|
||||||
|
|
|
@ -493,7 +493,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
||||||
roomNameLabel_ = new QLabel(QString::fromStdString(info_.name), this);
|
roomNameLabel_ = new QLabel(QString::fromStdString(info_.name), this);
|
||||||
roomNameLabel_->setFont(largeFont);
|
roomNameLabel_->setFont(largeFont);
|
||||||
|
|
||||||
auto membersLabel = new QLabel(tr("%n member(s)", "", info_.member_count), this);
|
auto membersLabel = new QLabel(tr("%n member(s)", "", (int)info_.member_count), this);
|
||||||
|
|
||||||
auto textLayout = new QVBoxLayout;
|
auto textLayout = new QVBoxLayout;
|
||||||
textLayout->addWidget(roomNameLabel_);
|
textLayout->addWidget(roomNameLabel_);
|
||||||
|
|
|
@ -35,14 +35,14 @@ SuggestionsPopup::addRooms(const std::vector<RoomSearchResult> &rooms)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t layoutCount = layout_->count();
|
const int layoutCount = (int)layout_->count();
|
||||||
const size_t roomCount = rooms.size();
|
const int roomCount = (int)rooms.size();
|
||||||
|
|
||||||
// Remove the extra widgets from the layout.
|
// Remove the extra widgets from the layout.
|
||||||
if (roomCount < layoutCount)
|
if (roomCount < layoutCount)
|
||||||
removeLayoutItemsAfter(roomCount - 1);
|
removeLayoutItemsAfter(roomCount - 1);
|
||||||
|
|
||||||
for (size_t i = 0; i < roomCount; ++i) {
|
for (int i = 0; i < roomCount; ++i) {
|
||||||
auto item = layout_->itemAt(i);
|
auto item = layout_->itemAt(i);
|
||||||
|
|
||||||
// Create a new widget if there isn't already one in that
|
// Create a new widget if there isn't already one in that
|
||||||
|
@ -62,7 +62,7 @@ SuggestionsPopup::addRooms(const std::vector<RoomSearchResult> &rooms)
|
||||||
resetSelection();
|
resetSelection();
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
||||||
resize(geometry().width(), 40 * rooms.size());
|
resize(geometry().width(), 40 * (int)rooms.size());
|
||||||
|
|
||||||
selectNextSuggestion();
|
selectNextSuggestion();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,8 @@ SuggestionsPopup::removeLayoutItemsAfter(size_t startingPos)
|
||||||
size_t posToRemove = layout_->count() - 1;
|
size_t posToRemove = layout_->count() - 1;
|
||||||
|
|
||||||
QLayoutItem *item;
|
QLayoutItem *item;
|
||||||
while (startingPos <= posToRemove && (item = layout_->takeAt(posToRemove)) != nullptr) {
|
while (startingPos <= posToRemove &&
|
||||||
|
(item = layout_->takeAt((int)posToRemove)) != nullptr) {
|
||||||
delete item->widget();
|
delete item->widget();
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ public:
|
||||||
friend uint qHash(const Index &i, uint seed = 0) noexcept
|
friend uint qHash(const Index &i, uint seed = 0) noexcept
|
||||||
{
|
{
|
||||||
QtPrivate::QHashCombine hash;
|
QtPrivate::QHashCombine hash;
|
||||||
seed = hash(seed, QByteArray::fromRawData(i.room.data(), i.room.size()));
|
seed =
|
||||||
|
hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size()));
|
||||||
seed = hash(seed, i.idx);
|
seed = hash(seed, i.idx);
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +47,9 @@ public:
|
||||||
friend uint qHash(const IdIndex &i, uint seed = 0) noexcept
|
friend uint qHash(const IdIndex &i, uint seed = 0) noexcept
|
||||||
{
|
{
|
||||||
QtPrivate::QHashCombine hash;
|
QtPrivate::QHashCombine hash;
|
||||||
seed = hash(seed, QByteArray::fromRawData(i.room.data(), i.room.size()));
|
seed =
|
||||||
seed = hash(seed, QByteArray::fromRawData(i.id.data(), i.id.size()));
|
hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size()));
|
||||||
|
seed = hash(seed, QByteArray::fromRawData(i.id.data(), (int)i.id.size()));
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace std {
|
||||||
inline uint
|
inline uint
|
||||||
qHash(const std::string &key, uint seed = 0)
|
qHash(const std::string &key, uint seed = 0)
|
||||||
{
|
{
|
||||||
return qHash(QByteArray::fromRawData(key.data(), key.length()), seed);
|
return qHash(QByteArray::fromRawData(key.data(), (int)key.length()), seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,7 +1208,7 @@ TimelineModel::cacheMedia(QString eventId)
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
file.write(QByteArray(temp.data(), temp.size()));
|
file.write(QByteArray(temp.data(), (int)temp.size()));
|
||||||
file.close();
|
file.close();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
nhlog::ui()->warn("Error while saving file to: {}", e.what());
|
nhlog::ui()->warn("Error while saving file to: {}", e.what());
|
||||||
|
@ -1227,7 +1227,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, QColor bg)
|
||||||
"multiple users. Second argument is the last user of that list. (If only one user is "
|
"multiple users. Second argument is the last user of that list. (If only one user is "
|
||||||
"typing, %1 is empty. You should still use it in your string though to silence Qt "
|
"typing, %1 is empty. You should still use it in your string though to silence Qt "
|
||||||
"warnings.)",
|
"warnings.)",
|
||||||
users.size());
|
(int)users.size());
|
||||||
|
|
||||||
if (users.empty()) {
|
if (users.empty()) {
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in a new issue