Skip to content

Commit

Permalink
improved langs for stickers, fixed confirmed actions from chats conte…
Browse files Browse the repository at this point in the history
…xt menu, changed AppUserModelId for beta version
  • Loading branch information
john-preston committed Dec 6, 2015
1 parent 93c29a1 commit 128cbef
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 80 deletions.
6 changes: 4 additions & 2 deletions Telegram/Resources/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,10 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
"lng_stickers_default_set" = "Great Minds";
"lng_stickers_you_have" = "Manage and reorder sticker packs";
"lng_stickers_packs" = "Sticker Packs";
"lng_stickers_remove" = "Remove";
"lng_stickers_return" = "Return";
"lng_stickers_reorder" = "Click and drag to reorder sticker packs";
"lng_stickers_remove" = "Delete";
"lng_stickers_return" = "Undo";
"lng_stickers_restore" = "Restore";
"lng_stickers_count" = "{count:Loading..|# sticker|# stickers}";

"lng_in_dlg_photo" = "Photo";
Expand Down
15 changes: 9 additions & 6 deletions Telegram/Resources/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1424,12 +1424,13 @@ contactsNewItemIconPosition: point(29px, 19px);
contactsNewItemTop: 18px;
contactsNewItemFg: #4b82af;
contactsAboutBg: #f7f7f7;
contactsAboutShadow: #0000001F;
contactsAdminCheckbox: Checkbox(defaultCheckbox) {
font: semiboldFont;
textBg: #f7f7f7;
textPosition: point(34px, 1px);
}
contactsAboutHeight: 80px;
contactsAboutHeight: 42px;
contactsAboutTop: 9px;
contactsScroll: flatScroll(boxScroll) {
deltab: 0px;
Expand Down Expand Up @@ -1794,6 +1795,8 @@ stickersScroll: flatScroll(boxScroll) {
deltat: 23px;
deltab: 9px;
}
stickersReorderPadding: margins(0px, 12px, 0px, 12px);
stickersReorderFg: #777;
stickersRowDisabledOpacity: 0.4;
stickersRowDuration: 200;

Expand Down Expand Up @@ -1938,11 +1941,11 @@ stickerIconLeft: sprite(342px, 72px, 40px, 1px);
stickerIconRight: sprite(342px, 73px, 40px, 1px);
stickerIconMove: 400;

verifiedCheckProfile: sprite(285px, 240px, 22px, 22px);
verifiedCheckProfilePos: point(9px, 4px);
verifiedCheck: sprite(285px, 221px, 19px, 19px);
verifiedCheckInv: sprite(304px, 221px, 19px, 19px);
verifiedCheckPos: point(5px, 0px);
verifiedCheckProfile: sprite(285px, 235px, 18px, 18px);
verifiedCheckProfilePos: point(7px, 6px);
verifiedCheck: sprite(285px, 221px, 14px, 14px);
verifiedCheckInv: sprite(299px, 221px, 14px, 14px);
verifiedCheckPos: point(4px, 2px);

botKbDuration: 200;
botKbBg: #f7f7f7;
Expand Down
Binary file modified Telegram/SourceFiles/art/sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Telegram/SourceFiles/art/sprite_200x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions Telegram/SourceFiles/boxes/contactsbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace {

ContactsInner::ContactsInner(ChatData *chat, MembersFilter membersFilter) : TWidget()
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _newItemHeight((membersFilter == MembersFilterAdmins) ? (st::contactsNewItemHeight + st::contactsAboutHeight) : 0)
, _newItemHeight(0)
, _newItemSel(false)
, _chat(chat)
, _channel(0)
Expand All @@ -119,8 +119,11 @@ ContactsInner::ContactsInner(ChatData *chat, MembersFilter membersFilter) : TWid
, _addContactLnk(this, lang(lng_add_contact_button))
, _saving(false) {
initList();
if (membersFilter == MembersFilterAdmins && !_contacts->list.count) {
App::api()->requestFullPeer(_chat);
if (membersFilter == MembersFilterAdmins) {
_newItemHeight = st::contactsNewItemHeight + qMax(_aboutAllAdmins.countHeight(_aboutWidth), _aboutAdmins.countHeight(_aboutWidth)) + st::contactsAboutHeight;
if (!_contacts->list.count) {
App::api()->requestFullPeer(_chat);
}
}
init();
}
Expand Down Expand Up @@ -775,9 +778,9 @@ void ContactsInner::changeCheckState(ContactData *data, PeerData *peer) {
int32 ContactsInner::selectedCount() const {
int32 result = _selCount;
if (_chat) {
result += (_chat->count > 0) ? _chat->count : 1;
result += qMax(_chat->count, 1);
} else if (_channel) {
result += _already.size();
result += qMax(_channel->count, _already.size());
} else if (_creating == CreatingGroupGroup) {
result += 1;
}
Expand Down
55 changes: 36 additions & 19 deletions Telegram/SourceFiles/boxes/stickersetbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ StickersInner::StickersInner() : TWidget()
, _aboveShadowFadeStart(0)
, _aboveShadowFadeOpacity(0, 0)
, _a_shifting(animFunc(this, &StickersInner::animStep_shifting))
, _itemsTop(st::membersPadding.top())
, _saving(false)
, _removeSel(-1)
, _removeDown(-1)
, _removeWidth(st::normalFont->width(lang(lng_stickers_remove)))
, _returnWidth(st::normalFont->width(lang(lng_stickers_return)))
, _restoreWidth(st::normalFont->width(lang(lng_stickers_restore)))
, _selected(-1)
, _started(-1)
, _dragging(-1)
Expand All @@ -357,14 +359,14 @@ void StickersInner::paintEvent(QPaintEvent *e) {

p.fillRect(r, st::white);
p.setClipRect(r);

int32 yFrom = r.y() - st::membersPadding.top(), yTo = r.y() + r.height() - st::membersPadding.top();
p.translate(0, st::membersPadding.top());
if (_rows.isEmpty()) {
p.setFont(st::noContactsFont->f);
p.setPen(st::noContactsColor->p);
p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
} else {
p.translate(0, _itemsTop);

int32 yFrom = r.y() - _itemsTop, yTo = r.y() + r.height() - _itemsTop;
int32 from = floorclamp(yFrom - _rowHeight, _rowHeight, 0, _rows.size());
int32 to = ceilclamp(yTo + _rowHeight, _rowHeight, 0, _rows.size());
p.translate(0, from * _rowHeight);
Expand Down Expand Up @@ -396,7 +398,9 @@ void StickersInner::paintRow(Painter &p, int32 index) {
} else {
p.setPen(st::btnDefLink.color->p);
}
p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), lang(s->disabled ? lng_stickers_return : lng_stickers_remove), s->disabled ? _returnWidth : _removeWidth);
int32 remWidth = s->disabled ? (s->official ? _restoreWidth : _returnWidth) : _removeWidth;
QString remText = lang(s->disabled ? (s->official ? lng_stickers_restore : lng_stickers_return) : lng_stickers_remove);
p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), remText, remWidth);

if (index == _above) {
float64 current = _aboveShadowFadeOpacity.current();
Expand Down Expand Up @@ -441,7 +445,7 @@ void StickersInner::mousePressEvent(QMouseEvent *e) {
onUpdateSelected();
if (_removeSel >= 0) {
_removeDown = _removeSel;
update(0, st::membersPadding.top() + _removeSel * _rowHeight, width(), _rowHeight);
update(0, _itemsTop + _removeSel * _rowHeight, width(), _rowHeight);
} else if (_selected >= 0) {
_above = _dragging = _started = _selected;
_dragStart = mapFromGlobal(_mouse);
Expand Down Expand Up @@ -489,14 +493,14 @@ void StickersInner::onUpdateSelected() {

emit checkDraggingScroll(local.y());
} else {
bool in = rect().marginsRemoved(QMargins(0, st::membersPadding.top(), 0, st::membersPadding.bottom())).contains(local);
_selected = in ? floorclamp(local.y() - st::membersPadding.top(), _rowHeight, 0, _rows.size() - 1) : -1;
bool in = rect().marginsRemoved(QMargins(0, _itemsTop, 0, st::membersPadding.bottom())).contains(local);
_selected = in ? floorclamp(local.y() - _itemsTop, _rowHeight, 0, _rows.size() - 1) : -1;
int32 removeSel = -1;

if (_selected >= 0) {
int32 remw = _rows.at(_selected)->disabled ? _returnWidth : _removeWidth;
int32 remw = _rows.at(_selected)->disabled ? (_rows.at(_selected)->official ? _restoreWidth : _returnWidth) : _removeWidth;
QRect rem(myrtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - remw, st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, remw, st::normalFont->height));
removeSel = rem.contains(local.x(), local.y() - st::membersPadding.top() - _selected * _rowHeight) ? _selected : -1;
removeSel = rem.contains(local.x(), local.y() - _itemsTop - _selected * _rowHeight) ? _selected : -1;
}
setRemoveSel(removeSel);
emit noDraggingScroll();
Expand Down Expand Up @@ -529,7 +533,7 @@ void StickersInner::mouseReleaseEvent(QMouseEvent *e) {
_dragging = _started = -1;
}
if (_removeDown >= 0) {
update(0, st::membersPadding.top() + _removeDown * _rowHeight, width(), _rowHeight);
update(0, _itemsTop + _removeDown * _rowHeight, width(), _rowHeight);
_removeDown = -1;
}
}
Expand All @@ -551,7 +555,7 @@ void StickersInner::updateAnimatedRegions() {
if (updateMax < _dragging) updateMax = _dragging;
}
if (updateMin >= 0) {
update(0, st::membersPadding.top() + _rowHeight * (updateMin - 1), width(), _rowHeight * (updateMax - updateMin + 3));
update(0, _itemsTop + _rowHeight * (updateMin - 1), width(), _rowHeight * (updateMax - updateMin + 3));
}
}

Expand Down Expand Up @@ -610,9 +614,9 @@ void StickersInner::clear() {

void StickersInner::setRemoveSel(int32 removeSel) {
if (removeSel != _removeSel) {
if (_removeSel >= 0) update(0, st::membersPadding.top() + _removeSel * _rowHeight, width(), _rowHeight);
if (_removeSel >= 0) update(0, _itemsTop + _removeSel * _rowHeight, width(), _rowHeight);
_removeSel = removeSel;
if (_removeSel >= 0) update(0, st::membersPadding.top() + _removeSel * _rowHeight, width(), _rowHeight);
if (_removeSel >= 0) update(0, _itemsTop + _removeSel * _rowHeight, width(), _rowHeight);
setCursor((_removeSel >= 0 && (_removeDown < 0 || _removeDown == _removeSel)) ? style::cur_pointer : style::cur_default);
}
}
Expand All @@ -621,7 +625,7 @@ void StickersInner::rebuild() {
QList<StickerSetRow*> rows, rowsDisabled;

int32 namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
int32 namew = st::boxWideWidth - namex - st::contactsPadding.right() - st::contactsCheckPosition.x() - qMax(_returnWidth, _removeWidth);
int32 namew = st::boxWideWidth - namex - st::contactsPadding.right() - st::contactsCheckPosition.x() - qMax(qMax(_returnWidth, _removeWidth), _restoreWidth);

clear();
const StickerSetsOrder &order(cStickerSetsOrder());
Expand Down Expand Up @@ -656,7 +660,8 @@ void StickersInner::rebuild() {
if (titleWidth > namew) {
title = st::contactsNameFont->elided(title, namew);
}
(disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, disabled, pixw, pixh));
bool official = (it->flags & MTPDstickerSet::flag_official);
(disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, official, disabled, pixw, pixh));
_animStartTimes.push_back(0);
if (it->stickers.isEmpty() || (it->flags & MTPDstickerSet_flag_NOT_LOADED)) {
App::api()->scheduleStickerSetRequest(it->id, it->access);
Expand All @@ -665,7 +670,7 @@ void StickersInner::rebuild() {
}
App::api()->requestStickerSets();
_rows = rows + rowsDisabled;
resize(width(), st::membersPadding.top() + _rows.size() * _rowHeight + st::membersPadding.bottom());
resize(width(), _itemsTop + _rows.size() * _rowHeight + st::membersPadding.bottom());
}

QVector<uint64> StickersInner::getOrder() const {
Expand Down Expand Up @@ -706,8 +711,13 @@ StickersBox::StickersBox() : ItemListBox(st::boxScroll)
, _save(this, lang(lng_settings_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
, _reorderRequest(0)
, _bottomShadow(this) {
ItemListBox::init(&_inner, st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
, _topShadow(this, st::contactsAboutShadow)
, _bottomShadow(this)
, _scrollDelta(0)
, _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPhotoSize - st::contactsPadding.left() - st::contactsPadding.right())
, _about(st::boxTextFont, lang(lng_stickers_reorder), _defaultOptions, _aboutWidth)
, _aboutHeight(st::stickersReorderPadding.top() + _about.countHeight(_aboutWidth) + st::stickersReorderPadding.bottom()) {
ItemListBox::init(&_inner, st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(), st::boxTitleHeight + _aboutHeight);
setMaxHeight(snap(countHeight(), int32(st::sessionsHeight), int32(st::boxMaxListHeight)));

connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
Expand All @@ -727,7 +737,7 @@ StickersBox::StickersBox() : ItemListBox(st::boxScroll)
}

int32 StickersBox::countHeight() const {
return st::boxTitleHeight + _inner.height() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom();
return st::boxTitleHeight + _aboutHeight + _inner.height() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom();
}

void StickersBox::disenableDone(const MTPBool & result, mtpRequestId req) {
Expand Down Expand Up @@ -780,6 +790,10 @@ void StickersBox::paintEvent(QPaintEvent *e) {

paintTitle(p, lang(lng_stickers_packs));
p.translate(0, st::boxTitleHeight);

p.fillRect(0, 0, width(), _aboutHeight, st::contactsAboutBg);
p.setPen(st::stickersReorderFg);
_about.drawLeft(p, st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left(), st::stickersReorderPadding.top(), _aboutWidth, width());
}

void StickersBox::closePressed() {
Expand All @@ -803,6 +817,7 @@ void StickersBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
_inner.resize(width(), _inner.height());
_topShadow.setGeometry(0, st::boxTitleHeight + _aboutHeight, width(), st::lineWidth);
_bottomShadow.setGeometry(0, height() - st::boxButtonPadding.bottom() - _save.height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth);
_inner.setVisibleScrollbar((_scroll.scrollTopMax() > 0) ? (st::boxScroll.width - st::boxScroll.deltax) : 0);
}
Expand Down Expand Up @@ -908,13 +923,15 @@ void StickersBox::onSave() {
void StickersBox::hideAll() {
_save.hide();
_cancel.hide();
_topShadow.hide();
_bottomShadow.hide();
ItemListBox::hideAll();
}

void StickersBox::showAll() {
_save.show();
_cancel.show();
_topShadow.show();
_bottomShadow.show();
ItemListBox::showAll();
}
Expand Down
14 changes: 11 additions & 3 deletions Telegram/SourceFiles/boxes/stickersetbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ public slots:

int32 _rowHeight;
struct StickerSetRow {
StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool disabled, int32 pixw, int32 pixh) : id(id)
StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool official, bool disabled, int32 pixw, int32 pixh) : id(id)
, sticker(sticker)
, count(count)
, title(title)
, official(official)
, disabled(disabled)
, pixw(pixw)
, pixh(pixh)
Expand All @@ -167,7 +168,7 @@ public slots:
DocumentData *sticker;
int32 count;
QString title;
bool disabled;
bool official, disabled;
int32 pixw, pixh;
anim::ivalue yadd;
};
Expand All @@ -178,9 +179,11 @@ public slots:
anim::fvalue _aboveShadowFadeOpacity;
Animation _a_shifting;

int32 _itemsTop;

bool _saving;

int32 _removeSel, _removeDown, _removeWidth, _returnWidth;
int32 _removeSel, _removeDown, _removeWidth, _returnWidth, _restoreWidth;

QPoint _mouse;
int32 _selected;
Expand Down Expand Up @@ -232,11 +235,16 @@ public slots:
BoxButton _save, _cancel;
QMap<mtpRequestId, NullType> _disenableRequests;
mtpRequestId _reorderRequest;
PlainShadow _topShadow;
ScrollableBoxShadow _bottomShadow;

QTimer _scrollTimer;
int32 _scrollDelta;

int32 _aboutWidth;
Text _about;
int32 _aboutHeight;

};

int32 stickerPacksCount(bool includeDisabledOfficial = false);
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ enum {

MTPDebugBufferSize = 1024 * 1024, // 1 mb start size

MaxUsersPerInvite = 100, // max users in one super group invite request

MTPPingDelayDisconnect = 60, // 1 min
MTPPingSendAfterAuto = 30, // send new ping starting from 30 seconds (add to existing container)
MTPPingSendAfter = 45, // send new ping after 45 seconds without ping
Expand Down
Loading

0 comments on commit 128cbef

Please sign in to comment.