mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added setting to hide photo editor hint.
This commit is contained in:
parent
e4cff8cb4b
commit
948302cf02
5 changed files with 39 additions and 5 deletions
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_editing.h"
|
#include "api/api_editing.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_session_settings.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
|
@ -392,7 +393,11 @@ EditCaptionBox::EditCaptionBox(
|
||||||
st::editMediaHintLabel),
|
st::editMediaHintLabel),
|
||||||
st::editMediaLabelMargins);
|
st::editMediaLabelMargins);
|
||||||
_hintLabel = label.data();
|
_hintLabel = label.data();
|
||||||
_hintLabel->toggle(_photo, anim::type::instant);
|
_hintLabel->toggle(
|
||||||
|
_controller->session().settings().photoEditorHintShown()
|
||||||
|
? _photo
|
||||||
|
: false,
|
||||||
|
anim::type::instant);
|
||||||
|
|
||||||
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
|
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
|
||||||
this,
|
this,
|
||||||
|
@ -649,7 +654,9 @@ void EditCaptionBox::updateEditPreview() {
|
||||||
|
|
||||||
const auto showCheckbox = _photo && (_albumType == Ui::AlbumType::None);
|
const auto showCheckbox = _photo && (_albumType == Ui::AlbumType::None);
|
||||||
_wayWrap->toggle(showCheckbox, anim::type::instant);
|
_wayWrap->toggle(showCheckbox, anim::type::instant);
|
||||||
_hintLabel->toggle(_photo, anim::type::instant);
|
if (_controller->session().settings().photoEditorHintShown()) {
|
||||||
|
_hintLabel->toggle(_photo, anim::type::instant);
|
||||||
|
}
|
||||||
_photoEditorButton->setVisible(_photo);
|
_photoEditorButton->setVisible(_photo);
|
||||||
|
|
||||||
if (!_doc) {
|
if (!_doc) {
|
||||||
|
@ -1160,7 +1167,10 @@ void EditCaptionBox::save() {
|
||||||
action.options = options;
|
action.options = options;
|
||||||
action.replaceMediaOf = item->fullId().msg;
|
action.replaceMediaOf = item->fullId().msg;
|
||||||
|
|
||||||
Storage::ApplyModifications(_preparedList);
|
if (Storage::ApplyModifications(_preparedList)) {
|
||||||
|
_controller->session().settings().incrementPhotoEditorHintShown();
|
||||||
|
_controller->session().saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
_controller->session().api().editMedia(
|
_controller->session().api().editMedia(
|
||||||
std::move(_preparedList),
|
std::move(_preparedList),
|
||||||
|
|
|
@ -70,6 +70,7 @@ QByteArray SessionSettings::serialize() const {
|
||||||
}
|
}
|
||||||
stream << qint32(_dialogsFiltersEnabled ? 1 : 0);
|
stream << qint32(_dialogsFiltersEnabled ? 1 : 0);
|
||||||
stream << qint32(_supportAllSilent ? 1 : 0);
|
stream << qint32(_supportAllSilent ? 1 : 0);
|
||||||
|
stream << qint32(_photoEditorHintShowsCount);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +130,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
||||||
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
|
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
|
||||||
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
||||||
|
qint32 photoEditorHintShowsCount = _photoEditorHintShowsCount;
|
||||||
|
|
||||||
stream >> versionTag;
|
stream >> versionTag;
|
||||||
if (versionTag == kVersionTag) {
|
if (versionTag == kVersionTag) {
|
||||||
|
@ -327,6 +329,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> supportAllSilent;
|
stream >> supportAllSilent;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> photoEditorHintShowsCount;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for SessionSettings::addFromSerialized()"));
|
"Bad data for SessionSettings::addFromSerialized()"));
|
||||||
|
@ -369,6 +374,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
_hiddenPinnedMessages = std::move(hiddenPinnedMessages);
|
_hiddenPinnedMessages = std::move(hiddenPinnedMessages);
|
||||||
_dialogsFiltersEnabled = (dialogsFiltersEnabled == 1);
|
_dialogsFiltersEnabled = (dialogsFiltersEnabled == 1);
|
||||||
_supportAllSilent = (supportAllSilent == 1);
|
_supportAllSilent = (supportAllSilent == 1);
|
||||||
|
_photoEditorHintShowsCount = std::move(photoEditorHintShowsCount);
|
||||||
|
|
||||||
if (version < 2) {
|
if (version < 2) {
|
||||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||||
|
@ -507,4 +513,14 @@ rpl::producer<bool> SessionSettings::skipArchiveInSearchChanges() const {
|
||||||
return _skipArchiveInSearch.changes();
|
return _skipArchiveInSearch.changes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SessionSettings::photoEditorHintShown() const {
|
||||||
|
return _photoEditorHintShowsCount < kPhotoEditorHintMaxShowsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionSettings::incrementPhotoEditorHintShown() {
|
||||||
|
if (photoEditorHintShown()) {
|
||||||
|
_photoEditorHintShowsCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Main
|
} // namespace Main
|
||||||
|
|
|
@ -120,8 +120,12 @@ public:
|
||||||
_dialogsFiltersEnabled = value;
|
_dialogsFiltersEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool photoEditorHintShown() const;
|
||||||
|
void incrementPhotoEditorHintShown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
||||||
|
static constexpr auto kPhotoEditorHintMaxShowsCount = 10;
|
||||||
|
|
||||||
ChatHelpers::SelectorTab _selectorTab; // per-window
|
ChatHelpers::SelectorTab _selectorTab; // per-window
|
||||||
base::flat_set<PeerId> _groupStickersSectionHidden;
|
base::flat_set<PeerId> _groupStickersSectionHidden;
|
||||||
|
@ -133,6 +137,7 @@ private:
|
||||||
std::vector<std::pair<DocumentId, crl::time>> _mediaLastPlaybackPosition;
|
std::vector<std::pair<DocumentId, crl::time>> _mediaLastPlaybackPosition;
|
||||||
base::flat_map<PeerId, MsgId> _hiddenPinnedMessages;
|
base::flat_map<PeerId, MsgId> _hiddenPinnedMessages;
|
||||||
bool _dialogsFiltersEnabled = false;
|
bool _dialogsFiltersEnabled = false;
|
||||||
|
int _photoEditorHintShowsCount = 0;
|
||||||
|
|
||||||
Support::SwitchSettings _supportSwitch;
|
Support::SwitchSettings _supportSwitch;
|
||||||
bool _supportFixChatsOrder = true;
|
bool _supportFixChatsOrder = true;
|
||||||
|
|
|
@ -309,16 +309,19 @@ void UpdateImageDetails(PreparedFile &file, int previewWidth) {
|
||||||
file.preview.setDevicePixelRatio(cRetinaFactor());
|
file.preview.setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyModifications(const PreparedList &list) {
|
bool ApplyModifications(const PreparedList &list) {
|
||||||
|
auto applied = false;
|
||||||
for (auto &file : list.files) {
|
for (auto &file : list.files) {
|
||||||
const auto image = std::get_if<Image>(&file.information->media);
|
const auto image = std::get_if<Image>(&file.information->media);
|
||||||
if (!image || !image->modifications) {
|
if (!image || !image->modifications) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
applied = true;
|
||||||
image->data = Editor::ImageModified(
|
image->data = Editor::ImageModified(
|
||||||
std::move(image->data),
|
std::move(image->data),
|
||||||
image->modifications);
|
image->modifications);
|
||||||
}
|
}
|
||||||
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
|
@ -44,6 +44,6 @@ Ui::PreparedList PrepareMediaFromImage(
|
||||||
void PrepareDetails(Ui::PreparedFile &file, int previewWidth);
|
void PrepareDetails(Ui::PreparedFile &file, int previewWidth);
|
||||||
void UpdateImageDetails(Ui::PreparedFile &file, int previewWidth);
|
void UpdateImageDetails(Ui::PreparedFile &file, int previewWidth);
|
||||||
|
|
||||||
void ApplyModifications(const Ui::PreparedList &list);
|
bool ApplyModifications(const Ui::PreparedList &list);
|
||||||
|
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
Loading…
Add table
Reference in a new issue