2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

tilde fix in 100%, dialogs repaint fix, markdown (bold, italic, code, pre support) added

This commit is contained in:
John Preston
2015-10-23 18:06:56 +02:00
parent 2b36f4d23a
commit 3df66a7ed3
24 changed files with 1027 additions and 525 deletions

View File

@@ -1138,7 +1138,7 @@ void HistoryInner::updateBotInfo(bool recount) {
int32 newh = 0;
if (botInfo && !botInfo->description.isEmpty()) {
if (botInfo->text.isEmpty()) {
botInfo->text.setText(st::msgFont, botInfo->description, _historyBotOptions);
botInfo->text.setText(st::msgFont, botInfo->description, _historyBotNoMonoOptions);
if (recount) {
int32 tw = scrollArea->width() - st::msgMargin.left() - st::msgMargin.right();
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
@@ -1643,7 +1643,7 @@ bool MessageField::hasSendText() const {
const QString &text(getLastText());
for (const QChar *ch = text.constData(), *e = ch + text.size(); ch != e; ++ch) {
ushort code = ch->unicode();
if (code != ' ' && code != '\n' && code != '\r' && !replaceCharBySpace(code)) {
if (code != ' ' && code != '\n' && code != '\r' && !chReplacedBySpace(code)) {
return true;
}
}
@@ -2528,6 +2528,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
_attachDragDocument.hide();
_attachDragPhoto.hide();
_topShadow.hide();
_sideShadow.setVisible(cWideMode());
connect(&_attachDragDocument, SIGNAL(dropped(const QMimeData*)), this, SLOT(onDocumentDrop(const QMimeData*)));
connect(&_attachDragPhoto, SIGNAL(dropped(const QMimeData*)), this, SLOT(onPhotoDrop(const QMimeData*)));
}
@@ -2890,20 +2893,24 @@ void HistoryWidget::setKbWasHidden() {
}
void HistoryWidget::fastShowAtEnd(History *h) {
h->getReadyFor(ShowAtTheEndMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop);
if (h == _history) {
h->getReadyFor(ShowAtTheEndMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop);
if (_history != h) return;
clearAllLoadRequests();
clearAllLoadRequests();
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
if (h->isReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop)) {
historyLoaded();
} else {
firstLoadMessages();
doneShow();
if (h->isReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop)) {
historyLoaded();
} else {
firstLoadMessages();
doneShow();
}
} else if (h) {
MsgId fixInScrollMsgId = 0;
int32 fixInScrollMsgTop = 0;
h->getReadyFor(ShowAtTheEndMsgId, fixInScrollMsgId, fixInScrollMsgTop);
}
}
@@ -3218,6 +3225,7 @@ void HistoryWidget::updateReportSpamStatus() {
}
void HistoryWidget::updateControlsVisibility() {
_topShadow.setVisible(_peer ? true : false);
if (!_history || _a_show.animating()) {
_reportSpamPanel.hide();
_scroll.hide();
@@ -3822,28 +3830,19 @@ void HistoryWidget::onSend(bool ctrlShiftEnter, MsgId replyTo) {
if (!_history) return;
bool lastKeyboardUsed = lastForceReplyReplied(FullMsgId(_channel, replyTo));
QString text = prepareSentText(_field.getLastText());
if (!text.isEmpty()) {
App::main()->readServerHistory(_history, false);
fastShowAtEnd(_history);
WebPageId webPageId = _previewCancelled ? 0xFFFFFFFFFFFFFFFFULL : ((_previewData && _previewData->pendingTill >= 0) ? _previewData->id : 0);
App::main()->sendPreparedText(_history, text, replyTo, _broadcast.checked(), webPageId);
WebPageId webPageId = _previewCancelled ? 0xFFFFFFFFFFFFFFFFULL : ((_previewData && _previewData->pendingTill >= 0) ? _previewData->id : 0);
App::main()->sendMessage(_history, _field.getLastText(), replyTo, _broadcast.checked(), webPageId);
setFieldText(QString());
_saveDraftText = true;
_saveDraftStart = getms();
onDraftSave();
setFieldText(QString());
_saveDraftText = true;
_saveDraftStart = getms();
onDraftSave();
if (!_attachMention.isHidden()) _attachMention.hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
if (!_attachMention.isHidden()) _attachMention.hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
} else if (readyToForward()) {
App::main()->readServerHistory(_history, false);
fastShowAtEnd(_history);
App::main()->finishForwarding(_history, _broadcast.checked());
}
if (replyTo < 0) cancelReply(lastKeyboardUsed);
if (_previewData && _previewData->pendingTill) previewCancel();
_field.setFocus();
@@ -4069,7 +4068,7 @@ bool HistoryWidget::animStep_show(float64 ms) {
if (dt >= 1) {
_a_show.stop();
_sideShadow.setVisible(cWideMode());
_topShadow.show();
_topShadow.setVisible(_peer ? true : false);
res = false;
a_coordUnder.finish();
@@ -4110,7 +4109,7 @@ void HistoryWidget::animStop() {
if (!_a_show.animating()) return;
_a_show.stop();
_sideShadow.setVisible(cWideMode());
_topShadow.show();
_topShadow.setVisible(_peer ? true : false);
}
bool HistoryWidget::recordStep(float64 ms) {
@@ -4306,9 +4305,6 @@ void HistoryWidget::stopRecording(bool send) {
void HistoryWidget::sendBotCommand(const QString &cmd, MsgId replyTo) { // replyTo != 0 from ReplyKeyboardMarkup, == 0 from cmd links
if (!_history) return;
App::main()->readServerHistory(_history, false);
fastShowAtEnd(_history);
bool lastKeyboardUsed = (_keyboard.forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard.forMsgId() == FullMsgId(_channel, replyTo));
QString toSend = cmd;
@@ -4320,7 +4316,7 @@ void HistoryWidget::sendBotCommand(const QString &cmd, MsgId replyTo) { // reply
toSend += '@' + username;
}
App::main()->sendPreparedText(_history, toSend, replyTo ? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0, false);
App::main()->sendMessage(_history, toSend, replyTo ? ((!_peer->isUser()/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0, false);
if (replyTo) {
cancelReply();
if (_keyboard.singleUse() && _keyboard.hasMarkup() && lastKeyboardUsed) {
@@ -5724,10 +5720,6 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) {
if (sticker->sticker()) App::main()->incrementSticker(sticker);
App::historyRegRandom(randomId, newId);
App::main()->historyToDown(_history);
App::main()->dialogsToUp();
peerMessagesUpdated(_peer->id);
if (!_attachMention.isHidden()) _attachMention.hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();