mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Allow creating new packs
This commit is contained in:
parent
16d0190f4e
commit
e5a6b2b6ef
6 changed files with 58 additions and 6 deletions
|
@ -186,7 +186,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
ToggleButton {
|
ToggleButton {
|
||||||
checked: imagePack.isEmotePack
|
checked: imagePack.isEmotePack
|
||||||
onToggled: imagePack.isEmotePack = checked
|
onClicked: imagePack.isEmotePack = checked
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
ToggleButton {
|
ToggleButton {
|
||||||
checked: imagePack.isStickerPack
|
checked: imagePack.isStickerPack
|
||||||
onToggled: imagePack.isStickerPack = checked
|
onClicked: imagePack.isStickerPack = checked
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
ToggleButton {
|
ToggleButton {
|
||||||
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsEmote)
|
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsEmote)
|
||||||
onToggled: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.IsEmote)
|
onClicked: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsEmote)
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
ToggleButton {
|
ToggleButton {
|
||||||
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsSticker)
|
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsSticker)
|
||||||
onToggled: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.IsSticker)
|
onClicked: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsSticker)
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,34 @@ ApplicationWindow {
|
||||||
enabled: !Settings.mobileMode
|
enabled: !Settings.mobileMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer: ColumnLayout {
|
||||||
|
Button {
|
||||||
|
palette: Nheko.colors
|
||||||
|
onClicked: {
|
||||||
|
var dialog = packEditor.createObject(timelineRoot, {
|
||||||
|
"imagePack": packlist.newPack(false)
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
width: packlist.width
|
||||||
|
visible: !packlist.containsAccountPack
|
||||||
|
text: qsTr("Create account pack")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
palette: Nheko.colors
|
||||||
|
onClicked: {
|
||||||
|
var dialog = packEditor.createObject(timelineRoot, {
|
||||||
|
"imagePack": packlist.newPack(true)
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
width: packlist.width
|
||||||
|
text: qsTr("New room pack")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
delegate: AvatarListTile {
|
delegate: AvatarListTile {
|
||||||
id: packItem
|
id: packItem
|
||||||
|
|
||||||
|
|
|
@ -3401,7 +3401,7 @@ Cache::getImagePacks(const std::string &room_id, std::optional<bool> stickers)
|
||||||
info.pack.pack = pack.pack;
|
info.pack.pack = pack.pack;
|
||||||
|
|
||||||
for (const auto &img : pack.images) {
|
for (const auto &img : pack.images) {
|
||||||
if (img.second.overrides_usage() &&
|
if (stickers.has_value() && img.second.overrides_usage() &&
|
||||||
(stickers ? !img.second.is_sticker() : !img.second.is_emoji()))
|
(stickers ? !img.second.is_sticker() : !img.second.is_emoji()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -74,3 +74,21 @@ ImagePackListModel::packAt(int row)
|
||||||
QQmlEngine::setObjectOwnership(e, QQmlEngine::CppOwnership);
|
QQmlEngine::setObjectOwnership(e, QQmlEngine::CppOwnership);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SingleImagePackModel *
|
||||||
|
ImagePackListModel::newPack(bool inRoom)
|
||||||
|
{
|
||||||
|
ImagePackInfo info{};
|
||||||
|
if (inRoom)
|
||||||
|
info.source_room = room_id;
|
||||||
|
return new SingleImagePackModel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ImagePackListModel::containsAccountPack() const
|
||||||
|
{
|
||||||
|
for (const auto &p : packs)
|
||||||
|
if (p->roomid().isEmpty())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ class SingleImagePackModel;
|
||||||
class ImagePackListModel : public QAbstractListModel
|
class ImagePackListModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool containsAccountPack READ containsAccountPack CONSTANT)
|
||||||
public:
|
public:
|
||||||
enum Roles
|
enum Roles
|
||||||
{
|
{
|
||||||
|
@ -29,6 +30,9 @@ public:
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
Q_INVOKABLE SingleImagePackModel *packAt(int row);
|
Q_INVOKABLE SingleImagePackModel *packAt(int row);
|
||||||
|
Q_INVOKABLE SingleImagePackModel *newPack(bool inRoom);
|
||||||
|
|
||||||
|
bool containsAccountPack() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string room_id;
|
std::string room_id;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "timeline/Permissions.h"
|
#include "timeline/Permissions.h"
|
||||||
#include "timeline/TimelineModel.h"
|
#include "timeline/TimelineModel.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(mtx::common::ImageInfo);
|
Q_DECLARE_METATYPE(mtx::common::ImageInfo)
|
||||||
|
|
||||||
SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
|
SingleImagePackModel::SingleImagePackModel(ImagePackInfo pack_, QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
|
@ -285,6 +285,8 @@ SingleImagePackModel::save()
|
||||||
ChatPage::instance()->showNotification(
|
ChatPage::instance()->showNotification(
|
||||||
tr("Failed to update image pack: {}")
|
tr("Failed to update image pack: {}")
|
||||||
.arg(QString::fromStdString(e->matrix_error.error)));
|
.arg(QString::fromStdString(e->matrix_error.error)));
|
||||||
|
|
||||||
|
nhlog::net()->info("Uploaded image pack: {}", statekey_);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue