Skip to content

Commit

Permalink
navigation improved in single column layout, document viewer improved
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Dec 15, 2014
1 parent 2a50004 commit 37917db
Show file tree
Hide file tree
Showing 26 changed files with 328 additions and 149 deletions.
4 changes: 2 additions & 2 deletions Telegram/Resources/lang.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ lng_menu_settings: "Settings";
lng_menu_about: "About";
lng_menu_update: "Update";
lng_menu_restart: "Restart";
lng_menu_start_messaging: "Start Messaging";
lng_menu_conversations: "Conversations List";
lng_menu_back: "Back";

lng_open_from_tray: "Open Telegram";
lng_minimize_to_tray: "Minimize to tray";
Expand Down Expand Up @@ -272,6 +271,7 @@ some of the new settings. Restart now?";
lng_settings_restart_now: "Restart";
lng_settings_restart_later: "Later";

lng_topbar_info: "Info";
lng_profile_settings_section: "Settings";
lng_profile_participants_section: "Participants";
lng_profile_info: "Contact info";
Expand Down
6 changes: 4 additions & 2 deletions Telegram/Resources/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ titleHeight: 39px;
titleShadowColor: rgba(0, 0, 0, 24);//#ebebeb
titleShadow: 1px;
titleIconPos: point(7px, 7px);
titleIconRect: sprite(160px, 100px, 26px, 26px);
titleIconImg: sprite(160px, 100px, 26px, 26px);
titleFont: font(17px);
titlePos: point(44px, 29px);
titleMenuOffset: 36px;
Expand Down Expand Up @@ -695,9 +695,10 @@ dlgActiveDateColor: #d3e2ee;
topBarHeight: 54px;
topBarBG: white;
topBarDuration: 200;
topBarForwardPadding: margins(17px, 8px, 40px, 8px);
topBarForwardPadding: margins(17px, 8px, 39px, 8px);
topBarForwardAlpha: 0.6;
topBarForwardImg: sprite(45px, 112px, 9px, 16px);
topBarBackwardImg: sprite(35px, 112px, 9px, 16px);
topBarBackPadding: margins(15px, 7px, 9px, 7px);
topBarBackAlpha: 0.8;
topBarBackImg: sprite(65px, 112px, 9px, 16px);
Expand Down Expand Up @@ -1584,6 +1585,7 @@ medviewDocumentSprite: sprite(341px, 150px, 20px, 22px);
medviewDocumentSpritePos: point(16px, 13px);
medviewPhotoSprite: sprite(363px, 150px, 23px, 20px);
medviewPhotoSpritePos: point(14px, 14px);
medviewTransparentBrush: sprite(148px, 197px, 8px, 8px);

overviewPhotoSkip: 10px;
overviewPhotoMinSize: 100px;
Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ namespace App {
::quiting = true;
}

QImage readImage(QByteArray data, QByteArray *format) {
QImage readImage(QByteArray data, QByteArray *format, bool opaque) {
QByteArray tmpFormat;
QImage result;
QBuffer buffer(&data);
Expand Down Expand Up @@ -1999,7 +1999,7 @@ namespace App {
}
exif_data_free(exifData);
}
} else {
} else if (opaque) {
QImage solid(result.width(), result.height(), QImage::Format_ARGB32_Premultiplied);
solid.fill(st::white->c);
{
Expand All @@ -2010,12 +2010,12 @@ namespace App {
return result;
}

QImage readImage(const QString &file, QByteArray *format) {
QImage readImage(const QString &file, QByteArray *format, bool opaque) {
QFile f(file);
if (!f.open(QIODevice::ReadOnly)) {
return QImage();
}
return readImage(f.readAll(), format);
return readImage(f.readAll(), format, opaque);
}

void regVideoItem(VideoData *data, HistoryItem *item) {
Expand Down
5 changes: 2 additions & 3 deletions Telegram/SourceFiles/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ namespace App {
bool quiting();
void setQuiting();


QImage readImage(QByteArray data, QByteArray *format = 0);
QImage readImage(const QString &file, QByteArray *format = 0);
QImage readImage(QByteArray data, QByteArray *format = 0, bool opaque = true);
QImage readImage(const QString &file, QByteArray *format = 0, bool opaque = true);

void regVideoItem(VideoData *data, HistoryItem *item);
void unregVideoItem(VideoData *data, HistoryItem *item);
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.
1 change: 1 addition & 0 deletions Telegram/SourceFiles/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ enum {

MediaViewImageSizeLimit = 100 * 1024 * 1024, // show up to 100mb jpg/png/gif docs in app
MaxZoomLevel = 7, // x8
ZoomToScreenLevel = 1024, // just constant

PreloadHeightsCount = 3, // when 3 screens to scroll left make a preload request
EmojiPadPerRow = 7,
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/dialogswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void DialogsListWidget::dialogsReceived(const QVector<MTPDialog> &added) {
addDialog(i->c_dialog());
}
}
if (App::wnd()) App::wnd()->psUpdateCounter();
if (App::wnd()) App::wnd()->updateCounter();
if (!sel && dialogs.list.count) {
sel = dialogs.list.begin;
contactSel = false;
Expand Down Expand Up @@ -1309,7 +1309,7 @@ void DialogsWidget::unreadCountsReceived(const QVector<MTPDialog> &dialogs) {
}
}
}
if (App::wnd()) App::wnd()->psUpdateCounter();
if (App::wnd()) App::wnd()->updateCounter();
}

void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs) {
Expand Down
6 changes: 6 additions & 0 deletions Telegram/SourceFiles/gui/twidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class TWidget : public QWidget {

virtual void leaveToChildEvent(QEvent *e) { // e -- from enterEvent() of child TWidget
}
virtual void enterFromChildEvent(QEvent *e) { // e -- from leaveEvent() of child TWidget
}

bool event(QEvent *e) {
return QWidget::event(e);
Expand All @@ -44,6 +46,10 @@ class TWidget : public QWidget {
TWidget *p(tparent());
if (p) p->leaveToChildEvent(e);
}
void leaveEvent(QEvent *e) {
TWidget *p(tparent());
if (p) p->enterFromChildEvent(e);
}

private:

Expand Down
6 changes: 3 additions & 3 deletions Telegram/SourceFiles/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ void DocumentOpenLink::onClick(Qt::MouseButton button) const {
if (reader.supportsAnimation() && reader.imageCount() > 1 && App::hoveredLinkItem()) {
startGif(App::hoveredLinkItem(), already);
} else {
App::wnd()->showDocument(data, QPixmap::fromImage(App::readImage(already)), App::hoveredLinkItem());
App::wnd()->showDocument(data, QPixmap::fromImage(App::readImage(already, 0, false)), App::hoveredLinkItem());
}
} else {
psOpenFile(already);
Expand Down Expand Up @@ -1631,7 +1631,7 @@ void History::setUnreadCount(int32 newUnreadCount, bool psUpdate) {
App::histories().unreadFull += newUnreadCount - unreadCount;
if (mute) App::histories().unreadMuted += newUnreadCount - unreadCount;
unreadCount = newUnreadCount;
if (psUpdate) App::wnd()->psUpdateCounter();
if (psUpdate) App::wnd()->updateCounter();
if (unreadBar) unreadBar->setCount(unreadCount);
}
}
Expand All @@ -1646,7 +1646,7 @@ void History::setMsgCount(int32 newMsgCount) {
if (mute != newMute) {
App::histories().unreadMuted += newMute ? unreadCount : (-unreadCount);
mute = newMute;
App::wnd()->psUpdateCounter();
App::wnd()->updateCounter();
}
}

Expand Down
15 changes: 12 additions & 3 deletions Telegram/SourceFiles/historywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,9 @@ void HistoryWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth)

if (!hist) return;

QRect rectForName(st::topBarForwardPadding.left(), st::topBarForwardPadding.top(), width() - decreaseWidth - st::topBarForwardPadding.left() - st::topBarForwardPadding.right(), st::msgNameFont->height);
int32 increaseLeft = decreaseWidth;
if (!cWideMode()) decreaseWidth += (st::topBarForwardPadding.right() - st::topBarForwardPadding.left());
QRect rectForName(st::topBarForwardPadding.left() + increaseLeft, st::topBarForwardPadding.top(), width() - decreaseWidth - st::topBarForwardPadding.left() - st::topBarForwardPadding.right(), st::msgNameFont->height);
p.setFont(st::dlgHistFont->f);
if (hist->typing.isEmpty()) {
p.setPen(st::titleStatusColor->p);
Expand All @@ -2731,9 +2733,12 @@ void HistoryWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth)
p.setPen(st::dlgNameColor->p);
hist->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());

if (!decreaseWidth) {
if (cWideMode()) {
p.setOpacity(st::topBarForwardAlpha + (1 - st::topBarForwardAlpha) * over);
p.drawPixmap(QPoint(width() - (st::topBarForwardPadding.right() + st::topBarForwardImg.pxWidth()) / 2, (st::topBarHeight - st::topBarForwardImg.pxHeight()) / 2), App::sprite(), st::topBarForwardImg);
} else {
p.setOpacity(st::topBarForwardAlpha + (1 - st::topBarForwardAlpha) * over);
p.drawPixmap(QPoint((st::topBarForwardPadding.right() - st::topBarBackwardImg.pxWidth()) / 2, (st::topBarHeight - st::topBarBackwardImg.pxHeight()) / 2), App::sprite(), st::topBarBackwardImg);
}
}

Expand All @@ -2745,7 +2750,11 @@ void HistoryWidget::topBarShadowParams(int32 &x, float64 &o) {
}

void HistoryWidget::topBarClick() {
if (hist) App::main()->showPeerProfile(histPeer);
if (cWideMode()) {
if (hist) App::main()->showPeerProfile(histPeer);
} else {
App::main()->onShowDialogs();
}
}

void HistoryWidget::updateOnlineDisplay(int32 x, int32 w) {
Expand Down
44 changes: 37 additions & 7 deletions Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org

#include "audio.h"

TopBarWidget::TopBarWidget(MainWidget *w) : QWidget(w),
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w),
a_over(0), _drawShadow(true), _selCount(0), _selStrWidth(0), _animating(false),
_clearSelection(this, lang(lng_selected_clear), st::topBarButton),
_forward(this, lang(lng_selected_forward), st::topBarActionButton),
_delete(this, lang(lng_selected_delete), st::topBarActionButton),
_info(this, lang(lng_topbar_info), st::topBarButton),
_edit(this, lang(lng_profile_edit_contact), st::topBarButton),
_leaveGroup(this, lang(lng_profile_delete_and_exit), st::topBarButton),
_addContact(this, lang(lng_profile_add_contact), st::topBarButton),
Expand All @@ -42,6 +43,7 @@ TopBarWidget::TopBarWidget(MainWidget *w) : QWidget(w),
connect(&_forward, SIGNAL(clicked()), this, SLOT(onForwardSelection()));
connect(&_delete, SIGNAL(clicked()), this, SLOT(onDeleteSelection()));
connect(&_clearSelection, SIGNAL(clicked()), this, SLOT(onClearSelection()));
connect(&_info, SIGNAL(clicked()), this, SLOT(onInfoClicked()));
connect(&_addContact, SIGNAL(clicked()), this, SLOT(onAddContact()));
connect(&_deleteContact, SIGNAL(clicked()), this, SLOT(onDeleteContact()));
connect(&_edit, SIGNAL(clicked()), this, SLOT(onEdit()));
Expand All @@ -63,9 +65,9 @@ void TopBarWidget::onClearSelection() {
if (App::main()) App::main()->clearSelectedItems();
}

void TopBarWidget::onEdit() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0;
if (p) App::wnd()->showLayer(new AddContactBox(p));
void TopBarWidget::onInfoClicked() {
PeerData *p = App::main() ? App::main()->historyPeer() : 0;
if (p) App::main()->showPeerProfile(p);
}

void TopBarWidget::onAddContact() {
Expand All @@ -74,6 +76,11 @@ void TopBarWidget::onAddContact() {
if (u) App::wnd()->showLayer(new AddContactBox(u->firstName, u->lastName, u->phone));
}

void TopBarWidget::onEdit() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0;
if (p) App::wnd()->showLayer(new AddContactBox(p));
}

void TopBarWidget::onDeleteContact() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0;
UserData *u = (p && !p->chat) ? p->asUser() : 0;
Expand Down Expand Up @@ -119,11 +126,21 @@ void TopBarWidget::enterEvent(QEvent *e) {
anim::start(this);
}

void TopBarWidget::enterFromChildEvent(QEvent *e) {
a_over.start(1);
anim::start(this);
}

void TopBarWidget::leaveEvent(QEvent *e) {
a_over.start(0);
anim::start(this);
}

void TopBarWidget::leaveToChildEvent(QEvent *e) {
a_over.start(0);
anim::start(this);
}

bool TopBarWidget::animStep(float64 ms) {
float64 dt = ms / st::topBarDuration;
bool res = true;
Expand All @@ -148,7 +165,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
p.fillRect(QRect(0, 0, width(), st::topBarHeight), st::topBarBG->b);
if (_clearSelection.isHidden()) {
p.save();
main()->paintTopBar(p, a_over.current(), 0);
main()->paintTopBar(p, a_over.current(), _info.isHidden() ? 0 : _info.width());
p.restore();
} else {
p.setFont(st::linkFont->f);
Expand Down Expand Up @@ -184,6 +201,7 @@ void TopBarWidget::resizeEvent(QResizeEvent *e) {
_forward.move(availX + (availW - _forward.width() - _delete.width() - st::topBarActionSkip) / 2, (st::topBarHeight - _forward.height()) / 2);
_delete.move(availX + (availW + _forward.width() - _delete.width() + st::topBarActionSkip) / 2, (st::topBarHeight - _forward.height()) / 2);
}
if (!_info.isHidden()) _info.move(r -= _info.width(), 0);
if (!_clearSelection.isHidden()) _clearSelection.move(r -= _clearSelection.width(), 0);
if (!_deleteContact.isHidden()) _deleteContact.move(r -= _deleteContact.width(), 0);
if (!_leaveGroup.isHidden()) _leaveGroup.move(r -= _leaveGroup.width(), 0);
Expand All @@ -193,6 +211,7 @@ void TopBarWidget::resizeEvent(QResizeEvent *e) {
}

void TopBarWidget::startAnim() {
_info.hide();
_edit.hide();
_leaveGroup.hide();
_addContact.hide();
Expand Down Expand Up @@ -237,6 +256,7 @@ void TopBarWidget::showAll() {
_deleteContact.hide();
}
_clearSelection.hide();
_info.hide();
_delete.hide();
_forward.hide();
_mediaType.hide();
Expand All @@ -260,6 +280,11 @@ void TopBarWidget::showAll() {
_mediaType.hide();
}
}
if (App::main() && App::main()->historyPeer() && !cWideMode()) {
_info.show();
} else {
_info.hide();
}
}
resizeEvent(0);
}
Expand Down Expand Up @@ -1043,7 +1068,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
if (reader.supportsAnimation() && reader.imageCount() > 1 && item) {
startGif(item, already);
} else {
App::wnd()->showDocument(document, QPixmap::fromImage(App::readImage(already)), item);
App::wnd()->showDocument(document, QPixmap::fromImage(App::readImage(already, 0, false)), item);
}
} else {
psOpenFile(already);
Expand Down Expand Up @@ -1262,6 +1287,10 @@ void MainWidget::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPe
dialogs.peerAfter(inPeer, inMsg, outPeer, outMsg);
}

PeerData *MainWidget::historyPeer() {
return history.peer();
}

PeerData *MainWidget::peer() {
return overview ? overview->peer() : history.peer();
}
Expand Down Expand Up @@ -1754,13 +1783,14 @@ void MainWidget::keyPressEvent(QKeyEvent *e) {

void MainWidget::updateWideMode() {
showAll();
_topBar.showAll();
}

bool MainWidget::needBackButton() {
return overview || profile || (history.peer() && history.peer()->id);
}

void MainWidget::onTitleBack() {
void MainWidget::onShowDialogs() {
showPeer(0, 0, false, true);
}

Expand Down
Loading

0 comments on commit 37917db

Please sign in to comment.