mirror of https://github.com/procxx/kepka.git
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_day_year" = "{month} {day}, {year}";
|
||||||
"lng_month_year" = "{month} {year}";
|
"lng_month_year" = "{month} {year}";
|
||||||
|
|
||||||
|
"lng_calendar_beginning" = "Beginning";
|
||||||
|
|
||||||
"lng_box_ok" = "OK";
|
"lng_box_ok" = "OK";
|
||||||
"lng_box_done" = "Done";
|
"lng_box_done" = "Done";
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,7 @@ public:
|
||||||
|
|
||||||
int countHeight();
|
int countHeight();
|
||||||
void setDateChosenCallback(Fn<void(QDate)> callback);
|
void setDateChosenCallback(Fn<void(QDate)> callback);
|
||||||
|
void selectBeginning();
|
||||||
|
|
||||||
~Inner();
|
~Inner();
|
||||||
|
|
||||||
|
@ -420,6 +421,10 @@ void CalendarBox::Inner::setDateChosenCallback(Fn<void(QDate)> callback) {
|
||||||
_dateChosenCallback = std::move(callback);
|
_dateChosenCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalendarBox::Inner::selectBeginning() {
|
||||||
|
_dateChosenCallback(_context->dateFromIndex(_context->minDayIndex()));
|
||||||
|
}
|
||||||
|
|
||||||
CalendarBox::Inner::~Inner() = default;
|
CalendarBox::Inner::~Inner() = default;
|
||||||
|
|
||||||
class CalendarBox::Title : public TWidget, private base::Subscriber {
|
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 = setInnerWidget(object_ptr<Inner>(this, _context.get()), st::calendarScroll, st::calendarTitleHeight);
|
||||||
_inner->setDateChosenCallback(std::move(_callback));
|
_inner->setDateChosenCallback(std::move(_callback));
|
||||||
|
|
||||||
|
addLeftButton(tr::lng_calendar_beginning(), [this] { _inner->selectBeginning(); });
|
||||||
addButton(tr::lng_close(), [this] { closeBox(); });
|
addButton(tr::lng_close(), [this] { closeBox(); });
|
||||||
|
|
||||||
subscribe(_context->month(), [this](QDate month) { monthChanged(month); });
|
subscribe(_context->month(), [this](QDate month) { monthChanged(month); });
|
||||||
|
@ -558,6 +564,8 @@ void CalendarBox::resizeEvent(QResizeEvent *e) {
|
||||||
void CalendarBox::keyPressEvent(QKeyEvent *e) {
|
void CalendarBox::keyPressEvent(QKeyEvent *e) {
|
||||||
if (e->key() == Qt::Key_Escape) {
|
if (e->key() == Qt::Key_Escape) {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
|
} else if (e->key() == Qt::Key_Home) {
|
||||||
|
_inner->selectBeginning();
|
||||||
} else if (e->key() == Qt::Key_Left) {
|
} else if (e->key() == Qt::Key_Left) {
|
||||||
goPreviousMonth();
|
goPreviousMonth();
|
||||||
} else if (e->key() == Qt::Key_Right) {
|
} else if (e->key() == Qt::Key_Right) {
|
||||||
|
|
Loading…
Reference in New Issue