mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Added "Beginning" button to calendar
This commit is contained in:
parent
f1eddcd584
commit
3ca57ae50d
@ -76,6 +76,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_month_day_year" = "{month} {day}, {year}";
|
||||
"lng_month_year" = "{month} {year}";
|
||||
|
||||
"lng_calendar_beginning" = "Beginning";
|
||||
|
||||
"lng_box_ok" = "OK";
|
||||
"lng_box_done" = "Done";
|
||||
|
||||
|
@ -192,6 +192,7 @@ public:
|
||||
|
||||
int countHeight();
|
||||
void setDateChosenCallback(Fn<void(QDate)> callback);
|
||||
void selectBeginning();
|
||||
|
||||
~Inner();
|
||||
|
||||
@ -420,6 +421,10 @@ void CalendarBox::Inner::setDateChosenCallback(Fn<void(QDate)> callback) {
|
||||
_dateChosenCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void CalendarBox::Inner::selectBeginning() {
|
||||
_dateChosenCallback(_context->dateFromIndex(_context->minDayIndex()));
|
||||
}
|
||||
|
||||
CalendarBox::Inner::~Inner() = default;
|
||||
|
||||
class CalendarBox::Title : public TWidget, private base::Subscriber {
|
||||
@ -504,6 +509,7 @@ void CalendarBox::prepare() {
|
||||
// _inner = setInnerWidget(object_ptr<Inner>(this, _context.get()), st::calendarScroll, st::calendarTitleHeight);
|
||||
_inner->setDateChosenCallback(std::move(_callback));
|
||||
|
||||
addLeftButton(tr::lng_calendar_beginning(), [this] { _inner->selectBeginning(); });
|
||||
addButton(tr::lng_close(), [this] { closeBox(); });
|
||||
|
||||
subscribe(_context->month(), [this](QDate month) { monthChanged(month); });
|
||||
@ -558,6 +564,8 @@ void CalendarBox::resizeEvent(QResizeEvent *e) {
|
||||
void CalendarBox::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
e->ignore();
|
||||
} else if (e->key() == Qt::Key_Home) {
|
||||
_inner->selectBeginning();
|
||||
} else if (e->key() == Qt::Key_Left) {
|
||||
goPreviousMonth();
|
||||
} else if (e->key() == Qt::Key_Right) {
|
||||
|
Loading…
Reference in New Issue
Block a user