mirror of https://github.com/procxx/kepka.git
Add export format selection (text / json).
This commit is contained in:
parent
1a24ba857c
commit
4e0d11f517
|
@ -1676,6 +1676,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_export_option_gifs" = "Animated GIFs";
|
"lng_export_option_gifs" = "Animated GIFs";
|
||||||
"lng_export_option_files" = "Files";
|
"lng_export_option_files" = "Files";
|
||||||
"lng_export_option_size_limit" = "Size limit: {size}";
|
"lng_export_option_size_limit" = "Size limit: {size}";
|
||||||
|
"lng_export_header_format" = "Format";
|
||||||
|
"lng_export_option_text" = "Human-readable text";
|
||||||
|
"lng_export_option_json" = "Machine-readable JSON";
|
||||||
"lng_export_start" = "Export";
|
"lng_export_start" = "Export";
|
||||||
"lng_export_state_initializing" = "Initializing...";
|
"lng_export_state_initializing" = "Initializing...";
|
||||||
"lng_export_state_userpics" = "Personal photos";
|
"lng_export_state_userpics" = "Personal photos";
|
||||||
|
|
|
@ -29,8 +29,8 @@ struct Result;
|
||||||
class Stats;
|
class Stats;
|
||||||
|
|
||||||
enum class Format {
|
enum class Format {
|
||||||
Json,
|
|
||||||
Text,
|
Text,
|
||||||
|
Json,
|
||||||
Yaml,
|
Yaml,
|
||||||
Html,
|
Html,
|
||||||
};
|
};
|
||||||
|
|
|
@ -143,6 +143,9 @@ QByteArray SerializeText(
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
return SerializeString("");
|
return SerializeString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.nesting.push_back(Context::kArray);
|
||||||
|
|
||||||
const auto text = ranges::view::all(
|
const auto text = ranges::view::all(
|
||||||
data
|
data
|
||||||
) | ranges::view::transform([&](const Data::TextPart &part) {
|
) | ranges::view::transform([&](const Data::TextPart &part) {
|
||||||
|
@ -187,6 +190,8 @@ QByteArray SerializeText(
|
||||||
});
|
});
|
||||||
}) | ranges::to_vector;
|
}) | ranges::to_vector;
|
||||||
|
|
||||||
|
context.nesting.pop_back();
|
||||||
|
|
||||||
if (data.size() == 1 && data[0].type == Data::TextPart::Type::Text) {
|
if (data.size() == 1 && data[0].type == Data::TextPart::Type::Text) {
|
||||||
return text[0];
|
return text[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "export/view/export_view_settings.h"
|
#include "export/view/export_view_settings.h"
|
||||||
|
|
||||||
|
#include "export/output/export_output_abstract.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -213,6 +214,25 @@ void SettingsWidget::setupContent() {
|
||||||
addSubOption(lng_export_option_files, MediaType::File);
|
addSubOption(lng_export_option_files, MediaType::File);
|
||||||
createSizeSlider(media);
|
createSizeSlider(media);
|
||||||
|
|
||||||
|
const auto formatGroup = std::make_shared<Ui::RadioenumGroup<Format>>(
|
||||||
|
_data.format);
|
||||||
|
formatGroup->setChangedCallback([=](Format format) {
|
||||||
|
_data.format = format;
|
||||||
|
});
|
||||||
|
const auto addFormatOption = [&](LangKey key, Format format) {
|
||||||
|
const auto radio = content->add(
|
||||||
|
object_ptr<Ui::Radioenum<Format>>(
|
||||||
|
content,
|
||||||
|
formatGroup,
|
||||||
|
format,
|
||||||
|
lang(key),
|
||||||
|
st::defaultBoxCheckbox),
|
||||||
|
st::exportSettingPadding);
|
||||||
|
};
|
||||||
|
addHeader(content, lng_export_header_format);
|
||||||
|
addFormatOption(lng_export_option_text, Format::Text);
|
||||||
|
addFormatOption(lng_export_option_json, Format::Json);
|
||||||
|
|
||||||
_dataTypesChanges.events_starting_with_copy(
|
_dataTypesChanges.events_starting_with_copy(
|
||||||
_data.types
|
_data.types
|
||||||
) | rpl::start_with_next([=](Settings::Types types) {
|
) | rpl::start_with_next([=](Settings::Types types) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ private:
|
||||||
using Types = Settings::Types;
|
using Types = Settings::Types;
|
||||||
using MediaType = MediaSettings::Type;
|
using MediaType = MediaSettings::Type;
|
||||||
using MediaTypes = MediaSettings::Types;
|
using MediaTypes = MediaSettings::Types;
|
||||||
|
using Format = Output::Format;
|
||||||
|
|
||||||
void setupContent();
|
void setupContent();
|
||||||
void chooseFolder();
|
void chooseFolder();
|
||||||
|
|
Loading…
Reference in New Issue