'base::optional_variant<' -> 'std::variant<v::null_t,'

This commit is contained in:
John Preston 2020-08-31 13:04:17 +04:00
parent 734d834a20
commit f0e1d2fd02
38 changed files with 189 additions and 169 deletions

View File

@ -2750,7 +2750,7 @@ void ApiWrap::refreshFileReference(
const auto fail = [&] { const auto fail = [&] {
handler(UpdatedFileReferences()); handler(UpdatedFileReferences());
}; };
origin.data.match([&](Data::FileOriginMessage data) { v::match(origin.data, [&](Data::FileOriginMessage data) {
if (const auto item = _session->data().message(data)) { if (const auto item = _session->data().message(data)) {
if (item->isScheduled()) { if (item->isScheduled()) {
const auto &scheduled = _session->data().scheduledMessages(); const auto &scheduled = _session->data().scheduledMessages();

View File

@ -103,7 +103,7 @@ private:
return !(*this == other); 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; int getSelectionIndex(const Selection &selection) const;
void repaintPaper(int index); void repaintPaper(int index);
@ -358,16 +358,16 @@ void BackgroundBox::Inner::paintPaper(
p.drawPixmap(x, y, paper.thumbnail); 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()) { if (paper.data.id() == Window::Theme::Background()->id()) {
const auto checkLeft = x + st::backgroundSize.width() - st::overviewCheckSkip - st::overviewCheck.size; const auto checkLeft = x + st::backgroundSize.width() - st::overviewCheckSkip - st::overviewCheck.size;
const auto checkTop = y + st::backgroundSize.height() - st::overviewCheckSkip - st::overviewCheck.size; const auto checkTop = y + st::backgroundSize.height() - st::overviewCheckSkip - st::overviewCheck.size;
_check->paint(p, checkLeft, checkTop, width()); _check->paint(p, checkLeft, checkTop, width());
} else if (Data::IsCloudWallPaper(paper.data) } else if (Data::IsCloudWallPaper(paper.data)
&& !Data::IsDefaultWallPaper(paper.data) && !Data::IsDefaultWallPaper(paper.data)
&& over.has_value() && !v::is_null(over)
&& (&paper == &_papers[getSelectionIndex(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); const auto deletePos = QPoint(x + st::backgroundSize.width() - st::stickerPanDeleteIconBg.width(), y);
p.setOpacity(deleteSelected ? st::stickerPanDeleteOpacityBgOver : st::stickerPanDeleteOpacityBg); p.setOpacity(deleteSelected ? st::stickerPanDeleteOpacityBgOver : st::stickerPanDeleteOpacityBg);
st::stickerPanDeleteIconBg.paint(p, deletePos, width()); st::stickerPanDeleteIconBg.paint(p, deletePos, width());
@ -414,7 +414,7 @@ void BackgroundBox::Inner::mouseMoveEvent(QMouseEvent *e) {
repaintPaper(getSelectionIndex(_over)); repaintPaper(getSelectionIndex(_over));
_over = newOver; _over = newOver;
repaintPaper(getSelectionIndex(_over)); repaintPaper(getSelectionIndex(_over));
setCursor((_over.has_value() || _overDown.has_value()) setCursor((!v::is_null(_over) || !v::is_null(_overDown))
? style::cur_pointer ? style::cur_pointer
: style::cur_default); : style::cur_default);
} }
@ -442,7 +442,7 @@ void BackgroundBox::Inner::mousePressEvent(QMouseEvent *e) {
int BackgroundBox::Inner::getSelectionIndex( int BackgroundBox::Inner::getSelectionIndex(
const Selection &selection) const { const Selection &selection) const {
return selection.match([](const Selected &data) { return v::match(selection, [](const Selected &data) {
return data.index; return data.index;
}, [](const DeleteSelected &data) { }, [](const DeleteSelected &data) {
return data.index; return data.index;
@ -452,12 +452,12 @@ int BackgroundBox::Inner::getSelectionIndex(
} }
void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) { 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); const auto index = getSelectionIndex(_over);
if (index >= 0 && index < _papers.size()) { if (index >= 0 && index < _papers.size()) {
if (base::get_if<DeleteSelected>(&_over)) { if (std::get_if<DeleteSelected>(&_over)) {
_backgroundRemove.fire_copy(_papers[index].data); _backgroundRemove.fire_copy(_papers[index].data);
} else if (base::get_if<Selected>(&_over)) { } else if (std::get_if<Selected>(&_over)) {
auto &paper = _papers[index]; auto &paper = _papers[index];
if (!paper.dataMedia) { if (!paper.dataMedia) {
if (const auto document = paper.data.document()) { if (const auto document = paper.data.document()) {
@ -468,7 +468,7 @@ void BackgroundBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
_backgroundChosen.fire_copy(paper.data); _backgroundChosen.fire_copy(paper.data);
} }
} }
} else if (!_over.has_value()) { } else if (v::is_null(_over)) {
setCursor(style::cur_default); setCursor(style::cur_default);
} }
} }

View File

@ -489,7 +489,7 @@ void EditCaptionBox::updateEditPreview() {
auto isGif = false; auto isGif = false;
auto shouldAsDoc = true; auto shouldAsDoc = true;
auto docPhotoSize = QSize(); 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( shouldAsDoc = !Storage::ValidateThumbDimensions(
image->data.width(), image->data.width(),
image->data.height()); image->data.height());
@ -501,14 +501,14 @@ void EditCaptionBox::updateEditPreview() {
_animated = isGif; _animated = isGif;
_photo = !isGif && !shouldAsDoc; _photo = !isGif && !shouldAsDoc;
_isImage = true; _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; isGif = video->isGifv;
_animated = true; _animated = true;
shouldAsDoc = false; shouldAsDoc = false;
} }
if (shouldAsDoc) { if (shouldAsDoc) {
auto nameString = filename; 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( nameString = DocumentData::ComposeNameString(
filename, filename,
song->title, song->title,
@ -684,7 +684,7 @@ bool EditCaptionBox::fileFromClipboard(not_null<const QMimeData*> data) {
const auto imageAsDoc = [&] { const auto imageAsDoc = [&] {
using Info = FileMediaInformation; using Info = FileMediaInformation;
const auto fileMedia = &file->information->media; 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( return !Storage::ValidateThumbDimensions(
image->data.width(), image->data.width(),
image->data.height()); image->data.height());

View File

@ -105,7 +105,7 @@ private:
return (index == other.index); 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 updateSelected(Selection selected);
void updatePressed(Selection pressed); void updatePressed(Selection pressed);
@ -327,7 +327,7 @@ void Rows::mouseMoveEvent(QMouseEvent *e) {
void Rows::mousePressEvent(QMouseEvent *e) { void Rows::mousePressEvent(QMouseEvent *e) {
updatePressed(_selected); updatePressed(_selected);
if (_pressed.has_value() if (!v::is_null(_pressed)
&& !rowBySelection(_pressed).menuToggleForceRippled) { && !rowBySelection(_pressed).menuToggleForceRippled) {
addRipple(_pressed, e->pos()); addRipple(_pressed, e->pos());
} }
@ -348,11 +348,11 @@ QRect Rows::menuToggleArea(not_null<const Row*> row) const {
} }
void Rows::addRipple(Selection selected, QPoint position) { void Rows::addRipple(Selection selected, QPoint position) {
Expects(selected.has_value()); Expects(!v::is_null(selected));
ensureRippleBySelection(selected); ensureRippleBySelection(selected);
const auto menu = selected.is<MenuSelection>(); const auto menu = v::is<MenuSelection>(selected);
const auto &row = rowBySelection(selected); const auto &row = rowBySelection(selected);
const auto menuArea = menuToggleArea(&row); const auto menuArea = menuToggleArea(&row);
auto &ripple = rippleBySelection(&row, selected); auto &ripple = rippleBySelection(&row, selected);
@ -369,7 +369,7 @@ void Rows::ensureRippleBySelection(not_null<Row*> row, Selection selected) {
if (ripple) { if (ripple) {
return; return;
} }
const auto menu = selected.is<MenuSelection>(); const auto menu = v::is<MenuSelection>(selected);
const auto menuArea = menuToggleArea(row); const auto menuArea = menuToggleArea(row);
auto mask = menu auto mask = menu
? Ui::RippleAnimation::ellipseMask(menuArea.size()) ? Ui::RippleAnimation::ellipseMask(menuArea.size())
@ -391,7 +391,7 @@ void Rows::mouseReleaseEvent(QMouseEvent *e) {
const auto pressed = _pressed; const auto pressed = _pressed;
updatePressed({}); updatePressed({});
if (pressed == _selected) { if (pressed == _selected) {
pressed.match([&](RowSelection data) { v::match(pressed, [&](RowSelection data) {
activateByIndex(data.index); activateByIndex(data.index);
}, [&](MenuSelection data) { }, [&](MenuSelection data) {
showMenu(data.index); showMenu(data.index);
@ -597,7 +597,7 @@ int Rows::count() const {
} }
int Rows::indexFromSelection(Selection selected) const { int Rows::indexFromSelection(Selection selected) const {
return selected.match([&](RowSelection data) { return v::match(selected, [&](RowSelection data) {
return data.index; return data.index;
}, [&](MenuSelection data) { }, [&](MenuSelection data) {
return data.index; return data.index;
@ -648,7 +648,7 @@ rpl::producer<bool> Rows::isEmpty() const {
} }
void Rows::repaint(Selection selected) { void Rows::repaint(Selection selected) {
selected.match([](v::null_t) { v::match(selected, [](v::null_t) {
}, [&](const auto &data) { }, [&](const auto &data) {
repaint(data.index); repaint(data.index);
}); });
@ -672,17 +672,17 @@ void Rows::repaintChecked(not_null<const Row*> row) {
} }
void Rows::updateSelected(Selection selected) { 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); repaint(_selected);
_selected = selected; _selected = selected;
repaint(_selected); repaint(_selected);
if (changed) { if (changed) {
_hasSelection.fire(_selected.has_value()); _hasSelection.fire(!v::is_null(_selected));
} }
} }
void Rows::updatePressed(Selection pressed) { void Rows::updatePressed(Selection pressed) {
if (_pressed.has_value()) { if (!v::is_null(_pressed)) {
if (!rowBySelection(_pressed).menuToggleForceRippled) { if (!rowBySelection(_pressed).menuToggleForceRippled) {
if (const auto ripple = rippleBySelection(_pressed).get()) { if (const auto ripple = rippleBySelection(_pressed).get()) {
ripple->lastStop(); ripple->lastStop();
@ -725,7 +725,7 @@ const std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection( std::unique_ptr<Ui::RippleAnimation> &Rows::rippleBySelection(
not_null<Row*> row, not_null<Row*> row,
Selection selected) { Selection selected) {
return selected.is<MenuSelection>() return v::is<MenuSelection>(selected)
? row->menuToggleRipple ? row->menuToggleRipple
: row->ripple; : row->ripple;
} }
@ -796,7 +796,7 @@ void Rows::paintEvent(QPaintEvent *e) {
const auto menu = menuToggleArea(); const auto menu = menuToggleArea();
const auto selectedIndex = (_menuShownIndex >= 0) const auto selectedIndex = (_menuShownIndex >= 0)
? _menuShownIndex ? _menuShownIndex
: indexFromSelection(_pressed.has_value() ? _pressed : _selected); : indexFromSelection(!v::is_null(_pressed) ? _pressed : _selected);
for (auto i = 0, till = count(); i != till; ++i) { for (auto i = 0, till = count(); i != till; ++i) {
const auto &row = rowByIndex(i); const auto &row = rowByIndex(i);
if (row.top + row.height <= clip.y()) { if (row.top + row.height <= clip.y()) {

View File

@ -766,11 +766,11 @@ SingleMediaPreview *SingleMediaPreview::Create(
auto preview = QImage(); auto preview = QImage();
bool animated = false; bool animated = false;
bool animationPreview = 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)) { &file.information->media)) {
preview = image->data; preview = image->data;
animated = animationPreview = image->animated; 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)) { &file.information->media)) {
preview = video->thumbnail; preview = video->thumbnail;
animated = true; animated = true;
@ -1004,10 +1004,10 @@ void SingleFilePreview::prepareThumb(const QImage &preview) {
void SingleFilePreview::preparePreview(const Storage::PreparedFile &file) { void SingleFilePreview::preparePreview(const Storage::PreparedFile &file) {
auto preview = QImage(); auto preview = QImage();
if (const auto image = base::get_if<FileMediaInformation::Image>( if (const auto image = std::get_if<FileMediaInformation::Image>(
&file.information->media)) { &file.information->media)) {
preview = image->data; 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)) { &file.information->media)) {
preview = video->thumbnail; preview = video->thumbnail;
} }
@ -1034,7 +1034,7 @@ void SingleFilePreview::preparePreview(const Storage::PreparedFile &file) {
auto songTitle = QString(); auto songTitle = QString();
auto songPerformer = QString(); auto songPerformer = QString();
if (file.information) { if (file.information) {
if (const auto song = base::get_if<FileMediaInformation::Song>( if (const auto song = std::get_if<FileMediaInformation::Song>(
&file.information->media)) { &file.information->media)) {
songTitle = song->title; songTitle = song->title;
songPerformer = song->performer; songPerformer = song->performer;

View File

@ -179,7 +179,7 @@ private:
return false; return false;
} }
}; };
using SelectedRow = base::optional_variant<MegagroupSet, int>; using SelectedRow = std::variant<v::null_t, MegagroupSet, int>;
class AddressField : public Ui::UsernameInput { class AddressField : public Ui::UsernameInput {
public: public:
using UsernameInput::UsernameInput; using UsernameInput::UsernameInput;
@ -1101,7 +1101,7 @@ void StickersBox::Inner::paintRow(Painter &p, not_null<Row*> row, int index) {
if (_megagroupSet) { if (_megagroupSet) {
auto selectedIndex = [&] { auto selectedIndex = [&] {
if (auto index = base::get_if<int>(&_selected)) { if (auto index = std::get_if<int>(&_selected)) {
return *index; return *index;
} }
return -1; return -1;
@ -1341,7 +1341,7 @@ void StickersBox::Inner::mousePressEvent(QMouseEvent *e) {
if (_actionSel >= 0) { if (_actionSel >= 0) {
setActionDown(_actionSel); setActionDown(_actionSel);
update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight); 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) { if (_section == Section::Installed && !_rows[*selectedIndex]->isRecentSet() && _inDragArea) {
_above = _dragging = _started = *selectedIndex; _above = _dragging = _started = *selectedIndex;
_dragStart = mapFromGlobal(_mouse); _dragStart = mapFromGlobal(_mouse);
@ -1394,7 +1394,7 @@ void StickersBox::Inner::setSelected(SelectedRow selected) {
return; return;
} }
auto countSelectedIndex = [&] { auto countSelectedIndex = [&] {
if (auto index = base::get_if<int>(&_selected)) { if (auto index = std::get_if<int>(&_selected)) {
return *index; return *index;
} }
return -1; return -1;
@ -1416,7 +1416,7 @@ void StickersBox::Inner::setPressed(SelectedRow pressed) {
return; return;
} }
auto countPressedIndex = [&] { auto countPressedIndex = [&] {
if (auto index = base::get_if<int>(&_pressed)) { if (auto index = std::get_if<int>(&_pressed)) {
return *index; return *index;
} }
return -1; return -1;
@ -1544,7 +1544,7 @@ void StickersBox::Inner::updateCursor() {
? ((_actionSel >= 0 && (_actionDown < 0 || _actionDown == _actionSel)) ? ((_actionSel >= 0 && (_actionDown < 0 || _actionDown == _actionSel))
? style::cur_pointer ? style::cur_pointer
: style::cur_default) : style::cur_default)
: (_selected.has_value() || _pressed.has_value()) : (!v::is_null(_selected) || !v::is_null(_pressed))
? style::cur_pointer ? style::cur_pointer
: style::cur_default); : style::cur_default);
} }
@ -1582,7 +1582,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
_dragging = _started = -1; _dragging = _started = -1;
} else if (pressed == _selected && _actionSel < 0 && _actionDown < 0) { } else if (pressed == _selected && _actionSel < 0 && _actionDown < 0) {
const auto selectedIndex = [&] { const auto selectedIndex = [&] {
if (auto index = base::get_if<int>(&_selected)) { if (auto index = std::get_if<int>(&_selected)) {
return *index; return *index;
} }
return -1; return -1;
@ -1602,7 +1602,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
showSetByRow(*row); showSetByRow(*row);
} }
} }
} else if (_megagroupSelectedSet && _selected.is<MegagroupSet>()) { } else if (_megagroupSelectedSet && v::is<MegagroupSet>(_selected)) {
showSetByRow(*_megagroupSelectedSet); showSetByRow(*_megagroupSelectedSet);
} }
} }

View File

@ -1509,8 +1509,10 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
} }
auto &sets = shownSets(); auto &sets = shownSets();
auto selectedSticker = base::get_if<OverSticker>(&_selected); auto selectedSticker = std::get_if<OverSticker>(&_selected);
auto selectedButton = base::get_if<OverButton>(_pressed ? &_pressed : &_selected); auto selectedButton = std::get_if<OverButton>(!v::is_null(_pressed)
? &_pressed
: &_selected);
if (sets.empty() && _section == Section::Search) { if (sets.empty() && _section == Section::Search) {
paintEmptySearchResults(p); paintEmptySearchResults(p);
@ -1625,7 +1627,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
if (clip.top() + clip.height() <= info.rowsTop) { if (clip.top() + clip.height() <= info.rowsTop) {
return true; return true;
} else if (set.id == Data::Stickers::MegagroupSetId && set.stickers.empty()) { } 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); paintMegagroupEmptySet(p, info.rowsTop, buttonSelected);
return true; return true;
} }
@ -1971,20 +1973,20 @@ void StickersListWidget::mousePressEvent(QMouseEvent *e) {
} }
void StickersListWidget::setPressed(OverState newPressed) { void StickersListWidget::setPressed(OverState newPressed) {
if (auto button = base::get_if<OverButton>(&_pressed)) { if (auto button = std::get_if<OverButton>(&_pressed)) {
auto &sets = shownSets(); auto &sets = shownSets();
Assert(button->section >= 0 && button->section < sets.size()); Assert(button->section >= 0 && button->section < sets.size());
auto &set = sets[button->section]; auto &set = sets[button->section];
if (set.ripple) { if (set.ripple) {
set.ripple->lastStop(); set.ripple->lastStop();
} }
} else if (base::get_if<OverGroupAdd>(&_pressed)) { } else if (std::get_if<OverGroupAdd>(&_pressed)) {
if (_megagroupSetButtonRipple) { if (_megagroupSetButtonRipple) {
_megagroupSetButtonRipple->lastStop(); _megagroupSetButtonRipple->lastStop();
} }
} }
_pressed = newPressed; _pressed = newPressed;
if (auto button = base::get_if<OverButton>(&_pressed)) { if (auto button = std::get_if<OverButton>(&_pressed)) {
auto &sets = shownSets(); auto &sets = shownSets();
Assert(button->section >= 0 && button->section < sets.size()); Assert(button->section >= 0 && button->section < sets.size());
auto &set = sets[button->section]; auto &set = sets[button->section];
@ -1992,7 +1994,7 @@ void StickersListWidget::setPressed(OverState newPressed) {
set.ripple = createButtonRipple(button->section); set.ripple = createButtonRipple(button->section);
} }
set.ripple->add(mapFromGlobal(QCursor::pos()) - buttonRippleTopLeft(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) { if (!_megagroupSetButtonRipple) {
auto maskSize = _megagroupSetButtonRect.size(); auto maskSize = _megagroupSetButtonRect.size();
auto mask = Ui::RippleAnimation::roundRectMask(maskSize, st::buttonRadius); auto mask = Ui::RippleAnimation::roundRectMask(maskSize, st::buttonRadius);
@ -2059,10 +2061,10 @@ void StickersListWidget::fillContextMenu(
SendMenu::Type type) { SendMenu::Type type) {
auto selected = _selected; auto selected = _selected;
auto &sets = shownSets(); auto &sets = shownSets();
if (!selected || _pressed) { if (v::is_null(selected) || !v::is_null(_pressed)) {
return; 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()); Assert(sticker->section >= 0 && sticker->section < sets.size());
auto &set = sets[sticker->section]; auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size()); Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
@ -2124,8 +2126,8 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
updateSelected(); updateSelected();
auto &sets = shownSets(); auto &sets = shownSets();
if (pressed && pressed == _selected) { if (!v::is_null(pressed) && pressed == _selected) {
if (auto sticker = base::get_if<OverSticker>(&pressed)) { if (auto sticker = std::get_if<OverSticker>(&pressed)) {
Assert(sticker->section >= 0 && sticker->section < sets.size()); Assert(sticker->section >= 0 && sticker->section < sets.size());
auto &set = sets[sticker->section]; auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size()); Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
@ -2145,10 +2147,10 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
} else { } else {
_chosen.fire_copy({ .document = document }); _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()); Assert(set->section >= 0 && set->section < sets.size());
displaySet(sets[set->section].id); 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()); Assert(button->section >= 0 && button->section < sets.size());
if (sets[button->section].externalLayout) { if (sets[button->section].externalLayout) {
installSet(sets[button->section].id); installSet(sets[button->section].id);
@ -2159,7 +2161,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
} else { } else {
removeSet(sets[button->section].id); 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)); Ui::show(Box<StickersBox>(controller(), _megagroupSet));
} }
} }
@ -2750,7 +2752,7 @@ bool StickersListWidget::preventAutoHide() {
} }
void StickersListWidget::updateSelected() { void StickersListWidget::updateSelected() {
if (_pressed && !_previewShown) { if (!v::is_null(_pressed) && !_previewShown) {
return; return;
} }
@ -2827,13 +2829,15 @@ bool StickersListWidget::stickerHasDeleteButton(const Set &set, int index) const
void StickersListWidget::setSelected(OverState newSelected) { void StickersListWidget::setSelected(OverState newSelected) {
if (_selected != 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 &sets = shownSets();
auto updateSelected = [&]() { auto updateSelected = [&]() {
if (auto sticker = base::get_if<OverSticker>(&_selected)) { if (auto sticker = std::get_if<OverSticker>(&_selected)) {
rtlupdate(stickerRect(sticker->section, sticker->index)); 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 if (button->section >= 0
&& button->section < sets.size() && button->section < sets.size()
&& sets[button->section].externalLayout) { && sets[button->section].externalLayout) {
@ -2841,7 +2845,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
} else { } else {
rtlupdate(removeButtonRect(button->section)); rtlupdate(removeButtonRect(button->section));
} }
} else if (base::get_if<OverGroupAdd>(&_selected)) { } else if (std::get_if<OverGroupAdd>(&_selected)) {
rtlupdate(megagroupSetButtonRectFinal()); rtlupdate(megagroupSetButtonRectFinal());
} }
}; };
@ -2850,7 +2854,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
updateSelected(); updateSelected();
if (_previewShown && _pressed != _selected) { if (_previewShown && _pressed != _selected) {
if (const auto sticker = base::get_if<OverSticker>(&_selected)) { if (const auto sticker = std::get_if<OverSticker>(&_selected)) {
_pressed = _selected; _pressed = _selected;
Assert(sticker->section >= 0 && sticker->section < sets.size()); Assert(sticker->section >= 0 && sticker->section < sets.size());
const auto &set = sets[sticker->section]; const auto &set = sets[sticker->section];
@ -2865,7 +2869,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
} }
void StickersListWidget::showPreview() { 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(); const auto &sets = shownSets();
Assert(sticker->section >= 0 && sticker->section < sets.size()); Assert(sticker->section >= 0 && sticker->section < sets.size());
const auto &set = sets[sticker->section]; const auto &set = sets[sticker->section];

View File

@ -144,7 +144,8 @@ private:
friend inline bool operator==(OverGroupAdd a, OverGroupAdd b) { friend inline bool operator==(OverGroupAdd a, OverGroupAdd b) {
return true; return true;
} }
using OverState = base::optional_variant< using OverState = std::variant<
v::null_t,
OverSticker, OverSticker,
OverSet, OverSet,
OverButton, OverButton,

View File

@ -199,10 +199,10 @@ CloudPasswordCheckRequest ParseCloudPasswordCheckRequest(
} }
CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) { CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) {
if (!parsed.is<CloudPasswordAlgoModPow>()) { if (!v::is<CloudPasswordAlgoModPow>(parsed)) {
return v::null; return v::null;
} }
auto &value = parsed.get_unchecked<CloudPasswordAlgoModPow>(); auto &value = std::get<CloudPasswordAlgoModPow>(parsed);
const auto already = value.salt1.size(); const auto already = value.salt1.size();
value.salt1.resize(already + kAdditionalSalt); value.salt1.resize(already + kAdditionalSalt);
bytes::set_random(bytes::make_span(value.salt1).subspan(already)); bytes::set_random(bytes::make_span(value.salt1).subspan(already));
@ -210,7 +210,7 @@ CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) {
} }
MTPPasswordKdfAlgo PrepareCloudPasswordAlgo(const CloudPasswordAlgo &data) { MTPPasswordKdfAlgo PrepareCloudPasswordAlgo(const CloudPasswordAlgo &data) {
return data.match([](const CloudPasswordAlgoModPow &data) { return v::match(data, [](const CloudPasswordAlgoModPow &data) {
return MTP_passwordKdfAlgoModPow( return MTP_passwordKdfAlgoModPow(
MTP_bytes(data.salt1), MTP_bytes(data.salt1),
MTP_bytes(data.salt2), MTP_bytes(data.salt2),
@ -228,7 +228,7 @@ CloudPasswordResult::operator bool() const {
bytes::vector ComputeCloudPasswordHash( bytes::vector ComputeCloudPasswordHash(
const CloudPasswordAlgo &algo, const CloudPasswordAlgo &algo,
bytes::const_span password) { bytes::const_span password) {
return algo.match([&](const CloudPasswordAlgoModPow &data) { return v::match(algo, [&](const CloudPasswordAlgoModPow &data) {
return ComputeHash(data, password); return ComputeHash(data, password);
}, [](v::null_t) -> bytes::vector { }, [](v::null_t) -> bytes::vector {
Unexpected("Bad cloud password algorithm."); Unexpected("Bad cloud password algorithm.");
@ -238,7 +238,7 @@ bytes::vector ComputeCloudPasswordHash(
CloudPasswordDigest ComputeCloudPasswordDigest( CloudPasswordDigest ComputeCloudPasswordDigest(
const CloudPasswordAlgo &algo, const CloudPasswordAlgo &algo,
bytes::const_span password) { bytes::const_span password) {
return algo.match([&](const CloudPasswordAlgoModPow &data) { return v::match(algo, [&](const CloudPasswordAlgoModPow &data) {
return ComputeDigest(data, password); return ComputeDigest(data, password);
}, [](v::null_t) -> CloudPasswordDigest { }, [](v::null_t) -> CloudPasswordDigest {
Unexpected("Bad cloud password algorithm."); Unexpected("Bad cloud password algorithm.");
@ -248,7 +248,7 @@ CloudPasswordDigest ComputeCloudPasswordDigest(
CloudPasswordResult ComputeCloudPasswordCheck( CloudPasswordResult ComputeCloudPasswordCheck(
const CloudPasswordCheckRequest &request, const CloudPasswordCheckRequest &request,
bytes::const_span hash) { bytes::const_span hash) {
return request.algo.match([&](const CloudPasswordAlgoModPow &data) { return v::match(request.algo, [&](const CloudPasswordAlgoModPow &data) {
return ComputeCheck(request, data, hash); return ComputeCheck(request, data, hash);
}, [](v::null_t) -> CloudPasswordResult { }, [](v::null_t) -> CloudPasswordResult {
Unexpected("Bad cloud password algorithm."); Unexpected("Bad cloud password algorithm.");
@ -270,10 +270,10 @@ SecureSecretAlgo ParseSecureSecretAlgo(
} }
SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) { SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) {
if (!parsed.is<SecureSecretAlgoPBKDF2>()) { if (!v::is<SecureSecretAlgoPBKDF2>(parsed)) {
return v::null; return v::null;
} }
auto &value = parsed.get_unchecked<SecureSecretAlgoPBKDF2>(); auto &value = std::get<SecureSecretAlgoPBKDF2>(parsed);
const auto already = value.salt.size(); const auto already = value.salt.size();
value.salt.resize(already + kAdditionalSalt); value.salt.resize(already + kAdditionalSalt);
bytes::set_random(bytes::make_span(value.salt).subspan(already)); bytes::set_random(bytes::make_span(value.salt).subspan(already));
@ -282,7 +282,7 @@ SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) {
MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo( MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo(
const SecureSecretAlgo &data) { const SecureSecretAlgo &data) {
return data.match([](const SecureSecretAlgoPBKDF2 &data) { return v::match(data, [](const SecureSecretAlgoPBKDF2 &data) {
return MTP_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000( return MTP_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000(
MTP_bytes(data.salt)); MTP_bytes(data.salt));
}, [](const SecureSecretAlgoSHA512 &data) { }, [](const SecureSecretAlgoSHA512 &data) {
@ -295,7 +295,7 @@ MTPSecurePasswordKdfAlgo PrepareSecureSecretAlgo(
bytes::vector ComputeSecureSecretHash( bytes::vector ComputeSecureSecretHash(
const SecureSecretAlgo &algo, const SecureSecretAlgo &algo,
bytes::const_span password) { bytes::const_span password) {
return algo.match([&](const auto &data) { return v::match(algo, [&](const auto &data) {
return ComputeHash(data, password); return ComputeHash(data, password);
}); });
} }

View File

@ -31,7 +31,7 @@ inline bool operator==(
&& (a.p == b.p); && (a.p == b.p);
} }
using CloudPasswordAlgo = base::optional_variant<CloudPasswordAlgoModPow>; using CloudPasswordAlgo = std::variant<v::null_t, CloudPasswordAlgoModPow>;
CloudPasswordAlgo ParseCloudPasswordAlgo(const MTPPasswordKdfAlgo &data); CloudPasswordAlgo ParseCloudPasswordAlgo(const MTPPasswordKdfAlgo &data);
CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed); CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed);
@ -43,7 +43,7 @@ struct CloudPasswordCheckRequest {
CloudPasswordAlgo algo; CloudPasswordAlgo algo;
explicit operator bool() const { explicit operator bool() const {
return !!algo; return !v::is_null(algo);
} }
}; };
@ -106,7 +106,8 @@ inline bool operator==(
return (a.salt == b.salt); return (a.salt == b.salt);
} }
using SecureSecretAlgo = base::optional_variant< using SecureSecretAlgo = std::variant<
v::null_t,
SecureSecretAlgoSHA512, SecureSecretAlgoSHA512,
SecureSecretAlgoPBKDF2>; SecureSecretAlgoPBKDF2>;

View File

@ -97,7 +97,8 @@ struct FileOriginTheme {
}; };
struct FileOrigin { struct FileOrigin {
using Variant = base::optional_variant< using Variant = std::variant<
v::null_t,
FileOriginMessage, FileOriginMessage,
FileOriginUserPhoto, FileOriginUserPhoto,
FileOriginPeerPhoto, FileOriginPeerPhoto,
@ -123,7 +124,7 @@ struct FileOrigin {
} }
explicit operator bool() const { explicit operator bool() const {
return data.has_value(); return !v::is_null(data);
} }
inline bool operator<(const FileOrigin &other) const { inline bool operator<(const FileOrigin &other) const {
return data < other.data; return data < other.data;

View File

@ -858,7 +858,7 @@ Peer EmptyPeer(PeerId peerId) {
} }
File &Media::file() { File &Media::file() {
return content.match([](Photo &data) -> File& { return v::match(content, [](Photo &data) -> File& {
return data.image.file; return data.image.file;
}, [](Document &data) -> File& { }, [](Document &data) -> File& {
return data.file; return data.file;
@ -871,7 +871,7 @@ File &Media::file() {
} }
const File &Media::file() const { 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; return data.image.file;
}, [](const Document &data) -> const File& { }, [](const Document &data) -> const File& {
return data.file; return data.file;
@ -884,7 +884,7 @@ const File &Media::file() const {
} }
Image &Media::thumb() { Image &Media::thumb() {
return content.match([](Document &data) -> Image& { return v::match(content, [](Document &data) -> Image& {
return data.thumb; return data.thumb;
}, [](auto&) -> Image& { }, [](auto&) -> Image& {
static Image result; static Image result;
@ -893,7 +893,7 @@ Image &Media::thumb() {
} }
const Image &Media::thumb() const { 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; return data.thumb;
}, [](const auto &) -> const Image& { }, [](const auto &) -> const Image& {
static const Image result; static const Image result;
@ -1104,7 +1104,7 @@ ServiceAction ParseServiceAction(
File &Message::file() { File &Message::file() {
const auto service = &action.content; 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 photo->photo.image.file;
} }
return media.file(); return media.file();
@ -1112,7 +1112,7 @@ File &Message::file() {
const File &Message::file() const { const File &Message::file() const {
const auto service = &action.content; 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 photo->photo.image.file;
} }
return media.file(); return media.file();

View File

@ -309,7 +309,8 @@ struct UnsupportedMedia {
}; };
struct Media { struct Media {
base::optional_variant< std::variant<
v::null_t,
Photo, Photo,
Document, Document,
SharedContact, SharedContact,
@ -449,7 +450,8 @@ struct ActionPhoneNumberRequest {
}; };
struct ServiceAction { struct ServiceAction {
base::optional_variant< std::variant<
v::null_t,
ActionChatCreate, ActionChatCreate,
ActionChatEditTitle, ActionChatEditTitle,
ActionChatEditPhoto, ActionChatEditPhoto,

View File

@ -1655,8 +1655,8 @@ bool ApiWrap::processFileLoad(
} }
using Type = MediaSettings::Type; using Type = MediaSettings::Type;
const auto type = message ? message->media.content.match( const auto type = message ? v::match(message->media.content, [&](
[&](const Data::Document &data) { const Data::Document &data) {
if (data.isSticker) { if (data.isSticker) {
return Type::Sticker; return Type::Sticker;
} else if (data.isVideoMessage) { } else if (data.isVideoMessage) {

View File

@ -161,13 +161,13 @@ rpl::producer<State> ControllerObject::state() const {
) | rpl::then( ) | rpl::then(
_stateChanges.events() _stateChanges.events()
) | rpl::filter([](const State &state) { ) | 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; return !password || !password->requesting;
}); });
} }
void ControllerObject::setState(State &&state) { void ControllerObject::setState(State &&state) {
if (_state.is<CancelledState>()) { if (v::is<CancelledState>(_state)) {
return; return;
} }
_state = std::move(state); _state = std::move(state);

View File

@ -96,7 +96,8 @@ struct FinishedState {
int64 bytesCount = 0; int64 bytesCount = 0;
}; };
using State = base::optional_variant< using State = std::variant<
v::null_t,
PasswordCheckState, PasswordCheckState,
ProcessingState, ProcessingState,
ApiErrorState, ApiErrorState,

View File

@ -973,7 +973,7 @@ auto HtmlWriter::Wrap::pushMessage(
info.forwardedFromName = message.forwardedFromName; info.forwardedFromName = message.forwardedFromName;
info.forwardedDate = message.forwardedDate; info.forwardedDate = message.forwardedDate;
info.forwarded = message.forwarded; info.forwarded = message.forwarded;
if (message.media.content.is<UnsupportedMedia>()) { if (v::is<UnsupportedMedia>(message.media.content)) {
return { info, pushServiceMessage( return { info, pushServiceMessage(
message.id, message.id,
dialog, dialog,
@ -990,8 +990,8 @@ auto HtmlWriter::Wrap::pushMessage(
const auto isChannel = (dialog.type == DialogType::PrivateChannel) const auto isChannel = (dialog.type == DialogType::PrivateChannel)
|| (dialog.type == DialogType::PublicChannel); || (dialog.type == DialogType::PublicChannel);
const auto serviceFrom = peers.wrapUserName(message.fromId); const auto serviceFrom = peers.wrapUserName(message.fromId);
const auto serviceText = message.action.content.match( const auto serviceText = v::match(message.action.content, [&](
[&](const ActionChatCreate &data) { const ActionChatCreate &data) {
return serviceFrom return serviceFrom
+ " created group &laquo;" + data.title + "&raquo;" + " created group &laquo;" + data.title + "&raquo;"
+ (data.userIds.empty() + (data.userIds.empty()
@ -1094,8 +1094,8 @@ auto HtmlWriter::Wrap::pushMessage(
if (!serviceText.isEmpty()) { if (!serviceText.isEmpty()) {
const auto &content = message.action.content; const auto &content = message.action.content;
const auto photo = content.is<ActionChatEditPhoto>() const auto photo = v::is<ActionChatEditPhoto>(content)
? &content.get_unchecked<ActionChatEditPhoto>().photo ? &std::get<ActionChatEditPhoto>(content).photo
: nullptr; : nullptr;
return { info, pushServiceMessage( return { info, pushServiceMessage(
message.id, message.id,
@ -1256,7 +1256,7 @@ QByteArray HtmlWriter::Wrap::pushMedia(
return pushGenericMedia(data); return pushGenericMedia(data);
} }
const auto &content = message.media.content; 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); Assert(!message.media.ttl);
if (document->isSticker) { if (document->isSticker) {
return pushStickerMedia(*document, basePath); return pushStickerMedia(*document, basePath);
@ -1266,13 +1266,13 @@ QByteArray HtmlWriter::Wrap::pushMedia(
return pushVideoFileMedia(*document, basePath); return pushVideoFileMedia(*document, basePath);
} }
Unexpected("Non generic document in HtmlWriter::Wrap::pushMedia."); 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); Assert(!message.media.ttl);
return pushPhotoMedia(*photo, basePath); 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); return pushPoll(*poll);
} }
Assert(!content.has_value()); Assert(v::is_null(content));
return QByteArray(); return QByteArray();
} }
@ -1602,7 +1602,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
auto result = MediaData(); auto result = MediaData();
const auto &action = message.action; 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.classes = "media_call";
result.title = peers.peer(message.out result.title = peers.peer(message.out
? message.peerId ? message.peerId
@ -1628,7 +1628,7 @@ MediaData HtmlWriter::Wrap::prepareMediaData(
return result; return result;
} }
message.media.content.match([&](const Photo &data) { v::match(message.media.content, [&](const Photo &data) {
if (message.media.ttl) { if (message.media.ttl) {
result.title = "Self-destructing photo"; result.title = "Self-destructing photo";
result.status = data.id result.status = data.id

View File

@ -221,7 +221,7 @@ QByteArray SerializeMessage(
const QString &internalLinksDomain) { const QString &internalLinksDomain) {
using namespace Data; using namespace Data;
if (message.media.content.is<UnsupportedMedia>()) { if (v::is<UnsupportedMedia>(message.media.content)) {
return SerializeObject(context, { return SerializeObject(context, {
{ "id", Data::NumberToString(message.id) }, { "id", Data::NumberToString(message.id) },
{ "type", SerializeString("unsupported") } { "type", SerializeString("unsupported") }
@ -254,7 +254,9 @@ QByteArray SerializeMessage(
{ "id", NumberToString(message.id) }, { "id", NumberToString(message.id) },
{ {
"type", "type",
SerializeString(message.action.content ? "service" : "message") SerializeString(!v::is_null(message.action.content)
? "service"
: "message")
}, },
{ "date", SerializeDate(message.date) }, { "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(); pushActor();
pushAction("create_group"); pushAction("create_group");
push("title", data.title); push("title", data.title);
@ -473,7 +475,7 @@ QByteArray SerializeMessage(
pushAction("requested_phone_number"); pushAction("requested_phone_number");
}, [](v::null_t) {}); }, [](v::null_t) {});
if (!message.action.content) { if (v::is_null(message.action.content)) {
pushFrom(); pushFrom();
push("author", message.signature); push("author", message.signature);
if (message.forwardedFromId) { 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); pushPhoto(photo.image);
pushTTL(); pushTTL();
}, [&](const Document &data) { }, [&](const Document &data) {

View File

@ -102,7 +102,7 @@ QByteArray SerializeMessage(
const QString &internalLinksDomain) { const QString &internalLinksDomain) {
using namespace Data; using namespace Data;
if (message.media.content.is<UnsupportedMedia>()) { if (v::is<UnsupportedMedia>(message.media.content)) {
return "Error! This message is not supported " return "Error! This message is not supported "
"by this version of Telegram Desktop. " "by this version of Telegram Desktop. "
"Please update the application."; "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(); pushActor();
pushAction("Create group"); pushAction("Create group");
push("Title", data.title); push("Title", data.title);
@ -340,7 +340,7 @@ QByteArray SerializeMessage(
pushAction("Request Phone Number"); pushAction("Request Phone Number");
}, [](v::null_t) {}); }, [](v::null_t) {});
if (!message.action.content) { if (v::is_null(message.action.content)) {
pushFrom(); pushFrom();
push("Author", message.signature); push("Author", message.signature);
if (message.forwardedFromId) { 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); pushPhoto(photo.image);
pushTTL(); pushTTL();
}, [&](const Document &data) { }, [&](const Document &data) {

View File

@ -41,11 +41,11 @@ struct Content {
return std::move( return std::move(
state state
) | rpl::filter([](const State &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) { }) | 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); 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); return ContentFromState(*done);
} }
Unexpected("State type in ContentFromState."); Unexpected("State type in ContentFromState.");

View File

@ -306,7 +306,7 @@ void PanelController::showProgress() {
progress->doneClicks( progress->doneClicks(
) | rpl::start_with_next([=] { ) | 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); File::ShowInFolder(finished->path);
LOG(("Export Info: Panel Hide By Done: %1." LOG(("Export Info: Panel Hide By Done: %1."
).arg(finished->path)); ).arg(finished->path));
@ -319,7 +319,7 @@ void PanelController::showProgress() {
} }
void PanelController::stopWithConfirmation(FnMut<void()> callback) { void PanelController::stopWithConfirmation(FnMut<void()> callback) {
if (!_state.is<ProcessingState>()) { if (!v::is<ProcessingState>(_state)) {
LOG(("Export Info: Stop Panel Without Confirmation.")); LOG(("Export Info: Stop Panel Without Confirmation."));
stopExport(); stopExport();
if (callback) { if (callback) {
@ -367,7 +367,7 @@ rpl::producer<> PanelController::stopRequests() const {
return _panelCloseEvents.events( return _panelCloseEvents.events(
) | rpl::flatten_latest( ) | rpl::flatten_latest(
) | rpl::filter([=] { ) | 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) { 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); fillParams(*start);
} }
if (!_panel) { if (!_panel) {
createPanel(); createPanel();
} }
_state = std::move(state); _state = std::move(state);
if (const auto apiError = base::get_if<ApiErrorState>(&_state)) { if (const auto apiError = std::get_if<ApiErrorState>(&_state)) {
showError(*apiError); showError(*apiError);
} else if (const auto error = base::get_if<OutputErrorState>(&_state)) { } else if (const auto error = std::get_if<OutputErrorState>(&_state)) {
showError(*error); showError(*error);
} else if (_state.is<FinishedState>()) { } else if (v::is<FinishedState>(_state)) {
_panel->setTitle(tr::lng_export_title()); _panel->setTitle(tr::lng_export_title());
_panel->setHideOnDeactivate(false); _panel->setHideOnDeactivate(false);
} else if (_state.is<CancelledState>()) { } else if (v::is<CancelledState>(_state)) {
LOG(("Export Info: Stop Panel After Cancel.")); LOG(("Export Info: Stop Panel After Cancel."));
stopExport(); stopExport();
} }

View File

@ -47,7 +47,7 @@ PeerData *Key::peer() const {
} }
//Data::Feed *Key::feed() const { // #feed //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 *feed;
// } // }
// return nullptr; // return nullptr;

View File

@ -62,7 +62,8 @@ private:
Looped, Looped,
Finished, Finished,
}; };
using ReadEnoughState = base::optional_variant< using ReadEnoughState = std::variant<
v::null_t,
FrameResult, FrameResult,
Shared::PrepareNextCheck>; Shared::PrepareNextCheck>;
@ -225,7 +226,7 @@ void VideoTrackObject::readFrames() {
auto time = trackTime().trackTime; auto time = trackTime().trackTime;
while (true) { while (true) {
const auto result = readEnoughFrames(time); const auto result = readEnoughFrames(time);
result.match([&](FrameResult result) { v::match(result, [&](FrameResult result) {
if (result == FrameResult::Done if (result == FrameResult::Done
|| result == FrameResult::Finished) { || result == FrameResult::Finished) {
presentFrameIfNeeded(); presentFrameIfNeeded();
@ -241,7 +242,7 @@ void VideoTrackObject::readFrames() {
} }
}, [](v::null_t) { }, [](v::null_t) {
}); });
if (result.has_value()) { if (!v::is_null(result)) {
break; break;
} }
} }
@ -251,7 +252,7 @@ auto VideoTrackObject::readEnoughFrames(crl::time trackTime)
-> ReadEnoughState { -> ReadEnoughState {
const auto dropStaleFrames = !_options.waitForMarkAsShown; const auto dropStaleFrames = !_options.waitForMarkAsShown;
const auto state = _shared->prepareState(trackTime, dropStaleFrames); const auto state = _shared->prepareState(trackTime, dropStaleFrames);
return state.match([&](Shared::PrepareFrame frame) -> ReadEnoughState { return v::match(state, [&](Shared::PrepareFrame frame) -> ReadEnoughState {
while (true) { while (true) {
const auto result = readFrame(frame); const auto result = readFrame(frame);
if (result != FrameResult::Done) { if (result != FrameResult::Done) {
@ -670,7 +671,7 @@ auto VideoTrack::Shared::prepareState(
// If player already awaits next frame - we ignore if it's stale. // If player already awaits next frame - we ignore if it's stale.
dropStaleFrames = false; dropStaleFrames = false;
const auto result = prepareNext(index); const auto result = prepareNext(index);
return result.is<PrepareNextCheck>() ? PrepareState() : result; return v::is<PrepareNextCheck>(result) ? PrepareState() : result;
}; };
switch (counter()) { switch (counter()) {

View File

@ -91,7 +91,8 @@ private:
public: public:
using PrepareFrame = not_null<Frame*>; using PrepareFrame = not_null<Frame*>;
using PrepareNextCheck = crl::time; using PrepareNextCheck = crl::time;
using PrepareState = base::optional_variant< using PrepareState = std::variant<
v::null_t,
PrepareFrame, PrepareFrame,
PrepareNextCheck>; PrepareNextCheck>;
struct PresentFrame { struct PresentFrame {

View File

@ -39,7 +39,7 @@ using Key = GroupThumbs::Key;
Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) { Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) {
return v::match(key, [&](PhotoId photoId) { return v::match(key, [&](PhotoId photoId) {
return context.match([&](PeerId peerId) { return v::match(context, [&](PeerId peerId) {
return peerIsUser(peerId) return peerIsUser(peerId)
? Data::FileOriginUserPhoto(peerToUser(peerId), photoId) ? Data::FileOriginUserPhoto(peerToUser(peerId), photoId)
: Data::FileOrigin(Data::FileOriginPeerPhoto(peerId)); : Data::FileOrigin(Data::FileOriginPeerPhoto(peerId));
@ -49,7 +49,7 @@ Data::FileOrigin ComputeFileOrigin(const Key &key, const Context &context) {
}, [](FullMsgId itemId) { }, [](FullMsgId itemId) {
return Data::FileOrigin(itemId); return Data::FileOrigin(itemId);
}, [&](GroupThumbs::CollageKey) { }, [&](GroupThumbs::CollageKey) {
return context.match([](const GroupThumbs::CollageSlice &slice) { return v::match(context, [](const GroupThumbs::CollageSlice &slice) {
return Data::FileOrigin(slice.context); return Data::FileOrigin(slice.context);
}, [](auto&&) { }, [](auto&&) {
return Data::FileOrigin(); return Data::FileOrigin();
@ -442,7 +442,7 @@ void GroupThumbs::RefreshFromSlice(
if (instance) { if (instance) {
instance->updateContext(context); instance->updateContext(context);
} }
if (!context) { if (v::is_null(context)) {
if (instance) { if (instance) {
instance->resizeToWidth(availableWidth); instance->resizeToWidth(availableWidth);
} }
@ -579,7 +579,7 @@ auto GroupThumbs::createThumb(Key key)
} }
return createThumb(key, nullptr); return createThumb(key, nullptr);
} else if (const auto collageKey = std::get_if<CollageKey>(&key)) { } 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 item = _session->data().message(*itemId)) {
if (const auto media = item->media()) { if (const auto media = item->media()) {
if (const auto page = media->webpage()) { if (const auto page = media->webpage()) {

View File

@ -80,7 +80,8 @@ public:
return _lifetime; return _lifetime;
} }
using Context = base::optional_variant< using Context = std::variant<
v::null_t,
PeerId, PeerId,
MessageGroupId, MessageGroupId,
FullMsgId>; FullMsgId>;

View File

@ -1621,10 +1621,10 @@ Data::FileOrigin OverlayWidget::fileOrigin() const {
Data::FileOrigin OverlayWidget::fileOrigin(const Entity &entity) const { Data::FileOrigin OverlayWidget::fileOrigin(const Entity &entity) const {
if (const auto item = entity.item) { if (const auto item = entity.item) {
return item->fullId(); return item->fullId();
} else if (!entity.data.is<not_null<PhotoData*>>()) { } else if (!v::is<not_null<PhotoData*>>(entity.data)) {
return Data::FileOrigin(); 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) { if (_user) {
return Data::FileOriginUserPhoto(_user->bareId(), photo->id); return Data::FileOriginUserPhoto(_user->bareId(), photo->id);
} else if (_peer && _peer->userpicPhotoId() == photo->id) { } else if (_peer && _peer->userpicPhotoId() == photo->id) {
@ -3605,16 +3605,17 @@ OverlayWidget::Entity OverlayWidget::entityByIndex(int index) const {
} }
void OverlayWidget::setContext( void OverlayWidget::setContext(
base::optional_variant< std::variant<
v::null_t,
not_null<HistoryItem*>, not_null<HistoryItem*>,
not_null<PeerData*>> context) { 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(); _msgid = (*item)->fullId();
_canForwardItem = (*item)->allowsForward(); _canForwardItem = (*item)->allowsForward();
_canDeleteItem = (*item)->canDelete(); _canDeleteItem = (*item)->canDelete();
_history = (*item)->history(); _history = (*item)->history();
_peer = _history->peer; _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(); _msgid = FullMsgId();
_canForwardItem = _canDeleteItem = false; _canForwardItem = _canDeleteItem = false;
_history = (*peer)->owner().history(*peer); _history = (*peer)->owner().history(*peer);
@ -3681,7 +3682,7 @@ bool OverlayWidget::moveToNext(int delta) {
} }
bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) { bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) {
if (!entity.data && !entity.item) { if (v::is_null(entity.data) && !entity.item) {
return false; return false;
} }
if (const auto item = entity.item) { if (const auto item = entity.item) {
@ -3693,9 +3694,9 @@ bool OverlayWidget::moveToEntity(const Entity &entity, int preloadDelta) {
} }
clearStreaming(); clearStreaming();
_streamingStartPaused = false; _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); 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); displayDocument(*document, entity.item);
} else { } else {
displayDocument(nullptr, entity.item); displayDocument(nullptr, entity.item);
@ -3716,11 +3717,11 @@ void OverlayWidget::preloadData(int delta) {
auto documents = base::flat_set<std::shared_ptr<Data::DocumentMedia>>(); auto documents = base::flat_set<std::shared_ptr<Data::DocumentMedia>>();
for (auto index = from; index != till + 1; ++index) { for (auto index = from; index != till + 1; ++index) {
auto entity = entityByIndex(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()); const auto [i, ok] = photos.emplace((*photo)->createMediaView());
(*i)->wanted(Data::PhotoSize::Small, fileOrigin(entity)); (*i)->wanted(Data::PhotoSize::Small, fileOrigin(entity));
(*photo)->load(fileOrigin(entity), LoadFromCloudOrLocal, true); (*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)) { &entity.data)) {
const auto [i, ok] = documents.emplace( const auto [i, ok] = documents.emplace(
(*document)->createMediaView()); (*document)->createMediaView());

View File

@ -153,7 +153,8 @@ private:
OverVideo, OverVideo,
}; };
struct Entity { struct Entity {
base::optional_variant< std::variant<
v::null_t,
not_null<PhotoData*>, not_null<PhotoData*>,
not_null<DocumentData*>> data; not_null<DocumentData*>> data;
HistoryItem *item; HistoryItem *item;
@ -212,7 +213,8 @@ private:
Entity entityByIndex(int index) const; Entity entityByIndex(int index) const;
Entity entityForItemId(const FullMsgId &itemId) const; Entity entityForItemId(const FullMsgId &itemId) const;
bool moveToEntity(const Entity &entity, int preloadDelta = 0); 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<HistoryItem*>,
not_null<PeerData*>> context); not_null<PeerData*>> context);

View File

@ -25,7 +25,7 @@ struct DataError {
// QByteArray - bad existing scan with such file_hash // QByteArray - bad existing scan with such file_hash
// QString - bad data field value with such key // QString - bad data field value with such key
// std::nullopt - additional scan required // 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 type; // personal_details, passport, etc.
QString text; QString text;

View File

@ -866,7 +866,7 @@ void FormController::submitPassword(
const auto &settings = wrapped->c_secureSecretSettings(); const auto &settings = wrapped->c_secureSecretSettings();
const auto algo = Core::ParseSecureSecretAlgo( const auto algo = Core::ParseSecureSecretAlgo(
settings.vsecure_algo()); settings.vsecure_algo());
if (!algo) { if (v::is_null(algo)) {
_view->showUpdateAppBox(); _view->showUpdateAppBox();
return; return;
} }
@ -956,7 +956,7 @@ void FormController::checkSavedPasswordSettings(
const auto &settings = wrapped->c_secureSecretSettings(); const auto &settings = wrapped->c_secureSecretSettings();
const auto algo = Core::ParseSecureSecretAlgo( const auto algo = Core::ParseSecureSecretAlgo(
settings.vsecure_algo()); settings.vsecure_algo());
if (!algo) { if (v::is_null(algo)) {
_view->showUpdateAppBox(); _view->showUpdateAppBox();
return; return;
} else if (!settings.vsecure_secret().v.isEmpty() } else if (!settings.vsecure_secret().v.isEmpty()
@ -2609,8 +2609,8 @@ void FormController::showForm() {
return; return;
} }
if (_password.unknownAlgo if (_password.unknownAlgo
|| !_password.newAlgo || v::is_null(_password.newAlgo)
|| !_password.newSecureAlgo) { || v::is_null(_password.newSecureAlgo)) {
_view->showUpdateAppBox(); _view->showUpdateAppBox();
return; return;
} else if (_password.request) { } else if (_password.request) {

View File

@ -287,9 +287,11 @@ struct PasswordSettings {
// different random parts added on the client to the server salts. // different random parts added on the client to the server salts.
// && (newAlgo == other.newAlgo) // && (newAlgo == other.newAlgo)
// && (newSecureAlgo == other.newSecureAlgo) // && (newSecureAlgo == other.newSecureAlgo)
&& ((!newAlgo && !other.newAlgo) || (newAlgo && other.newAlgo)) && ((v::is_null(newAlgo) && v::is_null(other.newAlgo))
&& ((!newSecureAlgo && !other.newSecureAlgo) || (!v::is_null(newAlgo) && !v::is_null(other.newAlgo)))
|| (newSecureAlgo && other.newSecureAlgo)) && ((v::is_null(newSecureAlgo) && v::is_null(other.newSecureAlgo))
|| (!v::is_null(newSecureAlgo)
&& !v::is_null(other.newSecureAlgo)))
&& (hint == other.hint) && (hint == other.hint)
&& (unconfirmedPattern == other.unconfirmedPattern) && (unconfirmedPattern == other.unconfirmedPattern)
&& (confirmedEmail == other.confirmedEmail) && (confirmedEmail == other.confirmedEmail)

View File

@ -676,8 +676,8 @@ void PanelController::setupPassword() {
const auto &settings = _form->passwordSettings(); const auto &settings = _form->passwordSettings();
if (settings.unknownAlgo if (settings.unknownAlgo
|| !settings.newAlgo || v::is_null(settings.newAlgo)
|| !settings.newSecureAlgo) { || v::is_null(settings.newSecureAlgo)) {
showUpdateAppBox(); showUpdateAppBox();
return; return;
} else if (settings.request) { } else if (settings.request) {

View File

@ -583,8 +583,8 @@ bool CheckEditCloudPassword(not_null<::Main::Session*> session) {
Assert(current.has_value()); Assert(current.has_value());
if (!current->unknownAlgorithm if (!current->unknownAlgorithm
&& current->newPassword && !v::is_null(current->newPassword)
&& current->newSecureSecret) { && !v::is_null(current->newSecureSecret)) {
return true; return true;
} }
return false; return false;

View File

@ -717,7 +717,7 @@ void FileLoadTask::process() {
_information = readMediaInformation(Core::MimeTypeForFile(info).name()); _information = readMediaInformation(Core::MimeTypeForFile(info).name());
} }
filemime = _information->filemime; filemime = _information->filemime;
if (auto image = base::get_if<FileMediaInformation::Image>( if (auto image = std::get_if<FileMediaInformation::Image>(
&_information->media)) { &_information->media)) {
fullimage = base::take(image->data); fullimage = base::take(image->data);
if (!Core::IsMimeSticker(filemime)) { if (!Core::IsMimeSticker(filemime)) {
@ -732,7 +732,7 @@ void FileLoadTask::process() {
filemime = "audio/ogg"; filemime = "audio/ogg";
} else { } else {
if (_information) { if (_information) {
if (auto image = base::get_if<FileMediaInformation::Image>( if (auto image = std::get_if<FileMediaInformation::Image>(
&_information->media)) { &_information->media)) {
fullimage = base::take(image->data); fullimage = base::take(image->data);
} }
@ -757,7 +757,7 @@ void FileLoadTask::process() {
} }
} else { } else {
if (_information) { if (_information) {
if (auto image = base::get_if<FileMediaInformation::Image>( if (auto image = std::get_if<FileMediaInformation::Image>(
&_information->media)) { &_information->media)) {
fullimage = base::take(image->data); fullimage = base::take(image->data);
} }
@ -807,13 +807,13 @@ void FileLoadTask::process() {
_information = readMediaInformation(filemime); _information = readMediaInformation(filemime);
filemime = _information->filemime; filemime = _information->filemime;
} }
if (auto song = base::get_if<FileMediaInformation::Song>( if (auto song = std::get_if<FileMediaInformation::Song>(
&_information->media)) { &_information->media)) {
isSong = true; isSong = true;
auto flags = MTPDdocumentAttributeAudio::Flag::f_title | MTPDdocumentAttributeAudio::Flag::f_performer; 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())); 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)); 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)) { &_information->media)) {
isVideo = true; isVideo = true;
auto coverWidth = video->thumbnail.width(); auto coverWidth = video->thumbnail.width();

View File

@ -258,7 +258,7 @@ struct FileMediaInformation {
}; };
QString filemime; QString filemime;
base::optional_variant<Image, Song, Video> media; std::variant<v::null_t, Image, Song, Video> media;
}; };
class FileLoadTask final : public Task { class FileLoadTask final : public Task {

View File

@ -83,7 +83,7 @@ bool PrepareAlbumMediaIsWaiting(
using Image = FileMediaInformation::Image; using Image = FileMediaInformation::Image;
using Video = FileMediaInformation::Video; using Video = FileMediaInformation::Video;
if (const auto image = base::get_if<Image>( if (const auto image = std::get_if<Image>(
&file.information->media)) { &file.information->media)) {
if (ValidPhotoForAlbum(*image, file.mime)) { if (ValidPhotoForAlbum(*image, file.mime)) {
file.shownDimensions = PrepareShownDimensions(image->data); file.shownDimensions = PrepareShownDimensions(image->data);
@ -95,7 +95,7 @@ bool PrepareAlbumMediaIsWaiting(
file.preview.setDevicePixelRatio(cRetinaFactor()); file.preview.setDevicePixelRatio(cRetinaFactor());
file.type = PreparedFile::AlbumType::Photo; 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)) { &file.information->media)) {
if (ValidVideoForAlbum(*video)) { if (ValidVideoForAlbum(*video)) {
auto blurred = Images::prepareBlur(Images::prepareOpaque(video->thumbnail)); auto blurred = Images::prepareBlur(Images::prepareOpaque(video->thumbnail));
@ -349,7 +349,7 @@ std::optional<PreparedList> PreparedList::PreparedFileFromFilesDialog(
using Info = FileMediaInformation; using Info = FileMediaInformation;
const auto media = &file.information->media; 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( return Storage::ValidateThumbDimensions(
data.data.width(), data.data.width(),
data.data.height()) data.data.height())

@ -1 +1 @@
Subproject commit 0060349806529cd517201bec2d25208ad8d0bb89 Subproject commit 3f67c206afb85b4f5277b43db2768cb41daed245

@ -1 +1 @@
Subproject commit b060b25b45bf0100ae6d35f558eb0818380ebc13 Subproject commit b83eed16812f4de3c2537cd12722d3dece95021b