Address macOS issue where right-clicking a username in the main chat (#4523)

* Address macOS issue where right-clicking a username in the main chat (or game chat) areas would pop up a seemingly empty user profile. This is because the resize event is overridden and doesn't actually attempt to resize based on the size hint of the dialog. Now that we're explicit with the call, this resize should be forced and have comparable results to popping up user profile from the user list.

* use datetime for calculating account age (#4526)

* use datetime for calculating account age

make translating easier by using tr multiples
automatically account for leap days

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
Zach H 2022-01-16 16:51:13 -05:00 committed by GitHub
parent baaf22d0c4
commit d61c604bf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 30 deletions

View file

@ -1,6 +1,7 @@
#ifndef USERINFOBOX_H
#define USERINFOBOX_H
#include <QDateTime>
#include <QLabel>
#include <QPushButton>
#include <QWidget>
@ -20,9 +21,18 @@ private:
QPushButton editButton, passwordButton, avatarButton;
QPixmap avatarPixmap;
static QString getAgeString(int ageSeconds);
public:
UserInfoBox(AbstractClient *_client, bool editable, QWidget *parent = nullptr, Qt::WindowFlags flags = {});
void retranslateUi();
inline static QPair<int, int> getDaysAndYearsBetween(const QDate &then, const QDate &now)
{
int years = now.addDays(1 - then.dayOfYear()).year() - then.year(); // there is no yearsTo
int days = then.addYears(years).daysTo(now);
return {days, years};
}
private slots:
void processResponse(const Response &r);
void processEditResponse(const Response &r);