Version 0.10.14 alpha: userpic images are now generated as icons.

Also fixed Windows build by adding breakpad include path back to gyp.
This commit is contained in:
John Preston 2016-10-18 14:48:03 +03:00
parent ba4dcc42dc
commit 2f4b2d0a33
36 changed files with 175 additions and 137 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -41,15 +41,6 @@ transparent: #fff0;
white: #fff;
black: #000;
color1: #c03d33; // red
color2: #4fad2d; // green
color3: #d09306; // yellow
color4: #348cd4; // blue
color5: #8544d6; // purple
color6: #cd4073; // pink
color7: #2996ad; // sea
color8: #ce671b; // orange
wndMinWidth: 380px;
adaptiveNormalWidth: 640px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -1,46 +1,27 @@
<RCC>
<qresource prefix="/gui">
<file>art/fonts/OpenSans-Regular.ttf</file>
<file>art/fonts/OpenSans-Bold.ttf</file>
<file>art/fonts/OpenSans-Semibold.ttf</file>
<file>art/newmsg.wav</file>
<file>art/bg.jpg</file>
<file>art/bg0.png</file>
<file>art/sprite.png</file>
<file>art/sprite_125x.png</file>
<file>art/sprite_150x.png</file>
<file>art/sprite_200x.png</file>
<file>art/blank.gif</file>
<file>art/icon256.png</file>
<file>art/iconbig256.png</file>
</qresource>
<qresource prefix="/ava">
<file>art/chatcolor1.png</file>
<file>art/chatcolor2.png</file>
<file>art/chatcolor3.png</file>
<file>art/chatcolor4.png</file>
<file>art/channelcolor1.png</file>
<file>art/channelcolor2.png</file>
<file>art/channelcolor3.png</file>
<file>art/channelcolor4.png</file>
<file>art/usercolor1.png</file>
<file>art/usercolor2.png</file>
<file>art/usercolor3.png</file>
<file>art/usercolor4.png</file>
<file>art/usercolor5.png</file>
<file>art/usercolor6.png</file>
<file>art/usercolor7.png</file>
<file>art/usercolor8.png</file>
</qresource>
<qresource prefix="/qt-project.org">
<file>qmime/freedesktop.org.xml</file>
</qresource>
<qresource prefix="/langs">
<file alias="lang_it.strings">langs/lang_it.strings</file>
<file alias="lang_es.strings">langs/lang_es.strings</file>
<file alias="lang_de.strings">langs/lang_de.strings</file>
<file alias="lang_nl.strings">langs/lang_nl.strings</file>
<file alias="lang_pt_BR.strings">langs/lang_pt_BR.strings</file>
<file alias="lang_ko.strings">langs/lang_ko.strings</file>
</qresource>
<qresource prefix="/gui">
<file>art/fonts/OpenSans-Regular.ttf</file>
<file>art/fonts/OpenSans-Bold.ttf</file>
<file>art/fonts/OpenSans-Semibold.ttf</file>
<file>art/newmsg.wav</file>
<file>art/bg.jpg</file>
<file>art/bg0.png</file>
<file>art/sprite.png</file>
<file>art/sprite_125x.png</file>
<file>art/sprite_150x.png</file>
<file>art/sprite_200x.png</file>
<file>art/icon256.png</file>
<file>art/iconbig256.png</file>
</qresource>
<qresource prefix="/qt-project.org">
<file>qmime/freedesktop.org.xml</file>
</qresource>
<qresource prefix="/langs">
<file alias="lang_it.strings">langs/lang_it.strings</file>
<file alias="lang_es.strings">langs/lang_es.strings</file>
<file alias="lang_de.strings">langs/lang_de.strings</file>
<file alias="lang_nl.strings">langs/lang_nl.strings</file>
<file alias="lang_pt_BR.strings">langs/lang_pt_BR.strings</file>
<file alias="lang_ko.strings">langs/lang_ko.strings</file>
</qresource>
</RCC>

View File

@ -92,3 +92,44 @@ historyViewsInSelectedIcon: icon {{ "history_views", #6a9bc5 }};
historyViewsOutIcon: icon {{ "history_views", historyOutFg }};
historyViewsOutSelectedIcon: icon {{ "history_views", historyOutSelectedFg }};
historyViewsInvertedIcon: icon {{ "history_views", #ffffffe6 }};
historyPeer1NameFg: #c03d33; // red
historyPeer1UserpicBg: #ed9482;
historyPeer1UserpicFg: #d3644b;
historyPeer1UserpicPerson: icon {{ size(120px, 120px), historyPeer1UserpicBg }, { "userpic_person", historyPeer1UserpicFg }};
historyPeer1UserpicChat: icon {{ size(120px, 120px), historyPeer1UserpicBg }, { "userpic_chat", historyPeer1UserpicFg }};
historyPeer1UserpicChannel: icon {{ size(120px, 120px), historyPeer1UserpicBg }, { "userpic_channel", historyPeer1UserpicFg }};
historyPeer2NameFg: #4fad2d; // green
historyPeer2UserpicBg: #a8db92;
historyPeer2UserpicFg: #75c057;
historyPeer2UserpicPerson: icon {{ size(120px, 120px), historyPeer2UserpicBg }, { "userpic_person", historyPeer2UserpicFg }};
historyPeer2UserpicChat: icon {{ size(120px, 120px), historyPeer2UserpicBg }, { "userpic_chat", historyPeer2UserpicFg }};
historyPeer2UserpicChannel: icon {{ size(120px, 120px), historyPeer2UserpicBg }, { "userpic_channel", historyPeer2UserpicFg }};
historyPeer3NameFg: #d09306; // yellow
historyPeer3UserpicBg: #efd289;
historyPeer3UserpicFg: #e4a861;
historyPeer3UserpicPerson: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_person", historyPeer3UserpicFg }};
historyPeer3UserpicChat: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_chat", historyPeer3UserpicFg }};
historyPeer3UserpicChannel: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_channel", historyPeer3UserpicFg }};
historyPeer4NameFg: #348cd4; // blue
historyPeer4UserpicBg: #8fbfe9;
historyPeer4UserpicFg: #649fd3;
historyPeer4UserpicPerson: icon {{ size(120px, 120px), historyPeer4UserpicBg }, { "userpic_person", historyPeer4UserpicFg }};
historyPeer4UserpicChat: icon {{ size(120px, 120px), historyPeer4UserpicBg }, { "userpic_chat", historyPeer4UserpicFg }};
historyPeer4UserpicChannel: icon {{ size(120px, 120px), historyPeer4UserpicBg }, { "userpic_channel", historyPeer4UserpicFg }};
historyPeer5NameFg: #8544d6; // purple
historyPeer5UserpicBg: #9992e4;
historyPeer5UserpicFg: #7b72cf;
historyPeer5UserpicPerson: icon {{ size(120px, 120px), historyPeer5UserpicBg }, { "userpic_person", historyPeer5UserpicFg }};
historyPeer6NameFg: #cd4073; // pink
historyPeer6UserpicBg: #ffa9c3;
historyPeer6UserpicFg: #e87497;
historyPeer6UserpicPerson: icon {{ size(120px, 120px), historyPeer6UserpicBg }, { "userpic_person", historyPeer6UserpicFg }};
historyPeer7NameFg: #2996ad; // sea
historyPeer7UserpicBg: #8eccdb;
historyPeer7UserpicFg: #5eb2c7;
historyPeer7UserpicPerson: icon {{ size(120px, 120px), historyPeer7UserpicBg }, { "userpic_person", historyPeer7UserpicFg }};
historyPeer8NameFg: #ce671b; // orange
historyPeer8UserpicBg: #f7b37c;
historyPeer8UserpicFg: #de8d62;
historyPeer8UserpicPerson: icon {{ size(120px, 120px), historyPeer8UserpicBg }, { "userpic_person", historyPeer8UserpicFg }};

View File

@ -76,18 +76,14 @@ void LocationManager::init() {
#endif // OS_MAC_OLD
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply*)));
if (black) {
delete black->v();
delete black;
if (notLoadedPlaceholder) {
delete notLoadedPlaceholder->v();
delete notLoadedPlaceholder;
}
QImage b(cIntRetinaFactor(), cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
{
QPainter p(&b);
p.fillRect(QRect(0, 0, cIntRetinaFactor(), cIntRetinaFactor()), st::white->b);
}
QPixmap p = App::pixmapFromImageInPlace(std_::move(b));
p.setDevicePixelRatio(cRetinaFactor());
black = new ImagePtr(p, "PNG");
auto data = QImage(cIntRetinaFactor(), cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
data.fill(st::white->c);
data.setDevicePixelRatio(cRetinaFactor());
notLoadedPlaceholder = new ImagePtr(App::pixmapFromImageInPlace(std_::move(data)), "GIF");
}
void LocationManager::reinit() {
@ -99,10 +95,10 @@ void LocationManager::deinit() {
delete manager;
manager = nullptr;
}
if (black) {
delete black->v();
delete black;
black = nullptr;
if (notLoadedPlaceholder) {
delete notLoadedPlaceholder->v();
delete notLoadedPlaceholder;
notLoadedPlaceholder = nullptr;
}
dataLoadings.clear();
imageLoadings.clear();
@ -206,7 +202,7 @@ void LocationManager::onFinished(QNetworkReply *reply) {
if (format.isEmpty()) format = QByteArray("JPG");
}
d->loading = false;
d->thumb = thumb.isNull() ? (*black) : ImagePtr(thumb, format);
d->thumb = thumb.isNull() ? (*notLoadedPlaceholder) : ImagePtr(thumb, format);
serverRedirects.remove(d);
if (App::main()) App::main()->update();
}
@ -236,7 +232,7 @@ void LocationManager::onFailed(QNetworkReply *reply) {
void LocationManager::failed(LocationData *data) {
data->loading = false;
data->thumb = *black;
data->thumb = *notLoadedPlaceholder;
serverRedirects.remove(data);
}

View File

@ -115,6 +115,6 @@ private:
QNetworkAccessManager *manager = nullptr;
QMap<QNetworkReply*, LocationData*> dataLoadings, imageLoadings;
QMap<LocationData*, int32> serverRedirects;
ImagePtr *black = nullptr;
ImagePtr *notLoadedPlaceholder = nullptr;
};

View File

@ -2296,7 +2296,7 @@ void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, u
if (_contact) {
_contact->paintUserpic(p, st::msgFileThumbSize, rthumb.x(), rthumb.y());
} else {
p.drawPixmap(rthumb.topLeft(), userDefPhoto(qAbs(_userId) % UserColorsCount)->pixCircled(st::msgFileThumbSize, st::msgFileThumbSize));
p.drawPixmap(rthumb.topLeft(), userDefPhoto(qAbs(_userId) % kUserColorsCount)->pixCircled(st::msgFileThumbSize, st::msgFileThumbSize));
}
if (selected) {
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlaySmallCorners);
@ -2313,7 +2313,7 @@ void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, u
statustop = st::msgFileStatusTop;
QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, width));
p.drawPixmap(inner.topLeft(), userDefPhoto(qAbs(_parent->id) % UserColorsCount)->pixCircled(st::msgFileSize, st::msgFileSize));
p.drawPixmap(inner.topLeft(), userDefPhoto(qAbs(_parent->id) % kUserColorsCount)->pixCircled(st::msgFileSize, st::msgFileSize));
}
int32 namewidth = width - nameleft - nameright;

View File

@ -146,7 +146,7 @@ ImagePtr ItemBase::getResultThumb() const {
QPixmap ItemBase::getResultContactAvatar(int width, int height) const {
if (_result->_type == Result::Type::Contact) {
return userDefPhoto(qHash(_result->_id) % UserColorsCount)->pixCircled(width, height);
return userDefPhoto(qHash(_result->_id) % kUserColorsCount)->pixCircled(width, height);
}
return QPixmap();
}

View File

@ -34,64 +34,81 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "media/media_audio.h"
#include "localstorage.h"
#include "history/history_media_types.h"
#include "styles/style_history.h"
namespace {
int peerColorIndex(const PeerId &peer) {
UserId myId(MTP::authedId()), peerId(peerToBareInt(peer));
QByteArray both(qsl("%1%2").arg(peerId).arg(myId).toUtf8());
if (both.size() > 15) {
both = both.mid(0, 15);
}
uchar md5[16];
hashMd5(both.constData(), both.size(), md5);
return (md5[peerId & 0x0F] & (peerIsUser(peer) ? 0x07 : 0x03));
}
int peerColorIndex(const PeerId &peer) {
auto myId = MTP::authedId();
auto peerId = peerToBareInt(peer);
auto both = (QByteArray::number(peerId) + QByteArray::number(myId)).mid(0, 15);
uchar md5[16];
hashMd5(both.constData(), both.size(), md5);
return (md5[peerId & 0x0F] & (peerIsUser(peer) ? 0x07 : 0x03));
}
style::color peerColor(int index) {
static const style::color peerColors[8] = {
style::color(st::color1),
style::color(st::color2),
style::color(st::color3),
style::color(st::color4),
style::color(st::color5),
style::color(st::color6),
style::color(st::color7),
style::color(st::color8)
struct ColorReferenceWrap {
ColorReferenceWrap(const style::color &data) : data(data) {
}
const style::color &data;
};
ImagePtr generateUserpicImage(const style::icon &icon) {
auto data = QImage(icon.width() * cIntRetinaFactor(), icon.height() * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
{
Painter p(&data);
icon.paint(p, 0, 0, icon.width());
}
data.setDevicePixelRatio(cRetinaFactor());
return ImagePtr(App::pixmapFromImageInPlace(std_::move(data)), "PNG");
}
} // namespace
const style::color &peerColor(int index) {
static const ColorReferenceWrap peerColors[kUserColorsCount] = {
st::historyPeer1NameFg,
st::historyPeer2NameFg,
st::historyPeer3NameFg,
st::historyPeer4NameFg,
st::historyPeer5NameFg,
st::historyPeer6NameFg,
st::historyPeer7NameFg,
st::historyPeer8NameFg,
};
return peerColors[index];
return peerColors[index].data;
}
ImagePtr userDefPhoto(int index) {
static const ImagePtr userDefPhotos[UserColorsCount] = {
ImagePtr(qsl(":/ava/art/usercolor1.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor2.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor3.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor4.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor5.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor6.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor7.png"), "PNG"),
ImagePtr(qsl(":/ava/art/usercolor8.png"), "PNG"),
static const ImagePtr userDefPhotos[kUserColorsCount] = {
generateUserpicImage(st::historyPeer1UserpicPerson),
generateUserpicImage(st::historyPeer2UserpicPerson),
generateUserpicImage(st::historyPeer3UserpicPerson),
generateUserpicImage(st::historyPeer4UserpicPerson),
generateUserpicImage(st::historyPeer5UserpicPerson),
generateUserpicImage(st::historyPeer6UserpicPerson),
generateUserpicImage(st::historyPeer7UserpicPerson),
generateUserpicImage(st::historyPeer8UserpicPerson),
};
return userDefPhotos[index];
}
ImagePtr chatDefPhoto(int index) {
static const ImagePtr chatDefPhotos[4] = {
ImagePtr(qsl(":/ava/art/chatcolor1.png"), "PNG"),
ImagePtr(qsl(":/ava/art/chatcolor2.png"), "PNG"),
ImagePtr(qsl(":/ava/art/chatcolor3.png"), "PNG"),
ImagePtr(qsl(":/ava/art/chatcolor4.png"), "PNG"),
static const ImagePtr chatDefPhotos[kChatColorsCount] = {
generateUserpicImage(st::historyPeer1UserpicChat),
generateUserpicImage(st::historyPeer2UserpicChat),
generateUserpicImage(st::historyPeer3UserpicChat),
generateUserpicImage(st::historyPeer4UserpicChat),
};
return chatDefPhotos[index];
}
ImagePtr channelDefPhoto(int index) {
static const ImagePtr channelDefPhotos[4] = {
ImagePtr(qsl(":/ava/art/channelcolor1.png"), "PNG"),
ImagePtr(qsl(":/ava/art/channelcolor2.png"), "PNG"),
ImagePtr(qsl(":/ava/art/channelcolor3.png"), "PNG"),
ImagePtr(qsl(":/ava/art/channelcolor4.png"), "PNG"),
static const ImagePtr channelDefPhotos[kChannelColorsCount] = {
generateUserpicImage(st::historyPeer1UserpicChannel),
generateUserpicImage(st::historyPeer2UserpicChannel),
generateUserpicImage(st::historyPeer3UserpicChannel),
generateUserpicImage(st::historyPeer4UserpicChannel),
};
return channelDefPhotos[index];
}

View File

@ -199,9 +199,11 @@ inline bool isNotifyMuted(NotifySettingsPtr settings, TimeId *changeIn = 0) {
return false;
}
static const int UserColorsCount = 8;
static constexpr int kUserColorsCount = 8;
static constexpr int kChatColorsCount = 4;
static constexpr int kChannelColorsCount = 4;
style::color peerColor(int index);
const style::color &peerColor(int index);
ImagePtr userDefPhoto(int index);
ImagePtr chatDefPhoto(int index);
ImagePtr channelDefPhoto(int index);

View File

@ -27,29 +27,38 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "pspecific.h"
namespace {
typedef QMap<QString, Image*> LocalImages;
LocalImages localImages;
typedef QMap<QString, WebImage*> WebImages;
WebImages webImages;
using LocalImages = QMap<QString, Image*>;
LocalImages localImages;
Image *blank() {
static Image *img = internal::getImage(qsl(":/gui/art/blank.gif"), "GIF");
return img;
}
using WebImages = QMap<QString, WebImage*>;
WebImages webImages;
typedef QMap<StorageKey, StorageImage*> StorageImages;
StorageImages storageImages;
int64 globalAcquiredSize = 0;
static const uint64 BlurredCacheSkip = 0x1000000000000000LLU;
static const uint64 ColoredCacheSkip = 0x2000000000000000LLU;
static const uint64 BlurredColoredCacheSkip = 0x3000000000000000LLU;
static const uint64 RoundedCacheSkip = 0x4000000000000000LLU;
static const uint64 CircledCacheSkip = 0x5000000000000000LLU;
Image *generateBlankImage() {
auto data = QImage(cIntRetinaFactor(), cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
data.fill(QColor(255, 255, 255, 0));
data.setDevicePixelRatio(cRetinaFactor());
return internal::getImage(App::pixmapFromImageInPlace(std_::move(data)), "GIF");
}
Image *blank() {
static auto blankImage = generateBlankImage();
return blankImage;
}
using StorageImages = QMap<StorageKey, StorageImage*>;
StorageImages storageImages;
int64 globalAcquiredSize = 0;
constexpr uint64 BlurredCacheSkip = 0x1000000000000000LLU;
constexpr uint64 ColoredCacheSkip = 0x2000000000000000LLU;
constexpr uint64 BlurredColoredCacheSkip = 0x3000000000000000LLU;
constexpr uint64 RoundedCacheSkip = 0x4000000000000000LLU;
constexpr uint64 CircledCacheSkip = 0x5000000000000000LLU;
} // namespace
StorageImageLocation StorageImageLocation::Null;
bool Image::isNull() const {

View File

@ -58,7 +58,6 @@
'pt-BR',
],
'travis_defines%': '',
'linux_path_breakpad%': '<(libs_loc)/breakpad',
},
'includes': [
'common_executable.gypi',
@ -86,7 +85,7 @@
'include_dirs': [
'<(src_loc)',
'<(SHARED_INTERMEDIATE_DIR)',
'<(linux_path_breakpad)/include/breakpad',
'<(libs_loc)/breakpad/src',
'<(libs_loc)/lzma/C',
'<(libs_loc)/libexif-0.6.20',
'<(libs_loc)/zlib-1.2.8',

View File

@ -31,19 +31,21 @@
'linux_path_openal%': '/usr/local',
'linux_path_libexif_lib%': '<(libs_loc)/libexif-0.6.20/libexif/.libs',
'linux_path_va%': '/usr/local',
'linux_path_breakpad%': '<(libs_loc)/breakpad',
},
'include_dirs': [
'/usr/local/include',
'<(linux_path_ffmpeg)/include',
'<(linux_path_openal)/include',
'<(linux_path_breakpad)/include/breakpad',
],
'library_dirs': [
'/usr/local/lib',
'<(linux_path_ffmpeg)/lib',
'<(linux_path_openal)/lib',
'<(linux_path_breakpad)/lib',
'<(linux_path_libexif_lib)',
'<(linux_path_va)/lib',
'<(linux_path_breakpad)/lib',
],
'libraries': [
'breakpad_client',