mirror of https://github.com/procxx/kepka.git
Remove lambda_slot() and lambda_slot_once().
This commit is contained in:
parent
cb5b6d0cb8
commit
a143505fd6
|
@ -576,49 +576,4 @@ inline lambda_internal::guard_t<PointersAndLambda...> lambda_guarded(PointersAnd
|
||||||
return lambda_internal::guard_t<PointersAndLambda...>(std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
return lambda_internal::guard_t<PointersAndLambda...>(std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass lambda instead of a Qt void() slot.
|
|
||||||
|
|
||||||
class lambda_slot_wrap : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
lambda_slot_wrap(QObject *parent, lambda<void()> lambda) : QObject(parent), _lambda(std::move(lambda)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots :
|
|
||||||
void action() {
|
|
||||||
_lambda();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
lambda<void()> _lambda;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda<void()> lambda) {
|
|
||||||
return new lambda_slot_wrap(parent, std::move(lambda));
|
|
||||||
}
|
|
||||||
|
|
||||||
class lambda_slot_once_wrap : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
lambda_slot_once_wrap(QObject *parent, lambda_once<void()> lambda) : QObject(parent), _lambda(std::move(lambda)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots :
|
|
||||||
void action() {
|
|
||||||
_lambda();
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
lambda_once<void()> _lambda;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
inline lambda_slot_once_wrap *lambda_slot_once(QObject *parent, lambda_once<void()> lambda) {
|
|
||||||
return new lambda_slot_once_wrap(parent, std::move(lambda));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace App {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
void CallDelayed(int duration, base::lambda_once<void()> &&lambda) {
|
void CallDelayed(int duration, base::lambda_once<void()> &&lambda) {
|
||||||
QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std::move(lambda)), SLOT(action()));
|
Messenger::Instance().callDelayed(duration, std::move(lambda));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "base/observer.h"
|
#include "base/observer.h"
|
||||||
#include "mtproto/auth_key.h"
|
#include "mtproto/auth_key.h"
|
||||||
|
#include "base/timer.h"
|
||||||
|
|
||||||
namespace App {
|
namespace App {
|
||||||
void quit();
|
void quit();
|
||||||
|
@ -170,6 +171,10 @@ public:
|
||||||
void call_handleDelayedPeerUpdates();
|
void call_handleDelayedPeerUpdates();
|
||||||
void call_handleObservables();
|
void call_handleObservables();
|
||||||
|
|
||||||
|
void callDelayed(int duration, base::lambda_once<void()> &&lambda) {
|
||||||
|
_callDelayedTimer.call(duration, std::move(lambda));
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void peerPhotoDone(PeerId peer);
|
void peerPhotoDone(PeerId peer);
|
||||||
void peerPhotoFail(PeerId peer);
|
void peerPhotoFail(PeerId peer);
|
||||||
|
@ -220,4 +225,6 @@ private:
|
||||||
QImage _logo;
|
QImage _logo;
|
||||||
QImage _logoNoMargin;
|
QImage _logoNoMargin;
|
||||||
|
|
||||||
|
base::DelayedCallTimer _callDelayedTimer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -407,10 +407,10 @@ void MainWindow::psFirstShow() {
|
||||||
void MainWindow::createGlobalMenu() {
|
void MainWindow::createGlobalMenu() {
|
||||||
auto main = psMainMenu.addMenu(qsl("Telegram"));
|
auto main = psMainMenu.addMenu(qsl("Telegram"));
|
||||||
auto about = main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")));
|
auto about = main->addAction(lng_mac_menu_about_telegram(lt_telegram, qsl("Telegram")));
|
||||||
connect(about, SIGNAL(triggered()), base::lambda_slot(about, [] {
|
connect(about, &QAction::triggered, about, [] {
|
||||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||||
Ui::show(Box<AboutBox>());
|
Ui::show(Box<AboutBox>());
|
||||||
}), SLOT(action()));
|
});
|
||||||
about->setMenuRole(QAction::AboutQtRole);
|
about->setMenuRole(QAction::AboutQtRole);
|
||||||
|
|
||||||
main->addSeparator();
|
main->addSeparator();
|
||||||
|
@ -433,12 +433,12 @@ void MainWindow::createGlobalMenu() {
|
||||||
|
|
||||||
QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window));
|
QMenu *window = psMainMenu.addMenu(lang(lng_mac_menu_window));
|
||||||
psContacts = window->addAction(lang(lng_mac_menu_contacts));
|
psContacts = window->addAction(lang(lng_mac_menu_contacts));
|
||||||
connect(psContacts, SIGNAL(triggered()), base::lambda_slot(psContacts, [] {
|
connect(psContacts, &QAction::triggered, psContacts, [] {
|
||||||
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
if (App::wnd() && App::wnd()->isHidden()) App::wnd()->showFromTray();
|
||||||
|
|
||||||
if (!App::self()) return;
|
if (!App::self()) return;
|
||||||
Ui::show(Box<ContactsBox>());
|
Ui::show(Box<ContactsBox>());
|
||||||
}), SLOT(action()));
|
});
|
||||||
psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact()));
|
psAddContact = window->addAction(lang(lng_mac_menu_add_contact), App::wnd(), SLOT(onShowAddContact()));
|
||||||
window->addSeparator();
|
window->addSeparator();
|
||||||
psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
|
psNewGroup = window->addAction(lang(lng_mac_menu_new_group), App::wnd(), SLOT(onShowNewGroup()));
|
||||||
|
|
|
@ -61,7 +61,7 @@ QAction *Menu::addAction(const QString &text, const QObject *receiver, const cha
|
||||||
|
|
||||||
QAction *Menu::addAction(const QString &text, base::lambda<void()> callback, const style::icon *icon, const style::icon *iconOver) {
|
QAction *Menu::addAction(const QString &text, base::lambda<void()> callback, const style::icon *icon, const style::icon *iconOver) {
|
||||||
auto action = addAction(new QAction(text, this), icon, iconOver);
|
auto action = addAction(new QAction(text, this), icon, iconOver);
|
||||||
connect(action, SIGNAL(triggered(bool)), base::lambda_slot(action, std::move(callback)), SLOT(action()), Qt::QueuedConnection);
|
connect(action, &QAction::triggered, action, std::move(callback), Qt::QueuedConnection);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue