2017-03-07 14:03:07 +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.
|
2017-03-07 14:03:07 +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
|
2017-03-07 14:03:07 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-01-19 07:14:50 +00:00
|
|
|
#include "ui/layers/box_content.h"
|
|
|
|
#include "base/observer.h"
|
2017-03-07 14:03:07 +00:00
|
|
|
|
2018-10-06 18:51:07 +00:00
|
|
|
namespace style {
|
|
|
|
struct CalendarSizes;
|
|
|
|
} // namespace style
|
|
|
|
|
2017-03-07 14:03:07 +00:00
|
|
|
namespace Ui {
|
2021-01-19 07:14:50 +00:00
|
|
|
|
2017-03-07 14:03:07 +00:00
|
|
|
class IconButton;
|
|
|
|
|
2021-01-19 07:14:50 +00:00
|
|
|
class CalendarBox : public BoxContent, private base::Subscriber {
|
2017-03-07 14:03:07 +00:00
|
|
|
public:
|
2018-10-06 11:06:07 +00:00
|
|
|
CalendarBox(
|
|
|
|
QWidget*,
|
|
|
|
QDate month,
|
|
|
|
QDate highlighted,
|
|
|
|
Fn<void(QDate date)> callback,
|
|
|
|
FnMut<void(not_null<CalendarBox*>)> finalize = nullptr);
|
2018-10-06 18:51:07 +00:00
|
|
|
CalendarBox(
|
|
|
|
QWidget*,
|
|
|
|
QDate month,
|
|
|
|
QDate highlighted,
|
|
|
|
Fn<void(QDate date)> callback,
|
|
|
|
FnMut<void(not_null<CalendarBox*>)> finalize,
|
|
|
|
const style::CalendarSizes &st);
|
|
|
|
|
2019-09-08 20:12:48 +00:00
|
|
|
void setBeginningButton(bool enabled);
|
|
|
|
bool hasBeginningButton() const;
|
2017-03-07 16:40:17 +00:00
|
|
|
|
|
|
|
void setMinDate(QDate date);
|
|
|
|
void setMaxDate(QDate date);
|
|
|
|
|
2017-03-07 14:03:07 +00:00
|
|
|
~CalendarBox();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
2018-12-30 20:14:25 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-03-07 14:03:07 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2020-05-18 20:04:28 +00:00
|
|
|
void wheelEvent(QWheelEvent *e) override;
|
2017-03-07 14:03:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void monthChanged(QDate month);
|
|
|
|
|
2017-03-07 16:40:17 +00:00
|
|
|
bool isPreviousEnabled() const;
|
|
|
|
bool isNextEnabled() const;
|
|
|
|
|
2018-12-30 20:14:25 +00:00
|
|
|
void goPreviousMonth();
|
|
|
|
void goNextMonth();
|
|
|
|
|
2018-10-06 18:51:07 +00:00
|
|
|
const style::CalendarSizes &_st;
|
|
|
|
|
2017-03-07 14:03:07 +00:00
|
|
|
class Context;
|
|
|
|
std::unique_ptr<Context> _context;
|
|
|
|
|
|
|
|
class Inner;
|
|
|
|
object_ptr<Inner> _inner;
|
|
|
|
|
|
|
|
class Title;
|
|
|
|
object_ptr<Title> _title;
|
2021-01-19 07:14:50 +00:00
|
|
|
object_ptr<IconButton> _previous;
|
|
|
|
object_ptr<IconButton> _next;
|
2017-03-07 14:03:07 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(QDate date)> _callback;
|
2018-10-06 11:06:07 +00:00
|
|
|
FnMut<void(not_null<CalendarBox*>)> _finalize;
|
2017-03-07 14:03:07 +00:00
|
|
|
|
|
|
|
};
|
2021-01-19 07:14:50 +00:00
|
|
|
|
|
|
|
} // namespace Ui
|