menu_common.cpp 625 B

123456789101112131415161718192021222324252627
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "ui/widgets/menu/menu_common.h"
  8. #include <QAction>
  9. namespace Ui::Menu {
  10. not_null<QAction*> CreateAction(
  11. QWidget *parent,
  12. const QString &text,
  13. Fn<void()> &&callback) {
  14. const auto action = new QAction(text, parent);
  15. parent->connect(
  16. action,
  17. &QAction::triggered,
  18. action,
  19. std::move(callback),
  20. Qt::QueuedConnection);
  21. return action;
  22. }
  23. } // namespace Ui::Menu