mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Take session name from device model.
This commit is contained in:
parent
aab4dbb7cf
commit
a511681113
4 changed files with 15 additions and 24 deletions
|
@ -46,12 +46,10 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
|
|||
return version;
|
||||
}();
|
||||
|
||||
result.name = QString("%1%2").arg(
|
||||
appName,
|
||||
appVer.isEmpty() ? QString() : (' ' + appVer));
|
||||
result.name = qs(data.vdevice_model());
|
||||
|
||||
const auto country = qs(data.vcountry());
|
||||
const auto platform = qs(data.vplatform());
|
||||
//const auto platform = qs(data.vplatform());
|
||||
//const auto &countries = countriesByISO2();
|
||||
//const auto j = countries.constFind(country);
|
||||
//if (j != countries.cend()) {
|
||||
|
@ -61,14 +59,10 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
|
|||
result.activeTime = data.vdate_active().v
|
||||
? data.vdate_active().v
|
||||
: data.vdate_created().v;
|
||||
result.info = QString("%1, %2%3").arg(
|
||||
qs(data.vdevice_model()),
|
||||
platform.isEmpty() ? QString() : platform + ' ',
|
||||
qs(data.vsystem_version()));
|
||||
result.ip = qs(data.vip())
|
||||
+ (country.isEmpty()
|
||||
? QString()
|
||||
: QString::fromUtf8(" \xe2\x80\x93 ") + country);
|
||||
result.info = QString("%1%2").arg(
|
||||
appName,
|
||||
appVer.isEmpty() ? QString() : (' ' + appVer));
|
||||
result.ip = qs(data.vip());
|
||||
if (!result.hash) {
|
||||
result.active = tr::lng_status_online(tr::now);
|
||||
} else {
|
||||
|
@ -85,6 +79,10 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
|
|||
result.active = lastDate.toString(cDateFormat());
|
||||
}
|
||||
}
|
||||
result.location = (country.isEmpty() ? result.ip : country)
|
||||
+ (result.hash
|
||||
? (QString::fromUtf8(" \xe2\x80\x93 ") + result.active)
|
||||
: QString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
bool incomplete = false;
|
||||
TimeId activeTime = 0;
|
||||
QString name, active, info, ip;
|
||||
QString name, active, info, ip, location;
|
||||
};
|
||||
using List = std::vector<Entry>;
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ sessionWhenFont: msgDateFont;
|
|||
sessionWhenFg: windowSubTextFg;
|
||||
sessionInfoFont: msgFont;
|
||||
sessionInfoFg: windowSubTextFg;
|
||||
sessionTerminateTop: 28px;
|
||||
sessionTerminateTop: 9px;
|
||||
sessionTerminateSkip: 22px;
|
||||
sessionNamePadding: margins(0px, 0px, 5px, 0px);
|
||||
sessionTerminate: IconButton {
|
||||
|
|
|
@ -49,16 +49,15 @@ private:
|
|||
, incomplete(entry.incomplete)
|
||||
, activeTime(entry.activeTime)
|
||||
, name(st::sessionNameStyle, entry.name)
|
||||
, active(st::sessionWhenStyle, entry.active)
|
||||
, info(st::sessionInfoStyle, entry.info)
|
||||
, ip(st::sessionInfoStyle, entry.ip) {
|
||||
, ip(st::sessionInfoStyle, entry.location) {
|
||||
};
|
||||
|
||||
uint64 hash = 0;
|
||||
|
||||
bool incomplete = false;
|
||||
TimeId activeTime = 0;
|
||||
Ui::Text::String name, active, info, ip;
|
||||
Ui::Text::String name, info, ip;
|
||||
};
|
||||
struct Full {
|
||||
Entry current;
|
||||
|
@ -496,17 +495,11 @@ void SessionsContent::List::paintEvent(QPaintEvent *e) {
|
|||
for (auto i = from; i != till; ++i) {
|
||||
const auto &entry = _items[i];
|
||||
|
||||
const auto activeW = entry.active.maxWidth();
|
||||
const auto nameW = available
|
||||
- activeW
|
||||
- st::sessionNamePadding.right();
|
||||
const auto nameW = _rowWidth.info;
|
||||
const auto nameH = entry.name.style()->font->height;
|
||||
const auto infoW = entry.hash ? _rowWidth.info : available;
|
||||
const auto infoH = entry.info.style()->font->height;
|
||||
|
||||
p.setPen(entry.hash ? st::sessionWhenFg : st::contactsStatusFgOnline);
|
||||
entry.active.drawRight(p, xact, y, activeW, w);
|
||||
|
||||
p.setPen(st::sessionNameFg);
|
||||
entry.name.drawLeftElided(p, x, y, nameW, w);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue