Info button replaced by userpic in single column layout.

Icons for file inline results never display a download icon.
Using !lastMsg->detached() to detect that all new messages are loaded.
This commit is contained in:
John Preston 2016-04-11 11:43:40 +04:00
parent 00367ec07a
commit 03bbb2269d
15 changed files with 60 additions and 13 deletions

View File

@ -399,7 +399,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_preview_loading" = "Getting Link Info..."; "lng_preview_loading" = "Getting Link Info...";
"lng_profile_chat_unaccessible" = "Group is unaccessible"; "lng_profile_chat_unaccessible" = "Group is unaccessible";
"lng_topbar_info" = "Info";
"lng_profile_about_section" = "About"; "lng_profile_about_section" = "About";
"lng_profile_description_section" = "Description"; "lng_profile_description_section" = "Description";
"lng_profile_settings_section" = "Settings"; "lng_profile_settings_section" = "Settings";
@ -899,6 +898,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_full_name" = "{first_name} {last_name}"; "lng_full_name" = "{first_name} {last_name}";
// Not used
"lng_topbar_info" = "Info";
// Wnd specific // Wnd specific
"lng_wnd_choose_program_menu" = "Choose Default Program..."; "lng_wnd_choose_program_menu" = "Choose Default Program...";

View File

@ -2515,3 +2515,8 @@ toastFg: #FFF;
toastPadding: margins(19px, 13px, 19px, 12px); toastPadding: margins(19px, 13px, 19px, 12px);
toastFadeInDuration: 200; toastFadeInDuration: 200;
toastFadeOutDuration: 1000; toastFadeOutDuration: 1000;
infoButton: PeerAvatarButton {
size: topBarHeight;
photoSize: 42px;
}

View File

@ -405,3 +405,8 @@ InputField {
iconSprite: sprite; iconSprite: sprite;
iconPosition: point; iconPosition: point;
} }
PeerAvatarButton {
size: number;
photoSize: number;
}

View File

@ -182,6 +182,7 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele
unread += h->unreadCount; unread += h->unreadCount;
} }
} }
int texttop = st::dlgPaddingVer + st::dlgFont->height + st::dlgSep;
if (unread) { if (unread) {
QString unreadStr = QString::number(unread); QString unreadStr = QString::number(unread);
int unreadWidth = st::dlgUnreadFont->width(unreadStr); int unreadWidth = st::dlgUnreadFont->width(unreadStr);
@ -190,7 +191,7 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele
accumulate_max(unreadRectWidth, unreadRectHeight); accumulate_max(unreadRectWidth, unreadRectHeight);
int unreadRectLeft = w - st::dlgPaddingHor - unreadRectWidth; int unreadRectLeft = w - st::dlgPaddingHor - unreadRectWidth;
int unreadRectTop = st::dlgHeight - st::dlgPaddingVer - unreadRectHeight; int unreadRectTop = texttop + st::dlgHistFont->ascent - st::dlgUnreadFont->ascent - st::dlgUnreadTop;
lastWidth -= unreadRectWidth + st::dlgUnreadPaddingHor; lastWidth -= unreadRectWidth + st::dlgUnreadPaddingHor;
paintUnreadBadge(p, QRect(unreadRectLeft, unreadRectTop, unreadRectWidth, unreadRectHeight), active, history->mute); paintUnreadBadge(p, QRect(unreadRectLeft, unreadRectTop, unreadRectWidth, unreadRectHeight), active, history->mute);
@ -200,10 +201,10 @@ void RowPainter::paint(Painter &p, const Row *row, int w, bool active, bool sele
p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + st::dlgUnreadTop + st::dlgUnreadFont->ascent, unreadStr); p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + st::dlgUnreadTop + st::dlgUnreadFont->ascent, unreadStr);
} }
if (history->typing.isEmpty() && history->sendActions.isEmpty()) { if (history->typing.isEmpty() && history->sendActions.isEmpty()) {
item->drawInDialog(p, QRect(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, lastWidth, st::dlgFont->height), active, history->textCachedFor, history->lastItemTextCache); item->drawInDialog(p, QRect(nameleft, texttop, lastWidth, st::dlgFont->height), active, history->textCachedFor, history->lastItemTextCache);
} else { } else {
p.setPen(active ? st::dlgActiveColor : st::dlgSystemColor); p.setPen(active ? st::dlgActiveColor : st::dlgSystemColor);
history->typingText.drawElided(p, nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, lastWidth); history->typingText.drawElided(p, nameleft, texttop, lastWidth);
} }
}); });
} }
@ -212,8 +213,8 @@ void RowPainter::paint(Painter &p, const FakeRow *row, int w, bool active, bool
auto item = row->item(); auto item = row->item();
auto history = item->history(); auto history = item->history();
paintRow(p, history, item, w, active, selected, onlyBackground, [&p, row, active, item](int nameleft, int namewidth) { paintRow(p, history, item, w, active, selected, onlyBackground, [&p, row, active, item](int nameleft, int namewidth) {
int32 lastWidth = namewidth; int lastWidth = namewidth, texttop = st::dlgPaddingVer + st::dlgFont->height + st::dlgSep;
item->drawInDialog(p, QRect(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, lastWidth, st::dlgFont->height), active, row->_cacheFor, row->_cache); item->drawInDialog(p, QRect(nameleft, texttop, lastWidth, st::dlgFont->height), active, row->_cacheFor, row->_cache);
}); });
} }

View File

@ -1566,7 +1566,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
asChannelHistory()->checkJoinedMessage(); asChannelHistory()->checkJoinedMessage();
asChannelHistory()->checkMaxReadMessageDate(); asChannelHistory()->checkMaxReadMessageDate();
} }
if (newLoaded && !lastMsg) setLastMessage(lastImportantMessage()); checkLastMsg();
} }
void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPMessageGroup> *collapsed) { void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPMessageGroup> *collapsed) {
@ -1574,7 +1574,9 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
if (slice.isEmpty()) { if (slice.isEmpty()) {
newLoaded = true; newLoaded = true;
if (!lastMsg) setLastMessage(lastImportantMessage()); if (!lastMsg) {
setLastMessage(lastImportantMessage());
}
} }
t_assert(!isBuildingFrontBlock()); t_assert(!isBuildingFrontBlock());
@ -1632,6 +1634,17 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
} }
if (isChannel()) asChannelHistory()->checkJoinedMessage(); if (isChannel()) asChannelHistory()->checkJoinedMessage();
checkLastMsg();
}
void History::checkLastMsg() {
if (lastMsg) {
if (!newLoaded && !lastMsg->detached() && (!isChannel() || asChannelHistory()->onlyImportant())) {
newLoaded = true;
}
} else if (newLoaded) {
setLastMessage(lastImportantMessage());
}
} }
int History::countUnread(MsgId upTo) { int History::countUnread(MsgId upTo) {

View File

@ -518,6 +518,9 @@ protected:
private: private:
// After adding a new history slice check the lastMsg and newLoaded.
void checkLastMsg();
enum class Flag { enum class Flag {
f_has_pending_resized_items = (1 << 0), f_has_pending_resized_items = (1 << 0),
f_pending_resize = (1 << 1), f_pending_resize = (1 << 1),

View File

@ -731,7 +731,7 @@ void File::paint(Painter &p, const QRect &clip, uint32 selection, const PaintCon
icon = st::msgFileInPause; icon = st::msgFileInPause;
} else if (radial || document->loading()) { } else if (radial || document->loading()) {
icon = st::msgFileInCancel; icon = st::msgFileInCancel;
} else if (document->loaded()) { } else if (true || document->loaded()) {
if (document->isImage()) { if (document->isImage()) {
icon = st::msgFileInImage; icon = st::msgFileInImage;
} else if (document->voice() || document->song()) { } else if (document->voice() || document->song()) {

View File

@ -110,6 +110,7 @@ std_::unique_ptr<ItemBase> ItemBase::createLayout(Result *result, bool forceThum
case Type::Sticker: return std_::make_unique<internal::Sticker>(result); break; case Type::Sticker: return std_::make_unique<internal::Sticker>(result); break;
case Type::Gif: return std_::make_unique<internal::Gif>(result); break; case Type::Gif: return std_::make_unique<internal::Gif>(result); break;
case Type::Article: case Type::Article:
case Type::Geo:
case Type::Venue: return std_::make_unique<internal::Article>(result, forceThumb); break; case Type::Venue: return std_::make_unique<internal::Article>(result, forceThumb); break;
case Type::Contact: return std_::make_unique<internal::Contact>(result); break; case Type::Contact: return std_::make_unique<internal::Contact>(result); break;
} }

View File

@ -74,6 +74,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
result->insert(qsl("article"), Result::Type::Article); result->insert(qsl("article"), Result::Type::Article);
result->insert(qsl("contact"), Result::Type::Contact); result->insert(qsl("contact"), Result::Type::Contact);
result->insert(qsl("venue"), Result::Type::Venue); result->insert(qsl("venue"), Result::Type::Venue);
result->insert(qsl("geo"), Result::Type::Geo);
return result.release(); return result.release();
})() }; })() };

View File

@ -55,7 +55,7 @@ TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
, _forward(this, lang(lng_selected_forward), st::topBarActionButton) , _forward(this, lang(lng_selected_forward), st::topBarActionButton)
, _delete(this, lang(lng_selected_delete), st::topBarActionButton) , _delete(this, lang(lng_selected_delete), st::topBarActionButton)
, _selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth())) , _selectionButtonsWidth(_clearSelection.width() + _forward.width() + _delete.width()), _forwardDeleteWidth(qMax(_forward.textWidth(), _delete.textWidth()))
, _info(this, lang(lng_topbar_info), st::topBarButton) , _info(this, nullptr, st::infoButton)
, _edit(this, lang(lng_profile_edit_contact), st::topBarButton) , _edit(this, lang(lng_profile_edit_contact), st::topBarButton)
, _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton) , _leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton)
, _addContact(this, lang(lng_profile_add_contact), st::topBarButton) , _addContact(this, lang(lng_profile_add_contact), st::topBarButton)
@ -362,6 +362,7 @@ void TopBarWidget::showAll() {
} }
if (h && !o && !p && _clearSelection.isHidden()) { if (h && !o && !p && _clearSelection.isHidden()) {
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
_info.setPeer(h);
_info.show(); _info.show();
} else { } else {
_info.hide(); _info.hide();

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "profilewidget.h" #include "profilewidget.h"
#include "overviewwidget.h" #include "overviewwidget.h"
#include "playerwidget.h" #include "playerwidget.h"
#include "ui/buttons/peer_avatar_button.h"
class Window; class Window;
class ApiWrap; class ApiWrap;
@ -111,7 +112,7 @@ private:
FlatButton _forward, _delete; FlatButton _forward, _delete;
int32 _selectionButtonsWidth, _forwardDeleteWidth; int32 _selectionButtonsWidth, _forwardDeleteWidth;
FlatButton _info; PeerAvatarButton _info;
FlatButton _edit, _leaveGroup, _addContact, _deleteContact; FlatButton _edit, _leaveGroup, _addContact, _deleteContact;
FlatButton _mediaType; FlatButton _mediaType;

View File

@ -214,7 +214,7 @@ void UserData::setPhoto(const MTPUserProfilePhoto &p) { // see Local::readPeer a
default: { default: {
newPhotoId = 0; newPhotoId = 0;
if (id == ServiceUserId) { if (id == ServiceUserId) {
if (_userpic->isNull()) { if (_userpic.v() == userDefPhoto(colorIndex).v()) {
newPhoto = ImagePtr(QPixmap::fromImage(App::wnd()->iconLarge().scaledToWidth(160, Qt::SmoothTransformation), Qt::ColorOnly), "PNG"); newPhoto = ImagePtr(QPixmap::fromImage(App::wnd()->iconLarge().scaledToWidth(160, Qt::SmoothTransformation), Qt::ColorOnly), "PNG");
} }
} else { } else {

View File

@ -128,6 +128,7 @@ SOURCES += \
./SourceFiles/mtproto/rpc_sender.cpp \ ./SourceFiles/mtproto/rpc_sender.cpp \
./SourceFiles/mtproto/scheme_auto.cpp \ ./SourceFiles/mtproto/scheme_auto.cpp \
./SourceFiles/mtproto/session.cpp \ ./SourceFiles/mtproto/session.cpp \
./SourceFiles/ui/buttons/peer_avatar_button.cpp \
./SourceFiles/ui/toast/toast.cpp \ ./SourceFiles/ui/toast/toast.cpp \
./SourceFiles/ui/toast/toast_manager.cpp \ ./SourceFiles/ui/toast/toast_manager.cpp \
./SourceFiles/ui/toast/toast_widget.cpp \ ./SourceFiles/ui/toast/toast_widget.cpp \
@ -236,6 +237,7 @@ HEADERS += \
./SourceFiles/mtproto/scheme_auto.h \ ./SourceFiles/mtproto/scheme_auto.h \
./SourceFiles/mtproto/session.h \ ./SourceFiles/mtproto/session.h \
./SourceFiles/pspecific.h \ ./SourceFiles/pspecific.h \
./SourceFiles/ui/buttons/peer_avatar_button.h \
./SourceFiles/ui/toast/toast.h \ ./SourceFiles/ui/toast/toast.h \
./SourceFiles/ui/toast/toast_manager.h \ ./SourceFiles/ui/toast/toast_manager.h \
./SourceFiles/ui/toast/toast_widget.h \ ./SourceFiles/ui/toast/toast_widget.h \

View File

@ -1165,8 +1165,10 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="ui\buttons\peer_avatar_button.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CustomBuild Include="ui\buttons\peer_avatar_button.h" />
<CustomBuild Include="SourceFiles\pspecific_winrt.h"> <CustomBuild Include="SourceFiles\pspecific_winrt.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">Moc%27ing pspecific_winrt.h...</Message> <Message Condition="'$(Configuration)|$(Platform)'=='Deploy|Win32'">Moc%27ing pspecific_winrt.h...</Message>

View File

@ -64,6 +64,9 @@
<Filter Include="dialogs"> <Filter Include="dialogs">
<UniqueIdentifier>{405e59c2-0800-4f73-b975-1749c8c36e87}</UniqueIdentifier> <UniqueIdentifier>{405e59c2-0800-4f73-b975-1749c8c36e87}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="ui\buttons">
<UniqueIdentifier>{24292a88-6707-4070-b2d2-8b53acd5cdd0}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="SourceFiles\main.cpp"> <ClCompile Include="SourceFiles\main.cpp">
@ -1029,6 +1032,9 @@
<ClCompile Include="SourceFiles\dialogs\dialogs_indexed_list.cpp"> <ClCompile Include="SourceFiles\dialogs\dialogs_indexed_list.cpp">
<Filter>dialogs</Filter> <Filter>dialogs</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ui\buttons\peer_avatar_button.cpp">
<Filter>ui\buttons</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="SourceFiles\stdafx.h"> <ClInclude Include="SourceFiles\stdafx.h">
@ -1408,6 +1414,9 @@
<CustomBuild Include="SourceFiles\ui\toast\toast_manager.h"> <CustomBuild Include="SourceFiles\ui\toast\toast_manager.h">
<Filter>ui\toast</Filter> <Filter>ui\toast</Filter>
</CustomBuild> </CustomBuild>
<CustomBuild Include="ui\buttons\peer_avatar_button.h">
<Filter>ui\buttons</Filter>
</CustomBuild>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\langs\lang_it.strings"> <None Include="Resources\langs\lang_it.strings">