mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Replace base::lambda with shorter term.
base::lambda -> Fn (type alias for std::function). base::lambda_once -> FnMut (type alias for base::unique_function). base::lambda_guarded -> crl::guard. base::lambda_call_type_t -> crl::deduced_call_type.
This commit is contained in:
@@ -38,7 +38,7 @@ public:
|
||||
BackgroundWidget(QWidget *parent) : TWidget(parent) {
|
||||
}
|
||||
|
||||
void setDoneCallback(base::lambda<void()> callback) {
|
||||
void setDoneCallback(Fn<void()> callback) {
|
||||
_doneCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
QPixmap _specialLayerCache;
|
||||
QPixmap _layerCache;
|
||||
|
||||
base::lambda<void()> _doneCallback;
|
||||
Fn<void()> _doneCallback;
|
||||
|
||||
bool _wasAnimating = false;
|
||||
bool _inPaintEvent = false;
|
||||
|
@@ -35,10 +35,10 @@ public:
|
||||
|
||||
bool overlaps(const QRect &globalRect);
|
||||
|
||||
void setClosedCallback(base::lambda<void()> callback) {
|
||||
void setClosedCallback(Fn<void()> callback) {
|
||||
_closedCallback = std::move(callback);
|
||||
}
|
||||
void setResizedCallback(base::lambda<void()> callback) {
|
||||
void setResizedCallback(Fn<void()> callback) {
|
||||
_resizedCallback = std::move(callback);
|
||||
}
|
||||
virtual bool takeToThirdSection() {
|
||||
@@ -72,8 +72,8 @@ protected:
|
||||
|
||||
private:
|
||||
bool _closing = false;
|
||||
base::lambda<void()> _closedCallback;
|
||||
base::lambda<void()> _resizedCallback;
|
||||
Fn<void()> _closedCallback;
|
||||
Fn<void()> _resizedCallback;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -827,7 +827,7 @@ bool CopyColorsToPalette(const QString &path, const QByteArray &themeContent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> callback) {
|
||||
bool ReadPaletteValues(const QByteArray &content, Fn<bool(QLatin1String name, QLatin1String value)> callback) {
|
||||
if (content.size() > kThemeSchemeSizeLimit) {
|
||||
LOG(("Theme Error: color scheme file too large (should be less than 1 MB, got %2)").arg(content.size()));
|
||||
return false;
|
||||
|
@@ -135,7 +135,7 @@ void ComputeBackgroundRects(QRect wholeFill, QSize imageSize, QRect &to, QRect &
|
||||
|
||||
bool CopyColorsToPalette(const QString &path, const QByteArray &themeContent);
|
||||
|
||||
bool ReadPaletteValues(const QByteArray &content, base::lambda<bool(QLatin1String name, QLatin1String value)> callback);
|
||||
bool ReadPaletteValues(const QByteArray &content, Fn<bool(QLatin1String name, QLatin1String value)> callback);
|
||||
|
||||
} // namespace Theme
|
||||
} // namespace Window
|
||||
|
@@ -194,19 +194,19 @@ class Editor::Inner : public TWidget, private base::Subscriber {
|
||||
public:
|
||||
Inner(QWidget *parent, const QString &path);
|
||||
|
||||
void setErrorCallback(base::lambda<void()> callback) {
|
||||
void setErrorCallback(Fn<void()> callback) {
|
||||
_errorCallback = std::move(callback);
|
||||
}
|
||||
void setFocusCallback(base::lambda<void()> callback) {
|
||||
void setFocusCallback(Fn<void()> callback) {
|
||||
_focusCallback = std::move(callback);
|
||||
}
|
||||
void setScrollCallback(base::lambda<void(int top, int bottom)> callback) {
|
||||
void setScrollCallback(Fn<void(int top, int bottom)> callback) {
|
||||
_scrollCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void prepare();
|
||||
|
||||
base::lambda<void()> exportCallback();
|
||||
Fn<void()> exportCallback();
|
||||
|
||||
void filterRows(const QString &query);
|
||||
void chooseRow();
|
||||
@@ -238,9 +238,9 @@ private:
|
||||
|
||||
QString _path;
|
||||
QByteArray _paletteContent;
|
||||
base::lambda<void()> _errorCallback;
|
||||
base::lambda<void()> _focusCallback;
|
||||
base::lambda<void(int top, int bottom)> _scrollCallback;
|
||||
Fn<void()> _errorCallback;
|
||||
Fn<void()> _focusCallback;
|
||||
Fn<void(int top, int bottom)> _scrollCallback;
|
||||
|
||||
object_ptr<EditorBlock> _existingRows;
|
||||
object_ptr<EditorBlock> _newRows;
|
||||
@@ -318,7 +318,7 @@ void Editor::Inner::prepare() {
|
||||
}
|
||||
}
|
||||
|
||||
base::lambda<void()> Editor::Inner::exportCallback() {
|
||||
Fn<void()> Editor::Inner::exportCallback() {
|
||||
return App::LambdaDelayed(st::defaultRippleAnimation.hideDuration, this, [this] {
|
||||
auto background = Background()->pixmap().toImage();
|
||||
auto backgroundContent = QByteArray();
|
||||
@@ -621,7 +621,7 @@ void ThemeExportBox::updateThumbnail() {
|
||||
}
|
||||
|
||||
void ThemeExportBox::chooseBackgroundFromFile() {
|
||||
FileDialog::GetOpenPath(this, lang(lng_theme_editor_choose_image), "Image files (*.jpeg *.jpg *.png)", base::lambda_guarded(this, [this](const FileDialog::OpenResult &result) {
|
||||
FileDialog::GetOpenPath(this, lang(lng_theme_editor_choose_image), "Image files (*.jpeg *.jpg *.png)", crl::guard(this, [this](const FileDialog::OpenResult &result) {
|
||||
auto content = result.remoteContent;
|
||||
if (!result.paths.isEmpty()) {
|
||||
QFile f(result.paths.front());
|
||||
@@ -651,7 +651,7 @@ void ThemeExportBox::exportTheme() {
|
||||
auto caption = lang(lng_theme_editor_choose_name);
|
||||
auto filter = "Themes (*.tdesktop-theme)";
|
||||
auto name = "awesome.tdesktop-theme";
|
||||
FileDialog::GetWritePath(this, caption, filter, name, base::lambda_guarded(this, [this](const QString &path) {
|
||||
FileDialog::GetWritePath(this, caption, filter, name, crl::guard(this, [this](const QString &path) {
|
||||
zlib::FileToWrite zip;
|
||||
|
||||
zip_fileinfo zfi = { { 0, 0, 0, 0, 0, 0 }, 0, 0, 0 };
|
||||
|
@@ -294,10 +294,10 @@ void EditorBlock::activateRow(const Row &row) {
|
||||
} else {
|
||||
_editing = findRowIndex(&row);
|
||||
if (auto box = Ui::show(Box<EditColorBox>(row.name(), row.value()))) {
|
||||
box->setSaveCallback(base::lambda_guarded(this, [this](QColor value) {
|
||||
box->setSaveCallback(crl::guard(this, [this](QColor value) {
|
||||
saveEditing(value);
|
||||
}));
|
||||
box->setCancelCallback(base::lambda_guarded(this, [this] {
|
||||
box->setCancelCallback(crl::guard(this, [this] {
|
||||
cancelEditing();
|
||||
}));
|
||||
_context->box = box;
|
||||
|
@@ -18,7 +18,7 @@ class WarningWidget : public TWidget {
|
||||
public:
|
||||
WarningWidget(QWidget *parent);
|
||||
|
||||
void setHiddenCallback(base::lambda<void()> callback) {
|
||||
void setHiddenCallback(Fn<void()> callback) {
|
||||
_hiddenCallback = std::move(callback);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
object_ptr<Ui::RoundButton> _keepChanges;
|
||||
object_ptr<Ui::RoundButton> _revert;
|
||||
|
||||
base::lambda<void()> _hiddenCallback;
|
||||
Fn<void()> _hiddenCallback;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -565,7 +565,7 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
|
||||
|
||||
QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
||||
MessageIdsList &&items,
|
||||
base::lambda_once<void()> &&successCallback) {
|
||||
FnMut<void()> &&successCallback) {
|
||||
const auto weak = std::make_shared<QPointer<PeerListBox>>();
|
||||
auto callback = [
|
||||
ids = std::move(items),
|
||||
@@ -684,7 +684,7 @@ void PeerMenuAddMuteAction(
|
||||
// callback);
|
||||
//}
|
||||
|
||||
base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer) {
|
||||
Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer) {
|
||||
return [peer] {
|
||||
const auto weak = std::make_shared<QPointer<ConfirmBox>>();
|
||||
const auto text = peer->isSelf()
|
||||
@@ -708,7 +708,7 @@ base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer) {
|
||||
};
|
||||
}
|
||||
|
||||
base::lambda<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer) {
|
||||
Fn<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer) {
|
||||
return [peer] {
|
||||
const auto warningText = peer->isSelf()
|
||||
? lang(lng_sure_delete_saved_messages)
|
||||
|
@@ -25,9 +25,9 @@ enum class PeerMenuSource {
|
||||
Profile,
|
||||
};
|
||||
|
||||
using PeerMenuCallback = base::lambda<QAction*(
|
||||
using PeerMenuCallback = Fn<QAction*(
|
||||
const QString &text,
|
||||
base::lambda<void()> handler)>;
|
||||
Fn<void()> handler)>;
|
||||
|
||||
void FillPeerMenu(
|
||||
not_null<Controller*> controller,
|
||||
@@ -51,11 +51,11 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel);
|
||||
//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed
|
||||
|
||||
//void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group); // #feed
|
||||
base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer);
|
||||
base::lambda<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer);
|
||||
Fn<void()> ClearHistoryHandler(not_null<PeerData*> peer);
|
||||
Fn<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer);
|
||||
|
||||
QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
||||
MessageIdsList &&items,
|
||||
base::lambda_once<void()> &&successCallback = nullptr);
|
||||
FnMut<void()> &&successCallback = nullptr);
|
||||
|
||||
} // namespace Window
|
||||
|
@@ -23,10 +23,10 @@ public:
|
||||
void setTopBarShadow(bool enabled);
|
||||
void setWithFade(bool withFade);
|
||||
|
||||
using RepaintCallback = base::lambda<void()>;
|
||||
using RepaintCallback = Fn<void()>;
|
||||
void setRepaintCallback(RepaintCallback &&callback);
|
||||
|
||||
using FinishedCallback = base::lambda<void()>;
|
||||
using FinishedCallback = Fn<void()>;
|
||||
void setFinishedCallback(FinishedCallback &&callback);
|
||||
|
||||
void start();
|
||||
|
Reference in New Issue
Block a user