download_path_box.h 1.3 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 Ui {
  10. template <typename Enum>
  11. class RadioenumGroup;
  12. template <typename Enum>
  13. class Radioenum;
  14. class LinkButton;
  15. } // namespace Ui
  16. namespace Window {
  17. class SessionController;
  18. } // namespace Window
  19. class DownloadPathBox : public Ui::BoxContent {
  20. public:
  21. DownloadPathBox(
  22. QWidget *parent,
  23. not_null<Window::SessionController*> controller);
  24. protected:
  25. void prepare() override;
  26. void resizeEvent(QResizeEvent *e) override;
  27. private:
  28. enum class Directory {
  29. Downloads,
  30. Temp,
  31. Custom,
  32. };
  33. void radioChanged(Directory value);
  34. Directory typeFromPath(const QString &path);
  35. void save();
  36. void updateControlsVisibility();
  37. void setPathText(const QString &text);
  38. void editPath();
  39. const not_null<Window::SessionController*> _controller;
  40. QString _path;
  41. QByteArray _pathBookmark;
  42. std::shared_ptr<Ui::RadioenumGroup<Directory>> _group;
  43. object_ptr<Ui::Radioenum<Directory>> _default;
  44. object_ptr<Ui::Radioenum<Directory>> _temp;
  45. object_ptr<Ui::Radioenum<Directory>> _dir;
  46. object_ptr<Ui::LinkButton> _pathLink;
  47. };