mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
'base::optional_variant<' -> 'std::variant<v::null_t,'
This commit is contained in:
parent
734d834a20
commit
f0e1d2fd02
38 changed files with 189 additions and 169 deletions
Telegram
SourceFiles
apiwrap.cpp
lib_baselib_lottieboxes
chat_helpers
core
data
export
info
media
streaming
view
passport
passport_encryption.hpassport_form_controller.cpppassport_form_controller.hpassport_panel_controller.cpp
settings
storage
|
@ -2750,7 +2750,7 @@ void ApiWrap::refreshFileReference(
|
|||
const auto fail = [&] {
|
||||
handler(UpdatedFileReferences());
|
||||
};
|
||||
origin.data.match([&](Data::FileOriginMessage data) {
|
||||
v::match(origin.data, [&](Data::FileOriginMessage data) {
|
||||
if (const auto item = _session->data().message(data)) {
|
||||
if (item->isScheduled()) {
|
||||
const auto &scheduled = _session->data().scheduledMessages();
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
using Selection = base::optional_variant<Selected, DeleteSelected>;
|
||||
using Selection = std::variant<v::null_t, Selected, DeleteSelected>;
|
||||
|
||||
int getSelectionIndex(const Selection &selection) const;
|
||||
void repaintPaper(int index);
|
||||
|
@ -358,16 +358,16 @@ void BackgroundBox::Inner::paintPaper(
|
|||
p.drawPixmap(x, y, paper.thumbnail);
|
||||
}
|
||||
|
||||
const auto over = _overDown ? _overDown : _over;
|
||||
const auto over = !v::is_null(_overDown) ? _overDown : _over;
|
||||
if (paper.data.id() == Window::Theme::Background()->id()) {
|
||||
const auto checkLeft = x + st::backgroundSize.width() - st::overviewCheckSkip - st::overviewCheck.size;
|
||||
const auto checkTop = y + st::backgroundSize.height() - st::overviewCheckSkip - st::overviewCheck.size;
|
||||
_check->paint(p, checkLeft, checkTop, width());
|
||||
} else if (Data::IsCloudWallPaper(paper.data)
|
||||
&& !Data::IsDefaultWallPaper(paper.data)
|
||||
&& over.has_value()
|
||||
&& !v::is_null(over)
|
||||
&& (&paper == &_papers[getSelectionIndex(over)])) {
|
||||
const auto deleteSelected = over.is<DeleteSelected>();
|
||||
const auto deleteSelected = v::is<DeleteSelected>(over);
|
||||
const auto deletePos = QPoint(x + st::backgroundSize.width() - st::stickerPanDeleteIconBg.width(), y);
|
||||
p.setOpacity(deleteSelected ? st::stickerPanDeleteOpacityBgOver : st::stickerPanDeleteOpacityBg);
|
||||
st::stickerPanDeleteIconBg.paint(p, deletePos, width());
|
||||
|
@ -414,7 +414,7 @@ void BackgroundBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
|||
repaintPaper(getSelectionIndex(_over));
|
||||
_over = newOver;
|
||||
repaintPaper(getSelectionIndex(_over));
|
||||
setCursor((_over.has_value() || _overDown.has_value())
|
||||
setCursor((!v::is_null(_over) || !v::is_null(_overDown))
|
||||
? style::cur_pointer
|
||||
: style::cur_default);
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ void BackgroundBox::Inner::mousePressEvent(QMouseEvent *e) {
|
|||
|
||||
int BackgroundBox::Inner::getSelectionIndex(
|
||||
const Selection &selection) const {
|
||||
return selection.match([](const Selected &data) {
|
||||
return v::match(selection, [](const Selected &data) {
|
||||
return data.index;
|
||||
}, [](const DeleteSelected &data) {
|
||||
return data.index;
|
||||
|
@ -452,12 +452,12 @@ int BackgroundBox::Inner::getSelectionIndex(
|
|||
}
|
||||
|
||||
void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (base::take(_overDown) == _over && _over.has_value()) {
|
||||
if (base::take(_overDown) == _over && !v::is_null(_over)) {
|
||||
const auto index = getSelectionIndex(_over);
|
||||
if (index >= 0 && index < _papers.size()) {
|
||||
if (base::get_if<DeleteSelected>(&_over)) {
|
||||
if (std::get_if<DeleteSelected>(&_over)) {
|
||||
_backgroundRemove.fire_copy(_papers[index].data);
|
||||
} else if (base::get_if<Selected>(&_over)) {
|
||||
} else if (std::get_if<Selected>(&_over)) {
|
||||
auto &paper = _papers[index];
|
||||
if (!paper.dataMedia) {
|
||||
if (const auto document = paper.data.document()) {
|
||||
|
@ -468,7 +468,7 @@ void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
_backgroundChosen.fire_copy(paper.data);
|
||||
}
|
||||
}
|
||||
} else if (!_over.has_value()) {
|
||||
} else if (v::is_null(_over)) {
|
||||
setCursor(style::cur_default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,7 +489,7 @@ void EditCaptionBox::updateEditPreview() {
|
|||
auto isGif = false;
|
||||
auto shouldAsDoc = true;
|
||||
auto docPhotoSize = QSize();
|
||||
if (const auto image = base::get_if<Info::Image>(fileMedia)) {
|
||||
if (const auto image = std::get_if<Info::Image>(fileMedia)) {
|
||||
shouldAsDoc = !Storage::ValidateThumbDimensions(
|
||||
image->data.width(),
|
||||
image->data.height());
|
||||
|
@ -501,14 +501,14 @@ void EditCaptionBox::updateEditPreview() {
|
|||
_animated = isGif;
|
||||
_photo = !isGif && !shouldAsDoc;
|
||||
_isImage = true;
|
||||
} else if (const auto video = base::get_if<Info::Video>(fileMedia)) {
|
||||
} else if (const auto video = std::get_if<Info::Video>(fileMedia)) {
|
||||
isGif = video->isGifv;
|
||||
_animated = true;
|
||||
shouldAsDoc = false;
|
||||
}
|
||||
if (shouldAsDoc) {
|
||||
auto nameString = filename;
|
||||
if (const auto song = base::get_if<Info::Song>(fileMedia)) {
|
||||
if (const auto song = std::get_if<Info::Song>(fileMedia)) {
|
||||
nameString = DocumentData::ComposeNameString(
|
||||
filename,
|
||||
song->title,
|
||||
|
@ -684,7 +684,7 @@ bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
|
|||
const auto imageAsDoc = [&] {
|
||||
using Info = FileMediaInformation;
|
||||
const auto fileMedia = &file->information->media;
|
||||
if (const auto image = base::get_if<Info::Image>(fileMedia)) {
|
||||
if (const auto image = std::get_if<Info::Image>(fileMedia)) {
|
||||
return !Storage::ValidateThumbDimensions(
|
||||
image->data.width(),
|
||||
image->data.height());
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
return (index == other.index);
|
||||
}
|
||||
};
|
||||
using Selection = base::optional_variant<RowSelection, MenuSelection>;
|
||||
using Selection = std::variant<v::null_t, RowSelection, MenuSelection>;
|
||||
|
||||
void updateSelected(Selection selected);
|
||||
void updatePressed(Selection pressed);
|
||||
|
@ -327,7 +327,7 @@ void Rows::mouseMoveEvent(QMouseEvent *e) {
|
|||
|
||||
void Rows::mousePressEvent(QMouseEvent *e) {
|
||||
updatePressed(_selected);
|
||||
if (_pressed.has_value()
|
||||
if (!v::is_null(_pressed)
|
||||
&& !rowBySelection(_pressed).menuToggleForceRippled) {
|
||||
addRipple(_pressed, e->pos());
|
||||
}
|
||||
|
@ -348,11 +348,11 @@ QRect Rows::menuToggleArea(not_null<const Row*> row) const {
|
|||
}
|
||||
|
||||
void Rows::addRipple(Selection selected, QPoint position) {
|
||||
Expects(selected.has_value());
|
||||
Expects(!v::is_null(selected));
|
||||
|
||||
ensureRippleBySelection(selected);
|
||||
|
||||
const auto menu = selected.is<MenuSelection>();
|
||||
const auto menu = v::is<MenuSelection>(selected);
|
||||
const auto &row = rowBySelection(selected);
|
||||
const auto menuArea = menuToggleArea(&row);
|
||||
auto &ripple = rippleBySelection(&row, selected);
|
||||
|
@ -369,7 +369,7 @@ void Rows::ensureRippleBySelection(not_null<Row*> row, Selection selected) {
|
|||
if (ripple) {
|
||||
return;
|
||||
}
|
||||
const auto menu = selected.is<MenuSelection>();
|
||||
const auto menu = v::is<MenuSelection>(selected);
|
||||
const auto menuArea = menuToggleArea(row);
|
||||
auto mask = menu
|
||||
? Ui::RippleAnimation::ellipseMask(menuArea.size())
|
||||
|
@ -391,7 +391,7 @@ void Rows::mouseReleaseEvent(QMouseEvent *e) {
|
|||
const auto pressed = _pressed;
|
||||
updatePressed({});
|
||||
if (pressed == _selected) {
|
||||
pressed.match([&](RowSelection data) {
|
||||
v::match(pressed, [&](RowSelection data) {
|
||||
activateByIndex(data.index);
|
||||
}, [&](MenuSelection data) {
|
||||
showMenu(data.index);
|
||||
|
@ -597,7 +597,7 @@ int Rows::count() const {
|
|||
}
|
||||
|
||||
int Rows::indexFromSelection(Selection selected) const {
|
||||
return selected.match([&](RowSelection data) {
|
||||
return v::match(selected, [&](RowSelection data) {
|
||||
return data.index;
|
||||
}, [&](MenuSelection data) {
|
||||
return data.index;
|
||||
|
@ -648,7 +648,7 @@ rpl::producer<bool> Rows::isEmpty() const {
|
|||
}
|
||||
|
||||
void Rows::repaint(Selection selected) {
|
||||
selected.match([](v::null_t) {
|
||||
v::match(selected, [](v::null_t) {
|
||||
}, [&](const auto &data) {
|
||||
repaint(data.index);
|
||||
});
|
||||
|
@ -672,17 +672,17 @@ void Rows::repaintChecked(not_null<const Row*> row) {
|
|||
}
|
||||
|
||||
void Rows::updateSelected(Selection selected) {
|
||||
const auto changed = (_selected.has_value() != selected.has_value());
|
||||
const auto changed = (v::is_null(_selected) != v::is_null(selected));
|
||||
repaint(_selected);
|
||||
_selected = selected;
|
||||
repaint(_selected);
|
||||
if (changed) {
|
||||
_hasSelection.fire(_selected.has_value());
|
||||
_hasSelection.fire(!v::is_null(_selected));
|
||||
}
|
||||
}
|
||||
|
||||
void Rows::updatePressed(Selection pressed) {
|
||||
if (_pressed.has_value()) {
|
||||
if (!v::is_null(_pressed)) {
|
||||
if (!rowBySelection(_pressed).menuToggleForceRippled) {
|
||||
if (const auto ripple = rippleBySelection(_pressed).get()) {
|
||||
ripple->lastStop();
|
||||
|
@ -725,7 +725,7 @@ const std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
|
|||
std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
|
||||
not_null<Row*> row,
|
||||
Selection selected) {
|
||||
return selected.is<MenuSelection>()
|
||||
return v::is<MenuSelection>(selected)
|
||||
? row->menuToggleRipple
|
||||
: row->ripple;
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ void Rows::paintEvent(QPaintEvent *e) {
|
|||
const auto menu = menuToggleArea();
|
||||
const auto selectedIndex = (_menuShownIndex >= 0)
|
||||
? _menuShownIndex
|
||||
: indexFromSelection(_pressed.has_value() ? _pressed : _selected);
|
||||
: indexFromSelection(!v::is_null(_pressed) ? _pressed : _selected);
|
||||
for (auto i = 0, till = count(); i != till; ++i) {
|
||||
const auto &row = rowByIndex(i);
|
||||
if (row.top + row.height <= clip.y()) {
|
||||
|
|
|
@ -766,11 +766,11 @@ SingleMediaPreview *SingleMediaPreview::Create(
|
|||
auto preview = QImage();
|
||||
bool animated = false;
|
||||
bool animationPreview = false;
|
||||
if (const auto image = base::get_if<FileMediaInformation::Image>(
|
||||
if (const auto image = std::get_if<FileMediaInformation::Image>(
|
||||
&file.information->media)) {
|
||||
preview = image->data;
|
||||
animated = animationPreview = image->animated;
|
||||
} else if (const auto video = base::get_if<FileMediaInformation::Video>(
|
||||
} else if (const auto video = std::get_if<FileMediaInformation::Video>(
|
||||
&file.information->media)) {
|
||||
preview = video->thumbnail;
|
||||
animated = true;
|
||||
|
@ -1004,10 +1004,10 @@ void SingleFilePreview::prepareThumb(const QImage &preview) {
|
|||
|
||||
void SingleFilePreview::preparePreview(const Storage::PreparedFile &file) {
|
||||
auto preview = QImage();
|
||||
if (const auto image = base::get_if<FileMediaInformation::Image>(
|
||||
if (const auto image = std::get_if<FileMediaInformation::Image>(
|
||||
&file.information->media)) {
|
||||
preview = image->data;
|
||||
} else if (const auto video = base::get_if<FileMediaInformation::Video>(
|
||||
} else if (const auto video = std::get_if<FileMediaInformation::Video>(
|
||||
&file.information->media)) {
|
||||
preview = video->thumbnail;
|
||||
}
|
||||
|
@ -1034,7 +1034,7 @@ void SingleFilePreview::preparePreview(const Storage::PreparedFile &file) {
|
|||
auto songTitle = QString();
|
||||
auto songPerformer = QString();
|
||||
if (file.information) {
|
||||
if (const auto song = base::get_if<FileMediaInformation::Song>(
|
||||
if (const auto song = std::get_if<FileMediaInformation::Song>(
|
||||
&file.information->media)) {
|
||||
songTitle = song->title;
|
||||
songPerformer = song->performer;
|
||||
|
|
|
@ -179,7 +179,7 @@ private:
|
|||
return false;
|
||||
}
|
||||
};
|
||||
using SelectedRow = base::optional_variant<MegagroupSet, int>;
|
||||
using SelectedRow = std::variant<v::null_t, MegagroupSet, int>;
|
||||
class AddressField : public Ui::UsernameInput {
|
||||
public:
|
||||
using UsernameInput::UsernameInput;
|
||||
|
@ -1101,7 +1101,7 @@ void StickersBox::Inner::paintRow(Painter &p, not_null<Row*> row, int index) {
|
|||
|
||||
if (_megagroupSet) {
|
||||
auto selectedIndex = [&] {
|
||||
if (auto index = base::get_if<int>(&_selected)) {
|
||||
if (auto index = std::get_if<int>(&_selected)) {
|
||||
return *index;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1341,7 +1341,7 @@ void StickersBox::Inner::mousePressEvent(QMouseEvent *e) {
|
|||
if (_actionSel >= 0) {
|
||||
setActionDown(_actionSel);
|
||||
update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight);
|
||||
} else if (auto selectedIndex = base::get_if<int>(&_selected)) {
|
||||
} else if (auto selectedIndex = std::get_if<int>(&_selected)) {
|
||||
if (_section == Section::Installed && !_rows[*selectedIndex]->isRecentSet() && _inDragArea) {
|
||||
_above = _dragging = _started = *selectedIndex;
|
||||
_dragStart = mapFromGlobal(_mouse);
|
||||
|
@ -1394,7 +1394,7 @@ void StickersBox::Inner::setSelected(SelectedRow selected) {
|
|||
return;
|
||||
}
|
||||
auto countSelectedIndex = [&] {
|
||||
if (auto index = base::get_if<int>(&_selected)) {
|
||||
if (auto index = std::get_if<int>(&_selected)) {
|
||||
return *index;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1416,7 +1416,7 @@ void StickersBox::Inner::setPressed(SelectedRow pressed) {
|
|||
return;
|
||||
}
|
||||
auto countPressedIndex = [&] {
|
||||
if (auto index = base::get_if<int>(&_pressed)) {
|
||||
if (auto index = std::get_if<int>(&_pressed)) {
|
||||
return *index;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1544,7 +1544,7 @@ void StickersBox::Inner::updateCursor() {
|
|||
? ((_actionSel >= 0 && (_actionDown < 0 || _actionDown == _actionSel))
|
||||
? style::cur_pointer
|
||||
: style::cur_default)
|
||||
: (_selected.has_value() || _pressed.has_value())
|
||||
: (!v::is_null(_selected) || !v::is_null(_pressed))
|
||||
? style::cur_pointer
|
||||
: style::cur_default);
|
||||
}
|
||||
|
@ -1582,7 +1582,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
_dragging = _started = -1;
|
||||
} else if (pressed == _selected && _actionSel < 0 && _actionDown < 0) {
|
||||
const auto selectedIndex = [&] {
|
||||
if (auto index = base::get_if<int>(&_selected)) {
|
||||
if (auto index = std::get_if<int>(&_selected)) {
|
||||
return *index;
|
||||
}
|
||||
return -1;
|
||||
|
@ -1602,7 +1602,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
showSetByRow(*row);
|
||||
}
|
||||
}
|
||||
} else if (_megagroupSelectedSet && _selected.is<MegagroupSet>()) {
|
||||
} else if (_megagroupSelectedSet && v::is<MegagroupSet>(_selected)) {
|
||||
showSetByRow(*_megagroupSelectedSet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1509,8 +1509,10 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
|||
}
|
||||
|
||||
auto &sets = shownSets();
|
||||
auto selectedSticker = base::get_if<OverSticker>(&_selected);
|
||||
auto selectedButton = base::get_if<OverButton>(_pressed ? &_pressed : &_selected);
|
||||
auto selectedSticker = std::get_if<OverSticker>(&_selected);
|
||||
auto selectedButton = std::get_if<OverButton>(!v::is_null(_pressed)
|
||||
? &_pressed
|
||||
: &_selected);
|
||||
|
||||
if (sets.empty() && _section == Section::Search) {
|
||||
paintEmptySearchResults(p);
|
||||
|
@ -1625,7 +1627,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
|||
if (clip.top() + clip.height() <= info.rowsTop) {
|
||||
return true;
|
||||
} else if (set.id == Data::Stickers::MegagroupSetId && set.stickers.empty()) {
|
||||
auto buttonSelected = (base::get_if<OverGroupAdd>(&_selected) != nullptr);
|
||||
auto buttonSelected = (std::get_if<OverGroupAdd>(&_selected) != nullptr);
|
||||
paintMegagroupEmptySet(p, info.rowsTop, buttonSelected);
|
||||
return true;
|
||||
}
|
||||
|
@ -1971,20 +1973,20 @@ void StickersListWidget::mousePressEvent(QMouseEvent *e) {
|
|||
}
|
||||
|
||||
void StickersListWidget::setPressed(OverState newPressed) {
|
||||
if (auto button = base::get_if<OverButton>(&_pressed)) {
|
||||
if (auto button = std::get_if<OverButton>(&_pressed)) {
|
||||
auto &sets = shownSets();
|
||||
Assert(button->section >= 0 && button->section < sets.size());
|
||||
auto &set = sets[button->section];
|
||||
if (set.ripple) {
|
||||
set.ripple->lastStop();
|
||||
}
|
||||
} else if (base::get_if<OverGroupAdd>(&_pressed)) {
|
||||
} else if (std::get_if<OverGroupAdd>(&_pressed)) {
|
||||
if (_megagroupSetButtonRipple) {
|
||||
_megagroupSetButtonRipple->lastStop();
|
||||
}
|
||||
}
|
||||
_pressed = newPressed;
|
||||
if (auto button = base::get_if<OverButton>(&_pressed)) {
|
||||
if (auto button = std::get_if<OverButton>(&_pressed)) {
|
||||
auto &sets = shownSets();
|
||||
Assert(button->section >= 0 && button->section < sets.size());
|
||||
auto &set = sets[button->section];
|
||||
|
@ -1992,7 +1994,7 @@ void StickersListWidget::setPressed(OverState newPressed) {
|
|||
set.ripple = createButtonRipple(button->section);
|
||||
}
|
||||
set.ripple->add(mapFromGlobal(QCursor::pos()) - buttonRippleTopLeft(button->section));
|
||||
} else if (base::get_if<OverGroupAdd>(&_pressed)) {
|
||||
} else if (std::get_if<OverGroupAdd>(&_pressed)) {
|
||||
if (!_megagroupSetButtonRipple) {
|
||||
auto maskSize = _megagroupSetButtonRect.size();
|
||||
auto mask = Ui::RippleAnimation::roundRectMask(maskSize, st::buttonRadius);
|
||||
|
@ -2059,10 +2061,10 @@ void StickersListWidget::fillContextMenu(
|
|||
SendMenu::Type type) {
|
||||
auto selected = _selected;
|
||||
auto &sets = shownSets();
|
||||
if (!selected || _pressed) {
|
||||
if (v::is_null(selected) || !v::is_null(_pressed)) {
|
||||
return;
|
||||
}
|
||||
if (auto sticker = base::get_if<OverSticker>(&selected)) {
|
||||
if (auto sticker = std::get_if<OverSticker>(&selected)) {
|
||||
Assert(sticker->section >= 0 && sticker->section < sets.size());
|
||||
auto &set = sets[sticker->section];
|
||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||
|
@ -2124,8 +2126,8 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
updateSelected();
|
||||
|
||||
auto &sets = shownSets();
|
||||
if (pressed && pressed == _selected) {
|
||||
if (auto sticker = base::get_if<OverSticker>(&pressed)) {
|
||||
if (!v::is_null(pressed) && pressed == _selected) {
|
||||
if (auto sticker = std::get_if<OverSticker>(&pressed)) {
|
||||
Assert(sticker->section >= 0 && sticker->section < sets.size());
|
||||
auto &set = sets[sticker->section];
|
||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
||||
|
@ -2145,10 +2147,10 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
} else {
|
||||
_chosen.fire_copy({ .document = document });
|
||||
}
|
||||
} else if (auto set = base::get_if<OverSet>(&pressed)) {
|
||||
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
||||
Assert(set->section >= 0 && set->section < sets.size());
|
||||
displaySet(sets[set->section].id);
|
||||
} else if (auto button = base::get_if<OverButton>(&pressed)) {
|
||||
} else if (auto button = std::get_if<OverButton>(&pressed)) {
|
||||
Assert(button->section >= 0 && button->section < sets.size());
|
||||
if (sets[button->section].externalLayout) {
|
||||
installSet(sets[button->section].id);
|
||||
|
@ -2159,7 +2161,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
} else {
|
||||
removeSet(sets[button->section].id);
|
||||
}
|
||||
} else if (base::get_if<OverGroupAdd>(&pressed)) {
|
||||
} else if (std::get_if<OverGroupAdd>(&pressed)) {
|
||||
Ui::show(Box<StickersBox>(controller(), _megagroupSet));
|
||||
}
|
||||
}
|
||||
|
@ -2750,7 +2752,7 @@ bool StickersListWidget::preventAutoHide() {
|
|||
}
|
||||
|
||||
void StickersListWidget::updateSelected() {
|
||||
if (_pressed && !_previewShown) {
|
||||
if (!v::is_null(_pressed) && !_previewShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2827,13 +2829,15 @@ bool StickersListWidget::stickerHasDeleteButton(const Set &set, int index) const
|
|||
|
||||
void StickersListWidget::setSelected(OverState newSelected) {
|
||||
if (_selected != newSelected) {
|
||||
setCursor(newSelected ? style::cur_pointer : style::cur_default);
|
||||
setCursor(!v::is_null(newSelected)
|
||||
? style::cur_pointer
|
||||
: style::cur_default);
|
||||
|
||||
auto &sets = shownSets();
|
||||
auto updateSelected = [&]() {
|
||||
if (auto sticker = base::get_if<OverSticker>(&_selected)) {
|
||||
if (auto sticker = std::get_if<OverSticker>(&_selected)) {
|
||||
rtlupdate(stickerRect(sticker->section, sticker->index));
|
||||
} else if (auto button = base::get_if<OverButton>(&_selected)) {
|
||||
} else if (auto button = std::get_if<OverButton>(&_selected)) {
|
||||
if (button->section >= 0
|
||||
&& button->section < sets.size()
|
||||
&& sets[button->section].externalLayout) {
|
||||
|
@ -2841,7 +2845,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
|
|||
} else {
|
||||
rtlupdate(removeButtonRect(button->section));
|
||||
}
|
||||
} else if (base::get_if<OverGroupAdd>(&_selected)) {
|
||||
} else if (std::get_if<OverGroupAdd>(&_selected)) {
|
||||
rtlupdate(megagroupSetButtonRectFinal());
|
||||
}
|
||||
};
|
||||
|
@ -2850,7 +2854,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
|
|||
updateSelected();
|
||||
|
||||
if (_previewShown && _pressed != _selected) {
|
||||
if (const auto sticker = base::get_if<OverSticker>(&_selected)) {
|
||||
if (const auto sticker = std::get_if<OverSticker>(&_selected)) {
|
||||
_pressed = _selected;
|
||||
Assert(sticker->section >= 0 && sticker->section < sets.size());
|
||||
const auto &set = sets[sticker->section];
|
||||
|
@ -2865,7 +2869,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
|
|||
}
|
||||
|
||||
void StickersListWidget::showPreview() {
|
||||
if (const auto sticker = base::get_if<OverSticker>(&_pressed)) {
|
||||
if (const auto sticker = std::get_if<OverSticker>(&_pressed)) {
|
||||
const auto &sets = shownSets();
|
||||
Assert(sticker->section >= 0 && sticker->section < sets.size());
|
||||
const auto &set = sets[sticker->section];
|
||||
|
|
|
@ -144,7 +144,8 @@ private:
|
|||
friend inline bool operator==(OverGroupAdd a, OverGroupAdd b) {
|
||||
return true;
|
||||
}
|
||||
using OverState = base::optional_variant<
|
||||
using OverState = std::variant<
|
||||
v::null_t,
|
||||
OverSticker,
|
||||
OverSet,
|
||||
OverButton,
|
||||
|
|
|
@ -199,10 +199,10 @@ CloudPasswordCheckRequest ParseCloudPasswordCheckRequest(
|
|||
}
|
||||
|
||||
CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) {
|
||||
if (!parsed.is<CloudPasswordAlgoModPow>()) {
|
||||
if (!v::is<CloudPasswordAlgoModPow>(parsed)) {
|
||||
return v::null;
|
||||
}
|
||||
auto &value = parsed.get_unchecked<CloudPasswordAlgoModPow>();
|
||||
auto &value = std::get<CloudPasswordAlgoModPow>(parsed);
|
||||
const auto already = value.salt1.size();
|
||||
value.salt1.resize(already + kAdditionalSalt);
|
||||
bytes::set_random(bytes::make_span(value.salt1).subspan(already));
|
||||
|
@ -210,7 +210,7 @@ CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) {
|
|||
}
|
||||
|
||||
MTPPasswordKdfAlgo PrepareCloudPasswordAlgo(const CloudPasswordAlgo &data) {
|
||||
return data.match([](const CloudPasswordAlgoModPow &data) {
|
||||
return v::match(data, [](const CloudPasswordAlgoModPow &data) {
|
||||
return MTP_passwordKdfAlgoModPow(
|
||||
MTP_bytes(data.salt1),
|
||||
MTP_bytes(data.salt2),
|
||||
|
@ -228,7 +228,7 @@ CloudPasswordResult::operator bool() const {
|
|||
bytes::vector ComputeCloudPasswordHash(
|
||||
const CloudPasswordAlgo &algo,
|
||||
bytes::const_span password) {
|
||||
return algo.match([&](const CloudPasswordAlgoModPow &data) {
|
||||
return v::match(algo, [&](const CloudPasswordAlgoModPow &data) {
|
||||
return ComputeHash(data, password);
|
||||
}, [](v::null_t) -> bytes::vector {
|
||||
Unexpected("Bad cloud password algorithm.");
|
||||
|
@ -238,7 +238,7 @@ bytes::vector ComputeCloudPasswordHash(
|
|||
CloudPasswordDigest ComputeCloudPasswordDigest(
|
||||
const CloudPasswordAlgo &algo,
|
||||
bytes::const_span password) {
|
||||
return algo.match([&](const CloudPasswordAlgoModPow &data) {
|
||||
return v::match(algo, [&](const CloudPasswordAlgoModPow &data) {
|
||||
return ComputeDigest(data, password);
|
||||
}, [](v::null_t) -> CloudPasswordDigest {
|
||||
Unexpected("Bad cloud password algorithm.");
|
||||
|
@ -248,7 +248,7 @@ CloudPasswordDigest ComputeCloudPasswordDigest(
|
|||
CloudPasswordResult ComputeCloudPasswordCheck(
|
||||
const CloudPasswordCheckRequest &request,
|
||||
bytes::const_span hash) {
|
||||
return request.algo.match([&](const CloudPasswordAlgoModPow &data) {
|
||||
return v::match(request.algo, [&](const CloudPasswordAlgoModPow &data) {
|
||||
return ComputeCheck(request, data, hash);
|
||||
}, [](v::null_t) -> CloudPasswordResult {
|
||||
Unexpected("Bad cloud password algorithm.");
|
||||
|
@ -270,10 +270,10 @@ SecureSecretAlgo ParseSecureSecretAlgo(
|
|||
}
|
||||
|
||||
SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) {
|
||||
if (!parsed.is<SecureSecretAlgoPBKDF2>()) {
|
||||
if (!v::is<SecureSecretAlgoPBKDF2>(parsed)) {
|
||||
return v::null;
|
||||
}
|
||||
auto &value = parsed.get_unchecked<SecureSecretAlgoPBKDF2>();
|
||||
auto &value = std::get<SecureSecretAlgoPBKDF2>(parsed);
|
||||
const auto already = value.salt.size();
|
||||
value.salt.resize(already + kAdditionalSalt);
|
||||
bytes::set_random(bytes::make_span(value.salt).subspan(already));
|
||||
|
@ -282,7 +282,7 @@ SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) {
|
|||
|
||||
MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo(
|
||||
const SecureSecretAlgo &data) {
|
||||
return data.match([](const SecureSecretAlgoPBKDF2 &data) {
|
||||
return v::match(data, [](const SecureSecretAlgoPBKDF2 &data) {
|
||||
return MTP_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000(
|
||||
MTP_bytes(data.salt));
|
||||
}, [](const SecureSecretAlgoSHA512 &data) {
|
||||
|
@ -295,7 +295,7 @@ MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo(
|
|||
bytes::vector ComputeSecureSecretHash(
|
||||
const SecureSecretAlgo &algo,
|
||||
bytes::const_span password) {
|
||||
return algo.match([&](const auto &data) {
|
||||
return v::match(algo, [&](const auto &data) {
|
||||
return ComputeHash(data, password);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ inline bool operator==(
|
|||
&& (a.p == b.p);
|
||||
}
|
||||
|
||||
using CloudPasswordAlgo = base::optional_variant<CloudPasswordAlgoModPow>;
|
||||
using CloudPasswordAlgo = std::variant<v::null_t, CloudPasswordAlgoModPow>;
|
||||
|
||||
CloudPasswordAlgo ParseCloudPasswordAlgo(const MTPPasswordKdfAlgo &data);
|
||||
CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed);
|
||||
|
@ -43,7 +43,7 @@ struct CloudPasswordCheckRequest {
|
|||
CloudPasswordAlgo algo;
|
||||
|
||||
explicit operator bool() const {
|
||||
return !!algo;
|
||||
return !v::is_null(algo);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -106,7 +106,8 @@ inline bool operator==(
|
|||
return (a.salt == b.salt);
|
||||
}
|
||||
|
||||
using SecureSecretAlgo = base::optional_variant<
|
||||
using SecureSecretAlgo = std::variant<
|
||||
v::null_t,
|
||||
SecureSecretAlgoSHA512,
|
||||
SecureSecretAlgoPBKDF2>;
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ struct FileOriginTheme {
|
|||
};
|
||||
|
||||
struct FileOrigin {
|
||||
using Variant = base::optional_variant<
|
||||
using Variant = std::variant<
|
||||
v::null_t,
|
||||
FileOriginMessage,
|
||||
FileOriginUserPhoto,
|
||||
FileOriginPeerPhoto,
|
||||
|
@ -123,7 +124,7 @@ struct FileOrigin {
|
|||
}
|
||||
|
||||
explicit operator bool() const {
|
||||
return data.has_value();
|
||||
return !v::is_null(data);
|
||||
}
|
||||
inline bool operator<(const FileOrigin &other) const {
|
||||
return data < other.data;
|
||||
|
|
|
@ -858,7 +858,7 @@ Peer EmptyPeer(PeerId peerId) {
|
|||
}
|
||||
|
||||
File &Media::file() {
|
||||
return content.match([](Photo &data) -> File& {
|
||||
return v::match(content, [](Photo &data) -> File& {
|
||||
return data.image.file;
|
||||
}, [](Document &data) -> File& {
|
||||
return data.file;
|
||||
|
@ -871,7 +871,7 @@ File &Media::file() {
|
|||
}
|
||||
|
||||
const File &Media::file() const {
|
||||
return content.match([](const Photo &data) -> const File& {
|
||||
return v::match(content, [](const Photo &data) -> const File& {
|
||||
return data.image.file;
|
||||
}, [](const Document &data) -> const File& {
|
||||
return data.file;
|
||||
|
@ -884,7 +884,7 @@ const File &Media::file() const {
|
|||
}
|
||||
|
||||
Image &Media::thumb() {
|
||||
return content.match([](Document &data) -> Image& {
|
||||
return v::match(content, [](Document &data) -> Image& {
|
||||
return data.thumb;
|
||||
}, [](auto&) -> Image& {
|
||||
static Image result;
|
||||
|
@ -893,7 +893,7 @@ Image &Media::thumb() {
|
|||
}
|
||||
|
||||
const Image &Media::thumb() const {
|
||||
return content.match([](const Document &data) -> const Image& {
|
||||
return v::match(content, [](const Document &data) -> const Image& {
|
||||
return data.thumb;
|
||||
}, [](const auto &) -> const Image& {
|
||||
static const Image result;
|
||||
|
@ -1104,7 +1104,7 @@ ServiceAction ParseServiceAction(
|
|||
|
||||
File &Message::file() {
|
||||
const auto service = &action.content;
|
||||
if (const auto photo = base::get_if<ActionChatEditPhoto>(service)) {
|
||||
if (const auto photo = std::get_if<ActionChatEditPhoto>(service)) {
|
||||
return photo->photo.image.file;
|
||||
}
|
||||
return media.file();
|
||||
|
@ -1112,7 +1112,7 @@ File &Message::file() {
|
|||
|
||||
const File &Message::file() const {
|
||||
const auto service = &action.content;
|
||||
if (const auto photo = base::get_if<ActionChatEditPhoto>(service)) {
|
||||
if (const auto photo = std::get_if<ActionChatEditPhoto>(service)) {
|
||||
return photo->photo.image.file;
|
||||
}
|
||||
return media.file();
|
||||
|
|
|
@ -309,7 +309,8 @@ struct UnsupportedMedia {
|
|||
};
|
||||
|
||||
struct Media {
|
||||
base::optional_variant<
|
||||
std::variant<
|
||||
v::null_t,
|
||||
Photo,
|
||||
Document,
|
||||
SharedContact,
|
||||
|
@ -449,7 +450,8 @@ struct ActionPhoneNumberRequest {
|
|||
};
|
||||
|
||||
struct ServiceAction {
|
||||
base::optional_variant<
|
||||
std::variant<
|
||||
v::null_t,
|
||||
ActionChatCreate,
|
||||
ActionChatEditTitle,
|
||||
ActionChatEditPhoto,
|
||||
|
|
|
@ -1655,8 +1655,8 @@ bool ApiWrap::processFileLoad(
|
|||
}
|
||||
|
||||
using Type = MediaSettings::Type;
|
||||
const auto type = message ? message->media.content.match(
|
||||
[&](const Data::Document &data) {
|
||||
const auto type = message ? v::match(message->media.content, [&](
|
||||
const Data::Document &data) {
|
||||
if (data.isSticker) {
|
||||
return Type::Sticker;
|
||||
} else if (data.isVideoMessage) {
|
||||
|
|
|
@ -161,13 +161,13 @@ rpl::producer<State> ControllerObject::state() const {
|
|||
) | rpl::then(
|
||||
_stateChanges.events()
|
||||
) | rpl::filter([](const State &state) {
|
||||
const auto password = base::get_if<PasswordCheckState>(&state);
|
||||
const auto password = std::get_if<PasswordCheckState>(&state);
|
||||
return !password || !password->requesting;
|
||||
});
|
||||
}
|
||||
|
||||
void ControllerObject::setState(State &&state) {
|
||||
if (_state.is<CancelledState>()) {
|
||||
if (v::is<CancelledState>(_state)) {
|
||||
return;
|
||||
}
|
||||
_state = std::move(state);
|
||||
|
|
|
@ -96,7 +96,8 @@ struct FinishedState {
|
|||
int64 bytesCount = 0;
|
||||
};
|
||||
|
||||
using State = base::optional_variant<
|
||||
using State = std::variant<
|
||||
v::null_t,
|
||||
PasswordCheckState,
|
||||
ProcessingState,
|
||||
ApiErrorState,
|
||||
|
|
|
@ -973,7 +973,7 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
info.forwardedFromName = message.forwardedFromName;
|
||||
info.forwardedDate = message.forwardedDate;
|
||||
info.forwarded = message.forwarded;
|
||||
if (message.media.content.is<UnsupportedMedia>()) {
|
||||
if (v::is<UnsupportedMedia>(message.media.content)) {
|
||||
return { info, pushServiceMessage(
|
||||
message.id,
|
||||
dialog,
|
||||
|
@ -990,8 +990,8 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
const auto isChannel = (dialog.type == DialogType::PrivateChannel)
|
||||
|| (dialog.type == DialogType::PublicChannel);
|
||||
const auto serviceFrom = peers.wrapUserName(message.fromId);
|
||||
const auto serviceText = message.action.content.match(
|
||||
[&](const ActionChatCreate &data) {
|
||||
const auto serviceText = v::match(message.action.content, [&](
|
||||
const ActionChatCreate &data) {
|
||||
return serviceFrom
|
||||
+ " created group «" + data.title + "»"
|
||||
+ (data.userIds.empty()
|
||||
|
@ -1094,8 +1094,8 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
|
||||
if (!serviceText.isEmpty()) {
|
||||
const auto &content = message.action.content;
|
||||
const auto photo = content.is<ActionChatEditPhoto>()
|
||||
? &content.get_unchecked<ActionChatEditPhoto>().photo
|
||||
const auto photo = v::is<ActionChatEditPhoto>(content)
|
||||
? &std::get<ActionChatEditPhoto>(content).photo
|
||||
: nullptr;
|
||||
return { info, pushServiceMessage(
|
||||
message.id,
|
||||
|
@ -1256,7 +1256,7 @@ QByteArray HtmlWriter::Wrap::pushMedia(
|
|||
return pushGenericMedia(data);
|
||||
}
|
||||
const auto &content = message.media.content;
|
||||
if (const auto document = base::get_if<Data::Document>(&content)) {
|
||||
if (const auto document = std::get_if<Data::Document>(&content)) {
|
||||
Assert(!message.media.ttl);
|
||||
if (document->isSticker) {
|
||||
return pushStickerMedia(*document, basePath);
|
||||
|
@ -1266,13 +1266,13 @@ QByteArray HtmlWriter::Wrap::pushMedia(
|
|||
return pushVideoFileMedia(*document, basePath);
|
||||
}
|
||||
Unexpected("Non generic document in HtmlWriter::Wrap::pushMedia.");
|
||||
} else if (const auto photo = base::get_if<Data::Photo>(&content)) {
|
||||
} else if (const auto photo = std::get_if<Data::Photo>(&content)) {
|
||||
Assert(!message.media.ttl);
|
||||
return pushPhotoMedia(*photo, basePath);
|
||||
} else if (const auto poll = base::get_if<Data::Poll>(&content)) {
|
||||
} else if (const auto poll = std::get_if<Data::Poll>(&content)) {
|
||||
return pushPoll(*poll);
|
||||
}
|
||||
Assert(!content.has_value());
|
||||
Assert(v::is_null(content));
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
|
@ -1602,7 +1602,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
|
|||
|
||||
auto result = MediaData();
|
||||
const auto &action = message.action;
|
||||
if (const auto call = base::get_if<ActionPhoneCall>(&action.content)) {
|
||||
if (const auto call = std::get_if<ActionPhoneCall>(&action.content)) {
|
||||
result.classes = "media_call";
|
||||
result.title = peers.peer(message.out
|
||||
? message.peerId
|
||||
|
@ -1628,7 +1628,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
|
|||
return result;
|
||||
}
|
||||
|
||||
message.media.content.match([&](const Photo &data) {
|
||||
v::match(message.media.content, [&](const Photo &data) {
|
||||
if (message.media.ttl) {
|
||||
result.title = "Self-destructing photo";
|
||||
result.status = data.id
|
||||
|
|
|
@ -221,7 +221,7 @@ QByteArray SerializeMessage(
|
|||
const QString &internalLinksDomain) {
|
||||
using namespace Data;
|
||||
|
||||
if (message.media.content.is<UnsupportedMedia>()) {
|
||||
if (v::is<UnsupportedMedia>(message.media.content)) {
|
||||
return SerializeObject(context, {
|
||||
{ "id", Data::NumberToString(message.id) },
|
||||
{ "type", SerializeString("unsupported") }
|
||||
|
@ -254,7 +254,9 @@ QByteArray SerializeMessage(
|
|||
{ "id", NumberToString(message.id) },
|
||||
{
|
||||
"type",
|
||||
SerializeString(message.action.content ? "service" : "message")
|
||||
SerializeString(!v::is_null(message.action.content)
|
||||
? "service"
|
||||
: "message")
|
||||
},
|
||||
{ "date", SerializeDate(message.date) },
|
||||
};
|
||||
|
@ -357,7 +359,7 @@ QByteArray SerializeMessage(
|
|||
}
|
||||
};
|
||||
|
||||
message.action.content.match([&](const ActionChatCreate &data) {
|
||||
v::match(message.action.content, [&](const ActionChatCreate &data) {
|
||||
pushActor();
|
||||
pushAction("create_group");
|
||||
push("title", data.title);
|
||||
|
@ -473,7 +475,7 @@ QByteArray SerializeMessage(
|
|||
pushAction("requested_phone_number");
|
||||
}, [](v::null_t) {});
|
||||
|
||||
if (!message.action.content) {
|
||||
if (v::is_null(message.action.content)) {
|
||||
pushFrom();
|
||||
push("author", message.signature);
|
||||
if (message.forwardedFromId) {
|
||||
|
@ -498,7 +500,7 @@ QByteArray SerializeMessage(
|
|||
}
|
||||
}
|
||||
|
||||
message.media.content.match([&](const Photo &photo) {
|
||||
v::match(message.media.content, [&](const Photo &photo) {
|
||||
pushPhoto(photo.image);
|
||||
pushTTL();
|
||||
}, [&](const Document &data) {
|
||||
|
|
|
@ -102,7 +102,7 @@ QByteArray SerializeMessage(
|
|||
const QString &internalLinksDomain) {
|
||||
using namespace Data;
|
||||
|
||||
if (message.media.content.is<UnsupportedMedia>()) {
|
||||
if (v::is<UnsupportedMedia>(message.media.content)) {
|
||||
return "Error! This message is not supported "
|
||||
"by this version of Telegram Desktop. "
|
||||
"Please update the application.";
|
||||
|
@ -219,7 +219,7 @@ QByteArray SerializeMessage(
|
|||
}
|
||||
};
|
||||
|
||||
message.action.content.match([&](const ActionChatCreate &data) {
|
||||
v::match(message.action.content, [&](const ActionChatCreate &data) {
|
||||
pushActor();
|
||||
pushAction("Create group");
|
||||
push("Title", data.title);
|
||||
|
@ -340,7 +340,7 @@ QByteArray SerializeMessage(
|
|||
pushAction("Request Phone Number");
|
||||
}, [](v::null_t) {});
|
||||
|
||||
if (!message.action.content) {
|
||||
if (v::is_null(message.action.content)) {
|
||||
pushFrom();
|
||||
push("Author", message.signature);
|
||||
if (message.forwardedFromId) {
|
||||
|
@ -357,7 +357,7 @@ QByteArray SerializeMessage(
|
|||
}
|
||||
}
|
||||
|
||||
message.media.content.match([&](const Photo &photo) {
|
||||
v::match(message.media.content, [&](const Photo &photo) {
|
||||
pushPhoto(photo.image);
|
||||
pushTTL();
|
||||
}, [&](const Document &data) {
|
||||
|
|
|
@ -41,11 +41,11 @@ struct Content {
|
|||
return std::move(
|
||||
state
|
||||
) | rpl::filter([](const State &state) {
|
||||
return state.is<ProcessingState>() || state.is<FinishedState>();
|
||||
return v::is<ProcessingState>(state) || v::is<FinishedState>(state);
|
||||
}) | rpl::map([=](const State &state) {
|
||||
if (const auto process = base::get_if<ProcessingState>(&state)) {
|
||||
if (const auto process = std::get_if<ProcessingState>(&state)) {
|
||||
return ContentFromState(settings, *process);
|
||||
} else if (const auto done = base::get_if<FinishedState>(&state)) {
|
||||
} else if (const auto done = std::get_if<FinishedState>(&state)) {
|
||||
return ContentFromState(*done);
|
||||
}
|
||||
Unexpected("State type in ContentFromState.");
|
||||
|
|
|
@ -306,7 +306,7 @@ void PanelController::showProgress() {
|
|||
|
||||
progress->doneClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (const auto finished = base::get_if<FinishedState>(&_state)) {
|
||||
if (const auto finished = std::get_if<FinishedState>(&_state)) {
|
||||
File::ShowInFolder(finished->path);
|
||||
LOG(("Export Info: Panel Hide By Done: %1."
|
||||
).arg(finished->path));
|
||||
|
@ -319,7 +319,7 @@ void PanelController::showProgress() {
|
|||
}
|
||||
|
||||
void PanelController::stopWithConfirmation(FnMut<void()> callback) {
|
||||
if (!_state.is<ProcessingState>()) {
|
||||
if (!v::is<ProcessingState>(_state)) {
|
||||
LOG(("Export Info: Stop Panel Without Confirmation."));
|
||||
stopExport();
|
||||
if (callback) {
|
||||
|
@ -367,7 +367,7 @@ rpl::producer<> PanelController::stopRequests() const {
|
|||
return _panelCloseEvents.events(
|
||||
) | rpl::flatten_latest(
|
||||
) | rpl::filter([=] {
|
||||
return !_state.is<ProcessingState>() || _stopRequested;
|
||||
return !v::is<ProcessingState>(_state) || _stopRequested;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -376,21 +376,21 @@ void PanelController::fillParams(const PasswordCheckState &state) {
|
|||
}
|
||||
|
||||
void PanelController::updateState(State &&state) {
|
||||
if (const auto start = base::get_if<PasswordCheckState>(&state)) {
|
||||
if (const auto start = std::get_if<PasswordCheckState>(&state)) {
|
||||
fillParams(*start);
|
||||
}
|
||||
if (!_panel) {
|
||||
createPanel();
|
||||
}
|
||||
_state = std::move(state);
|
||||
if (const auto apiError = base::get_if<ApiErrorState>(&_state)) {
|
||||
if (const auto apiError = std::get_if<ApiErrorState>(&_state)) {
|
||||
showError(*apiError);
|
||||
} else if (const auto error = base::get_if<OutputErrorState>(&_state)) {
|
||||
} else if (const auto error = std::get_if<OutputErrorState>(&_state)) {
|
||||
showError(*error);
|
||||
} else if (_state.is<FinishedState>()) {
|
||||
} else if (v::is<FinishedState>(_state)) {
|
||||
_panel->setTitle(tr::lng_export_title());
|
||||
_panel->setHideOnDeactivate(false);
|
||||
} else if (_state.is<CancelledState>()) {
|
||||
} else if (v::is<CancelledState>(_state)) {
|
||||
LOG(("Export Info: Stop Panel After Cancel."));
|
||||
stopExport();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ PeerData *Key::peer() const {
|
|||
}
|
||||
|
||||
//Data::Feed *Key::feed() const { // #feed
|
||||
// if (const auto feed = base::get_if<not_null<Data::Feed*>>(&_value)) {
|
||||
// if (const auto feed = std::get_if<not_null<Data::Feed*>>(&_value)) {
|
||||
// return *feed;
|
||||
// }
|
||||
// return nullptr;
|
||||
|
|
|
@ -62,7 +62,8 @@ private:
|
|||
Looped,
|
||||
Finished,
|
||||
};
|
||||
using ReadEnoughState = base::optional_variant<
|
||||
using ReadEnoughState = std::variant<
|
||||
v::null_t,
|
||||
FrameResult,
|
||||
Shared::PrepareNextCheck>;
|
||||
|
||||
|
@ -225,7 +226,7 @@ void VideoTrackObject::readFrames() {
|
|||
auto time = trackTime().trackTime;
|
||||
while (true) {
|
||||
const auto result = readEnoughFrames(time);
|
||||
result.match([&](FrameResult result) {
|
||||
v::match(result, [&](FrameResult result) {
|
||||
if (result == FrameResult::Done
|
||||
|| result == FrameResult::Finished) {
|
||||
presentFrameIfNeeded();
|
||||
|
@ -241,7 +242,7 @@ void VideoTrackObject::readFrames() {
|
|||
}
|
||||
}, [](v::null_t) {
|
||||
});
|
||||
if (result.has_value()) {
|
||||
if (!v::is_null(result)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +252,7 @@ auto VideoTrackObject::readEnoughFrames(crl::time trackTime)
|
|||
-> ReadEnoughState {
|
||||
const auto dropStaleFrames = !_options.waitForMarkAsShown;
|
||||
const auto state = _shared->prepareState(trackTime, dropStaleFrames);
|
||||
return state.match([&](Shared::PrepareFrame frame) -> ReadEnoughState {
|
||||
return v::match(state, [&](Shared::PrepareFrame frame) -> ReadEnoughState {
|
||||
while (true) {
|
||||
const auto result = readFrame(frame);
|
||||
if (result != FrameResult::Done) {
|
||||
|
@ -670,7 +671,7 @@ auto VideoTrack::Shared::prepareState(
|
|||
// If player already awaits next frame - we ignore if it's stale.
|
||||
dropStaleFrames = false;
|
||||
const auto result = prepareNext(index);
|
||||
return result.is<PrepareNextCheck>() ? PrepareState() : result;
|
||||
return v::is<PrepareNextCheck>(result) ? PrepareState() : result;
|
||||
};
|
||||
|
||||
switch (counter()) {
|
||||
|
|
|
@ -91,7 +91,8 @@ private:
|
|||
public:
|
||||
using PrepareFrame = not_null<Frame*>;
|
||||
using PrepareNextCheck = crl::time;
|
||||
using PrepareState = base::optional_variant<
|
||||
using PrepareState = std::variant<
|
||||
v::null_t,
|
||||
PrepareFrame,
|
||||
PrepareNextCheck>;
|
||||
struct PresentFrame {
|
||||
|
|
|
@ -39,7 +39,7 @@ using Key = GroupThumbs::Key;
|
|||
|
||||
Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) {
|
||||
return v::match(key, [&](PhotoId photoId) {
|
||||
return context.match([&](PeerId peerId) {
|
||||
return v::match(context, [&](PeerId peerId) {
|
||||
return peerIsUser(peerId)
|
||||
? Data::FileOriginUserPhoto(peerToUser(peerId), photoId)
|
||||
: Data::FileOrigin(Data::FileOriginPeerPhoto(peerId));
|
||||
|
@ -49,7 +49,7 @@ Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) {
|
|||
}, [](FullMsgId itemId) {
|
||||
return Data::FileOrigin(itemId);
|
||||
}, [&](GroupThumbs::CollageKey) {
|
||||
return context.match([](const GroupThumbs::CollageSlice &slice) {
|
||||
return v::match(context, [](const GroupThumbs::CollageSlice &slice) {
|
||||
return Data::FileOrigin(slice.context);
|
||||
}, [](auto&&) {
|
||||
return Data::FileOrigin();
|
||||
|
@ -442,7 +442,7 @@ void GroupThumbs::RefreshFromSlice(
|
|||
if (instance) {
|
||||
instance->updateContext(context);
|
||||
}
|
||||
if (!context) {
|
||||
if (v::is_null(context)) {
|
||||
if (instance) {
|
||||
instance->resizeToWidth(availableWidth);
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ auto GroupThumbs::createThumb(Key key)
|
|||
}
|
||||
return createThumb(key, nullptr);
|
||||
} else if (const auto collageKey = std::get_if<CollageKey>(&key)) {
|
||||
if (const auto itemId = base::get_if<FullMsgId>(&_context)) {
|
||||
if (const auto itemId = std::get_if<FullMsgId>(&_context)) {
|
||||
if (const auto item = _session->data().message(*itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto page = media->webpage()) {
|
||||
|
|
|
@ -80,7 +80,8 @@ public:
|
|||
return _lifetime;
|
||||
}
|
||||
|
||||
using Context = base::optional_variant<
|
||||
using Context = std::variant<
|
||||
v::null_t,
|
||||
PeerId,
|
||||
MessageGroupId,
|
||||
FullMsgId>;
|
||||
|
|
|
@ -1621,10 +1621,10 @@ Data::FileOrigin OverlayWidget::fileOrigin() const {
|
|||
Data::FileOrigin OverlayWidget::fileOrigin(const Entity &entity) const {
|
||||
if (const auto item = entity.item) {
|
||||
return item->fullId();
|
||||
} else if (!entity.data.is<not_null<PhotoData*>>()) {
|
||||
} else if (!v::is<not_null<PhotoData*>>(entity.data)) {
|
||||
return Data::FileOrigin();
|
||||
}
|
||||
const auto photo = entity.data.get_unchecked<not_null<PhotoData*>>();
|
||||
const auto photo = std::get<not_null<PhotoData*>>(entity.data);
|
||||
if (_user) {
|
||||
return Data::FileOriginUserPhoto(_user->bareId(), photo->id);
|
||||
} else if (_peer && _peer->userpicPhotoId() == photo->id) {
|
||||
|
@ -3605,16 +3605,17 @@ OverlayWidget::Entity OverlayWidget::entityByIndex(int index) const {
|
|||
}
|
||||
|
||||
void OverlayWidget::setContext(
|
||||
base::optional_variant<
|
||||
std::variant<
|
||||
v::null_t,
|
||||
not_null<HistoryItem*>,
|
||||
not_null<PeerData*>> context) {
|
||||
if (const auto item = base::get_if<not_null<HistoryItem*>>(&context)) {
|
||||
if (const auto item = std::get_if<not_null<HistoryItem*>>(&context)) {
|
||||
_msgid = (*item)->fullId();
|
||||
_canForwardItem = (*item)->allowsForward();
|
||||
_canDeleteItem = (*item)->canDelete();
|
||||
_history = (*item)->history();
|
||||
_peer = _history->peer;
|
||||
} else if (const auto peer = base::get_if<not_null<PeerData*>>(&context)) {
|
||||
} else if (const auto peer = std::get_if<not_null<PeerData*>>(&context)) {
|
||||
_msgid = FullMsgId();
|
||||
_canForwardItem = _canDeleteItem = false;
|
||||
_history = (*peer)->owner().history(*peer);
|
||||
|
@ -3681,7 +3682,7 @@ bool OverlayWidget::moveToNext(int delta) {
|
|||
}
|
||||
|
||||
bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) {
|
||||
if (!entity.data && !entity.item) {
|
||||
if (v::is_null(entity.data) && !entity.item) {
|
||||
return false;
|
||||
}
|
||||
if (const auto item = entity.item) {
|
||||
|
@ -3693,9 +3694,9 @@ bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) {
|
|||
}
|
||||
clearStreaming();
|
||||
_streamingStartPaused = false;
|
||||
if (auto photo = base::get_if<not_null<PhotoData*>>(&entity.data)) {
|
||||
if (auto photo = std::get_if<not_null<PhotoData*>>(&entity.data)) {
|
||||
displayPhoto(*photo, entity.item);
|
||||
} else if (auto document = base::get_if<not_null<DocumentData*>>(&entity.data)) {
|
||||
} else if (auto document = std::get_if<not_null<DocumentData*>>(&entity.data)) {
|
||||
displayDocument(*document, entity.item);
|
||||
} else {
|
||||
displayDocument(nullptr, entity.item);
|
||||
|
@ -3716,11 +3717,11 @@ void OverlayWidget::preloadData(int delta) {
|
|||
auto documents = base::flat_set<std::shared_ptr<Data::DocumentMedia>>();
|
||||
for (auto index = from; index != till + 1; ++index) {
|
||||
auto entity = entityByIndex(index);
|
||||
if (auto photo = base::get_if<not_null<PhotoData*>>(&entity.data)) {
|
||||
if (auto photo = std::get_if<not_null<PhotoData*>>(&entity.data)) {
|
||||
const auto [i, ok] = photos.emplace((*photo)->createMediaView());
|
||||
(*i)->wanted(Data::PhotoSize::Small, fileOrigin(entity));
|
||||
(*photo)->load(fileOrigin(entity), LoadFromCloudOrLocal, true);
|
||||
} else if (auto document = base::get_if<not_null<DocumentData*>>(
|
||||
} else if (auto document = std::get_if<not_null<DocumentData*>>(
|
||||
&entity.data)) {
|
||||
const auto [i, ok] = documents.emplace(
|
||||
(*document)->createMediaView());
|
||||
|
|
|
@ -153,7 +153,8 @@ private:
|
|||
OverVideo,
|
||||
};
|
||||
struct Entity {
|
||||
base::optional_variant<
|
||||
std::variant<
|
||||
v::null_t,
|
||||
not_null<PhotoData*>,
|
||||
not_null<DocumentData*>> data;
|
||||
HistoryItem *item;
|
||||
|
@ -212,7 +213,8 @@ private:
|
|||
Entity entityByIndex(int index) const;
|
||||
Entity entityForItemId(const FullMsgId &itemId) const;
|
||||
bool moveToEntity(const Entity &entity, int preloadDelta = 0);
|
||||
void setContext(base::optional_variant<
|
||||
void setContext(std::variant<
|
||||
v::null_t,
|
||||
not_null<HistoryItem*>,
|
||||
not_null<PeerData*>> context);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ struct DataError {
|
|||
// QByteArray - bad existing scan with such file_hash
|
||||
// QString - bad data field value with such key
|
||||
// std::nullopt - additional scan required
|
||||
base::optional_variant<QByteArray, QString> key;
|
||||
std::variant<v::null_t, QByteArray, QString> key;
|
||||
QString type; // personal_details, passport, etc.
|
||||
QString text;
|
||||
|
||||
|
|
|
@ -866,7 +866,7 @@ void FormController::submitPassword(
|
|||
const auto &settings = wrapped->c_secureSecretSettings();
|
||||
const auto algo = Core::ParseSecureSecretAlgo(
|
||||
settings.vsecure_algo());
|
||||
if (!algo) {
|
||||
if (v::is_null(algo)) {
|
||||
_view->showUpdateAppBox();
|
||||
return;
|
||||
}
|
||||
|
@ -956,7 +956,7 @@ void FormController::checkSavedPasswordSettings(
|
|||
const auto &settings = wrapped->c_secureSecretSettings();
|
||||
const auto algo = Core::ParseSecureSecretAlgo(
|
||||
settings.vsecure_algo());
|
||||
if (!algo) {
|
||||
if (v::is_null(algo)) {
|
||||
_view->showUpdateAppBox();
|
||||
return;
|
||||
} else if (!settings.vsecure_secret().v.isEmpty()
|
||||
|
@ -2609,8 +2609,8 @@ void FormController::showForm() {
|
|||
return;
|
||||
}
|
||||
if (_password.unknownAlgo
|
||||
|| !_password.newAlgo
|
||||
|| !_password.newSecureAlgo) {
|
||||
|| v::is_null(_password.newAlgo)
|
||||
|| v::is_null(_password.newSecureAlgo)) {
|
||||
_view->showUpdateAppBox();
|
||||
return;
|
||||
} else if (_password.request) {
|
||||
|
|
|
@ -287,9 +287,11 @@ struct PasswordSettings {
|
|||
// different random parts added on the client to the server salts.
|
||||
// && (newAlgo == other.newAlgo)
|
||||
// && (newSecureAlgo == other.newSecureAlgo)
|
||||
&& ((!newAlgo && !other.newAlgo) || (newAlgo && other.newAlgo))
|
||||
&& ((!newSecureAlgo && !other.newSecureAlgo)
|
||||
|| (newSecureAlgo && other.newSecureAlgo))
|
||||
&& ((v::is_null(newAlgo) && v::is_null(other.newAlgo))
|
||||
|| (!v::is_null(newAlgo) && !v::is_null(other.newAlgo)))
|
||||
&& ((v::is_null(newSecureAlgo) && v::is_null(other.newSecureAlgo))
|
||||
|| (!v::is_null(newSecureAlgo)
|
||||
&& !v::is_null(other.newSecureAlgo)))
|
||||
&& (hint == other.hint)
|
||||
&& (unconfirmedPattern == other.unconfirmedPattern)
|
||||
&& (confirmedEmail == other.confirmedEmail)
|
||||
|
|
|
@ -676,8 +676,8 @@ void PanelController::setupPassword() {
|
|||
|
||||
const auto &settings = _form->passwordSettings();
|
||||
if (settings.unknownAlgo
|
||||
|| !settings.newAlgo
|
||||
|| !settings.newSecureAlgo) {
|
||||
|| v::is_null(settings.newAlgo)
|
||||
|| v::is_null(settings.newSecureAlgo)) {
|
||||
showUpdateAppBox();
|
||||
return;
|
||||
} else if (settings.request) {
|
||||
|
|
|
@ -583,8 +583,8 @@ bool CheckEditCloudPassword(not_null<::Main::Session*> session) {
|
|||
Assert(current.has_value());
|
||||
|
||||
if (!current->unknownAlgorithm
|
||||
&& current->newPassword
|
||||
&& current->newSecureSecret) {
|
||||
&& !v::is_null(current->newPassword)
|
||||
&& !v::is_null(current->newSecureSecret)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -717,7 +717,7 @@ void FileLoadTask::process() {
|
|||
_information = readMediaInformation(Core::MimeTypeForFile(info).name());
|
||||
}
|
||||
filemime = _information->filemime;
|
||||
if (auto image = base::get_if<FileMediaInformation::Image>(
|
||||
if (auto image = std::get_if<FileMediaInformation::Image>(
|
||||
&_information->media)) {
|
||||
fullimage = base::take(image->data);
|
||||
if (!Core::IsMimeSticker(filemime)) {
|
||||
|
@ -732,7 +732,7 @@ void FileLoadTask::process() {
|
|||
filemime = "audio/ogg";
|
||||
} else {
|
||||
if (_information) {
|
||||
if (auto image = base::get_if<FileMediaInformation::Image>(
|
||||
if (auto image = std::get_if<FileMediaInformation::Image>(
|
||||
&_information->media)) {
|
||||
fullimage = base::take(image->data);
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ void FileLoadTask::process() {
|
|||
}
|
||||
} else {
|
||||
if (_information) {
|
||||
if (auto image = base::get_if<FileMediaInformation::Image>(
|
||||
if (auto image = std::get_if<FileMediaInformation::Image>(
|
||||
&_information->media)) {
|
||||
fullimage = base::take(image->data);
|
||||
}
|
||||
|
@ -807,13 +807,13 @@ void FileLoadTask::process() {
|
|||
_information = readMediaInformation(filemime);
|
||||
filemime = _information->filemime;
|
||||
}
|
||||
if (auto song = base::get_if<FileMediaInformation::Song>(
|
||||
if (auto song = std::get_if<FileMediaInformation::Song>(
|
||||
&_information->media)) {
|
||||
isSong = true;
|
||||
auto flags = MTPDdocumentAttributeAudio::Flag::f_title | MTPDdocumentAttributeAudio::Flag::f_performer;
|
||||
attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(song->duration), MTP_string(song->title), MTP_string(song->performer), MTPstring()));
|
||||
thumbnail = PrepareFileThumbnail(std::move(song->cover));
|
||||
} else if (auto video = base::get_if<FileMediaInformation::Video>(
|
||||
} else if (auto video = std::get_if<FileMediaInformation::Video>(
|
||||
&_information->media)) {
|
||||
isVideo = true;
|
||||
auto coverWidth = video->thumbnail.width();
|
||||
|
|
|
@ -258,7 +258,7 @@ struct FileMediaInformation {
|
|||
};
|
||||
|
||||
QString filemime;
|
||||
base::optional_variant<Image, Song, Video> media;
|
||||
std::variant<v::null_t, Image, Song, Video> media;
|
||||
};
|
||||
|
||||
class FileLoadTask final : public Task {
|
||||
|
|
|
@ -83,7 +83,7 @@ bool PrepareAlbumMediaIsWaiting(
|
|||
|
||||
using Image = FileMediaInformation::Image;
|
||||
using Video = FileMediaInformation::Video;
|
||||
if (const auto image = base::get_if<Image>(
|
||||
if (const auto image = std::get_if<Image>(
|
||||
&file.information->media)) {
|
||||
if (ValidPhotoForAlbum(*image, file.mime)) {
|
||||
file.shownDimensions = PrepareShownDimensions(image->data);
|
||||
|
@ -95,7 +95,7 @@ bool PrepareAlbumMediaIsWaiting(
|
|||
file.preview.setDevicePixelRatio(cRetinaFactor());
|
||||
file.type = PreparedFile::AlbumType::Photo;
|
||||
}
|
||||
} else if (const auto video = base::get_if<Video>(
|
||||
} else if (const auto video = std::get_if<Video>(
|
||||
&file.information->media)) {
|
||||
if (ValidVideoForAlbum(*video)) {
|
||||
auto blurred = Images::prepareBlur(Images::prepareOpaque(video->thumbnail));
|
||||
|
@ -349,7 +349,7 @@ std::optional<PreparedList> PreparedList::PreparedFileFromFilesDialog(
|
|||
using Info = FileMediaInformation;
|
||||
|
||||
const auto media = &file.information->media;
|
||||
const auto valid = media->match([](const Info::Image &data) {
|
||||
const auto valid = v::match(*media, [](const Info::Image &data) {
|
||||
return Storage::ValidateThumbDimensions(
|
||||
data.data.width(),
|
||||
data.data.height())
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0060349806529cd517201bec2d25208ad8d0bb89
|
||||
Subproject commit 3f67c206afb85b4f5277b43db2768cb41daed245
|
|
@ -1 +1 @@
|
|||
Subproject commit b060b25b45bf0100ae6d35f558eb0818380ebc13
|
||||
Subproject commit b83eed16812f4de3c2537cd12722d3dece95021b
|
Loading…
Add table
Reference in a new issue