mac retina support improved, windows settings hidden, reply-from-notify done

This commit is contained in:
John Preston 2014-06-15 16:31:03 +04:00
parent 9f36622c08
commit 11907318b2
45 changed files with 309 additions and 177 deletions

View File

@ -161,6 +161,7 @@ lng_settings_view_emojis: "View list";
lng_settings_emoji_list: "List of supported emojis"; lng_settings_emoji_list: "List of supported emojis";
lng_settings_send_enter: "Send by Enter"; lng_settings_send_enter: "Send by Enter";
lng_settings_send_ctrlenter: "Send by Ctrl+Enter"; lng_settings_send_ctrlenter: "Send by Ctrl+Enter";
lng_settings_send_cmdenter: "Send by Cmd+Enter";
lng_settings_cats_and_dogs: "Allow cats and dogs"; lng_settings_cats_and_dogs: "Allow cats and dogs";
lng_download_path_dont_ask: "Don't ask download path for each file"; lng_download_path_dont_ask: "Don't ask download path for each file";
@ -379,3 +380,4 @@ source code is available on [a href=\"https://github.com/telegramdesktop/tdeskto
lng_about_done: "Done"; lng_about_done: "Done";
// Keys finished // Keys finished

View File

@ -19,8 +19,9 @@ defaultFontFamily: 'Segoe UI';
//defaultFontFamily: 'ThoolikaTraditionalUnicode'; //defaultFontFamily: 'ThoolikaTraditionalUnicode';
semibold: 'Segoe WP Semibold'; semibold: 'Segoe WP Semibold';
spriteFile: ':/gui/art/sprite.png' / 2:':/gui/art/sprite_125x.png' / 3:':/gui/art/sprite_150x.png' / 4:':/gui/art/sprite_200x.png'; spriteFile: ':/gui/art/sprite.png' / 2:':/gui/art/sprite_125x.png' / 3:':/gui/art/sprite_150x.png' / 4:':/gui/art/sprite_200x.png'; // exceptional value for retina
emojisFile: ':/gui/art/emoji.png' / 2:':/gui/art/emoji_125x.png' / 3:':/gui/art/emoji_150x.png' / 4:':/gui/art/emoji_200x.png'; emojisFile: ':/gui/art/emoji.png' / 2:':/gui/art/emoji_125x.png' / 3:':/gui/art/emoji_150x.png' / 4:':/gui/art/emoji_200x.png'; // exceptional value for retina
emojiImgSize: 16px; // exceptional value for retina
emojiSize: 16px; emojiSize: 16px;
emojiPadding: 1px; emojiPadding: 1px;

View File

@ -60,7 +60,7 @@ string outputTypeNames[] = {
"color", "color",
"point", "point",
"rect", "rect",
"rect", "sprite",
"size", "size",
"transition", "transition",
"cursor", "cursor",
@ -1302,7 +1302,11 @@ string prepareObject(const string &cls, Fields fields, const string &obj, int va
} else if (f.value().first != j.value()) { } else if (f.value().first != j.value()) {
throw Exception(QString("Bad type of field %1 while parsing %2").arg(j.key().c_str()).arg(obj.c_str())); throw Exception(QString("Bad type of field %1 while parsing %2").arg(j.key().c_str()).arg(obj.c_str()));
} else { } else {
result += findScalarVariant(f.value().second, variant); if (variant == -1) { // retina
result += findScalarVariant(f.value().second, (j.value() == scSprite) ? 4 : 0);
} else {
result += findScalarVariant(f.value().second, variant);
}
} }
fields.erase(f); fields.erase(f);
if (++j != e) { if (++j != e) {
@ -1518,7 +1522,7 @@ GNU General Public License for more details.\n\
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE\n\ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE\n\
Copyright (c) 2014 John Preston, https://tdesktop.com\n\ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
*/\n"; */\n";
tcpp << "#include \"stdafx.h\"\n#include \"style_auto.h\"\n\n"; tcpp << "#include \"stdafx.h\"\n#include \"style_auto.h\"\n\nnamespace {\n";
for (int i = 0, l = scalars.size(); i < l; ++i) { for (int i = 0, l = scalars.size(); i < l; ++i) {
Scalar &sc(scalars[i]); Scalar &sc(scalars[i]);
tout << "\textern const style::" << outputTypeNames[sc.second.first].c_str() << " &" << sc.first.c_str() << ";\n"; tout << "\textern const style::" << outputTypeNames[sc.second.first].c_str() << " &" << sc.first.c_str() << ";\n";
@ -1531,7 +1535,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
tout << "\textern const style::" << obj.second.first.c_str() << " &" << obj.first.c_str() << ";\n"; tout << "\textern const style::" << obj.second.first.c_str() << " &" << obj.first.c_str() << ";\n";
tcpp << "\tstyle::" << obj.second.first.c_str() << " _" << obj.first.c_str() << prepareObject(obj.second.first, obj.second.second, obj.first, variant).c_str() << ";\n"; tcpp << "\tstyle::" << obj.second.first.c_str() << " _" << obj.first.c_str() << prepareObject(obj.second.first, obj.second.second, obj.first, variant).c_str() << ";\n";
} }
tout << "\n};\n"; tout << "};\n";
tcpp << "};\n";
tcpp << "\nnamespace st {\n"; tcpp << "\nnamespace st {\n";
for (int i = 0, l = scalars.size(); i < l; ++i) { for (int i = 0, l = scalars.size(); i < l; ++i) {
@ -1543,15 +1548,33 @@ Copyright (c) 2014 John Preston, https://tdesktop.com\n\
Object &obj(objects[i]); Object &obj(objects[i]);
tcpp << "\tconst style::" << obj.second.first.c_str() << " &" << obj.first.c_str() << "(_" << obj.first.c_str() << ");\n"; tcpp << "\tconst style::" << obj.second.first.c_str() << " &" << obj.first.c_str() << "(_" << obj.first.c_str() << ");\n";
} }
tcpp << "\n};\n"; tcpp << "};\n";
tcpp << "\nnamespace style {\n\n"; tcpp << "\nnamespace style {\n\n";
tcpp << "\tFontFamilies _fontFamilies;\n"; tcpp << "\tFontFamilies _fontFamilies;\n";
tcpp << "\tFontDatas _fontsMap;\n"; tcpp << "\tFontDatas _fontsMap;\n";
tcpp << "\tColorDatas _colorsMap;\n\n"; tcpp << "\tColorDatas _colorsMap;\n\n";
tcpp << "\tvoid startManager() {\n"; tcpp << "\tvoid startManager() {\n";
tcpp << "\n\t\tswitch (cScale()) {\n\n"; tcpp << "\n\t\tif (cRetina()) {\n";
tcpp << "\t\t\tcSetRealScale(dbisOne);\n\n";
for (int i = 0, l = scalars.size(); i < l; ++i) {
Scalar &sc(scalars[i]);
if (sc.second.first == scSprite || sc.first == "spriteFile" || sc.first == "emojisFile" || sc.first == "emojiImgSize") {
string v = findScalarVariant(sc.second.second, 4);
if (v != findScalarVariant(sc.second.second, 0)) {
tcpp << "\t\t\t_" << sc.first.c_str() << " = style::" << outputTypeNames[sc.second.first].c_str() << v.c_str() << ";\n";
}
}
}
for (int i = 0, l = objects.size(); i < l; ++i) {
Object &obj(objects[i]);
string v = prepareObject(obj.second.first, obj.second.second, obj.first, -1); // retina
if (v != prepareObject(obj.second.first, obj.second.second, obj.first, 0)) {
tcpp << "\t\t\t_" << obj.first.c_str() << " = style::" << obj.second.first.c_str() << v.c_str() << ";\n";
}
}
tcpp << "\t\t} else switch (cScale()) {\n\n";
for (int i = 1; i < variantsCount; ++i) { for (int i = 1; i < variantsCount; ++i) {
variant = variants[i]; variant = variants[i];
const char *varName = variantNames[i]; const char *varName = variantNames[i];

View File

@ -1204,9 +1204,11 @@ namespace App {
if (!::sprite) { if (!::sprite) {
::sprite = new QPixmap(st::spriteFile); ::sprite = new QPixmap(st::spriteFile);
if (cRetina()) ::sprite->setDevicePixelRatio(cRetinaFactor());
} }
if (!::emojis) { if (!::emojis) {
::emojis = new QPixmap(st::emojisFile); ::emojis = new QPixmap(st::emojisFile);
if (cRetina()) ::emojis->setDevicePixelRatio(cRetinaFactor());
} }
initEmoji(); initEmoji();
} }
@ -1300,12 +1302,13 @@ namespace App {
EmojisMap *map = &(fontHeight == st::taDefFlat.font->height ? mainEmojisMap : otherEmojisMap[fontHeight]); EmojisMap *map = &(fontHeight == st::taDefFlat.font->height ? mainEmojisMap : otherEmojisMap[fontHeight]);
EmojisMap::const_iterator i = map->constFind(emoji->code); EmojisMap::const_iterator i = map->constFind(emoji->code);
if (i == map->cend()) { if (i == map->cend()) {
QImage img(st::emojiSize + st::emojiPadding * 2, fontHeight, QImage::Format_ARGB32_Premultiplied); QImage img(st::emojiImgSize + st::emojiPadding * cIntRetinaFactor() * 2, fontHeight * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
if (cRetina()) img.setDevicePixelRatio(cRetinaFactor());
{ {
QPainter p(&img); QPainter p(&img);
p.setCompositionMode(QPainter::CompositionMode_Source); p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); p.fillRect(0, 0, img.width(), img.height(), Qt::transparent);
p.drawPixmap(QPoint(st::emojiPadding, (fontHeight - st::emojiSize) / 2), App::emojis(), QRect(emoji->x, emoji->y, st::emojiSize, st::emojiSize)); p.drawPixmap(QPoint(st::emojiPadding * cIntRetinaFactor(), (fontHeight * cIntRetinaFactor() - st::emojiImgSize) / 2), App::emojis(), QRect(emoji->x, emoji->y, st::emojiImgSize, st::emojiImgSize));
} }
i = map->insert(emoji->code, QPixmap::fromImage(img)); i = map->insert(emoji->code, QPixmap::fromImage(img));
} }

View File

@ -82,9 +82,10 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
installEventFilter(new _DebugWaiter(this)); installEventFilter(new _DebugWaiter(this));
QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_ui.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_ui.ttf"));
QFontDatabase::addApplicationFont(qsl(":/gui/art/segoeuib.ttf"));
QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_ui_semibold.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_ui_semibold.ttf"));
QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_wp_semibold.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/segoe_wp_semibold.ttf"));
QFontDatabase::addApplicationFont(qsl(":/gui/art/ThoolikaTrditionalUnicode.ttf")); // QFontDatabase::addApplicationFont(qsl(":/gui/art/ThoolikaTrditionalUnicode.ttf"));
float64 dpi = primaryScreen()->logicalDotsPerInch(); float64 dpi = primaryScreen()->logicalDotsPerInch();
if (dpi <= 108) { // 0-96-108 if (dpi <= 108) { // 0-96-108
@ -97,6 +98,12 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
cSetScreenScale(dbisTwo); cSetScreenScale(dbisTwo);
} }
if (devicePixelRatio() > 1) {
cSetRetina(true);
cSetRetinaFactor(devicePixelRatio());
cSetIntRetinaFactor(int32(cRetinaFactor()));
}
if (!cLangFile().isEmpty()) { if (!cLangFile().isEmpty()) {
LangLoaderPlain loader(cLangFile()); LangLoaderPlain loader(cLangFile());
if (!loader.errors().isEmpty()) { if (!loader.errors().isEmpty()) {
@ -498,10 +505,6 @@ void Application::startApp() {
App::writeUserConfig(); App::writeUserConfig();
cSetNeedConfigResave(false); cSetNeedConfigResave(false);
} }
if (devicePixelRatio() > 1) {
cSetRetina(true);
cSetRetinaFactor(devicePixelRatio());
}
window->createWinId(); window->createWinId();
window->init(); window->init();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -80,7 +80,7 @@ void AboutBox::paintEvent(QPaintEvent *e) {
// fill bg // fill bg
p.fillRect(0, 0, _width, _height, st::boxBG->b); p.fillRect(0, 0, _width, _height, st::boxBG->b);
p.drawPixmap(QPoint((_width - st::aboutIcon.width()) / 2, st::aboutIconTop), App::sprite(), st::aboutIcon); p.drawPixmap(QPoint((_width - st::aboutIcon.pxWidth()) / 2, st::aboutIconTop), App::sprite(), st::aboutIcon);
p.setPen(st::black->p); p.setPen(st::black->p);
p.setFont(st::aboutHeaderFont->f); p.setFont(st::aboutHeaderFont->f);

View File

@ -151,7 +151,7 @@ void AddParticipantInner::paintDialog(QPainter &p, DialogRow *row, bool sel) {
data->name.drawElided(p, left + st::profileListPhotoSize + st::profileListPadding.width(), st::profileListNameTop, width() - st::participantDelta - st::profileListPadding.width() * 2 - st::profileListPhotoSize - st::profileListPadding.width() * 2); data->name.drawElided(p, left + st::profileListPhotoSize + st::profileListPadding.width(), st::profileListNameTop, width() - st::participantDelta - st::profileListPadding.width() * 2 - st::profileListPhotoSize - st::profileListPadding.width() * 2);
if (sel || data->check) { if (sel || data->check) {
p.drawPixmap(QPoint(width() - st::profileCheckRect.width() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::profileCheckRect.height()) / 2 - st::profileCheckDeltaY), App::sprite(), (data->check ? st::profileCheckActiveRect : st::profileCheckRect)); p.drawPixmap(QPoint(width() - st::profileCheckRect.pxWidth() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::profileCheckRect.pxHeight()) / 2 - st::profileCheckDeltaY), App::sprite(), (data->check ? st::profileCheckActiveRect : st::profileCheckRect));
} }
p.setFont(st::profileSubFont->f); p.setFont(st::profileSubFont->f);

View File

@ -121,10 +121,10 @@ void ContactsInner::paintDialog(QPainter &p, DialogRow *row, bool sel) {
p.drawPixmap(left, st::profileListPadding.height(), user->photo->pix(st::profileListPhotoSize)); p.drawPixmap(left, st::profileListPadding.height(), user->photo->pix(st::profileListPhotoSize));
p.setPen(st::profileListNameColor->p); p.setPen(st::profileListNameColor->p);
data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::contactsImg.width()); data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::contactsImg.pxWidth());
if (sel) { if (sel) {
p.drawPixmap(QPoint(width() - st::contactsImg.width() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::contactsImg.height()) / 2 - st::profileCheckDeltaY), App::sprite(), st::contactsImg); p.drawPixmap(QPoint(width() - st::contactsImg.pxWidth() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::contactsImg.pxHeight()) / 2 - st::profileCheckDeltaY), App::sprite(), st::contactsImg);
} }
p.setFont(st::profileSubFont->f); p.setFont(st::profileSubFont->f);

View File

@ -150,7 +150,7 @@ void EmojiBox::paintEvent(QPaintEvent *e) {
for (BlockRow::const_iterator j = i->cbegin(), en = i->cend(); j != en; ++j) { for (BlockRow::const_iterator j = i->cbegin(), en = i->cend(); j != en; ++j) {
if (j->emoji) { if (j->emoji) {
QPoint pos(left + (st::emojiReplaceWidth - st::emojiSize) / 2, top + (st::emojiReplaceHeight - _blockHeight) / 2); QPoint pos(left + (st::emojiReplaceWidth - st::emojiSize) / 2, top + (st::emojiReplaceHeight - _blockHeight) / 2);
p.drawPixmap(pos, App::emojis(), QRect(j->emoji->x, j->emoji->y, st::emojiSize, st::emojiSize)); p.drawPixmap(pos, App::emojis(), QRect(j->emoji->x, j->emoji->y, st::emojiImgSize, st::emojiImgSize));
} }
QRect trect(left, top + (st::emojiReplaceHeight + _blockHeight) / 2 - st::emojiTextFont->height, st::emojiReplaceWidth, st::emojiTextFont->height); QRect trect(left, top + (st::emojiReplaceHeight + _blockHeight) / 2 - st::emojiTextFont->height, st::emojiReplaceWidth, st::emojiTextFont->height);
p.drawText(trect, j->text, QTextOption(Qt::AlignHCenter | Qt::AlignTop)); p.drawText(trect, j->text, QTextOption(Qt::AlignHCenter | Qt::AlignTop));

View File

@ -129,10 +129,10 @@ void NewGroupInner::paintDialog(QPainter &p, DialogRow *row, bool sel) {
} else { } else {
p.setPen(st::profileListNameColor->p); p.setPen(st::profileListNameColor->p);
} }
data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::profileCheckRect.width()); data->name.drawElided(p, left + st::profileListPhotoSize + st::participantDelta, st::profileListNameTop, width() - st::profileListPadding.width() - st::profileListPhotoSize - st::profileListPadding.width() - st::participantDelta - st::scrollDef.width - st::profileCheckRect.pxWidth());
if (sel || data->check) { if (sel || data->check) {
p.drawPixmap(QPoint(width() - st::profileCheckRect.width() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::profileCheckRect.height()) / 2 - st::profileCheckDeltaY), App::sprite(), (data->check ? st::profileCheckActiveRect : st::profileCheckRect)); p.drawPixmap(QPoint(width() - st::profileCheckRect.pxWidth() - st::profileCheckDeltaX, st::profileListPadding.height() + (st::profileListPhotoSize - st::profileCheckRect.pxHeight()) / 2 - st::profileCheckDeltaY), App::sprite(), (data->check ? st::profileCheckActiveRect : st::profileCheckRect));
} }
p.setFont(st::profileSubFont->f); p.setFont(st::profileSubFont->f);

View File

@ -348,7 +348,7 @@ void EmojiPanInner::paintEvent(QPaintEvent *e) {
p.drawRoundedRect(QRect(w, st::emojiPanSize), st::emojiPanRound, st::emojiPanRound); p.drawRoundedRect(QRect(w, st::emojiPanSize), st::emojiPanRound, st::emojiPanRound);
p.setOpacity(1); p.setOpacity(1);
} }
QRect r(_emojis[index]->x, _emojis[index]->y, st::emojiSize, st::emojiSize); QRect r(_emojis[index]->x, _emojis[index]->y, st::emojiImgSize, st::emojiImgSize);
p.drawPixmap(w + QPoint((st::emojiPanSize.width() - st::emojiSize) / 2, (st::emojiPanSize.height() - st::emojiSize) / 2), App::emojis(), r); p.drawPixmap(w + QPoint((st::emojiPanSize.width() - st::emojiSize) / 2, (st::emojiPanSize.height() - st::emojiSize) / 2), App::emojis(), r);
} }
} }

View File

@ -19,7 +19,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "boxshadow.h" #include "boxshadow.h"
BoxShadow::BoxShadow(const style::rect &topLeft) : _size(topLeft.width()) { BoxShadow::BoxShadow(const style::rect &topLeft) : _size(topLeft.width() / cIntRetinaFactor()) {
QImage cornersImage(_size * 2, _size * 2, QImage::Format_ARGB32_Premultiplied); QImage cornersImage(_size * 2, _size * 2, QImage::Format_ARGB32_Premultiplied);
{ {
QPainter p(&cornersImage); QPainter p(&cornersImage);

View File

@ -26,7 +26,9 @@ namespace {
void initEmoji() { void initEmoji() {
EmojiData *toFill = emojis = (EmojiData*)emojisData; EmojiData *toFill = emojis = (EmojiData*)emojisData;
switch (cScale()) { DBIScale emojiForScale = cRetina() ? dbisTwo : cScale();
switch (emojiForScale) {
case dbisOne: case dbisOne:
new (toFill++) EmojiData(176, 0, 169, 0, 1); new (toFill++) EmojiData(176, 0, 169, 0, 1);

View File

@ -28,7 +28,7 @@ FlatCheckbox::FlatCheckbox(QWidget *parent, const QString &text, bool checked, c
setCursor(_st.cursor); setCursor(_st.cursor);
int32 w = _st.width, h = _st.height; int32 w = _st.width, h = _st.height;
if (w <= 0) w = _st.textLeft + _st.font->m.width(_text) + 1; if (w <= 0) w = _st.textLeft + _st.font->m.width(_text) + 1;
if (h <= 0) h = qMax(_st.font->height, _st.imageRect.height()); if (h <= 0) h = qMax(_st.font->height, _st.imageRect.pxHeight());
resize(QSize(w, h)); resize(QSize(w, h));
} }

View File

@ -134,7 +134,7 @@ void FlatInput::paintEvent(QPaintEvent *e) {
p.drawRect(i, i, width() - 2 * i - 1, height() - 2 * i - 1); p.drawRect(i, i, width() - 2 * i - 1, height() - 2 * i - 1);
} }
} }
if (_st.imgRect.width()) { if (_st.imgRect.pxWidth()) {
p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect); p.drawPixmap(_st.imgPos, App::sprite(), _st.imgRect);
} }

View File

@ -60,18 +60,16 @@ const QPixmap &Image::pix(int32 w, int32 h) const {
checkload(); checkload();
if (w <= 0 || !width() || !height()) { if (w <= 0 || !width() || !height()) {
w = width() * cRetinaFactor(); w = width() * cIntRetinaFactor();
} else if (cRetina()) { } else if (cRetina()) {
w *= cRetinaFactor(); w *= cIntRetinaFactor();
h *= cRetinaFactor(); h *= cIntRetinaFactor();
} }
uint64 k = (uint64(w) << 32) | uint64(h); uint64 k = (uint64(w) << 32) | uint64(h);
Sizes::const_iterator i = _sizesCache.constFind(k); Sizes::const_iterator i = _sizesCache.constFind(k);
if (i == _sizesCache.cend()) { if (i == _sizesCache.cend()) {
QPixmap p(pixNoCache(w, h, true)); QPixmap p(pixNoCache(w, h, true));
if (cRetina()) { if (cRetina()) p.setDevicePixelRatio(cRetinaFactor());
p.setDevicePixelRatio(cRetinaFactor());
}
i = _sizesCache.insert(k, p); i = _sizesCache.insert(k, p);
if (!p.isNull()) { if (!p.isNull()) {
globalAquiredSize += int64(p.width()) * p.height() * 4; globalAquiredSize += int64(p.width()) * p.height() * 4;

View File

@ -200,6 +200,32 @@ inline bool operator!=(const Font &a, const Font &b) {
typedef float64 number; typedef float64 number;
typedef QString string; typedef QString string;
typedef QRect rect; typedef QRect rect;
class sprite : public rect {
public:
sprite() {
}
sprite(int left, int top, int width, int height) : rect(left, top, width, height) {
}
inline int pxWidth() const {
return rect::width() / cIntRetinaFactor();
}
inline int pxHeight() const {
return rect::height() / cIntRetinaFactor();
}
inline QSize pxSize() const {
return rect::size() / cIntRetinaFactor();
}
private:
inline int width() const {
return rect::width();
}
inline int height() const {
return rect::height();
}
inline QSize size() const {
return rect::size();
}
};
typedef QPoint point; typedef QPoint point;
typedef QSize size; typedef QSize size;
typedef anim::transition transition; typedef anim::transition transition;

View File

@ -1405,7 +1405,7 @@ public:
} }
} }
} }
_p->drawPixmap(QPoint((glyphX + int(st::emojiPadding)).toInt(), _y + _yDelta + emojiY), App::emojis(), QRect(static_cast<EmojiBlock*>(currentBlock)->emoji->x, static_cast<EmojiBlock*>(currentBlock)->emoji->y, st::emojiSize, st::emojiSize)); _p->drawPixmap(QPoint((glyphX + int(st::emojiPadding)).toInt(), _y + _yDelta + emojiY), App::emojis(), QRect(static_cast<EmojiBlock*>(currentBlock)->emoji->x, static_cast<EmojiBlock*>(currentBlock)->emoji->y, st::emojiImgSize, st::emojiImgSize));
// } else if (_p && currentBlock->type() == TextBlockSkip) { // debug // } else if (_p && currentBlock->type() == TextBlockSkip) { // debug
// _p->fillRect(QRect(x.toInt(), _y, currentBlock->width(), static_cast<SkipBlock*>(currentBlock)->height()), QColor(0, 0, 0, 32)); // _p->fillRect(QRect(x.toInt(), _y, currentBlock->width(), static_cast<SkipBlock*>(currentBlock)->height()), QColor(0, 0, 0, 32));
} }

View File

@ -18,7 +18,6 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#pragma once #pragma once
#include "gui/emoji_config.h" #include "gui/emoji_config.h"
#include "gui/style_core.h"
#include "../../../QtStatic/qtbase/src/gui/text/qfontengine_p.h" #include "../../../QtStatic/qtbase/src/gui/text/qfontengine_p.h"

View File

@ -1522,7 +1522,7 @@ void HistoryPhoto::draw(QPainter &p, const HistoryItem *parent, const QString &t
int32 dateX = _maxw - timeWidth - st::msgDateImgDelta - 2 * st::msgDateImgPadding.x(); int32 dateX = _maxw - timeWidth - st::msgDateImgDelta - 2 * st::msgDateImgPadding.x();
int32 dateY = _height - st::msgDateFont->height - 2 * st::msgDateImgPadding.y() - st::msgDateImgDelta; int32 dateY = _height - st::msgDateFont->height - 2 * st::msgDateImgPadding.y() - st::msgDateImgDelta;
if (parent->out()) { if (parent->out()) {
dateX -= st::msgCheckRect.width() + st::msgDateImgCheckSpace; dateX -= st::msgCheckRect.pxWidth() + st::msgDateImgCheckSpace;
} }
int32 dateW = _maxw - dateX - st::msgDateImgDelta; int32 dateW = _maxw - dateX - st::msgDateImgDelta;
int32 dateH = _height - dateY - st::msgDateImgDelta; int32 dateH = _height - dateY - st::msgDateImgDelta;
@ -1532,7 +1532,7 @@ void HistoryPhoto::draw(QPainter &p, const HistoryItem *parent, const QString &t
p.setPen(st::msgDateImgColor->p); p.setPen(st::msgDateImgColor->p);
p.drawText(dateX + st::msgDateImgPadding.x(), dateY + st::msgDateImgPadding.y() + st::msgDateFont->ascent, time); p.drawText(dateX + st::msgDateImgPadding.x(), dateY + st::msgDateImgPadding.y() + st::msgDateFont->ascent, time);
if (out) { if (out) {
QPoint iconPos(dateX - 2 + dateW - st::msgDateImgCheckSpace - st::msgCheckRect.width(), dateY + (dateH - st::msgCheckRect.height()) / 2); QPoint iconPos(dateX - 2 + dateW - st::msgDateImgCheckSpace - st::msgCheckRect.pxWidth(), dateY + (dateH - st::msgCheckRect.pxHeight()) / 2);
const QRect *iconRect; const QRect *iconRect;
if (parent->id > 0) { if (parent->id > 0) {
if (parent->unread()) { if (parent->unread()) {
@ -1735,7 +1735,7 @@ void HistoryVideo::draw(QPainter &p, const HistoryItem *parent, const QString &t
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right(); int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
int32 twidth = width - tleft - st::mediaPadding.right(); int32 twidth = width - tleft - st::mediaPadding.right();
int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) + st::msgPadding.right() - st::msgDateDelta.x(); int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) + st::msgPadding.right() - st::msgDateDelta.x();
int32 secondwidth = width - tleft - fullTimeWidth; int32 secondwidth = width - tleft - fullTimeWidth;
p.setFont(st::mediaFont->f); p.setFont(st::mediaFont->f);
@ -1775,7 +1775,7 @@ void HistoryVideo::draw(QPainter &p, const HistoryItem *parent, const QString &t
p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time); p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time);
if (out) { if (out) {
QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.width(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.height()); QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.pxWidth(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.pxHeight());
const QRect *iconRect; const QRect *iconRect;
if (parent->id > 0) { if (parent->id > 0) {
if (parent->unread()) { if (parent->unread()) {
@ -1857,7 +1857,7 @@ void HistoryAudio::draw(QPainter &p, const HistoryItem *parent, const QString &t
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right(); int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
int32 twidth = width - tleft - st::mediaPadding.right(); int32 twidth = width - tleft - st::mediaPadding.right();
int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) + st::msgPadding.right() - st::msgDateDelta.x(); int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) + st::msgPadding.right() - st::msgDateDelta.x();
int32 secondwidth = width - tleft - fullTimeWidth; int32 secondwidth = width - tleft - fullTimeWidth;
p.setFont(st::mediaFont->f); p.setFont(st::mediaFont->f);
@ -1897,7 +1897,7 @@ void HistoryAudio::draw(QPainter &p, const HistoryItem *parent, const QString &t
p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time); p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time);
if (out) { if (out) {
QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.width(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.height()); QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.pxWidth(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.pxHeight());
const QRect *iconRect; const QRect *iconRect;
if (parent->id > 0) { if (parent->id > 0) {
if (parent->unread()) { if (parent->unread()) {
@ -2048,7 +2048,8 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, const QString
p.fillRect(0, _height, width, st::msgShadow, shadow->b); p.fillRect(0, _height, width, st::msgShadow, shadow->b);
if (_thumbw) { if (_thumbw) {
p.drawPixmap(QPoint(st::mediaPadding.left(), st::mediaPadding.top()), data->thumb->pix(_thumbw), QRect(_thumbx, _thumby, st::mediaThumbSize, st::mediaThumbSize)); int32 rf(cIntRetinaFactor());
p.drawPixmap(QPoint(st::mediaPadding.left(), st::mediaPadding.top()), data->thumb->pix(_thumbw), QRect(_thumbx * rf, _thumby * rf, st::mediaThumbSize * rf, st::mediaThumbSize * rf));
} else { } else {
p.drawPixmap(QPoint(st::mediaPadding.left(), st::mediaPadding.top()), App::sprite(), (out ? st::mediaDocOutImg : st::mediaDocInImg)); p.drawPixmap(QPoint(st::mediaPadding.left(), st::mediaPadding.top()), App::sprite(), (out ? st::mediaDocOutImg : st::mediaDocInImg));
} }
@ -2058,7 +2059,7 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, const QString
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right(); int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
int32 twidth = width - tleft - st::mediaPadding.right(); int32 twidth = width - tleft - st::mediaPadding.right();
int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) + st::msgPadding.right() - st::msgDateDelta.x(); int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) + st::msgPadding.right() - st::msgDateDelta.x();
int32 secondwidth = width - tleft - fullTimeWidth; int32 secondwidth = width - tleft - fullTimeWidth;
p.setFont(st::mediaFont->f); p.setFont(st::mediaFont->f);
@ -2102,7 +2103,7 @@ void HistoryDocument::draw(QPainter &p, const HistoryItem *parent, const QString
p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time); p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time);
if (out) { if (out) {
QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.width(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.height()); QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.pxWidth(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.pxHeight());
const QRect *iconRect; const QRect *iconRect;
if (parent->id > 0) { if (parent->id > 0) {
if (parent->unread()) { if (parent->unread()) {
@ -2197,7 +2198,7 @@ HistoryContact::HistoryContact(int32 userId, const QString &first, const QString
void HistoryContact::initDimensions(const HistoryItem *parent, int32 timeWidth) { void HistoryContact::initDimensions(const HistoryItem *parent, int32 timeWidth) {
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right(); int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
int32 fullTimeWidth = timeWidth + st::msgDateSpace + (parent->out() ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) + st::msgPadding.right() - st::msgDateDelta.x(); int32 fullTimeWidth = timeWidth + st::msgDateSpace + (parent->out() ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) + st::msgPadding.right() - st::msgDateDelta.x();
if (name.maxWidth() + tleft + fullTimeWidth > _maxw) { if (name.maxWidth() + tleft + fullTimeWidth > _maxw) {
_maxw = name.maxWidth() + tleft + fullTimeWidth; _maxw = name.maxWidth() + tleft + fullTimeWidth;
} }
@ -2256,7 +2257,7 @@ void HistoryContact::draw(QPainter &p, const HistoryItem *parent, const QString
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right(); int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
int32 twidth = width - tleft - st::mediaPadding.right(); int32 twidth = width - tleft - st::mediaPadding.right();
int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) + st::msgPadding.right() - st::msgDateDelta.x(); int32 fullTimeWidth = timeWidth + st::msgDateSpace + (out ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) + st::msgPadding.right() - st::msgDateDelta.x();
int32 secondwidth = width - tleft - fullTimeWidth; int32 secondwidth = width - tleft - fullTimeWidth;
p.setFont(st::mediaFont->f); p.setFont(st::mediaFont->f);
@ -2279,7 +2280,7 @@ void HistoryContact::draw(QPainter &p, const HistoryItem *parent, const QString
p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time); p.drawText(width + st::msgDateDelta.x() - fullTimeWidth + st::msgDateSpace, _height - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time);
if (out) { if (out) {
QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.width(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.height()); QPoint iconPos(width + 5 - st::msgPadding.right() - st::msgCheckRect.pxWidth(), _height + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.pxHeight());
const QRect *iconRect; const QRect *iconRect;
if (parent->id > 0) { if (parent->id > 0) {
if (parent->unread()) { if (parent->unread()) {
@ -2383,7 +2384,7 @@ void HistoryMessage::initDimensions(const QString &text) {
_maxw = media->maxWidth(); _maxw = media->maxWidth();
_minh = media->height(); _minh = media->height();
} else { } else {
timeWidth += st::msgDateSpace + (out() ? st::msgDateCheckSpace + st::msgCheckRect.width() : 0) - st::msgDateDelta.x(); timeWidth += st::msgDateSpace + (out() ? st::msgDateCheckSpace + st::msgCheckRect.pxWidth() : 0) - st::msgDateDelta.x();
_text.setText(st::msgFont, text + textcmdSkipBlock(timeWidth, st::msgDateFont->height - st::msgDateDelta.y()), _historyTextOptions); _text.setText(st::msgFont, text + textcmdSkipBlock(timeWidth, st::msgDateFont->height - st::msgDateDelta.y()), _historyTextOptions);
_maxw = _text.maxWidth(); _maxw = _text.maxWidth();
_minh = _text.minHeight(); _minh = _text.minHeight();
@ -2470,7 +2471,7 @@ void HistoryMessage::draw(QPainter &p, uint32 selection) const {
p.drawText(r.right() - st::msgPadding.right() + st::msgDateDelta.x() - timeWidth + st::msgDateSpace, r.bottom() - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time); p.drawText(r.right() - st::msgPadding.right() + st::msgDateDelta.x() - timeWidth + st::msgDateSpace, r.bottom() - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgDateFont->descent, time);
if (_out) { if (_out) {
QPoint iconPos(r.right() + 5 - st::msgPadding.right() - st::msgCheckRect.width(), r.bottom() + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.height()); QPoint iconPos(r.right() + 5 - st::msgPadding.right() - st::msgCheckRect.pxWidth(), r.bottom() + 1 - st::msgPadding.bottom() + st::msgDateDelta.y() - st::msgCheckRect.pxHeight());
const QRect *iconRect; const QRect *iconRect;
if (id > 0) { if (id > 0) {
if (unread()) { if (unread()) {

View File

@ -72,7 +72,7 @@ void HistoryList::paintEvent(QPaintEvent *e) {
} }
if (hist->isEmpty()) { if (hist->isEmpty()) {
QPoint dogPos((width() - st::msgDogImg.width()) / 2, ((height() - st::msgDogImg.height()) * 4) / 9); QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - st::msgDogImg.pxHeight()) * 4) / 9);
p.drawPixmap(dogPos, App::sprite(), st::msgDogImg); p.drawPixmap(dogPos, App::sprite(), st::msgDogImg);
} else { } else {
adjustCurrent(r.top()); adjustCurrent(r.top());
@ -1746,20 +1746,7 @@ void HistoryWidget::historyToDown(History *history) {
} }
void HistoryWidget::historyWasRead(bool force) { void HistoryWidget::historyWasRead(bool force) {
if (histReadRequestId || !hist || !force && (!hist->unreadCount || !hist->unreadLoaded)) return; App::main()->readServerHistory(hist, force);
hist->inboxRead(true);
histReadRequestId = MTP::send(MTPmessages_ReadHistory(histPeer->input, MTP_int(0), MTP_int(0)), rpcDone(&HistoryWidget::partWasRead, histPeer));
}
void HistoryWidget::partWasRead(PeerData *peer, const MTPmessages_AffectedHistory &result) {
const MTPDmessages_affectedHistory &d(result.c_messages_affectedHistory());
App::main()->updUpdated(d.vpts.v, 0, 0, d.vseq.v);
histReadRequestId = 0;
int32 offset = d.voffset.v;
if (!MTP::authedId() || offset <= 0) return;
histReadRequestId = MTP::send(MTPmessages_ReadHistory(peer->input, MTP_int(0), MTP_int(offset)), rpcDone(&HistoryWidget::partWasRead, peer));
} }
bool HistoryWidget::messagesFailed(const RPCError &e, mtpRequestId requestId) { bool HistoryWidget::messagesFailed(const RPCError &e, mtpRequestId requestId) {
@ -1906,9 +1893,7 @@ void HistoryWidget::onVisibleChanged() {
QTimer::singleShot(0, this, SLOT(onListScroll())); QTimer::singleShot(0, this, SLOT(onListScroll()));
} }
QString HistoryWidget::prepareMessage() { QString HistoryWidget::prepareMessage(QString result) {
QString result = _field.getText();
result = result.replace('\t', qsl(" ")); result = result.replace('\t', qsl(" "));
result = result.replace(" --", QString::fromUtf8(" \xe2\x80\x94")); result = result.replace(" --", QString::fromUtf8(" \xe2\x80\x94"));
@ -1922,7 +1907,7 @@ QString HistoryWidget::prepareMessage() {
void HistoryWidget::onSend() { void HistoryWidget::onSend() {
if (!hist) return; if (!hist) return;
QString text = prepareMessage(); QString text = prepareMessage(_field.getText());
if (!text.isEmpty()) { if (!text.isEmpty()) {
MsgId newId = clientMsgId(); MsgId newId = clientMsgId();
uint64 randomId = MTP::nonce<uint64>(); uint64 randomId = MTP::nonce<uint64>();
@ -2314,7 +2299,7 @@ void HistoryWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth)
if (!decreaseWidth) { if (!decreaseWidth) {
p.setOpacity(st::topBarForwardAlpha + (1 - st::topBarForwardAlpha) * over); p.setOpacity(st::topBarForwardAlpha + (1 - st::topBarForwardAlpha) * over);
p.drawPixmap(QPoint(width() - (st::topBarForwardPadding.right() + st::topBarForwardImg.width()) / 2, (st::topBarHeight - st::topBarForwardImg.height()) / 2), App::sprite(), st::topBarForwardImg); p.drawPixmap(QPoint(width() - (st::topBarForwardPadding.right() + st::topBarForwardImg.pxWidth()) / 2, (st::topBarHeight - st::topBarForwardImg.pxHeight()) / 2), App::sprite(), st::topBarForwardImg);
} }
} }
@ -2790,11 +2775,11 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
p.fillRect(0, _field.y() - st::sendPadding, width(), _field.height() + 2 * st::sendPadding, st::taMsgField.bgColor->b); p.fillRect(0, _field.y() - st::sendPadding, width(), _field.height() + 2 * st::sendPadding, st::taMsgField.bgColor->b);
} }
} else { } else {
QPoint dogPos((width() - st::msgDogImg.width()) / 2, ((height() - _field.height() - 2 * st::sendPadding - st::msgDogImg.height()) * 4) / 9); QPoint dogPos((width() - st::msgDogImg.pxWidth()) / 2, ((height() - _field.height() - 2 * st::sendPadding - st::msgDogImg.pxHeight()) * 4) / 9);
p.drawPixmap(dogPos, App::sprite(), st::msgDogImg); p.drawPixmap(dogPos, App::sprite(), st::msgDogImg);
int32 pointsCount = 8, w = pointsCount * (st::introPointWidth + 2 * st::introPointDelta), h = st::introPointHeight; int32 pointsCount = 8, w = pointsCount * (st::introPointWidth + 2 * st::introPointDelta), h = st::introPointHeight;
int32 pointsLeft = (width() - w) / 2 + st::introPointDelta - st::introPointLeft, pointsTop = dogPos.y() + (st::msgDogImg.height() * 6) / 5; int32 pointsLeft = (width() - w) / 2 + st::introPointDelta - st::introPointLeft, pointsTop = dogPos.y() + (st::msgDogImg.pxHeight() * 6) / 5;
int32 curPoint = histRequestsCount % pointsCount; int32 curPoint = histRequestsCount % pointsCount;

View File

@ -311,6 +311,8 @@ public:
void noSelectingScroll(); void noSelectingScroll();
bool touchScroll(const QPoint &delta); bool touchScroll(const QPoint &delta);
QString prepareMessage(QString text);
~HistoryWidget(); ~HistoryWidget();
@ -365,7 +367,6 @@ public slots:
private: private:
bool messagesFailed(const RPCError &error, mtpRequestId requestId); bool messagesFailed(const RPCError &error, mtpRequestId requestId);
void partWasRead(PeerData *peer, const MTPmessages_AffectedHistory &result);
void updateListSize(int32 addToY = 0, bool initial = false); void updateListSize(int32 addToY = 0, bool initial = false);
void addMessagesToFront(const QVector<MTPMessage> &messages); void addMessagesToFront(const QVector<MTPMessage> &messages);
void chatLoaded(const MTPmessages_ChatFull &res); void chatLoaded(const MTPmessages_ChatFull &res);
@ -375,8 +376,6 @@ private:
void updateDragAreas(); void updateDragAreas();
QString prepareMessage();
int32 histOffset, histCount, histReadRequestId; int32 histOffset, histCount, histReadRequestId;
int32 histRequestsCount; int32 histRequestsCount;
PeerData *histPeer, *_activePeer; PeerData *histPeer, *_activePeer;

View File

@ -124,7 +124,7 @@ void IntroSignup::paintEvent(QPaintEvent *e) {
void IntroSignup::resizeEvent(QResizeEvent *e) { void IntroSignup::resizeEvent(QResizeEvent *e) {
textRect = QRect((width() - st::introTextSize.width()) / 2, 0, st::introTextSize.width(), st::introTextSize.height()); textRect = QRect((width() - st::introTextSize.width()) / 2, 0, st::introTextSize.width(), st::introTextSize.height());
_phLeft = (width() - st::setPhotoImg.width()) / 2; _phLeft = (width() - st::setPhotoImg.pxWidth()) / 2;
_phTop = st::introHeaderFont->height + st::introFinishSkip; _phTop = st::introHeaderFont->height + st::introFinishSkip;
if (e->oldSize().width() != width()) { if (e->oldSize().width() != width()) {
int sumNext = st::btnIntroNext.width - st::btnIntroBack.width - st::btnIntroSep; int sumNext = st::btnIntroNext.width - st::btnIntroBack.width - st::btnIntroSep;
@ -132,7 +132,7 @@ void IntroSignup::resizeEvent(QResizeEvent *e) {
} }
if (e->oldSize().width() != width()) { if (e->oldSize().width() != width()) {
next.move((width() - next.width()) / 2, st::introSize.height() - st::btnIntroNext.height); next.move((width() - next.width()) / 2, st::introSize.height() - st::btnIntroNext.height);
first.move((width() - first.width()) / 2, _phTop + st::setPhotoImg.height() + st::introFinishSkip); first.move((width() - first.width()) / 2, _phTop + st::setPhotoImg.pxHeight() + st::introFinishSkip);
last.move((width() - last.width()) / 2, first.y() + first.height() + st::introFinishSkip); last.move((width() - last.width()) / 2, first.y() + first.height() + st::introFinishSkip);
} }
} }

View File

@ -496,16 +496,52 @@ void MainWidget::clearSelectedItems() {
history.onClearSelected(); history.onClearSelected();
} }
QRect MainWidget::rectForTitleAnim() const {
int w = width();
w -= history.x() + st::sysBtnDelta * 2 + st::sysCls.img.width() + st::sysRes.img.width() + st::sysMin.img.width();
return QRect(history.x(), 0, w, App::wnd()->getTitle()->height());
}
DialogsIndexed &MainWidget::contactsList() { DialogsIndexed &MainWidget::contactsList() {
return dialogs.contactsList(); return dialogs.contactsList();
} }
void MainWidget::sendMessage(History *hist, const QString &text) {
readServerHistory(hist);
QString msg = history.prepareMessage(text);
if (!msg.isEmpty()) {
MsgId newId = clientMsgId();
uint64 randomId = MTP::nonce<uint64>();
App::historyRegRandom(randomId, newId);
MTPstring msgText(MTP_string(msg));
hist->addToBack(MTP_message(MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(hist->peer->id), MTP_bool(true), MTP_bool(true), MTP_int(unixtime()), msgText, MTP_messageMediaEmpty()));
historyToDown(hist);
if (history.peer() == hist->peer) {
history.peerMessagesUpdated();
}
MTP::send(MTPmessages_SendMessage(hist->peer->input, msgText, MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentDataReceived, randomId));
}
}
void MainWidget::readServerHistory(History *hist, bool force) {
if (!hist || (!force && (!hist->unreadCount || !hist->unreadLoaded))) return;
ReadRequests::const_iterator i = _readRequests.constFind(hist->peer);
if (i == _readRequests.cend()) {
hist->inboxRead(true);
_readRequests.insert(hist->peer, MTP::send(MTPmessages_ReadHistory(hist->peer->input, MTP_int(0), MTP_int(0)), rpcDone(&MainWidget::partWasRead, hist->peer)));
}
}
void MainWidget::partWasRead(PeerData *peer, const MTPmessages_AffectedHistory &result) {
const MTPDmessages_affectedHistory &d(result.c_messages_affectedHistory());
App::main()->updUpdated(d.vpts.v, 0, 0, d.vseq.v);
int32 offset = d.voffset.v;
if (!MTP::authedId() || offset <= 0) {
_readRequests.remove(peer);
} else {
_readRequests[peer] = MTP::send(MTPmessages_ReadHistory(peer->input, MTP_int(0), MTP_int(offset)), rpcDone(&MainWidget::partWasRead, peer));
}
}
void MainWidget::videoLoadProgress(mtpFileLoader *loader) { void MainWidget::videoLoadProgress(mtpFileLoader *loader) {
VideoData *video = App::video(loader->objId()); VideoData *video = App::video(loader->objId());
if (video->loader) { if (video->loader) {
@ -619,7 +655,7 @@ void MainWidget::onParentResize(const QSize &newSize) {
} }
void MainWidget::updateOnlineDisplay() { void MainWidget::updateOnlineDisplay() {
history.updateOnlineDisplay(history.x(), width() - history.x() - st::sysBtnDelta * 2 - st::sysCls.img.width() - st::sysRes.img.width() - st::sysMin.img.width()); history.updateOnlineDisplay(history.x(), width() - history.x() - st::sysBtnDelta * 2 - st::sysCls.img.pxWidth() - st::sysRes.img.pxWidth() - st::sysMin.img.pxWidth());
if (profile) profile->updateOnlineDisplay(); if (profile) profile->updateOnlineDisplay();
if (App::wnd()->settingsWidget()) App::wnd()->settingsWidget()->updateOnlineDisplay(); if (App::wnd()->settingsWidget()) App::wnd()->settingsWidget()->updateOnlineDisplay();
} }

View File

@ -187,9 +187,11 @@ public:
void deleteSelectedItems(); void deleteSelectedItems();
void clearSelectedItems(); void clearSelectedItems();
QRect rectForTitleAnim() const;
DialogsIndexed &contactsList(); DialogsIndexed &contactsList();
void sendMessage(History *history, const QString &text);
void readServerHistory(History *history, bool force = true);
~MainWidget(); ~MainWidget();
@ -233,6 +235,8 @@ public slots:
private: private:
void partWasRead(PeerData *peer, const MTPmessages_AffectedHistory &result);
uint64 failedObjId; uint64 failedObjId;
QString failedFileName; QString failedFileName;
void loadFailed(mtpFileLoader *loader, bool started, const char *retrySlot); void loadFailed(mtpFileLoader *loader, bool started, const char *retrySlot);
@ -278,4 +282,7 @@ private:
QSet<PeerData*> updateNotifySettingPeers; QSet<PeerData*> updateNotifySettingPeers;
QTimer updateNotifySettingTimer; QTimer updateNotifySettingTimer;
typedef QMap<PeerData*, mtpRequestId> ReadRequests;
ReadRequests _readRequests;
}; };

View File

@ -761,10 +761,10 @@ void ProfileWidget::paintTopBar(QPainter &p, float64 over, int32 decreaseWidth)
p.drawPixmap(a_coord.current(), 0, _animTopBarCache); p.drawPixmap(a_coord.current(), 0, _animTopBarCache);
} else { } else {
p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over); p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over);
p.drawPixmap(QPoint(st::topBarBackPadding.left(), (st::topBarHeight - st::topBarBackImg.height()) / 2), App::sprite(), st::topBarBackImg); p.drawPixmap(QPoint(st::topBarBackPadding.left(), (st::topBarHeight - st::topBarBackImg.pxHeight()) / 2), App::sprite(), st::topBarBackImg);
p.setFont(st::topBarBackFont->f); p.setFont(st::topBarBackFont->f);
p.setPen(st::topBarBackColor->p); p.setPen(st::topBarBackColor->p);
p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.width() + st::topBarBackPadding.right(), (st::topBarHeight - st::titleFont->height) / 2 + st::titleFont->ascent, lang(peer()->chat ? lng_profile_group_info : lng_profile_info)); p.drawText(st::topBarBackPadding.left() + st::topBarBackImg.pxWidth() + st::topBarBackPadding.right(), (st::topBarHeight - st::titleFont->height) / 2 + st::titleFont->ascent, lang(peer()->chat ? lng_profile_group_info : lng_profile_info));
} }
} }

View File

@ -112,7 +112,9 @@ void MacPrivate::notifyClicked(unsigned long long peer) {
} }
void MacPrivate::notifyReplied(unsigned long long peer, const char *str) { void MacPrivate::notifyReplied(unsigned long long peer, const char *str) {
History *history = App::history(PeerId(peer));
App::main()->sendMessage(history, QString::fromUtf8(str));
} }
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent), PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
@ -283,7 +285,7 @@ void PsMainWindow::psInitFrameless() {
connect(&psUpdatedPositionTimer, SIGNAL(timeout()), this, SLOT(psSavePosition())); connect(&psUpdatedPositionTimer, SIGNAL(timeout()), this, SLOT(psSavePosition()));
if (frameless) { if (frameless) {
// setWindowFlags(Qt::FramelessWindowHint); //setWindowFlags(Qt::FramelessWindowHint);
} }
connect(windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(psStateChanged(Qt::WindowState))); connect(windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(psStateChanged(Qt::WindowState)));
@ -348,6 +350,7 @@ void PsMainWindow::psFirstShow() {
bool showShadows = true; bool showShadows = true;
show(); show();
_private.enableShadow(winId());
if (cWindowPos().maximized) { if (cWindowPos().maximized) {
setWindowState(Qt::WindowMaximized); setWindowState(Qt::WindowMaximized);
} }
@ -371,7 +374,7 @@ void PsMainWindow::psFirstShow() {
} }
bool PsMainWindow::psHandleTitle() { bool PsMainWindow::psHandleTitle() {
return true; return false;
} }
void PsMainWindow::psInitSysMenu() { void PsMainWindow::psInitSysMenu() {
@ -685,10 +688,8 @@ PsNotifyWindow::PsNotifyWindow(HistoryItem *item, int32 x, int32 y) : history(it
alphaDuration(st::notifyFastAnim), posDuration(st::notifyFastAnim), aY(y + st::notifyHeight + st::notifyDeltaY), close(this, st::notifyClose), aOpacityFunc(st::notifyFastAnimFunc) { alphaDuration(st::notifyFastAnim), posDuration(st::notifyFastAnim), aY(y + st::notifyHeight + st::notifyDeltaY), close(this, st::notifyClose), aOpacityFunc(st::notifyFastAnimFunc) {
int32 w = st::notifyWidth, h = st::notifyHeight; int32 w = st::notifyWidth, h = st::notifyHeight;
QImage img(w * cRetinaFactor(), h * cRetinaFactor(), QImage::Format_ARGB32_Premultiplied); QImage img(w * cIntRetinaFactor(), h * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
if (cRetina()) { if (cRetina()) img.setDevicePixelRatio(cRetinaFactor());
img.setDevicePixelRatio(cRetinaFactor());
}
img.fill(st::notifyBG->c); img.fill(st::notifyBG->c);
{ {

View File

@ -32,6 +32,8 @@ public:
void activateWnd(WId winId); void activateWnd(WId winId);
void showNotify(unsigned long long peer, const char *utf8title, const char *subtitle, const char *utf8msg); void showNotify(unsigned long long peer, const char *utf8title, const char *subtitle, const char *utf8msg);
void clearNotifies(unsigned long long peer = 0); void clearNotifies(unsigned long long peer = 0);
void enableShadow(WId winId);
virtual void activeSpaceChanged() { virtual void activeSpaceChanged() {
} }

View File

@ -57,7 +57,9 @@ public:
} }
void onNotifyReply(NSUserNotification *notification) { void onNotifyReply(NSUserNotification *notification) {
// notification.response NSNumber *peerObj = [[notification userInfo] objectForKey:@"peer"];
unsigned long long peerLong = [peerObj unsignedLongLongValue];
wnd->notifyReplied(peerLong, [[[notification response] string] UTF8String]);
} }
~PsMacWindowData() { ~PsMacWindowData() {
@ -165,7 +167,7 @@ void PsMacWindowPrivate::showNotify(unsigned long long peer, const char *utf8tit
[notification setInformativeText:msg]; [notification setInformativeText:msg];
[msg release]; [msg release];
// [notification setHasReplyButton:YES]; [notification setHasReplyButton:YES];
[notification setSoundName:nil]; [notification setSoundName:nil];
@ -175,6 +177,11 @@ void PsMacWindowPrivate::showNotify(unsigned long long peer, const char *utf8tit
[notification release]; [notification release];
} }
void PsMacWindowPrivate::enableShadow(WId winId) {
// [[(NSView*)winId window] setStyleMask:NSBorderlessWindowMask];
// [[(NSView*)winId window] setHasShadow:YES];
}
void PsMacWindowPrivate::clearNotifies(unsigned long long peer) { void PsMacWindowPrivate::clearNotifies(unsigned long long peer) {
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
if (peer) { if (peer) {

View File

@ -67,6 +67,7 @@ QString gLangFile;
bool gRetina = false; bool gRetina = false;
float64 gRetinaFactor = 1.; float64 gRetinaFactor = 1.;
int32 gIntRetinaFactor = 1;
bool gCustomNotifies = false; bool gCustomNotifies = false;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -132,6 +132,7 @@ DeclareReadSetting(QString, LangFile);
DeclareSetting(bool, Retina); DeclareSetting(bool, Retina);
DeclareSetting(float64, RetinaFactor); DeclareSetting(float64, RetinaFactor);
DeclareSetting(int32, IntRetinaFactor);
DeclareSetting(bool, CustomNotifies); DeclareSetting(bool, CustomNotifies);
DeclareReadSetting(DBIPlatform, Platform); DeclareReadSetting(DBIPlatform, Platform);

View File

@ -32,7 +32,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
Slider::Slider(QWidget *parent, const style::slider &st, int32 count, int32 sel) : QWidget(parent), Slider::Slider(QWidget *parent, const style::slider &st, int32 count, int32 sel) : QWidget(parent),
_count(count), _sel(snap(sel, 0, _count)), _wasSel(_sel), _st(st), _pressed(false) { _count(count), _sel(snap(sel, 0, _count)), _wasSel(_sel), _st(st), _pressed(false) {
resize(_st.width, _st.bar.height()); resize(_st.width, _st.bar.pxHeight());
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
} }
@ -43,7 +43,7 @@ void Slider::mousePressEvent(QMouseEvent *e) {
void Slider::mouseMoveEvent(QMouseEvent *e) { void Slider::mouseMoveEvent(QMouseEvent *e) {
if (_pressed) { if (_pressed) {
int32 newSel = snap(qRound((_count - 1) * float64(e->pos().x() - _st.bar.width() / 2) / (width() - _st.bar.width())), 0, _count - 1); int32 newSel = snap(qRound((_count - 1) * float64(e->pos().x() - _st.bar.pxWidth() / 2) / (width() - _st.bar.pxWidth())), 0, _count - 1);
if (newSel != _sel) { if (newSel != _sel) {
_sel = newSel; _sel = newSel;
update(); update();
@ -81,7 +81,7 @@ void Slider::paintEvent(QPaintEvent *e) {
p.drawLine(0, i, width() - 1, i); p.drawLine(0, i, width() - 1, i);
} }
int32 x = qFloor(_sel * float64(width() - _st.bar.width()) / (_count - 1)), y = (height() - _st.bar.height()) / 2; int32 x = qFloor(_sel * float64(width() - _st.bar.pxWidth()) / (_count - 1)), y = (height() - _st.bar.pxHeight()) / 2;
p.drawPixmap(QPoint(x, y), App::sprite(), _st.bar); p.drawPixmap(QPoint(x, y), App::sprite(), _st.bar);
} }
@ -135,7 +135,7 @@ SettingsInner::SettingsInner(Settings *parent) : QWidget(parent),
_viewEmojis(this, lang(lng_settings_view_emojis)), _viewEmojis(this, lang(lng_settings_view_emojis)),
_enterSend(this, qsl("send_key"), 0, lang(lng_settings_send_enter), !cCtrlEnter()), _enterSend(this, qsl("send_key"), 0, lang(lng_settings_send_enter), !cCtrlEnter()),
_ctrlEnterSend(this, qsl("send_key"), 1, lang(lng_settings_send_ctrlenter), cCtrlEnter()), _ctrlEnterSend(this, qsl("send_key"), 1, lang((cPlatform() == dbipMac) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), cCtrlEnter()),
_downloadPathWidth(st::linkFont->m.width(lang(lng_download_path_label))), _downloadPathWidth(st::linkFont->m.width(lang(lng_download_path_label))),
_dontAskDownloadPath(this, lang(lng_download_path_dont_ask), !cAskDownloadPath()), _dontAskDownloadPath(this, lang(lng_download_path_dont_ask), !cAskDownloadPath()),
@ -345,36 +345,40 @@ void SettingsInner::paintEvent(QPaintEvent *e) {
p.drawText(_left + st::setVersionLeft, top + st::setVersionTop + st::linkFont->ascent, textToDraw); p.drawText(_left + st::setVersionLeft, top + st::setVersionTop + st::linkFont->ascent, textToDraw);
top += st::setVersionHeight; top += st::setVersionHeight;
top += _workmodeTray.height() + st::setLittleSkip; if (cPlatform() == dbipWindows) {
top += _workmodeWindow.height() + st::setSectionSkip; top += _workmodeTray.height() + st::setLittleSkip;
top += _workmodeWindow.height() + st::setSectionSkip;
top += _autoStart.height() + st::setLittleSkip;
top += _startMinimized.height(); top += _autoStart.height() + st::setLittleSkip;
top += _startMinimized.height();
p.setFont(st::setHeaderFont->f); }
p.setPen(st::setHeaderColor->p);
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_scale_label)); if (!cRetina()) {
top += st::setHeaderSkip; p.setFont(st::setHeaderFont->f);
top += _dpiAutoScale.height() + st::setLittleSkip; p.setPen(st::setHeaderColor->p);
p.drawText(_left + st::setHeaderLeft, top + st::setHeaderTop + st::setHeaderFont->ascent, lang(lng_settings_scale_label));
top += _dpiSlider.height() + st::dpiFont4->height; top += st::setHeaderSkip;
int32 sLeft = _dpiSlider.x() + _dpiWidth1 / 2, sWidth = _dpiSlider.width(); top += _dpiAutoScale.height() + st::setLittleSkip;
float64 sStep = (sWidth - _dpiWidth1 / 2 - _dpiWidth4 / 2) / float64(dbisScaleCount - 2);
p.setFont(st::dpiFont1->f); top += _dpiSlider.height() + st::dpiFont4->height;
int32 sLeft = _dpiSlider.x() + _dpiWidth1 / 2, sWidth = _dpiSlider.width();
p.setPen((scaleIs(dbisOne) ? st::dpiActive : st::dpiInactive)->p); float64 sStep = (sWidth - _dpiWidth1 / 2 - _dpiWidth4 / 2) / float64(dbisScaleCount - 2);
p.drawText(sLeft + qRound(0 * sStep) - _dpiWidth1 / 2, top - (st::dpiFont4->height - st::dpiFont1->height) / 2 - st::dpiFont1->descent, scaleLabel(dbisOne)); p.setFont(st::dpiFont1->f);
p.setFont(st::dpiFont2->f);
p.setPen((scaleIs(dbisOneAndQuarter) ? st::dpiActive : st::dpiInactive)->p); p.setPen((scaleIs(dbisOne) ? st::dpiActive : st::dpiInactive)->p);
p.drawText(sLeft + qRound(1 * sStep) - _dpiWidth2 / 2, top - (st::dpiFont4->height - st::dpiFont2->height) / 2 - st::dpiFont2->descent, scaleLabel(dbisOneAndQuarter)); p.drawText(sLeft + qRound(0 * sStep) - _dpiWidth1 / 2, top - (st::dpiFont4->height - st::dpiFont1->height) / 2 - st::dpiFont1->descent, scaleLabel(dbisOne));
p.setFont(st::dpiFont3->f); p.setFont(st::dpiFont2->f);
p.setPen((scaleIs(dbisOneAndHalf) ? st::dpiActive : st::dpiInactive)->p); p.setPen((scaleIs(dbisOneAndQuarter) ? st::dpiActive : st::dpiInactive)->p);
p.drawText(sLeft + qRound(2 * sStep) - _dpiWidth3 / 2, top - (st::dpiFont4->height - st::dpiFont3->height) / 2 - st::dpiFont3->descent, scaleLabel(dbisOneAndHalf)); p.drawText(sLeft + qRound(1 * sStep) - _dpiWidth2 / 2, top - (st::dpiFont4->height - st::dpiFont2->height) / 2 - st::dpiFont2->descent, scaleLabel(dbisOneAndQuarter));
p.setFont(st::dpiFont4->f); p.setFont(st::dpiFont3->f);
p.setPen((scaleIs(dbisTwo) ? st::dpiActive : st::dpiInactive)->p); p.setPen((scaleIs(dbisOneAndHalf) ? st::dpiActive : st::dpiInactive)->p);
p.drawText(sLeft + qRound(3 * sStep) - _dpiWidth4 / 2, top - (st::dpiFont4->height - st::dpiFont4->height) / 2 - st::dpiFont4->descent, scaleLabel(dbisTwo)); p.drawText(sLeft + qRound(2 * sStep) - _dpiWidth3 / 2, top - (st::dpiFont4->height - st::dpiFont3->height) / 2 - st::dpiFont3->descent, scaleLabel(dbisOneAndHalf));
p.setFont(st::linkFont->f); p.setFont(st::dpiFont4->f);
p.setPen((scaleIs(dbisTwo) ? st::dpiActive : st::dpiInactive)->p);
p.drawText(sLeft + qRound(3 * sStep) - _dpiWidth4 / 2, top - (st::dpiFont4->height - st::dpiFont4->height) / 2 - st::dpiFont4->descent, scaleLabel(dbisTwo));
p.setFont(st::linkFont->f);
}
if (_self) { if (_self) {
// chat options // chat options
p.setFont(st::setHeaderFont->f); p.setFont(st::setHeaderFont->f);
@ -451,16 +455,19 @@ void SettingsInner::resizeEvent(QResizeEvent *e) {
_restartNow.move(_left + st::setWidth - _restartNow.width(), top + st::setVersionTop); _restartNow.move(_left + st::setWidth - _restartNow.width(), top + st::setVersionTop);
top += st::setVersionHeight; top += st::setVersionHeight;
_workmodeTray.move(_left, top); top += _workmodeTray.height() + st::setLittleSkip; if (cPlatform() == dbipWindows) {
_workmodeWindow.move(_left, top); top += _workmodeWindow.height() + st::setSectionSkip; _workmodeTray.move(_left, top); top += _workmodeTray.height() + st::setLittleSkip;
_workmodeWindow.move(_left, top); top += _workmodeWindow.height() + st::setSectionSkip;
_autoStart.move(_left, top); top += _autoStart.height() + st::setLittleSkip;
_startMinimized.move(_left, top); top += _startMinimized.height(); _autoStart.move(_left, top); top += _autoStart.height() + st::setLittleSkip;
_startMinimized.move(_left, top); top += _startMinimized.height();
top += st::setHeaderSkip; }
_dpiAutoScale.move(_left, top); top += _dpiAutoScale.height() + st::setLittleSkip; if (!cRetina()) {
_dpiSlider.move(_left, top); top += _dpiSlider.height() + st::dpiFont4->height; top += st::setHeaderSkip;
_dpiAutoScale.move(_left, top); top += _dpiAutoScale.height() + st::setLittleSkip;
_dpiSlider.move(_left, top); top += _dpiSlider.height() + st::dpiFont4->height;
}
// chat options // chat options
if (_self) { if (_self) {
top += st::setHeaderSkip; top += st::setHeaderSkip;
@ -625,14 +632,27 @@ void SettingsInner::showAll() {
// general // general
_autoUpdate.show(); _autoUpdate.show();
_workmodeTray.show();
_workmodeWindow.show();
_autoStart.show();
setUpdatingState(_updatingState, true); setUpdatingState(_updatingState, true);
_startMinimized.show(); if (cPlatform() == dbipWindows) {
_dpiSlider.show(); _workmodeTray.show();
_workmodeWindow.show();
_autoStart.show();
_startMinimized.show();
} else {
_workmodeTray.hide();
_workmodeWindow.hide();
_autoStart.hide();
_startMinimized.hide();
}
if (cRetina()) {
_dpiSlider.hide();
_dpiAutoScale.hide();
} else {
_dpiSlider.show();
_dpiAutoScale.show();
}
// chat options // chat options
if (_self) { if (_self) {

View File

@ -45,8 +45,8 @@ void SysBtn::onStateChange(int oldState, ButtonStateChangeSource source) {
void SysBtn::paintEvent(QPaintEvent *e) { void SysBtn::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
int x = (width() - _st.img.width()) / 2, y = (height() - _st.img.height()) / 2; int x = (width() - _st.img.pxWidth()) / 2, y = (height() - _st.img.pxHeight()) / 2;
p.fillRect(x, y, _st.img.width(), _st.img.height(), a_color.current()); p.fillRect(x, y, _st.img.pxWidth(), _st.img.pxHeight(), a_color.current());
p.drawPixmap(QPoint(x, y), App::sprite(), _st.img); p.drawPixmap(QPoint(x, y), App::sprite(), _st.img);
} }

View File

@ -1,6 +1,7 @@
<RCC> <RCC>
<qresource prefix="/gui"> <qresource prefix="/gui">
<file>art/segoe_ui.ttf</file> <file>art/segoe_ui.ttf</file>
<file>art/segoeuib.ttf</file>
<file>art/segoe_ui_semibold.ttf</file> <file>art/segoe_ui_semibold.ttf</file>
<file>art/segoe_wp_semibold.ttf</file> <file>art/segoe_wp_semibold.ttf</file>
<file>art/newmsg.wav</file> <file>art/newmsg.wav</file>

View File

@ -76,6 +76,13 @@ TitleWidget::TitleWidget(Window *window)
connect(&_about, SIGNAL(clicked()), this, SLOT(onAbout())); connect(&_about, SIGNAL(clicked()), this, SLOT(onAbout()));
connect(wnd->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(stateChanged(Qt::WindowState))); connect(wnd->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(stateChanged(Qt::WindowState)));
connect(App::app(), SIGNAL(updateReady()), this, SLOT(showUpdateBtn())); connect(App::app(), SIGNAL(updateReady()), this, SLOT(showUpdateBtn()));
if (cPlatform() == dbipMac) {
_minimize.hide();
_maximize.hide();
_restore.hide();
_close.hide();
}
} }
void TitleWidget::paintEvent(QPaintEvent *e) { void TitleWidget::paintEvent(QPaintEvent *e) {
@ -118,17 +125,19 @@ TitleWidget::~TitleWidget() {
} }
void TitleWidget::resizeEvent(QResizeEvent *e) { void TitleWidget::resizeEvent(QResizeEvent *e) {
QPoint p(width() - (lastMaximized ? 0 : st::sysBtnDelta), 0); QPoint p(width() - ((cPlatform() == dbipWindows && lastMaximized) ? 0 : st::sysBtnDelta), 0);
p.setX(p.x() - _close.width()); if (cPlatform() != dbipMac) {
_close.move(p); p.setX(p.x() - _close.width());
_close.move(p);
p.setX(p.x() - _maximize.width());
_restore.move(p); _maximize.move(p); p.setX(p.x() - _maximize.width());
_restore.move(p); _maximize.move(p);
p.setX(p.x() - _minimize.width());
_minimize.move(p); p.setX(p.x() - _minimize.width());
_minimize.move(p);
}
if (!_update.isHidden()) { if (!_update.isHidden()) {
p.setX(p.x() - _update.width()); p.setX(p.x() - _update.width());
_update.move(p); _update.move(p);
@ -184,6 +193,8 @@ void TitleWidget::maximizedChanged(bool maximized) {
if (lastMaximized == maximized) return; if (lastMaximized == maximized) return;
lastMaximized = maximized; lastMaximized = maximized;
if (cPlatform() == dbipMac) return;
if (maximized) { if (maximized) {
_maximize.clearState(); _maximize.clearState();
} else { } else {
@ -202,7 +213,7 @@ HitTestType TitleWidget::hitTest(const QPoint &p) {
int x(p.x()), y(p.y()), w(width()), h(height() - st::titleShadow); int x(p.x()), y(p.y()), w(width()), h(height() - st::titleShadow);
if (hider && x >= App::main()->dlgsWidth()) return HitTestNone; if (hider && x >= App::main()->dlgsWidth()) return HitTestNone;
if (x >= st::titleIconPos.x() && y >= st::titleIconPos.y() && x < st::titleIconPos.x() + st::titleIconRect.width() && y < st::titleIconPos.y() + st::titleIconRect.height()) { if (x >= st::titleIconPos.x() && y >= st::titleIconPos.y() && x < st::titleIconPos.x() + st::titleIconRect.pxWidth() && y < st::titleIconPos.y() + st::titleIconRect.pxHeight()) {
return HitTestIcon; return HitTestIcon;
} else if (false } else if (false
|| (_update.hitTest(p - _update.geometry().topLeft()) == HitTestSysButton) && _update.isVisible() || (_update.hitTest(p - _update.geometry().topLeft()) == HitTestSysButton) && _update.isVisible()

View File

@ -43,20 +43,20 @@ void ConnectingWidget::set(const QString &text, const QString &reconnect) {
} else { } else {
_reconnect.setText(reconnect); _reconnect.setText(reconnect);
_reconnect.show(); _reconnect.show();
_reconnect.move(st::connectingPadding.left() + _textWidth, st::boxShadow.height() + st::connectingPadding.top()); _reconnect.move(st::connectingPadding.left() + _textWidth, st::boxShadow.pxHeight() + st::connectingPadding.top());
_reconnectWidth = _reconnect.width(); _reconnectWidth = _reconnect.width();
} }
resize(st::connectingPadding.left() + _textWidth + _reconnectWidth + st::connectingPadding.right() + st::boxShadow.width(), st::boxShadow.height() + st::connectingPadding.top() + st::linkFont->height + st::connectingPadding.bottom()); resize(st::connectingPadding.left() + _textWidth + _reconnectWidth + st::connectingPadding.right() + st::boxShadow.pxWidth(), st::boxShadow.pxHeight() + st::connectingPadding.top() + st::linkFont->height + st::connectingPadding.bottom());
update(); update();
} }
void ConnectingWidget::paintEvent(QPaintEvent *e) { void ConnectingWidget::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
_shadow.paint(p, QRect(0, st::boxShadow.height(), width() - st::boxShadow.width(), height() - st::boxShadow.height()), QPoint(0, 0), BoxShadow::Top | BoxShadow::Right); _shadow.paint(p, QRect(0, st::boxShadow.pxHeight(), width() - st::boxShadow.pxWidth(), height() - st::boxShadow.pxHeight()), QPoint(0, 0), BoxShadow::Top | BoxShadow::Right);
p.fillRect(0, st::boxShadow.height(), width() - st::boxShadow.width(), height() - st::boxShadow.height(), st::connectingBG->b); p.fillRect(0, st::boxShadow.pxHeight(), width() - st::boxShadow.pxWidth(), height() - st::boxShadow.pxHeight(), st::connectingBG->b);
p.setFont(st::linkFont->f); p.setFont(st::linkFont->f);
p.setPen(st::connectingColor->p); p.setPen(st::connectingColor->p);
p.drawText(st::connectingPadding.left(), st::boxShadow.height() + st::connectingPadding.top() + st::linkFont->ascent, _text); p.drawText(st::connectingPadding.left(), st::boxShadow.pxHeight() + st::connectingPadding.top() + st::linkFont->ascent, _text);
} }
void ConnectingWidget::onReconnect() { void ConnectingWidget::onReconnect() {
@ -438,7 +438,7 @@ bool Window::getVideoCoords(VideoData *video, int32 &x, int32 &y, int32 &w) cons
} }
QRect Window::iconRect() const { QRect Window::iconRect() const {
return QRect(st::titleIconPos + title->geometry().topLeft(), st::titleIconRect.size()); return QRect(st::titleIconPos + title->geometry().topLeft(), st::titleIconRect.pxSize());
} }
bool Window::eventFilter(QObject *obj, QEvent *evt) { bool Window::eventFilter(QObject *obj, QEvent *evt) {

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.5.1</string> <string>0.5.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>NOTE</key> <key>NOTE</key>

View File

@ -38,7 +38,7 @@
02F93BF511880983D3C57B84 /* dialogswidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = E466873F01ABA1E55E914489 /* dialogswidget.cpp */; settings = {ATTRIBUTES = (); }; }; 02F93BF511880983D3C57B84 /* dialogswidget.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = E466873F01ABA1E55E914489 /* dialogswidget.cpp */; settings = {ATTRIBUTES = (); }; };
03270F718426CFE84729079E /* flattextarea.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 5C7FD422BBEDA858D7237AE9 /* flattextarea.cpp */; settings = {ATTRIBUTES = (); }; }; 03270F718426CFE84729079E /* flattextarea.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 5C7FD422BBEDA858D7237AE9 /* flattextarea.cpp */; settings = {ATTRIBUTES = (); }; };
06EABCC49D2EEE4076322BE7 /* moc_mtp.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 924D4939FD169BB4B8AEB1C9 /* moc_mtp.cpp */; settings = {ATTRIBUTES = (); }; }; 06EABCC49D2EEE4076322BE7 /* moc_mtp.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 924D4939FD169BB4B8AEB1C9 /* moc_mtp.cpp */; settings = {ATTRIBUTES = (); }; };
07C3AF26194336250016CFF1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 07C3AF24194335ED0016CFF1 /* Images.xcassets */; }; 0749CE69194D723400345D61 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 07C3AF24194335ED0016CFF1 /* Images.xcassets */; };
0A49F3A5DC0680FB31519670 /* phoneinput.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 7C8F9CA4FCE8AF8FCCCB961E /* phoneinput.cpp */; settings = {ATTRIBUTES = (); }; }; 0A49F3A5DC0680FB31519670 /* phoneinput.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 7C8F9CA4FCE8AF8FCCCB961E /* phoneinput.cpp */; settings = {ATTRIBUTES = (); }; };
0CB7DE9A54CC9BF86FB7B5CA /* mtp.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 6D50D70712776D7ED3B00E5C /* mtp.cpp */; settings = {ATTRIBUTES = (); }; }; 0CB7DE9A54CC9BF86FB7B5CA /* mtp.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 6D50D70712776D7ED3B00E5C /* mtp.cpp */; settings = {ATTRIBUTES = (); }; };
0F0FC25286E16E5F78962FEE /* moc_newgroupbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 69FE16874104731CE2A66E0D /* moc_newgroupbox.cpp */; settings = {ATTRIBUTES = (); }; }; 0F0FC25286E16E5F78962FEE /* moc_newgroupbox.cpp in Compile Sources */ = {isa = PBXBuildFile; fileRef = 69FE16874104731CE2A66E0D /* moc_newgroupbox.cpp */; settings = {ATTRIBUTES = (); }; };
@ -1141,7 +1141,6 @@
87DF60DE337FB58864343E39 /* Resources */, 87DF60DE337FB58864343E39 /* Resources */,
AF39DD055C3EF8226FBE929D /* Frameworks */, AF39DD055C3EF8226FBE929D /* Frameworks */,
FE0A091FDBFB3E9C31B7A1BD /* Products */, FE0A091FDBFB3E9C31B7A1BD /* Products */,
07C3AF40194CCC310016CFF1 /* Preprocess copy-Info.plist */,
); );
name = Telegram; name = Telegram;
sourceTree = "<Group>"; sourceTree = "<Group>";
@ -1208,7 +1207,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
07C3AF26194336250016CFF1 /* Images.xcassets in Resources */, 0749CE69194D723400345D61 /* Images.xcassets in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1491,7 +1490,7 @@
"/usr/local/Qt-5.3.0/plugins/imageformats", "/usr/local/Qt-5.3.0/plugins/imageformats",
); );
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ./../Mac/DebugIntermediate/; OBJROOT = "./../Mac/$(CONFIGURATION)Intermediate";
OTHER_CFLAGS = ( OTHER_CFLAGS = (
"-pipe", "-pipe",
"-g", "-g",
@ -1542,7 +1541,7 @@
PRODUCT_NAME = Telegram; PRODUCT_NAME = Telegram;
QT_LIBRARY_SUFFIX = ""; QT_LIBRARY_SUFFIX = "";
SDKROOT = macosx; SDKROOT = macosx;
SYMROOT = ./; SYMROOT = ./../Mac;
}; };
name = Release; name = Release;
}; };
@ -1595,7 +1594,7 @@
"/usr/local/Qt-5.3.0/plugins/imageformats", "/usr/local/Qt-5.3.0/plugins/imageformats",
); );
MACOSX_DEPLOYMENT_TARGET = 10.7; MACOSX_DEPLOYMENT_TARGET = 10.7;
OBJROOT = ./../Mac/DebugIntermediate/; OBJROOT = "./../Mac/$(CONFIGURATION)Intermediate";
OTHER_CFLAGS = ( OTHER_CFLAGS = (
"-pipe", "-pipe",
"-g", "-g",
@ -1646,7 +1645,7 @@
PRODUCT_NAME = Telegram; PRODUCT_NAME = Telegram;
QT_LIBRARY_SUFFIX = _debug; QT_LIBRARY_SUFFIX = _debug;
SDKROOT = macosx; SDKROOT = macosx;
SYMROOT = ./; SYMROOT = ./../Mac;
}; };
name = Debug; name = Debug;
}; };
@ -1655,8 +1654,10 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.5.1; CURRENT_PROJECT_VERSION = 0.5.2;
DYLIB_CURRENT_VERSION = 0.5.2;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
LLVM_LTO = YES; LLVM_LTO = YES;
@ -1673,9 +1674,11 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.5.1; CURRENT_PROJECT_VERSION = 0.5.2;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_CURRENT_VERSION = 0.5.2;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
OBJROOT = ./../Mac/DebugIntermediate; OBJROOT = ./../Mac/DebugIntermediate;