From 8a8e0c1182bcb4e2be05e1c3e53e17992f52cda0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 13 Jan 2017 14:58:41 +0300 Subject: [PATCH] Passcode box layout fix. Drop image from Firefox fix. Also admin star color in group profile has separate palette entry. --- Telegram/Resources/colors.palette | 1 + Telegram/Resources/default.tdesktop-theme | 1 + Telegram/SourceFiles/boxes/passcodebox.cpp | 2 +- Telegram/SourceFiles/historywidget.cpp | 10 +++++----- Telegram/SourceFiles/localimageloader.cpp | 8 ++++---- Telegram/SourceFiles/localimageloader.h | 2 +- Telegram/SourceFiles/mtproto/connection.cpp | 6 ++++-- Telegram/SourceFiles/overviewwidget.cpp | 4 ++-- Telegram/SourceFiles/profile/profile.style | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Telegram/Resources/colors.palette b/Telegram/Resources/colors.palette index 6dd97d69d..8ccfb5708 100644 --- a/Telegram/Resources/colors.palette +++ b/Telegram/Resources/colors.palette @@ -411,6 +411,7 @@ overviewPhotoSelectOverlay: #40ace333; profileStatusFgOver: #7c99b2; profileVerifiedCheckBg: windowBgActive; profileVerifiedCheckFg: windowFgActive; +profileAdminStartFg: windowBgActive; // settings notificationsBoxMonitorFg: windowFg; diff --git a/Telegram/Resources/default.tdesktop-theme b/Telegram/Resources/default.tdesktop-theme index 8e61fd3bd..f567f5cfb 100644 --- a/Telegram/Resources/default.tdesktop-theme +++ b/Telegram/Resources/default.tdesktop-theme @@ -351,6 +351,7 @@ overviewPhotoSelectOverlay: #40ace333; profileStatusFgOver: #7c99b2; profileVerifiedCheckBg: windowBgActive; profileVerifiedCheckFg: windowFgActive; +profileAdminStartFg: windowBgActive; notificationsBoxMonitorFg: windowFg; notificationsBoxScreenBg: dialogsBgActive; notificationSampleUserpicFg: windowBgActive; diff --git a/Telegram/SourceFiles/boxes/passcodebox.cpp b/Telegram/SourceFiles/boxes/passcodebox.cpp index 8cfae3a49..d6c3243c9 100644 --- a/Telegram/SourceFiles/boxes/passcodebox.cpp +++ b/Telegram/SourceFiles/boxes/passcodebox.cpp @@ -143,7 +143,7 @@ void PasscodeBox::paintEvent(QPaintEvent *e) { Painter p(this); int32 w = st::boxWidth - st::boxPadding.left() * 1.5; - int32 abouty = (_passwordHint->isHidden() ? ((_reenterPasscode->isHidden() ? (_oldPasscode->y() + (_hasRecovery && !_hintText.isEmpty() ? st::passcodeTextLine : 0)) : _reenterPasscode->y()) + st::passcodeSkip) : (_passwordHint->y() + st::passcodeLittleSkip)) + _oldPasscode->height() + st::passcodeLittleSkip + st::passcodeAboutSkip; + int32 abouty = (_passwordHint->isHidden() ? ((_reenterPasscode->isHidden() ? (_oldPasscode->y() + (_hasRecovery && !_hintText.isEmpty() ? st::passcodeTextLine : 0)) : _reenterPasscode->y()) + st::passcodeSkip) : _passwordHint->y()) + _oldPasscode->height() + st::passcodeLittleSkip + st::passcodeAboutSkip; p.setPen(st::boxTextFg); _about.drawLeft(p, st::boxPadding.left(), abouty, w, width()); diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 580cffe8d..27e5b060b 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -6532,7 +6532,7 @@ bool HistoryWidget::confirmSendingFiles(const SendingFilesLists &lists, Compress return validateSendingFiles(lists, [this, &lists, compressed, addedComment](const QStringList &files) { auto image = QImage(); auto insertTextOnCancel = QString(); - auto prepareBox = [this, &files, &lists, compressed, &image] { + auto box = ([this, &files, &lists, compressed, &image] { if (files.size() > 1) { return Box(files, lists.allFilesForCompress ? compressed : CompressConfirm::None); } @@ -6540,12 +6540,12 @@ bool HistoryWidget::confirmSendingFiles(const SendingFilesLists &lists, Compress auto animated = false; image = App::readImage(filepath, nullptr, false, &animated); return Box(filepath, image, imageCompressConfirm(image, compressed, animated), animated); - }; + })(); auto sendCallback = [this, image](const QStringList &files, bool compressed, const QString &caption, MsgId replyTo) { auto type = compressed ? SendMediaType::Photo : SendMediaType::File; uploadFilesAfterConfirmation(files, image, QByteArray(), type, caption); }; - return showSendFilesBox(prepareBox(), insertTextOnCancel, addedComment, std_::move(sendCallback)); + return showSendFilesBox(std_::move(box), insertTextOnCancel, addedComment, std_::move(sendCallback)); }); } @@ -6686,7 +6686,7 @@ void HistoryWidget::uploadFilesAfterConfirmation(const QStringList &files, const if (filepath.isEmpty() && (!image.isNull() || !content.isNull())) { tasks.push_back(MakeShared(content, image, type, to, caption)); } else { - tasks.push_back(MakeShared(filepath, type, to, caption)); + tasks.push_back(MakeShared(filepath, image, type, to, caption)); } } _fileLoader.addTasks(tasks); @@ -6699,7 +6699,7 @@ void HistoryWidget::uploadFile(const QByteArray &fileContent, SendMediaType type auto to = FileLoadTo(_peer->id, _silent->checked(), replyToId()); auto caption = QString(); - _fileLoader.addTask(MakeShared(fileContent, type, to, caption)); + _fileLoader.addTask(MakeShared(fileContent, QImage(), type, to, caption)); cancelReplyAfterMediaSend(lastForceReplyReplied()); } diff --git a/Telegram/SourceFiles/localimageloader.cpp b/Telegram/SourceFiles/localimageloader.cpp index aff5837bc..3005b8459 100644 --- a/Telegram/SourceFiles/localimageloader.cpp +++ b/Telegram/SourceFiles/localimageloader.cpp @@ -172,9 +172,10 @@ void TaskQueueWorker::onTaskAdded() { _inTaskAdded = false; } -FileLoadTask::FileLoadTask(const QString &filepath, SendMediaType type, const FileLoadTo &to, const QString &caption) : _id(rand_value()) +FileLoadTask::FileLoadTask(const QString &filepath, const QImage &image, SendMediaType type, const FileLoadTo &to, const QString &caption) : _id(rand_value()) , _to(to) , _filepath(filepath) +, _image(image) , _type(type) , _caption(caption) { } @@ -214,9 +215,8 @@ void FileLoadTask::process() { auto gif = false; auto voice = (_type == SendMediaType::Audio); auto fullimage = base::take(_image); - - if (!_filepath.isEmpty()) { - QFileInfo info(_filepath); + auto info = _filepath.isEmpty() ? QFileInfo() : QFileInfo(_filepath); + if (info.exists()) { if (info.isDir()) { _result->filesize = -1; return; diff --git a/Telegram/SourceFiles/localimageloader.h b/Telegram/SourceFiles/localimageloader.h index a62219a8e..642795e5c 100644 --- a/Telegram/SourceFiles/localimageloader.h +++ b/Telegram/SourceFiles/localimageloader.h @@ -235,7 +235,7 @@ typedef QSharedPointer FileLoadResultPtr; class FileLoadTask : public Task { public: - FileLoadTask(const QString &filepath, SendMediaType type, const FileLoadTo &to, const QString &caption); + FileLoadTask(const QString &filepath, const QImage &image, SendMediaType type, const FileLoadTo &to, const QString &caption); FileLoadTask(const QByteArray &content, const QImage &image, SendMediaType type, const FileLoadTo &to, const QString &caption); FileLoadTask(const QByteArray &voice, int32 duration, const VoiceWaveform &waveform, const FileLoadTo &to, const QString &caption); diff --git a/Telegram/SourceFiles/mtproto/connection.cpp b/Telegram/SourceFiles/mtproto/connection.cpp index e1bfe19cc..cc55ec553 100644 --- a/Telegram/SourceFiles/mtproto/connection.cpp +++ b/Telegram/SourceFiles/mtproto/connection.cpp @@ -29,6 +29,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include #include "zlib.h" +#include "lang.h" #include "mtproto/rsa_public_key.h" @@ -869,7 +870,8 @@ void ConnectionPrivate::tryToSend() { MTPInitConnection initWrapperImpl, *initWrapper = &initWrapperImpl; int32 initSize = 0, initSizeInInts = 0; if (needsLayer) { - initWrapperImpl = MTPInitConnection(MTP_int(ApiId), MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(Sandbox::LangSystemISO()), mtpRequest()); + auto langCode = (cLang() == languageTest || cLang() == languageDefault) ? Sandbox::LangSystemISO() : str_const_toString(LanguageCodes[cLang()]); + initWrapperImpl = MTPInitConnection(MTP_int(ApiId), MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(langCode), mtpRequest()); initSizeInInts = (initWrapper->innerLength() >> 2) + 2; initSize = initSizeInInts * sizeof(mtpPrime); } @@ -1267,7 +1269,7 @@ void ConnectionPrivate::onOldConnection() { void ConnectionPrivate::onPingSender() { if (_pingId) { - if (_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto - 1) * 1000LL < getms(true)) { + if (_pingSendAt + (MTPPingSendAfter - MTPPingSendAfterAuto - 1) * 1000LL < getms(true)) { LOG(("Could not send ping for MTPPingSendAfter seconds, restarting...")); return restart(); } else { diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index 0793930a1..9a9d71c9b 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -1641,7 +1641,7 @@ void OverviewInner::mediaOverviewUpdated() { History::MediaOverview &o(_history->overview[_type]), *migratedOverview = _migrated ? &_migrated->overview[_type] : 0; int32 migrateCount = migratedIndexSkip(); int32 l = _inSearch ? _searchResults.size() : (migrateCount + o.size()), tocheck = qMin(l, _itemsToBeLoaded); - _items.reserve(withDates * tocheck); // day items + _items.reserve((withDates ? 2 : 1) * tocheck); // day items int32 top = 0, index = 0; bool allGood = true; @@ -1775,7 +1775,7 @@ void OverviewInner::repaintItem(const HistoryItem *msg) { int32 migrateindex = migratedIndexSkip(); MsgId msgid = msg->id; - if (history->overviewHasMsgId(_type, msgid) && (history == _history || migrateindex > 0)) { + if ((history == _history || migrateindex > 0) && (_inSearch || history->overviewHasMsgId(_type, msgid))) { if (_type == OverviewPhotos || _type == OverviewVideos) { if (history == _migrated) msgid = -msgid; for (int32 i = 0, l = _items.size(); i != l; ++i) { diff --git a/Telegram/SourceFiles/profile/profile.style b/Telegram/SourceFiles/profile/profile.style index 80c3eb1c3..6136624c0 100644 --- a/Telegram/SourceFiles/profile/profile.style +++ b/Telegram/SourceFiles/profile/profile.style @@ -132,7 +132,7 @@ profileMemberPhotoPosition: point(12px, 6px); profileMemberNamePosition: point(68px, 11px); profileMemberNameFg: windowBoldFg; profileMemberStatusPosition: point(68px, 31px); -profileMemberAdminIcon: icon {{ "profile_admin_star", windowBgActive, point(4px, 3px) }}; +profileMemberAdminIcon: icon {{ "profile_admin_star", profileAdminStartFg, point(4px, 3px) }}; profileLimitReachedLabel: FlatLabel(defaultFlatLabel) { width: 180px; margin: margins(profileMemberPaddingLeft, 9px, profileMemberPaddingLeft, 6px);