window_theme_warning.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "base/timer.h"
  9. #include "base/object_ptr.h"
  10. #include "ui/effects/animations.h"
  11. #include "ui/rp_widget.h"
  12. namespace Ui {
  13. class RoundButton;
  14. } // namespace Ui
  15. namespace Window {
  16. namespace Theme {
  17. class WarningWidget : public TWidget {
  18. public:
  19. WarningWidget(QWidget *parent);
  20. void setHiddenCallback(Fn<void()> callback) {
  21. _hiddenCallback = std::move(callback);
  22. }
  23. void showAnimated();
  24. void hideAnimated();
  25. protected:
  26. void keyPressEvent(QKeyEvent *e) override;
  27. void paintEvent(QPaintEvent *e) override;
  28. void resizeEvent(QResizeEvent *e) override;
  29. private:
  30. void refreshLang();
  31. void updateControlsGeometry();
  32. void setSecondsLeft(int secondsLeft);
  33. void startAnimation(bool hiding);
  34. void updateText();
  35. void handleTimer();
  36. bool _hiding = false;
  37. Ui::Animations::Simple _animation;
  38. QPixmap _cache;
  39. QRect _inner, _outer;
  40. base::Timer _timer;
  41. crl::time _started = 0;
  42. int _secondsLeft = 0;
  43. QString _text;
  44. object_ptr<Ui::RoundButton> _keepChanges;
  45. object_ptr<Ui::RoundButton> _revert;
  46. Fn<void()> _hiddenCallback;
  47. };
  48. } // namespace Theme
  49. } // namespace Window