mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: Add "Copy message as JSON" option when shift-right-clicking a message (#5150)
This commit is contained in:
parent
0393146187
commit
7fdb3841db
|
@ -113,6 +113,7 @@
|
|||
- Dev: `Details` file properties tab is now populated on Windows. (#4912)
|
||||
- Dev: Removed `Outcome` from network requests. (#4959)
|
||||
- Dev: Added Tests for Windows and MacOS in CI. (#4970, #5032)
|
||||
- Dev: Added "Copy message as JSON" option when shift-right-clicking a message. (#5150)
|
||||
- Dev: Move `clang-tidy` checker to its own CI job. (#4996)
|
||||
- Dev: Refactored the Image Uploader feature. (#4971)
|
||||
- Dev: Refactored the SplitOverlay code. (#5082)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "common/FlagsEnum.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <QColor>
|
||||
#include <QTime>
|
||||
|
||||
|
@ -107,3 +108,8 @@ struct Message {
|
|||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<chatterino::MessageFlag> {
|
||||
static constexpr bool is_flags = true;
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "widgets/TooltipWidget.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
|
||||
#include <magic_enum/magic_enum_flags.hpp>
|
||||
#include <QClipboard>
|
||||
#include <QColor>
|
||||
#include <QDate>
|
||||
|
@ -52,6 +53,7 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QEasingCurve>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QJsonDocument>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
|
@ -244,6 +246,30 @@ void addHiddenContextMenuItems(QMenu *menu,
|
|||
crossPlatformCopy(messageID);
|
||||
});
|
||||
}
|
||||
|
||||
const auto *message = layout->getMessage();
|
||||
|
||||
if (message != nullptr)
|
||||
{
|
||||
QJsonDocument jsonDocument;
|
||||
|
||||
QJsonObject jsonObject;
|
||||
|
||||
jsonObject["id"] = message->id;
|
||||
jsonObject["searchText"] = message->searchText;
|
||||
jsonObject["messageText"] = message->messageText;
|
||||
jsonObject["flags"] = QString::fromStdString(
|
||||
magic_enum::enum_flags_name(message->flags.value()));
|
||||
|
||||
jsonDocument.setObject(jsonObject);
|
||||
|
||||
auto jsonString =
|
||||
jsonDocument.toJson(QJsonDocument::JsonFormat::Indented);
|
||||
|
||||
menu->addAction("Copy message &JSON", [jsonString] {
|
||||
crossPlatformCopy(jsonString);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Current function: https://www.desmos.com/calculator/vdyamchjwh
|
||||
|
|
Loading…
Reference in a new issue