mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix StickerPicker padding and names of unnamed packs
This commit is contained in:
parent
7fab9a1d73
commit
58cfc39ac4
3 changed files with 53 additions and 27 deletions
|
@ -138,6 +138,8 @@ Menu {
|
||||||
section.delegate: sectionHeading
|
section.delegate: sectionHeading
|
||||||
section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
|
section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
|
||||||
|
|
||||||
|
spacing: Nheko.paddingSmall
|
||||||
|
|
||||||
ScrollHelper {
|
ScrollHelper {
|
||||||
flickable: parent
|
flickable: parent
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -148,6 +150,8 @@ Menu {
|
||||||
delegate: Row {
|
delegate: Row {
|
||||||
required property var row;
|
required property var row;
|
||||||
|
|
||||||
|
spacing: Nheko.paddingSmall
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: row
|
model: row
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "Cache.h"
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(StickerImage)
|
Q_DECLARE_METATYPE(StickerImage)
|
||||||
|
@ -104,7 +105,7 @@ GridImagePackModel::data(const QModelIndex &index, int role) const
|
||||||
const auto &pack = packs[rowToPack[index.row()]];
|
const auto &pack = packs[rowToPack[index.row()]];
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PackName:
|
case Roles::PackName:
|
||||||
return pack.packname;
|
return nameFromPack(pack);
|
||||||
case Roles::Row: {
|
case Roles::Row: {
|
||||||
std::size_t offset = static_cast<std::size_t>(index.row()) - pack.firstRow;
|
std::size_t offset = static_cast<std::size_t>(index.row()) - pack.firstRow;
|
||||||
QList<StickerImage> imgs;
|
QList<StickerImage> imgs;
|
||||||
|
@ -135,7 +136,7 @@ GridImagePackModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::PackName:
|
case Roles::PackName:
|
||||||
return pack.packname;
|
return nameFromPack(pack);
|
||||||
case Roles::Row: {
|
case Roles::Row: {
|
||||||
QList<StickerImage> imgs;
|
QList<StickerImage> imgs;
|
||||||
for (auto img = firstIndex;
|
for (auto img = firstIndex;
|
||||||
|
@ -162,6 +163,25 @@ GridImagePackModel::data(const QModelIndex &index, int role) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
GridImagePackModel::nameFromPack(const PackDesc &pack) const
|
||||||
|
{
|
||||||
|
if (!pack.packname.isEmpty()) {
|
||||||
|
return pack.packname;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pack.state_key.empty()) {
|
||||||
|
return QString::fromStdString(pack.state_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pack.room_id.empty()) {
|
||||||
|
auto info = cache::singleRoomInfo(pack.room_id);
|
||||||
|
return QString::fromStdString(info.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tr("Account Pack");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GridImagePackModel::setSearchString(QString key)
|
GridImagePackModel::setSearchString(QString key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,4 +85,6 @@ private:
|
||||||
trie<uint, std::pair<std::uint32_t, std::uint32_t>> trie_;
|
trie<uint, std::pair<std::uint32_t, std::uint32_t>> trie_;
|
||||||
std::vector<std::pair<std::uint32_t, std::uint32_t>> currentSearchResult;
|
std::vector<std::pair<std::uint32_t, std::uint32_t>> currentSearchResult;
|
||||||
std::vector<std::size_t> rowToFirstRowEntryFromSearch;
|
std::vector<std::size_t> rowToFirstRowEntryFromSearch;
|
||||||
|
|
||||||
|
QString nameFromPack(const PackDesc &pack) const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue