country_select_box.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "ui/layers/box_content.h"
  9. namespace Countries {
  10. struct Info;
  11. } // namespace Countries
  12. namespace Ui {
  13. class MultiSelect;
  14. class RippleAnimation;
  15. class CountrySelectBox : public BoxContent {
  16. public:
  17. enum class Type {
  18. Phones,
  19. Countries,
  20. };
  21. struct Entry {
  22. QString country;
  23. QString iso2;
  24. QString code;
  25. QString alternativeName;
  26. };
  27. CountrySelectBox(QWidget*);
  28. CountrySelectBox(QWidget*, const QString &iso, Type type);
  29. [[nodiscard]] rpl::producer<QString> countryChosen() const;
  30. [[nodiscard]] rpl::producer<Entry> entryChosen() const;
  31. protected:
  32. void prepare() override;
  33. void setInnerFocus() override;
  34. void keyPressEvent(QKeyEvent *e) override;
  35. void resizeEvent(QResizeEvent *e) override;
  36. private:
  37. void submit();
  38. void applyFilterUpdate(const QString &query);
  39. object_ptr<MultiSelect> _select;
  40. class Inner;
  41. object_ptr<Inner> _ownedInner;
  42. QPointer<Inner> _inner;
  43. };
  44. } // namespace Ui