2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Move to std::optional.

This commit is contained in:
John Preston
2018-09-21 19:28:46 +03:00
parent 850efbde95
commit 2e5a0e056c
115 changed files with 632 additions and 672 deletions

View File

@@ -414,7 +414,7 @@ void GroupInfoBox::createGroup(not_null<PeerListBox*> selectUsersBox, const QStr
App::main()->sentUpdatesReceived(result);
auto success = base::make_optional(&result)
| [](auto updates) -> base::optional<const QVector<MTPChat>*> {
| [](auto updates) -> std::optional<const QVector<MTPChat>*> {
switch (updates->type()) {
case mtpc_updates:
return &updates->c_updates().vchats.v;
@@ -422,12 +422,12 @@ void GroupInfoBox::createGroup(not_null<PeerListBox*> selectUsersBox, const QStr
return &updates->c_updatesCombined().vchats.v;
}
LOG(("API Error: unexpected update cons %1 (GroupInfoBox::creationDone)").arg(updates->type()));
return base::none;
return std::nullopt;
}
| [](auto chats) {
return (!chats->empty() && chats->front().type() == mtpc_chat)
? base::make_optional(chats)
: base::none;
: std::nullopt;
}
| [](auto chats) {
return App::chat(chats->front().c_chat().vid.v);
@@ -517,7 +517,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
App::main()->sentUpdatesReceived(result);
auto success = base::make_optional(&result)
| [](auto updates) -> base::optional<const QVector<MTPChat>*> {
| [](auto updates) -> std::optional<const QVector<MTPChat>*> {
switch (updates->type()) {
case mtpc_updates:
return &updates->c_updates().vchats.v;
@@ -525,12 +525,12 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
return &updates->c_updatesCombined().vchats.v;
}
LOG(("API Error: unexpected update cons %1 (GroupInfoBox::createChannel)").arg(updates->type()));
return base::none;
return std::nullopt;
}
| [](auto chats) {
return (!chats->empty() && chats->front().type() == mtpc_channel)
? base::make_optional(chats)
: base::none;
: std::nullopt;
}
| [](auto chats) {
return App::channel(chats->front().c_channel().vid.v);

View File

@@ -93,12 +93,12 @@ private:
Ui::Checkbox *signatures = nullptr;
};
struct Saving {
base::optional<QString> username;
base::optional<QString> title;
base::optional<QString> description;
base::optional<bool> hiddenPreHistory;
base::optional<bool> signatures;
base::optional<bool> everyoneInvites;
std::optional<QString> username;
std::optional<QString> title;
std::optional<QString> description;
std::optional<bool> hiddenPreHistory;
std::optional<bool> signatures;
std::optional<bool> everyoneInvites;
};
Fn<QString()> computeTitle() const;
@@ -143,7 +143,7 @@ private:
void revokeInviteLink();
void exportInviteLink(const QString &confirmation);
base::optional<Saving> validate() const;
std::optional<Saving> validate() const;
bool validateUsername(Saving &to) const;
bool validateTitle(Saving &to) const;
bool validateDescription(Saving &to) const;
@@ -1087,7 +1087,7 @@ void Controller::submitDescription() {
}
}
base::optional<Controller::Saving> Controller::validate() const {
std::optional<Controller::Saving> Controller::validate() const {
auto result = Saving();
if (validateUsername(result)
&& validateTitle(result)

View File

@@ -44,7 +44,7 @@ private:
bool reportFail(const RPCError &error);
not_null<PeerData*> _peer;
base::optional<MessageIdsList> _ids;
std::optional<MessageIdsList> _ids;
std::shared_ptr<Ui::RadioenumGroup<Reason>> _reasonGroup;
object_ptr<Ui::Radioenum<Reason>> _reasonSpam = { nullptr };

View File

@@ -136,7 +136,7 @@ private:
void drawSimpleFrame(Painter &p, QRect to, QSize size) const;
Ui::GroupMediaLayout _layout;
base::optional<QRect> _animateFromGeometry;
std::optional<QRect> _animateFromGeometry;
const QImage _fullPreview;
const int _shrinkSize = 0;
QPixmap _albumImage;
@@ -229,7 +229,7 @@ AlbumThumb::AlbumThumb(
}
void AlbumThumb::resetLayoutAnimation() {
_animateFromGeometry = base::none;
_animateFromGeometry = std::nullopt;
}
void AlbumThumb::animateLayoutToInitial() {