2016-08-28 19:16:23 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-08-28 19:16:23 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2018-08-29 13:23:16 +00:00
|
|
|
#include "storage/cache/storage_cache_database.h"
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2018-08-29 13:23:16 +00:00
|
|
|
namespace Storage {
|
|
|
|
namespace Cache {
|
|
|
|
class Database;
|
|
|
|
} // namespace Cache
|
|
|
|
} // namespace Storage
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
2018-08-29 13:23:16 +00:00
|
|
|
class VerticalLayout;
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2018-08-31 13:01:42 +00:00
|
|
|
class LabelSimple;
|
2019-03-01 14:20:04 +00:00
|
|
|
class MediaSlider;
|
2016-11-11 13:46:04 +00:00
|
|
|
} // namespace Ui
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
class LocalStorageBox : public Ui::BoxContent {
|
2018-08-29 13:23:16 +00:00
|
|
|
struct CreateTag {
|
|
|
|
};
|
2016-08-28 19:16:23 +00:00
|
|
|
|
|
|
|
public:
|
2018-08-29 13:23:16 +00:00
|
|
|
using Database = Storage::Cache::Database;
|
|
|
|
|
2019-03-01 14:20:04 +00:00
|
|
|
LocalStorageBox(
|
|
|
|
QWidget*,
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-03-01 14:20:04 +00:00
|
|
|
CreateTag);
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
static void Show(not_null<Main::Session*> session);
|
2016-08-28 19:16:23 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2018-08-29 13:23:16 +00:00
|
|
|
class Row;
|
|
|
|
|
2019-03-01 14:20:04 +00:00
|
|
|
void clearByTag(uint16 tag);
|
|
|
|
void update(Database::Stats &&stats, Database::Stats &&statsBig);
|
2018-08-29 13:23:16 +00:00
|
|
|
void updateRow(
|
|
|
|
not_null<Ui::SlideWrap<Row>*> row,
|
2019-03-01 14:20:04 +00:00
|
|
|
const Database::TaggedSummary *data);
|
2018-08-29 13:23:16 +00:00
|
|
|
void setupControls();
|
2018-08-31 13:01:42 +00:00
|
|
|
void setupLimits(not_null<Ui::VerticalLayout*> container);
|
2019-03-01 14:20:04 +00:00
|
|
|
void updateMediaLimit();
|
|
|
|
void updateTotalLimit();
|
|
|
|
void updateTotalLabel();
|
|
|
|
void updateMediaLabel();
|
2018-08-31 13:01:42 +00:00
|
|
|
void limitsChanged();
|
|
|
|
void save();
|
|
|
|
|
2019-03-01 14:20:04 +00:00
|
|
|
Database::TaggedSummary summary() const;
|
|
|
|
|
2018-08-31 13:01:42 +00:00
|
|
|
template <
|
|
|
|
typename Value,
|
|
|
|
typename Convert,
|
|
|
|
typename Callback,
|
|
|
|
typename = std::enable_if_t<
|
|
|
|
rpl::details::is_callable_plain_v<
|
|
|
|
Callback,
|
|
|
|
not_null<Ui::LabelSimple*>,
|
|
|
|
Value>
|
|
|
|
&& std::is_same_v<Value, decltype(std::declval<Convert>()(1))>>>
|
2019-03-01 14:20:04 +00:00
|
|
|
not_null<Ui::MediaSlider*> createLimitsSlider(
|
2018-08-31 13:01:42 +00:00
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
int valuesCount,
|
|
|
|
Convert &&convert,
|
|
|
|
Value currentValue,
|
|
|
|
Callback &&callback);
|
2018-08-29 13:23:16 +00:00
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
|
|
|
const not_null<Storage::Cache::Database*> _db;
|
|
|
|
const not_null<Storage::Cache::Database*> _dbBig;
|
|
|
|
|
2018-08-29 13:23:16 +00:00
|
|
|
Database::Stats _stats;
|
2019-03-01 14:20:04 +00:00
|
|
|
Database::Stats _statsBig;
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2019-03-01 14:20:04 +00:00
|
|
|
base::flat_map<uint16, not_null<Ui::SlideWrap<Row>*>> _rows;
|
|
|
|
Ui::MediaSlider *_totalSlider = nullptr;
|
|
|
|
Ui::LabelSimple *_totalLabel = nullptr;
|
|
|
|
Ui::MediaSlider *_mediaSlider = nullptr;
|
|
|
|
Ui::LabelSimple *_mediaLabel = nullptr;
|
2016-08-28 19:16:23 +00:00
|
|
|
|
2019-03-01 14:20:04 +00:00
|
|
|
int64 _totalSizeLimit = 0;
|
|
|
|
int64 _mediaSizeLimit = 0;
|
2018-08-31 13:01:42 +00:00
|
|
|
size_type _timeLimit = 0;
|
|
|
|
bool _limitsChanged = false;
|
|
|
|
|
2016-08-28 19:16:23 +00:00
|
|
|
};
|