tdesktop/Telegram/SourceFiles/boxes/download_path_box.h

65 lines
1.3 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "boxes/abstract_box.h"
#include "base/observer.h"
namespace Ui {
template <typename Enum>
class RadioenumGroup;
template <typename Enum>
class Radioenum;
class LinkButton;
} // namespace Ui
class DownloadPathBox : public BoxContent {
Q_OBJECT
public:
DownloadPathBox(QWidget *parent);
protected:
void prepare() override;
void resizeEvent(QResizeEvent *e) override;
private slots:
void onEditPath();
private:
enum class Directory {
Downloads,
Temp,
Custom,
};
void radioChanged(Directory value);
Directory typeFromPath(const QString &path) {
if (path.isEmpty()) {
return Directory::Downloads;
} else if (path == qsl("tmp")) {
return Directory::Temp;
}
return Directory::Custom;
}
void save();
void updateControlsVisibility();
void setPathText(const QString &text);
QString _path;
QByteArray _pathBookmark;
std::shared_ptr<Ui::RadioenumGroup<Directory>> _group;
object_ptr<Ui::Radioenum<Directory>> _default;
object_ptr<Ui::Radioenum<Directory>> _temp;
object_ptr<Ui::Radioenum<Directory>> _dir;
object_ptr<Ui::LinkButton> _pathLink;
};