mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
improved custom keyboard
This commit is contained in:
parent
052e0b827a
commit
e7914ac468
8 changed files with 75 additions and 21 deletions
|
@ -1053,7 +1053,7 @@ textRectMargins: margins(-2px, -1px, -2px, -1px);
|
|||
taMsgField: flatTextarea(taDefFlat) {
|
||||
font: msgFont;
|
||||
}
|
||||
maxFieldHeight: 223px;
|
||||
maxFieldHeight: 243px;
|
||||
|
||||
newMsgSound: ':/gui/art/newmsg.wav';
|
||||
|
||||
|
@ -1926,6 +1926,11 @@ mentionPadding: margins(8px, 5px, 8px, 5px);
|
|||
mentionTop: 11px;
|
||||
mentionFont: linkFont;
|
||||
mentionPhotoSize: msgPhotoSize;
|
||||
mentionBgOver: #f5f5f5;
|
||||
mentionFg: #777;
|
||||
mentionFgOver: #707070;
|
||||
mentionFgActive: #0080c0;
|
||||
mentionFgOverActive: #0077b3;
|
||||
botCommandFont: font(fsize semibold);
|
||||
botDescFont: font(fsize italic);
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void DialogsListWidget::paintEvent(QPaintEvent *e) {
|
|||
for (; from < to; ++from) {
|
||||
bool selected = (from == hashtagSel);
|
||||
if (selected) {
|
||||
p.fillRect(0, 0, w, st::mentionHeight, st::dlgHoverBG->b);
|
||||
p.fillRect(0, 0, w, st::mentionHeight, st::mentionBgOver->b);
|
||||
int skip = (st::mentionHeight - st::notifyClose.icon.pxHeight()) / 2;
|
||||
p.drawPixmap(QPoint(w - st::notifyClose.icon.pxWidth() - skip, skip), App::sprite(), st::notifyClose.icon);
|
||||
}
|
||||
|
@ -122,11 +122,11 @@ void DialogsListWidget::paintEvent(QPaintEvent *e) {
|
|||
|
||||
p.setFont(st::mentionFont->f);
|
||||
if (!first.isEmpty()) {
|
||||
p.setPen(st::profileOnlineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p);
|
||||
p.drawText(st::dlgPaddingHor, st::mentionTop + st::mentionFont->ascent, first);
|
||||
}
|
||||
if (!second.isEmpty()) {
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(st::dlgPaddingHor + firstwidth, st::mentionTop + st::mentionFont->ascent, second);
|
||||
}
|
||||
p.translate(0, st::mentionHeight);
|
||||
|
|
|
@ -2433,8 +2433,9 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
for (int32 i = from; i < to; ++i) {
|
||||
if (i >= last) break;
|
||||
|
||||
if (i == _sel) {
|
||||
p.fillRect(0, i * st::mentionHeight, width(), st::mentionHeight, st::dlgHoverBG->b);
|
||||
bool selected = (i == _sel);
|
||||
if (selected) {
|
||||
p.fillRect(0, i * st::mentionHeight, width(), st::mentionHeight, st::mentionBgOver->b);
|
||||
int skip = (st::mentionHeight - st::notifyClose.icon.pxHeight()) / 2;
|
||||
if (!_hrows->isEmpty()) p.drawPixmap(QPoint(width() - st::notifyClose.icon.pxWidth() - skip, i * st::mentionHeight + skip), App::sprite(), st::notifyClose.icon);
|
||||
}
|
||||
|
@ -2462,10 +2463,10 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
user->nameText.drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth);
|
||||
|
||||
p.setFont(st::mentionFont->f);
|
||||
p.setPen(st::profileOnlineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p);
|
||||
p.drawText(2 * st::mentionPadding.left() + st::mentionPhotoSize + namewidth + st::mentionPadding.right(), i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first);
|
||||
if (!second.isEmpty()) {
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(2 * st::mentionPadding.left() + st::mentionPhotoSize + namewidth + st::mentionPadding.right() + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second);
|
||||
}
|
||||
} else if (!_hrows->isEmpty()) {
|
||||
|
@ -2483,11 +2484,11 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
|
||||
p.setFont(st::mentionFont->f);
|
||||
if (!first.isEmpty()) {
|
||||
p.setPen(st::profileOnlineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p);
|
||||
p.drawText(htagleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first);
|
||||
}
|
||||
if (!second.isEmpty()) {
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(htagleft + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second);
|
||||
}
|
||||
} else {
|
||||
|
@ -2517,11 +2518,11 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
p.setFont(st::botCommandFont->f);
|
||||
if (!first.isEmpty()) {
|
||||
p.setPen(st::profileOnlineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p);
|
||||
p.drawText(htagleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first);
|
||||
}
|
||||
if (!second.isEmpty()) {
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(htagleft + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second);
|
||||
}
|
||||
addleft += firstwidth + secondwidth + st::mentionPadding.left();
|
||||
|
@ -2534,7 +2535,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
if (widthleft < paramswidth) {
|
||||
params = st::mentionFont->m.elidedText(params, Qt::ElideRight, widthleft);
|
||||
}
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(htagleft + addleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, params);
|
||||
|
||||
addleft += paramswidth + st::mentionPadding.left();
|
||||
|
@ -2548,7 +2549,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
|
|||
description = st::botDescFont->m.elidedText(description, Qt::ElideRight, widthleft);
|
||||
descwidth = st::botDescFont->m.width(description);
|
||||
}
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p);
|
||||
p.drawText(htagleft + addleft + (widthleft - descwidth), i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, description);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -744,7 +744,7 @@ namespace {
|
|||
void TextLink::onClick(Qt::MouseButton button) const {
|
||||
if (button == Qt::LeftButton || button == Qt::MiddleButton) {
|
||||
QString url = TextLink::encoded();
|
||||
QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)/?(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
QRegularExpressionMatch telegramMeGroup = QRegularExpression(qsl("^https?://telegram\\.me/joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
QRegularExpressionMatch telegramMeStickers = QRegularExpression(qsl("^https?://telegram\\.me/addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
if (telegramMeUser.hasMatch()) {
|
||||
|
|
|
@ -2557,6 +2557,30 @@ void HistoryWidget::calcNextReplyReturn() {
|
|||
if (!_replyReturn) updateControlsVisibility();
|
||||
}
|
||||
|
||||
bool HistoryWidget::kbWasHidden() {
|
||||
return _kbWasHidden;
|
||||
}
|
||||
|
||||
void HistoryWidget::setKbWasHidden() {
|
||||
if (_kbWasHidden || !_keyboard.hasMarkup()) return;
|
||||
|
||||
_kbWasHidden = true;
|
||||
if (!_showAnim.animating()) {
|
||||
_kbScroll.hide();
|
||||
_attachEmoji.show();
|
||||
_kbHide.hide();
|
||||
_kbShow.show();
|
||||
}
|
||||
_field.setMaxHeight(st::maxFieldHeight);
|
||||
_kbShown = false;
|
||||
_kbReplyTo = 0;
|
||||
if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) {
|
||||
_replyForwardPreviewCancel.hide();
|
||||
}
|
||||
resizeEvent(0);
|
||||
update();
|
||||
}
|
||||
|
||||
void HistoryWidget::showPeer(const PeerId &peer, MsgId msgId, bool force, bool leaveActive) {
|
||||
if (App::main()->selectingPeer() && !force) {
|
||||
hiderOffered = true;
|
||||
|
@ -2810,6 +2834,7 @@ void HistoryWidget::updateControlsVisibility() {
|
|||
if (_botStart.isHidden()) {
|
||||
_botStart.clearState();
|
||||
_botStart.show();
|
||||
_kbShown = false;
|
||||
}
|
||||
_send.hide();
|
||||
_field.hide();
|
||||
|
@ -3291,6 +3316,12 @@ void HistoryWidget::onBotStart() {
|
|||
MTP::send(MTPmessages_StartBot(histPeer->asUser()->inputUser, MTP_int(0), MTP_long(randomId), MTP_string(token)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, histPeer->asUser()));
|
||||
|
||||
histPeer->asUser()->botInfo->startToken = QString();
|
||||
if (_keyboard.hasMarkup()) {
|
||||
if (_keyboard.singleUse() && _keyboard.forMsgId() == hist->lastKeyboardId && hist->lastKeyboardUsed) _kbWasHidden = true;
|
||||
if (!_kbWasHidden) _kbShown = true;
|
||||
}
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4325,7 +4356,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
|
|||
_replyForwardPreviewCancel.move(width() - _replyForwardPreviewCancel.width(), _field.y() - st::sendPadding - _replyForwardPreviewCancel.height());
|
||||
updateListSize();
|
||||
|
||||
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - (_kbShow.isHidden() ? 0 : _kbShow.width()), _field.height());
|
||||
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - ((_kbShown || !_keyboard.hasMarkup()) ? 0 : _kbShow.width()), _field.height());
|
||||
|
||||
_toHistoryEnd.move((width() - _toHistoryEnd.width()) / 2, _scroll.y() + _scroll.height() - _toHistoryEnd.height() - st::historyToEndSkip);
|
||||
|
||||
|
|
|
@ -440,6 +440,9 @@ public:
|
|||
void setReplyReturns(PeerId peer, const QList<MsgId> &replyReturns);
|
||||
void calcNextReplyReturn();
|
||||
|
||||
bool kbWasHidden();
|
||||
void setKbWasHidden();
|
||||
|
||||
void updatePreview();
|
||||
void previewCancel();
|
||||
|
||||
|
|
|
@ -1902,7 +1902,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
|
|||
} else if (profile) {
|
||||
_stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop(), profile->allMediaShown()));
|
||||
} else {
|
||||
_stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns()));
|
||||
_stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns(), history.kbWasHidden()));
|
||||
}
|
||||
}
|
||||
if (overview) {
|
||||
|
@ -1949,7 +1949,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop,
|
|||
} else if (profile) {
|
||||
_stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop(), profile->allMediaShown()));
|
||||
} else {
|
||||
_stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns()));
|
||||
_stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns(), history.kbWasHidden()));
|
||||
}
|
||||
}
|
||||
if (overview) {
|
||||
|
@ -1987,6 +1987,7 @@ void MainWidget::showBackFromStack() {
|
|||
StackItemHistory *histItem = static_cast<StackItemHistory*>(item);
|
||||
showPeer(histItem->peer->id, App::main()->activeMsgId(), true);
|
||||
history.setReplyReturns(histItem->peer->id, histItem->replyReturns);
|
||||
if (histItem->kbWasHidden) history.setKbWasHidden();
|
||||
} else if (item->type() == ProfileStackItem) {
|
||||
StackItemProfile *profItem = static_cast<StackItemProfile*>(item);
|
||||
showPeerProfile(profItem->peer, true, profItem->lastScrollTop, profItem->allMediaShown);
|
||||
|
@ -2581,7 +2582,13 @@ void MainWidget::openUserByName(const QString &username, bool toProfile, const Q
|
|||
showPeerProfile(user);
|
||||
}
|
||||
} else {
|
||||
if (user->botInfo) user->botInfo->startToken = startToken;
|
||||
if (user->botInfo) {
|
||||
user->botInfo->startToken = startToken;
|
||||
if (user == history.peer()) {
|
||||
history.updateControlsVisibility();
|
||||
history.resizeEvent(0);
|
||||
}
|
||||
}
|
||||
emit showPeerAsync(user->id, 0, false, true);
|
||||
}
|
||||
} else {
|
||||
|
@ -2617,7 +2624,13 @@ void MainWidget::usernameResolveDone(QPair<bool, QString> toProfileStartToken, c
|
|||
showPeerProfile(user);
|
||||
}
|
||||
} else {
|
||||
if (user->botInfo) user->botInfo->startToken = toProfileStartToken.second;
|
||||
if (user->botInfo) {
|
||||
user->botInfo->startToken = toProfileStartToken.second;
|
||||
if (user == history.peer()) {
|
||||
history.updateControlsVisibility();
|
||||
history.resizeEvent(0);
|
||||
}
|
||||
}
|
||||
showPeer(user->id, 0, false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,13 +110,14 @@ public:
|
|||
|
||||
class StackItemHistory : public StackItem {
|
||||
public:
|
||||
StackItemHistory(PeerData *peer, int32 lastWidth, int32 lastScrollTop, QList<MsgId> replyReturns) : StackItem(peer), replyReturns(replyReturns), lastWidth(lastWidth), lastScrollTop(lastScrollTop) {
|
||||
StackItemHistory(PeerData *peer, int32 lastWidth, int32 lastScrollTop, QList<MsgId> replyReturns, bool kbWasHidden) : StackItem(peer), replyReturns(replyReturns), lastWidth(lastWidth), lastScrollTop(lastScrollTop), kbWasHidden(kbWasHidden) {
|
||||
}
|
||||
StackItemType type() const {
|
||||
return HistoryStackItem;
|
||||
}
|
||||
QList<MsgId> replyReturns;
|
||||
int32 lastWidth, lastScrollTop;
|
||||
bool kbWasHidden;
|
||||
};
|
||||
|
||||
class StackItemProfile : public StackItem {
|
||||
|
|
Loading…
Add table
Reference in a new issue