mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
started photoviewer redesign
This commit is contained in:
parent
8bc0410830
commit
782c254ea0
30 changed files with 1233 additions and 1108 deletions
|
@ -527,12 +527,16 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
"lng_search_found_results" = "{count:No messages found|Found # message|Found # messages}";
|
"lng_search_found_results" = "{count:No messages found|Found # message|Found # messages}";
|
||||||
"lng_search_global_results" = "Global search results";
|
"lng_search_global_results" = "Global search results";
|
||||||
|
|
||||||
"lng_mediaview_save" = "Download";
|
"lng_mediaview_save_as" = "Save as..";
|
||||||
|
"lng_mediaview_copy" = "Copy";
|
||||||
"lng_mediaview_forward" = "Forward";
|
"lng_mediaview_forward" = "Forward";
|
||||||
"lng_mediaview_delete" = "Delete";
|
"lng_mediaview_delete" = "Delete";
|
||||||
|
"lng_mediaview_photos_all" = "View all photos";
|
||||||
|
"lng_mediaview_files_all" = "View all files";
|
||||||
"lng_mediaview_single_photo" = "Single Photo";
|
"lng_mediaview_single_photo" = "Single Photo";
|
||||||
"lng_mediaview_group_photo" = "Group Photo";
|
"lng_mediaview_group_photo" = "Group Photo";
|
||||||
"lng_mediaview_profile_photo" = "Profile Photo";
|
"lng_mediaview_profile_photo" = "Profile Photo";
|
||||||
|
"lng_mediaview_file_n_of_count" = "{file} {n} of {count}";
|
||||||
"lng_mediaview_n_of_count" = "Photo {n} of {count}";
|
"lng_mediaview_n_of_count" = "Photo {n} of {count}";
|
||||||
"lng_mediaview_doc_image" = "File";
|
"lng_mediaview_doc_image" = "File";
|
||||||
"lng_mediaview_today" = "today at {time}";
|
"lng_mediaview_today" = "today at {time}";
|
||||||
|
|
|
@ -1361,12 +1361,16 @@ connectingBG: #fffe;
|
||||||
connectingColor: #777;
|
connectingColor: #777;
|
||||||
connectingPadding: margins(5px, 5px, 5px, 5px);
|
connectingPadding: margins(5px, 5px, 5px, 5px);
|
||||||
|
|
||||||
dropdownPadding: margins(10px, 10px, 10px, 10px);
|
dropdownDef: dropdown {
|
||||||
dropdownShadow: sprite(241px, 46px, 6px, 6px);
|
border: 1px;
|
||||||
dropdownBorder: 1px;
|
borderColor: #ebebeb;
|
||||||
dropdownBorderColor: #ebebeb;
|
|
||||||
dropdownBackground: white;
|
padding: margins(10px, 10px, 10px, 10px);
|
||||||
dropdownDuration: 150;
|
shadow: sprite(241px, 46px, 6px, 6px);
|
||||||
|
|
||||||
|
duration: 150;
|
||||||
|
width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
dropdownAttachDocument: iconedButton(btnAttachDocument) {
|
dropdownAttachDocument: iconedButton(btnAttachDocument) {
|
||||||
iconPos: point(14px, 13px);
|
iconPos: point(14px, 13px);
|
||||||
|
@ -1555,18 +1559,82 @@ stickerPanPadding: 2px;
|
||||||
stickerPanDelete: sprite(158px, 197px, 12px, 12px);
|
stickerPanDelete: sprite(158px, 197px, 12px, 12px);
|
||||||
stickerPanDeleteOpacity: 0.5;
|
stickerPanDeleteOpacity: 0.5;
|
||||||
|
|
||||||
medviewNavBarWidth: 132px;
|
mvBgColor: #222;
|
||||||
medviewLightNav: 0.5;
|
mvBgOpacity: 0.92;
|
||||||
medviewDarkNav: 1;
|
mvThickFont: font(fsize semibold);
|
||||||
medviewHeaderFont: font(semibold 18px);
|
mvFont: font(fsize);
|
||||||
medviewNameFont: font(16px);
|
|
||||||
medviewDateFont: font(14px);
|
mvTextLeft: 16px;
|
||||||
medviewNameTop: 13px;
|
mvTextSkip: 10px;
|
||||||
medviewDateTop: 39px;
|
mvHeaderTop: 48px;
|
||||||
medviewLeft: sprite(340px, 79px, 28px, 48px);
|
mvTextTop: 24px;
|
||||||
medviewRight: sprite(368px, 79px, 28px, 48px);
|
mvTextColor: white;
|
||||||
medviewDeltaFromLastAction: 5px;
|
mvTextOpacity: 0.5;
|
||||||
medviewSwipeDistance: 80px;
|
mvTextOverOpacity: 1;
|
||||||
|
|
||||||
|
mvIconOpacity: 0.45;
|
||||||
|
mvIconOverOpacity: 1;
|
||||||
|
mvControlBgColor: black;
|
||||||
|
mvControlBgOpacity: 0.3;
|
||||||
|
mvControlMargin: 0px;
|
||||||
|
mvControlSize: 90px;
|
||||||
|
mvIconSize: size(60px, 56px);
|
||||||
|
|
||||||
|
mvLeft: sprite(320px, 400px, 12px, 22px);
|
||||||
|
mvRight: sprite(332px, 400px, 12px, 22px);
|
||||||
|
mvClose: sprite(344px, 400px, 18px, 18px);
|
||||||
|
mvSave: sprite(362px, 400px, 14px, 19px);
|
||||||
|
mvMore: sprite(376px, 400px, 5px, 21px);
|
||||||
|
|
||||||
|
mvDropdown: dropdown(dropdownDef) {
|
||||||
|
shadow: sprite(0px, 0px, 0px, 0px);
|
||||||
|
padding: margins(11px, 12px, 11px, 12px);
|
||||||
|
|
||||||
|
border: 0;
|
||||||
|
width: 182px;
|
||||||
|
}
|
||||||
|
mvButton: iconedButton(btnDefIconed) {
|
||||||
|
bgColor: #383838;
|
||||||
|
overBgColor: #505050;
|
||||||
|
font: font(fsize);
|
||||||
|
|
||||||
|
opacity: 1;
|
||||||
|
overOpacity: 1;
|
||||||
|
|
||||||
|
width: -32px;
|
||||||
|
height: 36px;
|
||||||
|
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
textPos: point(16px, 9px);
|
||||||
|
downTextPos: point(16px, 10px);
|
||||||
|
|
||||||
|
duration: 0;
|
||||||
|
}
|
||||||
|
mvContextButton: iconedButton(mvButton) {
|
||||||
|
bgColor: #383838E6;
|
||||||
|
overBgColor: #505050E7;
|
||||||
|
}
|
||||||
|
mvWaitHide: 2000;
|
||||||
|
mvHideDuration: 1000;
|
||||||
|
mvShowDuration: 200;
|
||||||
|
mvFadeDuration: 150;
|
||||||
|
|
||||||
|
mvDocPadding: 18px;
|
||||||
|
mvDocSize: size(340px, 116px);
|
||||||
|
mvDocBg: white;
|
||||||
|
mvDocNameTop: 5px;
|
||||||
|
mvDocNameColor: black;
|
||||||
|
mvDocSizeTop: 30px;
|
||||||
|
mvDocSizeColor: #808080;
|
||||||
|
mvDocLinksTop: 57px;
|
||||||
|
mvDocRed: sprite(0px, 400px, 80px, 80px);
|
||||||
|
mvDocYellow: sprite(80px, 400px, 80px, 80px);
|
||||||
|
mvDocGreen: sprite(160px, 400px, 80px, 80px);
|
||||||
|
mvDocBlue: sprite(240px, 400px, 80px, 80px);
|
||||||
|
|
||||||
|
mvDeltaFromLastAction: 5px;
|
||||||
|
mvSwipeDistance: 80px;
|
||||||
|
|
||||||
medviewSaveMsgCheck: sprite(341px, 174px, 22px, 18px);
|
medviewSaveMsgCheck: sprite(341px, 174px, 22px, 18px);
|
||||||
medviewSaveMsgFont: font(16px);
|
medviewSaveMsgFont: font(16px);
|
||||||
|
@ -1578,87 +1646,7 @@ medviewSaveMsgShown: 2000;
|
||||||
medviewSaveMsgHiding: 2500;
|
medviewSaveMsgHiding: 2500;
|
||||||
medviewSaveMsg: #000000b2;
|
medviewSaveMsg: #000000b2;
|
||||||
|
|
||||||
medviewOverview: iconedButton(btnDefIconed) {
|
mvTransparentBrush: sprite(148px, 197px, 8px, 8px);
|
||||||
bgColor: #0000;
|
|
||||||
overBgColor: #00000040;
|
|
||||||
font: font(16px);
|
|
||||||
|
|
||||||
opacity: 0.77;
|
|
||||||
overOpacity: 1;
|
|
||||||
|
|
||||||
icon: sprite(340px, 129px, 19px, 19px);
|
|
||||||
iconPos: point(16px, 14px);
|
|
||||||
downIcon: sprite(340px, 129px, 19px, 19px);
|
|
||||||
downIconPos: point(16px, 14px);
|
|
||||||
|
|
||||||
width: -69px;
|
|
||||||
height: 47px;
|
|
||||||
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
textPos: point(51px, 13px);
|
|
||||||
downTextPos: point(51px, 14px);
|
|
||||||
}
|
|
||||||
medviewForward: iconedButton(medviewOverview) {
|
|
||||||
icon: sprite(357px, 58px, 22px, 17px);
|
|
||||||
iconPos: point(16px, 15px);
|
|
||||||
downIcon: sprite(357px, 58px, 22px, 17px);
|
|
||||||
downIconPos: point(16px, 15px);
|
|
||||||
|
|
||||||
width: -69px;
|
|
||||||
}
|
|
||||||
medviewDelete: iconedButton(medviewForward) {
|
|
||||||
icon: sprite(340px, 58px, 15px, 19px);
|
|
||||||
iconPos: point(16px, 14px);
|
|
||||||
downIcon: sprite(340px, 58px, 15px, 19px);
|
|
||||||
downIconPos: point(16px, 14px);
|
|
||||||
}
|
|
||||||
medviewClose: iconedButton(medviewOverview) {
|
|
||||||
icon: sprite(340px, 0px, 56px, 56px);
|
|
||||||
iconPos: point(0px, 0px);
|
|
||||||
downIcon: sprite(340px, 0px, 56px, 56px);
|
|
||||||
downIconPos: point(0px, 0px);
|
|
||||||
|
|
||||||
opacity: 0.6;
|
|
||||||
|
|
||||||
width: 56px;
|
|
||||||
height: 56px;
|
|
||||||
}
|
|
||||||
medviewBottomBar: 87px;
|
|
||||||
medviewBG: #272727D9;
|
|
||||||
medviewBottomBG: #272727;
|
|
||||||
medviewNavOpacity: 0.6;
|
|
||||||
medviewCloseOpacity: 0.6;
|
|
||||||
medviewNavBGOpacity: 0.4;
|
|
||||||
medviewNavOverOpacity: 1;
|
|
||||||
medviewCloseOverOpacity: 1;
|
|
||||||
medviewNameColor: black;
|
|
||||||
medviewDateColor: #999;
|
|
||||||
medviewSaveAs: iconedButton(medviewOverview) {
|
|
||||||
bgColor: #38abe6;
|
|
||||||
overBgColor: #299fdc;
|
|
||||||
|
|
||||||
opacity: 1;
|
|
||||||
|
|
||||||
icon: sprite(361px, 129px, 12px, 19px);
|
|
||||||
iconPos: point(18px, 15px);
|
|
||||||
downIcon: sprite(361px, 129px, 12px, 19px);
|
|
||||||
downIconPos: point(18px, 15px);
|
|
||||||
|
|
||||||
width: -62px;
|
|
||||||
height: 47px;
|
|
||||||
|
|
||||||
textPos: point(44px, 13px);
|
|
||||||
downTextPos: point(44px, 14px);
|
|
||||||
}
|
|
||||||
medviewSaveAsDisabledOpacity: 0.8;
|
|
||||||
medviewPolaroid: margins(17px, 18px, 17px, 72px);
|
|
||||||
medviewPolaroidMin: size(480px, 360px);
|
|
||||||
medviewDocumentSprite: sprite(341px, 150px, 20px, 22px);
|
|
||||||
medviewDocumentSpritePos: point(16px, 13px);
|
|
||||||
medviewPhotoSprite: sprite(363px, 150px, 23px, 20px);
|
|
||||||
medviewPhotoSpritePos: point(14px, 14px);
|
|
||||||
medviewTransparentBrush: sprite(148px, 197px, 8px, 8px);
|
|
||||||
|
|
||||||
overviewPhotoSkip: 10px;
|
overviewPhotoSkip: 10px;
|
||||||
overviewPhotoMinSize: 100px;
|
overviewPhotoMinSize: 100px;
|
||||||
|
@ -1704,6 +1692,12 @@ photoLoaderDuration1: 150; // ms fade in
|
||||||
photoLoaderDuration2: 150; // ms fade out
|
photoLoaderDuration2: 150; // ms fade out
|
||||||
photoLoaderAlphaMin: 0.1; // not less than that
|
photoLoaderAlphaMin: 0.1; // not less than that
|
||||||
|
|
||||||
|
radialSize: size(50px, 50px);
|
||||||
|
radialLine: 2px;
|
||||||
|
radialDuration: 200;
|
||||||
|
radialPeriod: 2000;
|
||||||
|
radialBgOpacity: 0.4;
|
||||||
|
|
||||||
overviewLoader: size(34px, 14px);
|
overviewLoader: size(34px, 14px);
|
||||||
overviewLoaderPoint: size(4px, 4px);
|
overviewLoaderPoint: size(4px, 4px);
|
||||||
overviewLoaderSkip: 4px;
|
overviewLoaderSkip: 4px;
|
||||||
|
|
|
@ -246,3 +246,14 @@ switcher {
|
||||||
|
|
||||||
duration: number;
|
duration: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dropdown {
|
||||||
|
border: number;
|
||||||
|
borderColor: color;
|
||||||
|
|
||||||
|
padding: margins;
|
||||||
|
shadow: sprite;
|
||||||
|
|
||||||
|
duration: number;
|
||||||
|
width: number;
|
||||||
|
}
|
||||||
|
|
|
@ -448,6 +448,7 @@ static const char *variantNames[] = { "dbisOne", "dbisOneAndQuarter", "dbisOneAn
|
||||||
static const char *variantPostfixes[] = { "", "_125x", "_150x", "_200x" };
|
static const char *variantPostfixes[] = { "", "_125x", "_150x", "_200x" };
|
||||||
QPixmap *spriteMax = 0;
|
QPixmap *spriteMax = 0;
|
||||||
QImage *variantSprites = 0;
|
QImage *variantSprites = 0;
|
||||||
|
int *spriteWidths = 0;
|
||||||
QImage *variantGrids = 0;
|
QImage *variantGrids = 0;
|
||||||
|
|
||||||
void readStyleGenToken(const char *&from, const char *end, StyleGenTokenType &tokenType, string &token) {
|
void readStyleGenToken(const char *&from, const char *end, StyleGenTokenType &tokenType, string &token) {
|
||||||
|
@ -1353,17 +1354,22 @@ bool genStyles(const QString &classes_in, const QString &classes_out, const QStr
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage sprites[variantsCount];
|
QImage sprites[variantsCount];
|
||||||
|
int widths[variantsCount] = { 0 };
|
||||||
variantSprites = sprites;
|
variantSprites = sprites;
|
||||||
|
spriteWidths = widths;
|
||||||
|
|
||||||
QString sprite0(path_to_sprites + "sprite" + QString(variantPostfixes[0]) + ".png"), spriteLast(path_to_sprites + "sprite" + QString(variantPostfixes[variantsCount - 1]) + ".png");
|
QString sprite0(path_to_sprites + "sprite" + QString(variantPostfixes[0]) + ".png"), spriteLast(path_to_sprites + "sprite" + QString(variantPostfixes[variantsCount - 1]) + ".png");
|
||||||
variantSprites[0] = QImage(sprite0);
|
variantSprites[0] = QImage(sprite0);
|
||||||
|
spriteWidths[0] = variantSprites[0].width();
|
||||||
for (int i = 1; i < variantsCount - 1; ++i) {
|
for (int i = 1; i < variantsCount - 1; ++i) {
|
||||||
variantSprites[i] = QImage(adjustPx(variants[i], variantSprites[0].width(), true), adjustPx(variants[i], variantSprites[0].height(), true), QImage::Format_ARGB32_Premultiplied);
|
variantSprites[i] = QImage(adjustPx(variants[i], variantSprites[0].width(), true), adjustPx(variants[i], variantSprites[0].height(), true), QImage::Format_ARGB32_Premultiplied);
|
||||||
|
spriteWidths[i] = variantSprites[i].width();
|
||||||
QPainter p(&variantSprites[i]);
|
QPainter p(&variantSprites[i]);
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
p.fillRect(0, 0, variantSprites[i].width(), variantSprites[i].height(), Qt::transparent);
|
p.fillRect(0, 0, variantSprites[i].width(), variantSprites[i].height(), Qt::transparent);
|
||||||
}
|
}
|
||||||
variantSprites[variantsCount - 1] = QImage(spriteLast);
|
variantSprites[variantsCount - 1] = QImage(spriteLast);
|
||||||
|
spriteWidths[variantsCount - 1] = variantSprites[variantsCount - 1].width();
|
||||||
|
|
||||||
QPixmap spriteMaxPix = QPixmap::fromImage(variantSprites[variantsCount - 1], Qt::ColorOnly);
|
QPixmap spriteMaxPix = QPixmap::fromImage(variantSprites[variantsCount - 1], Qt::ColorOnly);
|
||||||
spriteMax = &spriteMaxPix;
|
spriteMax = &spriteMaxPix;
|
||||||
|
@ -1567,11 +1573,13 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org\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";
|
||||||
|
tcpp << "int _spriteWidth = " << spriteWidths[0] << ";\n\n";
|
||||||
tcpp << "\tvoid startManager() {\n";
|
tcpp << "\tvoid startManager() {\n";
|
||||||
|
|
||||||
tcpp << "\n\t\tif (cRetina()) {\n";
|
tcpp << "\n\t\tif (cRetina()) {\n";
|
||||||
tcpp << "\t\t\tcSetRealScale(dbisOne);\n\n";
|
tcpp << "\t\t\tcSetRealScale(dbisOne);\n";
|
||||||
|
tcpp << "\t\t\t_spriteWidth = " << spriteWidths[variantsCount - 1] << ";\n\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]);
|
||||||
if (sc.second.first == scSprite || sc.first == "spriteFile" || sc.first == "emojisFile" || sc.first == "emojiImgSize") {
|
if (sc.second.first == scSprite || sc.first == "spriteFile" || sc.first == "emojisFile" || sc.first == "emojiImgSize") {
|
||||||
|
@ -1594,6 +1602,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org\n\
|
||||||
const char *varName = variantNames[i];
|
const char *varName = variantNames[i];
|
||||||
|
|
||||||
tcpp << "\t\tcase " << varName << ":\n";
|
tcpp << "\t\tcase " << varName << ":\n";
|
||||||
|
tcpp << "\t\t\t_spriteWidth = " << spriteWidths[i] << ";\n\n";
|
||||||
|
|
||||||
typedef QMap<string, int> FontFamilies;
|
typedef QMap<string, int> FontFamilies;
|
||||||
FontFamilies fontFamilies;
|
FontFamilies fontFamilies;
|
||||||
|
|
|
@ -1515,7 +1515,11 @@ namespace App {
|
||||||
audioInit();
|
audioInit();
|
||||||
|
|
||||||
if (!::sprite) {
|
if (!::sprite) {
|
||||||
::sprite = new QPixmap(st::spriteFile);
|
if (rtl()) {
|
||||||
|
::sprite = new QPixmap(QPixmap::fromImage(QImage(st::spriteFile).mirrored(true, false)));
|
||||||
|
} else {
|
||||||
|
::sprite = new QPixmap(st::spriteFile);
|
||||||
|
}
|
||||||
if (cRetina()) ::sprite->setDevicePixelRatio(cRetinaFactor());
|
if (cRetina()) ::sprite->setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
if (!::emojis) {
|
if (!::emojis) {
|
||||||
|
@ -1598,11 +1602,11 @@ namespace App {
|
||||||
return ::mousedItem;
|
return ::mousedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap &sprite() {
|
const QPixmap &sprite() {
|
||||||
return *::sprite;
|
return *::sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap &emojis() {
|
const QPixmap &emojis() {
|
||||||
return *::emojis;
|
return *::emojis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,8 +154,8 @@ namespace App {
|
||||||
void mousedItem(HistoryItem *item);
|
void mousedItem(HistoryItem *item);
|
||||||
HistoryItem *mousedItem();
|
HistoryItem *mousedItem();
|
||||||
|
|
||||||
QPixmap &sprite();
|
const QPixmap &sprite();
|
||||||
QPixmap &emojis();
|
const QPixmap &emojis();
|
||||||
const QPixmap &emojiSingle(const EmojiData *emoji, int32 fontHeight);
|
const QPixmap &emojiSingle(const EmojiData *emoji, int32 fontHeight);
|
||||||
|
|
||||||
void initMedia();
|
void initMedia();
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 160 KiB |
Binary file not shown.
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 205 KiB |
|
@ -71,7 +71,7 @@ void AbstractBox::paintTitle(Painter &p, const QString &title, bool withShadow)
|
||||||
// paint box title
|
// paint box title
|
||||||
p.setFont(st::boxTitleFont->f);
|
p.setFont(st::boxTitleFont->f);
|
||||||
p.setPen(st::black->p);
|
p.setPen(st::black->p);
|
||||||
p.drawTextLeft(st::boxTitlePos.x(), st::boxTitlePos.y(), width() - 2 * st::boxTitlePos.x(), title);
|
p.drawTextLeft(st::boxTitlePos.x(), st::boxTitlePos.y(), width(), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractBox::paintGrayTitle(QPainter &p, const QString &title) {
|
void AbstractBox::paintGrayTitle(QPainter &p, const QString &title) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ void SessionsInner::paintEvent(QPaintEvent *e) {
|
||||||
p.fillRect(r, st::white->b);
|
p.fillRect(r, st::white->b);
|
||||||
p.setFont(st::linkFont->f);
|
p.setFont(st::linkFont->f);
|
||||||
int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
|
int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
|
||||||
int32 w = width() - 2 * x, availw = width() - 2 * xact;
|
int32 w = width();
|
||||||
int32 from = (r.top() >= 0) ? qFloor(r.top() / st::sessionHeight) : 0, count = _list->size();
|
int32 from = (r.top() >= 0) ? qFloor(r.top() / st::sessionHeight) : 0, count = _list->size();
|
||||||
if (from < count) {
|
if (from < count) {
|
||||||
int32 to = (r.bottom() >= 0 ? qFloor(r.bottom() / st::sessionHeight) : 0) + 1;
|
int32 to = (r.bottom() >= 0 ? qFloor(r.bottom() / st::sessionHeight) : 0) + 1;
|
||||||
|
@ -52,7 +52,7 @@ void SessionsInner::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
p.setFont(st::sessionActiveFont->f);
|
p.setFont(st::sessionActiveFont->f);
|
||||||
p.setPen(st::sessionActiveColor->p);
|
p.setPen(st::sessionActiveColor->p);
|
||||||
p.drawTextRight(xact, st::sessionPadding.top(), availw, auth.active, auth.activeWidth);
|
p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth);
|
||||||
|
|
||||||
p.setFont(st::sessionInfoFont->f);
|
p.setFont(st::sessionInfoFont->f);
|
||||||
p.setPen(st::black->p);
|
p.setPen(st::black->p);
|
||||||
|
@ -132,7 +132,7 @@ void SessionsInner::listUpdated() {
|
||||||
j = _terminateButtons.insert(_list->at(i).hash, new IconedButton(this, st::sessionTerminate));
|
j = _terminateButtons.insert(_list->at(i).hash, new IconedButton(this, st::sessionTerminate));
|
||||||
connect(j.value(), SIGNAL(clicked()), this, SLOT(onTerminate()));
|
connect(j.value(), SIGNAL(clicked()), this, SLOT(onTerminate()));
|
||||||
}
|
}
|
||||||
j.value()->moveToRight(st::sessionTerminateSkip, i * st::sessionHeight + st::sessionTerminateTop, width() - 2 * st::sessionTerminateSkip);
|
j.value()->moveToRight(st::sessionTerminateSkip, i * st::sessionHeight + st::sessionTerminateTop, width());
|
||||||
}
|
}
|
||||||
for (TerminateButtons::iterator i = _terminateButtons.begin(); i != _terminateButtons.cend();) {
|
for (TerminateButtons::iterator i = _terminateButtons.begin(); i != _terminateButtons.cend();) {
|
||||||
if (i.value()->y() >= 0) {
|
if (i.value()->y() >= 0) {
|
||||||
|
@ -175,7 +175,7 @@ _terminateAll(this, lang(lng_sessions_terminate_all)), _terminateBox(0), _shortP
|
||||||
void SessionsBox::resizeEvent(QResizeEvent *e) {
|
void SessionsBox::resizeEvent(QResizeEvent *e) {
|
||||||
ScrollableBox::resizeEvent(e);
|
ScrollableBox::resizeEvent(e);
|
||||||
_done.move(0, height() - _done.height());
|
_done.move(0, height() - _done.height());
|
||||||
_terminateAll.moveToRight(st::sessionPadding.left(), st::boxTitleHeight + st::sessionHeight + st::boxTitlePos.y() + st::boxTitleFont->ascent - st::linkFont->ascent, width() - 2 * st::sessionPadding.left());
|
_terminateAll.moveToRight(st::sessionPadding.left(), st::boxTitleHeight + st::sessionHeight + st::boxTitlePos.y() + st::boxTitleFont->ascent - st::linkFont->ascent, width());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionsBox::hideAll() {
|
void SessionsBox::hideAll() {
|
||||||
|
@ -212,7 +212,7 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
|
||||||
p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
|
p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
|
||||||
} else {
|
} else {
|
||||||
int32 x = st::sessionPadding.left();
|
int32 x = st::sessionPadding.left();
|
||||||
int32 w = width() - x - st::sessionPadding.right();
|
int32 w = width();
|
||||||
|
|
||||||
p.setFont(st::sessionNameFont->f);
|
p.setFont(st::sessionNameFont->f);
|
||||||
p.setPen(st::black->p);
|
p.setPen(st::black->p);
|
||||||
|
|
|
@ -67,11 +67,11 @@ void DialogsListWidget::paintEvent(QPaintEvent *e) {
|
||||||
QRect r(e->rect());
|
QRect r(e->rect());
|
||||||
bool trivial = (rect() == r);
|
bool trivial = (rect() == r);
|
||||||
|
|
||||||
QPainter p(this);
|
Painter p(this);
|
||||||
if (!trivial) {
|
if (!trivial) {
|
||||||
p.setClipRect(r);
|
p.setClipRect(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_state == DefaultState) {
|
if (_state == DefaultState) {
|
||||||
int32 otherStart = dialogs.list.count * st::dlgHeight;
|
int32 otherStart = dialogs.list.count * st::dlgHeight;
|
||||||
PeerData *active = App::main()->activePeer(), *selected = sel ? sel->history->peer : 0;
|
PeerData *active = App::main()->activePeer(), *selected = sel ? sel->history->peer : 0;
|
||||||
|
|
|
@ -26,8 +26,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
|
||||||
Dropdown::Dropdown(QWidget *parent) : TWidget(parent),
|
Dropdown::Dropdown(QWidget *parent, const style::dropdown &st) : TWidget(parent),
|
||||||
_hiding(false), a_opacity(0), _shadow(st::dropdownShadow) {
|
_ignore(false), _selected(-1), _st(st), _width(_st.width), _hiding(false), a_opacity(0), _shadow(_st.shadow) {
|
||||||
resetButtons();
|
resetButtons();
|
||||||
|
|
||||||
_hideTimer.setSingleShot(true);
|
_hideTimer.setSingleShot(true);
|
||||||
|
@ -38,6 +38,10 @@ Dropdown::Dropdown(QWidget *parent) : TWidget(parent),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Dropdown::ignoreShow(bool ignore) {
|
||||||
|
_ignore = ignore;
|
||||||
|
}
|
||||||
|
|
||||||
void Dropdown::onWndActiveChanged() {
|
void Dropdown::onWndActiveChanged() {
|
||||||
if (!App::wnd()->windowHandle()->isActive() && !isHidden()) {
|
if (!App::wnd()->windowHandle()->isActive() && !isHidden()) {
|
||||||
leaveEvent(0);
|
leaveEvent(0);
|
||||||
|
@ -47,13 +51,21 @@ void Dropdown::onWndActiveChanged() {
|
||||||
IconedButton *Dropdown::addButton(IconedButton *button) {
|
IconedButton *Dropdown::addButton(IconedButton *button) {
|
||||||
button->setParent(this);
|
button->setParent(this);
|
||||||
|
|
||||||
_width = qMax(_width, st::dropdownPadding.left() + st::dropdownPadding.right() + button->width());
|
int32 nw = _st.padding.left() + _st.padding.right() + button->width();
|
||||||
if (!_buttons.isEmpty()) {
|
if (nw > _width) {
|
||||||
_height += st::dropdownBorder;
|
_width = nw;
|
||||||
|
for (int32 i = 0, l = _buttons.size(); i < l; ++i) _buttons[i]->resize(_width - _st.padding.left() - _st.padding.right(), _buttons[i]->height());
|
||||||
|
} else {
|
||||||
|
button->resize(_width - _st.padding.left() - _st.padding.right(), button->height());
|
||||||
|
}
|
||||||
|
if (!button->isHidden()) {
|
||||||
|
if (_height > _st.padding.top() + _st.padding.bottom()) {
|
||||||
|
_height += _st.border;
|
||||||
|
}
|
||||||
|
_height += button->height();
|
||||||
}
|
}
|
||||||
_height += button->height();
|
|
||||||
|
|
||||||
_buttons.push_back(button);
|
_buttons.push_back(button);
|
||||||
|
connect(button, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(buttonStateChanged(int, ButtonStateChangeSource)));
|
||||||
|
|
||||||
resize(_width, _height);
|
resize(_width, _height);
|
||||||
|
|
||||||
|
@ -61,20 +73,39 @@ IconedButton *Dropdown::addButton(IconedButton *button) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::resetButtons() {
|
void Dropdown::resetButtons() {
|
||||||
_width = st::dropdownPadding.left() + st::dropdownPadding.right();
|
_width = qMax(_st.padding.left() + _st.padding.right(), int(_st.width));
|
||||||
_height = st::dropdownPadding.top() + st::dropdownPadding.bottom();
|
_height = _st.padding.top() + _st.padding.bottom();
|
||||||
resize(_width, _height);
|
|
||||||
for (int32 i = 0, l = _buttons.size(); i < l; ++i) {
|
for (int32 i = 0, l = _buttons.size(); i < l; ++i) {
|
||||||
delete _buttons[i];
|
delete _buttons[i];
|
||||||
}
|
}
|
||||||
_buttons.clear();
|
_buttons.clear();
|
||||||
|
resize(_width, _height);
|
||||||
|
|
||||||
|
_selected = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dropdown::updateButtons() {
|
||||||
|
int32 top = _st.padding.top(), starttop = top;
|
||||||
|
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
||||||
|
if (!(*i)->isHidden()) {
|
||||||
|
(*i)->move(_st.padding.left(), top);
|
||||||
|
if ((*i)->width() != _width - _st.padding.left() - _st.padding.right()) {
|
||||||
|
(*i)->resize(_width - _st.padding.left() - _st.padding.right(), (*i)->height());
|
||||||
|
}
|
||||||
|
top += (*i)->height() + _st.border;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_height = top + _st.padding.bottom() - (top > starttop ? _st.border : 0);
|
||||||
|
resize(_width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::resizeEvent(QResizeEvent *e) {
|
void Dropdown::resizeEvent(QResizeEvent *e) {
|
||||||
int32 top = st::dropdownPadding.top();
|
int32 top = _st.padding.top();
|
||||||
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
||||||
(*i)->move(st::dropdownPadding.left(), top);
|
if (!(*i)->isHidden()) {
|
||||||
top += st::dropdownBorder + (*i)->height();
|
(*i)->move(_st.padding.left(), top);
|
||||||
|
top += (*i)->height() + _st.border;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,16 +116,24 @@ void Dropdown::paintEvent(QPaintEvent *e) {
|
||||||
p.setOpacity(a_opacity.current());
|
p.setOpacity(a_opacity.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect r(st::dropdownPadding.left(), st::dropdownPadding.top(), _width - st::dropdownPadding.left() - st::dropdownPadding.right(), _height - st::dropdownPadding.top() - st::dropdownPadding.bottom());
|
|
||||||
// draw shadow
|
// draw shadow
|
||||||
|
QRect r(_st.padding.left(), _st.padding.top(), _width - _st.padding.left() - _st.padding.right(), _height - _st.padding.top() - _st.padding.bottom());
|
||||||
_shadow.paint(p, r);
|
_shadow.paint(p, r);
|
||||||
|
|
||||||
if (!_buttons.isEmpty()) { // paint separators
|
if (!_buttons.isEmpty() && _st.border > 0) { // paint separators
|
||||||
int32 top = st::dropdownPadding.top() + _buttons.front()->height();
|
p.setPen(_st.borderColor->p);
|
||||||
p.setPen(st::dropdownBorderColor->p);
|
int32 top = _st.padding.top(), i = 0, l = _buttons.size();
|
||||||
for (int32 i = 1, s = _buttons.size(); i < s; ++i) {
|
for (; i < l; ++i) {
|
||||||
p.fillRect(st::dropdownPadding.left(), top, _width - st::dropdownPadding.left() - st::dropdownPadding.right(), st::dropdownBorder, st::dropdownBorderColor->b);
|
if (!_buttons.at(i)->isHidden()) break;
|
||||||
top += st::dropdownBorder + _buttons[i]->height();
|
}
|
||||||
|
if (i < l) {
|
||||||
|
top += _buttons.at(i)->height();
|
||||||
|
for (++i; i < l; ++i) {
|
||||||
|
if (!_buttons.at(i)->isHidden()) {
|
||||||
|
p.fillRect(_st.padding.left(), top, _width - _st.padding.left() - _st.padding.right(), _st.border, _st.borderColor->b);
|
||||||
|
top += _st.border + _buttons.at(i)->height();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +141,7 @@ void Dropdown::paintEvent(QPaintEvent *e) {
|
||||||
void Dropdown::enterEvent(QEvent *e) {
|
void Dropdown::enterEvent(QEvent *e) {
|
||||||
_hideTimer.stop();
|
_hideTimer.stop();
|
||||||
if (_hiding) showStart();
|
if (_hiding) showStart();
|
||||||
|
return TWidget::enterEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::leaveEvent(QEvent *e) {
|
void Dropdown::leaveEvent(QEvent *e) {
|
||||||
|
@ -110,6 +150,73 @@ void Dropdown::leaveEvent(QEvent *e) {
|
||||||
} else {
|
} else {
|
||||||
_hideTimer.start(300);
|
_hideTimer.start(300);
|
||||||
}
|
}
|
||||||
|
return TWidget::leaveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dropdown::keyPressEvent(QKeyEvent *e) {
|
||||||
|
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||||
|
if (_selected >= 0 && _selected < _buttons.size()) {
|
||||||
|
emit _buttons[_selected]->clicked();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (e->key() == Qt::Key_Escape) {
|
||||||
|
hideStart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) || _buttons.size() < 1) return;
|
||||||
|
|
||||||
|
bool none = (_selected < 0 || _selected >= _buttons.size());
|
||||||
|
int32 delta = (e->key() == Qt::Key_Down ? 1 : -1);
|
||||||
|
int32 newSelected = none ? (e->key() == Qt::Key_Down ? 0 : _buttons.size() - 1) : (_selected + delta);
|
||||||
|
if (newSelected < 0) {
|
||||||
|
newSelected = _buttons.size() - 1;
|
||||||
|
} else if (newSelected >= _buttons.size()) {
|
||||||
|
newSelected = 0;
|
||||||
|
}
|
||||||
|
int32 startFrom = newSelected;
|
||||||
|
while (_buttons.at(newSelected)->isHidden()) {
|
||||||
|
newSelected += delta;
|
||||||
|
if (newSelected < 0) {
|
||||||
|
newSelected = _buttons.size() - 1;
|
||||||
|
} else if (newSelected >= _buttons.size()) {
|
||||||
|
newSelected = 0;
|
||||||
|
}
|
||||||
|
if (newSelected == startFrom) return;
|
||||||
|
}
|
||||||
|
if (!none) {
|
||||||
|
_buttons[_selected]->setOver(false);
|
||||||
|
}
|
||||||
|
_selected = newSelected;
|
||||||
|
_buttons[_selected]->setOver(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dropdown::buttonStateChanged(int oldState, ButtonStateChangeSource source) {
|
||||||
|
if (source == ButtonByUser) {
|
||||||
|
for (int32 i = 0, l = _buttons.size(); i < l; ++i) {
|
||||||
|
if (_buttons[i]->getState() & Button::StateOver) {
|
||||||
|
if (i != _selected) {
|
||||||
|
_buttons[i]->setOver(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (source == ButtonByHover) {
|
||||||
|
bool found = false;
|
||||||
|
for (int32 i = 0, l = _buttons.size(); i < l; ++i) {
|
||||||
|
if (_buttons[i]->getState() & Button::StateOver) {
|
||||||
|
found = true;
|
||||||
|
if (i != _selected) {
|
||||||
|
int32 sel = _selected;
|
||||||
|
_selected = i;
|
||||||
|
if (sel >= 0 && sel < _buttons.size()) {
|
||||||
|
_buttons[sel]->setOver(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
_selected = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::otherEnter() {
|
void Dropdown::otherEnter() {
|
||||||
|
@ -147,13 +254,19 @@ void Dropdown::hideStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::hideFinish() {
|
void Dropdown::hideFinish() {
|
||||||
|
emit hiding();
|
||||||
hide();
|
hide();
|
||||||
|
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
||||||
|
(*i)->clearState();
|
||||||
|
}
|
||||||
|
_selected = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dropdown::showStart() {
|
void Dropdown::showStart() {
|
||||||
if (!isHidden() && a_opacity.current() == 1) {
|
if (!isHidden() && a_opacity.current() == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_selected = -1;
|
||||||
_hiding = false;
|
_hiding = false;
|
||||||
show();
|
show();
|
||||||
a_opacity.start(1);
|
a_opacity.start(1);
|
||||||
|
@ -161,7 +274,7 @@ void Dropdown::showStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dropdown::animStep(float64 ms) {
|
bool Dropdown::animStep(float64 ms) {
|
||||||
float64 dt = ms / st::dropdownDuration;
|
float64 dt = ms / _st.duration;
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (dt >= 1) {
|
if (dt >= 1) {
|
||||||
a_opacity.finish();
|
a_opacity.finish();
|
||||||
|
@ -312,7 +425,7 @@ void DragArea::showStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DragArea::animStep(float64 ms) {
|
bool DragArea::animStep(float64 ms) {
|
||||||
float64 dt = ms / st::dropdownDuration;
|
float64 dt = ms / st::dropdownDef.duration;
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (dt >= 1) {
|
if (dt >= 1) {
|
||||||
a_opacity.finish();
|
a_opacity.finish();
|
||||||
|
@ -648,7 +761,7 @@ void EmojiPanInner::showEmojiPack(DBIEmojiTab packIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EmojiPan::EmojiPan(QWidget *parent) : TWidget(parent),
|
EmojiPan::EmojiPan(QWidget *parent) : TWidget(parent),
|
||||||
_hiding(false), a_opacity(0), _shadow(st::dropdownShadow),
|
_hiding(false), a_opacity(0), _shadow(st::dropdownDef.shadow),
|
||||||
_recent (this, qsl("emoji_group"), dbietRecent , QString(), cEmojiTab() == dbietRecent , st::rbEmojiRecent),
|
_recent (this, qsl("emoji_group"), dbietRecent , QString(), cEmojiTab() == dbietRecent , st::rbEmojiRecent),
|
||||||
_people (this, qsl("emoji_group"), dbietPeople , QString(), cEmojiTab() == dbietPeople , st::rbEmojiPeople),
|
_people (this, qsl("emoji_group"), dbietPeople , QString(), cEmojiTab() == dbietPeople , st::rbEmojiPeople),
|
||||||
_nature (this, qsl("emoji_group"), dbietNature , QString(), cEmojiTab() == dbietNature , st::rbEmojiNature),
|
_nature (this, qsl("emoji_group"), dbietNature , QString(), cEmojiTab() == dbietNature , st::rbEmojiNature),
|
||||||
|
@ -665,15 +778,15 @@ _scroll(this, st::emojiScroll), _inner() {
|
||||||
_inner.showEmojiPack(cEmojiTab());
|
_inner.showEmojiPack(cEmojiTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
_scroll.setGeometry(st::dropdownPadding.left() + st::emojiPanPadding.left(), st::dropdownPadding.top() + _recent.height() + st::emojiPanPadding.top(), st::emojiPanPadding.left() + _inner.width() + st::emojiPanPadding.right(), EmojiPadRowsPerPage * st::emojiPanSize.height() - st::emojiPanSub);
|
_scroll.setGeometry(st::dropdownDef.padding.left() + st::emojiPanPadding.left(), st::dropdownDef.padding.top() + _recent.height() + st::emojiPanPadding.top(), st::emojiPanPadding.left() + _inner.width() + st::emojiPanPadding.right(), EmojiPadRowsPerPage * st::emojiPanSize.height() - st::emojiPanSub);
|
||||||
_scroll.setWidget(&_inner);
|
_scroll.setWidget(&_inner);
|
||||||
|
|
||||||
_width = st::dropdownPadding.left() + st::emojiPanPadding.left() + _scroll.width() + st::emojiPanPadding.right() + st::dropdownPadding.right();
|
_width = st::dropdownDef.padding.left() + st::emojiPanPadding.left() + _scroll.width() + st::emojiPanPadding.right() + st::dropdownDef.padding.right();
|
||||||
_height = st::dropdownPadding.top() + _recent.height() + st::emojiPanPadding.top() + _scroll.height() + st::emojiPanPadding.bottom() + st::dropdownPadding.bottom();
|
_height = st::dropdownDef.padding.top() + _recent.height() + st::emojiPanPadding.top() + _scroll.height() + st::emojiPanPadding.bottom() + st::dropdownDef.padding.bottom();
|
||||||
resize(_width, _height);
|
resize(_width, _height);
|
||||||
|
|
||||||
int32 left = st::dropdownPadding.left() + (_width - st::dropdownPadding.left() - st::dropdownPadding.right() - 7 * _recent.width()) / 2;
|
int32 left = st::dropdownDef.padding.left() + (_width - st::dropdownDef.padding.left() - st::dropdownDef.padding.right() - 7 * _recent.width()) / 2;
|
||||||
int32 top = st::dropdownPadding.top();
|
int32 top = st::dropdownDef.padding.top();
|
||||||
_recent.move(left, top); left += _recent.width();
|
_recent.move(left, top); left += _recent.width();
|
||||||
_people.move(left, top); left += _people.width();
|
_people.move(left, top); left += _people.width();
|
||||||
_nature.move(left, top); left += _nature.width();
|
_nature.move(left, top); left += _nature.width();
|
||||||
|
@ -716,7 +829,7 @@ void EmojiPan::paintEvent(QPaintEvent *e) {
|
||||||
p.setOpacity(a_opacity.current());
|
p.setOpacity(a_opacity.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect r(st::dropdownPadding.left(), st::dropdownPadding.top(), _width - st::dropdownPadding.left() - st::dropdownPadding.right(), _height - st::dropdownPadding.top() - st::dropdownPadding.bottom());
|
QRect r(st::dropdownDef.padding.left(), st::dropdownDef.padding.top(), _width - st::dropdownDef.padding.left() - st::dropdownDef.padding.right(), _height - st::dropdownDef.padding.top() - st::dropdownDef.padding.bottom());
|
||||||
|
|
||||||
// draw shadow
|
// draw shadow
|
||||||
_shadow.paint(p, r);
|
_shadow.paint(p, r);
|
||||||
|
@ -765,7 +878,7 @@ void EmojiPan::fastHide() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmojiPan::animStep(float64 ms) {
|
bool EmojiPan::animStep(float64 ms) {
|
||||||
float64 dt = ms / st::dropdownDuration;
|
float64 dt = ms / st::dropdownDef.duration;
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (dt >= 1) {
|
if (dt >= 1) {
|
||||||
a_opacity.finish();
|
a_opacity.finish();
|
||||||
|
@ -786,7 +899,7 @@ bool EmojiPan::animStep(float64 ms) {
|
||||||
void EmojiPan::hideStart() {
|
void EmojiPan::hideStart() {
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
showAll();
|
showAll();
|
||||||
_cache = myGrab(this, rect().marginsRemoved(st::dropdownPadding));
|
_cache = myGrab(this, rect().marginsRemoved(st::dropdownDef.padding));
|
||||||
}
|
}
|
||||||
hideAll();
|
hideAll();
|
||||||
_hiding = true;
|
_hiding = true;
|
||||||
|
@ -806,7 +919,7 @@ void EmojiPan::showStart() {
|
||||||
}
|
}
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
showAll();
|
showAll();
|
||||||
_cache = myGrab(this, rect().marginsRemoved(st::dropdownPadding));
|
_cache = myGrab(this, rect().marginsRemoved(st::dropdownDef.padding));
|
||||||
}
|
}
|
||||||
hideAll();
|
hideAll();
|
||||||
_hiding = false;
|
_hiding = false;
|
||||||
|
@ -1048,7 +1161,7 @@ void MentionsInner::onParentGeometryChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MentionsDropdown::MentionsDropdown(QWidget *parent) : QWidget(parent),
|
MentionsDropdown::MentionsDropdown(QWidget *parent) : QWidget(parent),
|
||||||
_scroll(this, st::mentionScroll), _inner(this, &_rows, &_hrows), _chat(0), _hiding(false), a_opacity(0), _shadow(st::dropdownShadow) {
|
_scroll(this, st::mentionScroll), _inner(this, &_rows, &_hrows), _chat(0), _hiding(false), a_opacity(0), _shadow(st::dropdownDef.shadow) {
|
||||||
_hideTimer.setSingleShot(true);
|
_hideTimer.setSingleShot(true);
|
||||||
connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideStart()));
|
connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideStart()));
|
||||||
connect(&_inner, SIGNAL(chosen(QString)), this, SIGNAL(chosen(QString)));
|
connect(&_inner, SIGNAL(chosen(QString)), this, SIGNAL(chosen(QString)));
|
||||||
|
@ -1235,7 +1348,7 @@ void MentionsDropdown::showStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MentionsDropdown::animStep(float64 ms) {
|
bool MentionsDropdown::animStep(float64 ms) {
|
||||||
float64 dt = ms / st::dropdownDuration;
|
float64 dt = ms / st::dropdownDef.duration;
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (dt >= 1) {
|
if (dt >= 1) {
|
||||||
a_opacity.finish();
|
a_opacity.finish();
|
||||||
|
@ -1284,330 +1397,3 @@ bool MentionsDropdown::eventFilter(QObject *obj, QEvent *e) {
|
||||||
|
|
||||||
MentionsDropdown::~MentionsDropdown() {
|
MentionsDropdown::~MentionsDropdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//StickerPanInner::StickerPanInner(QWidget *parent) : QWidget(parent), _emoji(0), _selected(-1), _pressedSel(-1) {
|
|
||||||
// resize(StickerPadPerRow * st::stickerPanSize.width(), EmojiPadRowsPerPage * st::emojiPanSize.height() - st::emojiPanSub);
|
|
||||||
// setMouseTracking(true);
|
|
||||||
// setFocusPolicy(Qt::NoFocus);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::paintEvent(QPaintEvent *e) {
|
|
||||||
// QPainter p(this);
|
|
||||||
// int32 size = _stickers.size();
|
|
||||||
//
|
|
||||||
// QRect r = e ? e->rect() : rect();
|
|
||||||
//
|
|
||||||
// int32 rows = (size / StickerPadPerRow) + ((size % StickerPadPerRow) ? 1 : 0);
|
|
||||||
// int32 fromrow = qMax(qFloor(r.top() / st::stickerPanSize.height()), 0), torow = qMin(qCeil(r.bottom() / st::stickerPanSize.height()) + 1, rows);
|
|
||||||
// for (int32 i = fromrow; i < torow; ++i) {
|
|
||||||
// for (int32 j = 0; j < StickerPadPerRow; ++j) {
|
|
||||||
// int32 index = i * StickerPadPerRow + j;
|
|
||||||
// if (index >= size) break;
|
|
||||||
//
|
|
||||||
// float64 hover = _hovers[index];
|
|
||||||
// QPoint pos(j * st::stickerPanSize.width(), i * st::stickerPanSize.height());
|
|
||||||
// if (hover > 0) {
|
|
||||||
// p.setOpacity(hover);
|
|
||||||
// p.setBrush(st::stickerPanHover->b);
|
|
||||||
// p.setPen(Qt::NoPen);
|
|
||||||
// p.drawRoundedRect(QRect(pos, st::stickerPanSize), st::stickerPanRound, st::stickerPanRound);
|
|
||||||
// p.setOpacity(1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// DocumentData *data = _stickers[index];
|
|
||||||
// bool already = !data->already().isEmpty(), hasdata = !data->data.isEmpty();
|
|
||||||
// if (!data->loader && data->status != FileFailed && !already && !hasdata) {
|
|
||||||
// data->save(QString());
|
|
||||||
// }
|
|
||||||
// if (data->sticker->isNull() && (already || hasdata)) {
|
|
||||||
// if (already) {
|
|
||||||
// data->sticker = ImagePtr(data->already());
|
|
||||||
// } else {
|
|
||||||
// data->sticker = ImagePtr(data->data);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// float64 coef = qMin(st::stickerPanSize.width() / float64(data->dimensions.width()), st::stickerPanSize.height() / float64(data->dimensions.height()));
|
|
||||||
// int32 w = qRound(coef * data->dimensions.width()), h = qRound(coef * data->dimensions.height());
|
|
||||||
// pos += QPoint((st::stickerPanSize.width() - w) / 2, (st::stickerPanSize.height() - h) / 2);
|
|
||||||
//
|
|
||||||
// if (data->sticker->isNull()) {
|
|
||||||
// p.drawPixmap(pos, data->thumb->pix(w));
|
|
||||||
// } else {
|
|
||||||
// p.drawPixmap(pos, data->sticker->pix(w));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::mousePressEvent(QMouseEvent *e) {
|
|
||||||
// _lastMousePos = e->globalPos();
|
|
||||||
// updateSelected();
|
|
||||||
// _pressedSel = _selected;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::mouseReleaseEvent(QMouseEvent *e) {
|
|
||||||
// _lastMousePos = e->globalPos();
|
|
||||||
// updateSelected();
|
|
||||||
// if (_selected == _pressedSel && _selected >= 0 && _selected < _stickers.size()) {
|
|
||||||
// emit stickerSelected(_stickers[_selected]);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::mouseMoveEvent(QMouseEvent *e) {
|
|
||||||
// _lastMousePos = e->globalPos();
|
|
||||||
// updateSelected();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::leaveEvent(QEvent *e) {
|
|
||||||
// _lastMousePos = QCursor::pos();
|
|
||||||
// updateSelected();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::updateSelected() {
|
|
||||||
// int32 selIndex = -1;
|
|
||||||
// QPoint p(mapFromGlobal(_lastMousePos));
|
|
||||||
// if (p.x() >= 0 && p.y() >= 0 && p.x() < StickerPadPerRow * st::stickerPanSize.width()) {
|
|
||||||
// selIndex = qFloor(p.y() / st::stickerPanSize.height()) * StickerPadPerRow + qFloor(p.x() / st::stickerPanSize.width());
|
|
||||||
// if (selIndex >= _stickers.size()) {
|
|
||||||
// selIndex = -1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (selIndex != _selected) {
|
|
||||||
// bool startanim = false;
|
|
||||||
// if (_selected >= 0) {
|
|
||||||
// _stickerAnimations.remove(_selected + 1);
|
|
||||||
// if (_stickerAnimations.find(-_selected - 1) == _stickerAnimations.end()) {
|
|
||||||
// if (_stickerAnimations.isEmpty()) startanim = true;
|
|
||||||
// _stickerAnimations.insert(-_selected - 1, getms());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// _selected = selIndex;
|
|
||||||
// if (_selected >= 0) {
|
|
||||||
// _stickerAnimations.remove(-_selected - 1);
|
|
||||||
// if (_stickerAnimations.find(_selected + 1) == _stickerAnimations.end()) {
|
|
||||||
// if (_stickerAnimations.isEmpty()) startanim = true;
|
|
||||||
// _stickerAnimations.insert(_selected + 1, getms());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (startanim) anim::start(this);
|
|
||||||
// setCursor((_selected >= 0) ? style::cur_pointer : style::cur_default);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//bool StickerPanInner::animStep(float64 ms) {
|
|
||||||
// uint64 now = getms();
|
|
||||||
// for (StickerAnimations::iterator i = _stickerAnimations.begin(); i != _stickerAnimations.end();) {
|
|
||||||
// float64 dt = float64(now - i.value()) / st::emojiPanDuration;
|
|
||||||
// if (dt >= 1) {
|
|
||||||
// _hovers[qAbs(i.key()) - 1] = (i.key() > 0) ? 1 : 0;
|
|
||||||
// i = _stickerAnimations.erase(i);
|
|
||||||
// } else {
|
|
||||||
// _hovers[qAbs(i.key()) - 1] = (i.key() > 0) ? dt : (1 - dt);
|
|
||||||
// ++i;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// update();
|
|
||||||
// return !_stickerAnimations.isEmpty();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPanInner::showStickerPack(EmojiPtr emoji) {
|
|
||||||
// StickerPack stickers = cStickers().value(emoji);
|
|
||||||
// if (stickers.isEmpty()) {
|
|
||||||
// _emoji = 0;
|
|
||||||
// } else {
|
|
||||||
// _emoji = emoji;
|
|
||||||
// _stickers = stickers;
|
|
||||||
// _hovers = QVector<float64>(_stickers.size(), 0);
|
|
||||||
// _stickerAnimations.clear();
|
|
||||||
// _selected = _pressedSel = -1;
|
|
||||||
// int32 size = _stickers.size();
|
|
||||||
// int32 h = qMax(((size / StickerPadPerRow) + ((size % StickerPadPerRow) ? 1 : 0)) * st::stickerPanSize.height(), EmojiPadRowsPerPage * st::emojiPanSize.height() - int(st::emojiPanSub));
|
|
||||||
// resize(width(), h);
|
|
||||||
// _lastMousePos = QCursor::pos();
|
|
||||||
// updateSelected();
|
|
||||||
// update();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//bool StickerPanInner::hasContent() const {
|
|
||||||
// return !!_emoji;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//StickerPan::StickerPan(QWidget *parent) : TWidget(parent),
|
|
||||||
//_hiding(false), a_opacity(0), _shadow(st::dropdownShadow),
|
|
||||||
//_scroll(this, st::emojiScroll), _emoji(0), _inner() {
|
|
||||||
// setFocusPolicy(Qt::NoFocus);
|
|
||||||
// _scroll.setFocusPolicy(Qt::NoFocus);
|
|
||||||
// _scroll.viewport()->setFocusPolicy(Qt::NoFocus);
|
|
||||||
//
|
|
||||||
// _inner.showStickerPack(0);
|
|
||||||
// _scroll.setGeometry(st::dropdownPadding.left() + st::stickerPanPadding.left(), st::dropdownPadding.top() + st::rbEmoji.height + st::stickerPanPadding.top(), st::stickerPanPadding.left() + _inner.width() + st::stickerPanPadding.right(), EmojiPadRowsPerPage * st::emojiPanSize.height() - st::emojiPanSub);
|
|
||||||
// _scroll.setWidget(&_inner);
|
|
||||||
//
|
|
||||||
// _width = st::dropdownPadding.left() + st::stickerPanPadding.left() + _scroll.width() + st::stickerPanPadding.right() + st::dropdownPadding.right();
|
|
||||||
// _height = st::dropdownPadding.top() + st::rbEmoji.height + st::stickerPanPadding.top() + _scroll.height() + st::stickerPanPadding.bottom() + st::dropdownPadding.bottom();
|
|
||||||
// resize(_width, _height);
|
|
||||||
//
|
|
||||||
// _hideTimer.setSingleShot(true);
|
|
||||||
// connect(&_hideTimer, SIGNAL(timeout()), this, SLOT(hideStart()));
|
|
||||||
//
|
|
||||||
// connect(&_scroll, SIGNAL(scrolled()), &_inner, SLOT(updateSelected()));
|
|
||||||
//
|
|
||||||
// connect(&_inner, SIGNAL(stickerSelected(DocumentData*)), this, SIGNAL(stickerSelected(DocumentData*)));
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::setStickerPack(EmojiPtr emoji, bool show) {
|
|
||||||
// _emoji = emoji;
|
|
||||||
// _inner.showStickerPack(_emoji);
|
|
||||||
// if (!_hiding && !isHidden() && !_inner.hasContent()) {
|
|
||||||
// _hideTimer.stop();
|
|
||||||
// hideStart();
|
|
||||||
// } else if ((_hiding || isHidden()) && _inner.hasContent() && show) {
|
|
||||||
// _hideTimer.stop();
|
|
||||||
// showStart();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::paintEvent(QPaintEvent *e) {
|
|
||||||
// QPainter p(this);
|
|
||||||
//
|
|
||||||
// if (!_cache.isNull()) {
|
|
||||||
// p.setOpacity(a_opacity.current());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// QRect r(st::dropdownPadding.left(), st::dropdownPadding.top(), _width - st::dropdownPadding.left() - st::dropdownPadding.right(), _height - st::dropdownPadding.top() - st::dropdownPadding.bottom());
|
|
||||||
//
|
|
||||||
// // draw shadow
|
|
||||||
// _shadow.paint(p, r);
|
|
||||||
//
|
|
||||||
// if (_cache.isNull()) {
|
|
||||||
// p.fillRect(r, st::white->b);
|
|
||||||
//
|
|
||||||
// p.setFont(st::stickerPanFont->f);
|
|
||||||
// p.setPen(st::stickerPanColor->p);
|
|
||||||
// p.drawText(QRect(st::dropdownPadding.left(), st::dropdownPadding.top(), width() - st::dropdownPadding.left() - st::dropdownPadding.right(), st::rbEmoji.height), lang(lng_attach_stickers_header), style::al_center);
|
|
||||||
// } else {
|
|
||||||
// p.drawPixmap(r.left(), r.top(), _cache);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::enterEvent(QEvent *e) {
|
|
||||||
// _hideTimer.stop();
|
|
||||||
// if (_hiding) showStart();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::leaveEvent(QEvent *e) {
|
|
||||||
// if (animating()) {
|
|
||||||
// hideStart();
|
|
||||||
// } else {
|
|
||||||
// _hideTimer.start(300);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::otherEnter() {
|
|
||||||
// _hideTimer.stop();
|
|
||||||
// showStart();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::otherLeave() {
|
|
||||||
// if (animating()) {
|
|
||||||
// hideStart();
|
|
||||||
// } else {
|
|
||||||
// _hideTimer.start(0);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::fastHide() {
|
|
||||||
// if (animating()) {
|
|
||||||
// anim::stop(this);
|
|
||||||
// }
|
|
||||||
// a_opacity = anim::fvalue(0, 0);
|
|
||||||
// _hideTimer.stop();
|
|
||||||
// hide();
|
|
||||||
// _cache = QPixmap();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//bool StickerPan::animStep(float64 ms) {
|
|
||||||
// float64 dt = ms / st::dropdownDuration;
|
|
||||||
// bool res = true;
|
|
||||||
// if (dt >= 1) {
|
|
||||||
// a_opacity.finish();
|
|
||||||
// if (_hiding) {
|
|
||||||
// hideFinish();
|
|
||||||
// } else {
|
|
||||||
// showAll();
|
|
||||||
// _cache = QPixmap();
|
|
||||||
// }
|
|
||||||
// res = false;
|
|
||||||
// } else {
|
|
||||||
// a_opacity.update(dt, anim::linear);
|
|
||||||
// }
|
|
||||||
// update();
|
|
||||||
// return res;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::hideStart() {
|
|
||||||
// if (_cache.isNull()) {
|
|
||||||
// showAll();
|
|
||||||
// _cache = myGrab(this, rect().marginsRemoved(st::dropdownPadding));
|
|
||||||
// }
|
|
||||||
// hideAll();
|
|
||||||
// _hiding = true;
|
|
||||||
// a_opacity.start(0);
|
|
||||||
// anim::start(this);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::hideFinish() {
|
|
||||||
// hide();
|
|
||||||
// _cache = QPixmap();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::showStart() {
|
|
||||||
// if (!isHidden() && a_opacity.current() == 1) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (!_inner.hasContent()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if (_cache.isNull()) {
|
|
||||||
// showAll();
|
|
||||||
// _cache = myGrab(this, rect().marginsRemoved(st::dropdownPadding));
|
|
||||||
// }
|
|
||||||
// hideAll();
|
|
||||||
// _hiding = false;
|
|
||||||
// show();
|
|
||||||
// a_opacity.start(1);
|
|
||||||
// anim::start(this);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//bool StickerPan::eventFilter(QObject *obj, QEvent *e) {
|
|
||||||
// if (e->type() == QEvent::Enter) {
|
|
||||||
// if (dynamic_cast<EmojiPan*>(obj)) {
|
|
||||||
// enterEvent(e);
|
|
||||||
// } else {
|
|
||||||
// otherEnter();
|
|
||||||
// }
|
|
||||||
// } else if (e->type() == QEvent::Leave) {
|
|
||||||
// if (dynamic_cast<EmojiPan*>(obj)) {
|
|
||||||
// leaveEvent(e);
|
|
||||||
// } else {
|
|
||||||
// otherLeave();
|
|
||||||
// }
|
|
||||||
// } else if (e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton && !dynamic_cast<EmojiPan*>(obj)) {
|
|
||||||
// if (isHidden() || _hiding) {
|
|
||||||
// otherEnter();
|
|
||||||
// } else {
|
|
||||||
// otherLeave();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::showAll() {
|
|
||||||
// _scroll.show();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void StickerPan::hideAll() {
|
|
||||||
// _scroll.hide();
|
|
||||||
//}
|
|
||||||
|
|
|
@ -25,25 +25,32 @@ class Dropdown : public TWidget, public Animated {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Dropdown(QWidget *parent);
|
Dropdown(QWidget *parent, const style::dropdown &st = st::dropdownDef);
|
||||||
|
|
||||||
IconedButton *addButton(IconedButton *button);
|
IconedButton *addButton(IconedButton *button);
|
||||||
void resetButtons();
|
void resetButtons();
|
||||||
|
void updateButtons();
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e);
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent *e);
|
||||||
|
|
||||||
void enterEvent(QEvent *e);
|
void enterEvent(QEvent *e);
|
||||||
void leaveEvent(QEvent *e);
|
void leaveEvent(QEvent *e);
|
||||||
|
void keyPressEvent(QKeyEvent *e);
|
||||||
void otherEnter();
|
void otherEnter();
|
||||||
void otherLeave();
|
void otherLeave();
|
||||||
|
|
||||||
void fastHide();
|
void fastHide();
|
||||||
|
void ignoreShow(bool ignore = true);
|
||||||
|
|
||||||
bool animStep(float64 ms);
|
bool animStep(float64 ms);
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *e);
|
bool eventFilter(QObject *obj, QEvent *e);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void hiding();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void hideStart();
|
void hideStart();
|
||||||
|
@ -52,13 +59,21 @@ public slots:
|
||||||
void showStart();
|
void showStart();
|
||||||
void onWndActiveChanged();
|
void onWndActiveChanged();
|
||||||
|
|
||||||
|
void buttonStateChanged(int oldState, ButtonStateChangeSource source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void adjustButtons();
|
void adjustButtons();
|
||||||
|
|
||||||
|
bool _ignore;
|
||||||
|
|
||||||
typedef QVector<IconedButton*> Buttons;
|
typedef QVector<IconedButton*> Buttons;
|
||||||
Buttons _buttons;
|
Buttons _buttons;
|
||||||
|
|
||||||
|
int32 _selected;
|
||||||
|
|
||||||
|
const style::dropdown &_st;
|
||||||
|
|
||||||
int32 _width, _height;
|
int32 _width, _height;
|
||||||
bool _hiding;
|
bool _hiding;
|
||||||
|
|
||||||
|
@ -336,97 +351,3 @@ private:
|
||||||
BoxShadow _shadow;
|
BoxShadow _shadow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//class StickerPanInner : public QWidget, public Animated {
|
|
||||||
// Q_OBJECT
|
|
||||||
//
|
|
||||||
//public:
|
|
||||||
//
|
|
||||||
// StickerPanInner(QWidget *parent = 0);
|
|
||||||
//
|
|
||||||
// void paintEvent(QPaintEvent *e);
|
|
||||||
//
|
|
||||||
// void mousePressEvent(QMouseEvent *e);
|
|
||||||
// void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
// void mouseMoveEvent(QMouseEvent *e);
|
|
||||||
// void leaveEvent(QEvent *e);
|
|
||||||
//
|
|
||||||
// bool animStep(float64 ms);
|
|
||||||
//
|
|
||||||
// void showStickerPack(EmojiPtr emoji);
|
|
||||||
// bool hasContent() const;
|
|
||||||
//
|
|
||||||
//public slots:
|
|
||||||
//
|
|
||||||
// void updateSelected();
|
|
||||||
//
|
|
||||||
//signals:
|
|
||||||
//
|
|
||||||
// void stickerSelected(DocumentData *sticker);
|
|
||||||
//
|
|
||||||
//private:
|
|
||||||
//
|
|
||||||
// typedef QMap<int32, uint64> StickerAnimations; // index - showing, -index - hiding
|
|
||||||
// StickerAnimations _stickerAnimations;
|
|
||||||
//
|
|
||||||
// StickerPack _stickers;
|
|
||||||
// QVector<float64> _hovers;
|
|
||||||
//
|
|
||||||
// EmojiPtr _emoji;
|
|
||||||
// int32 _selected, _pressedSel;
|
|
||||||
// QPoint _lastMousePos;
|
|
||||||
//
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
//class StickerPan : public TWidget, public Animated {
|
|
||||||
// Q_OBJECT
|
|
||||||
//
|
|
||||||
//public:
|
|
||||||
//
|
|
||||||
// StickerPan(QWidget *parent);
|
|
||||||
//
|
|
||||||
// void setStickerPack(EmojiPtr emoji, bool show);
|
|
||||||
// void paintEvent(QPaintEvent *e);
|
|
||||||
//
|
|
||||||
// void enterEvent(QEvent *e);
|
|
||||||
// void leaveEvent(QEvent *e);
|
|
||||||
// void otherEnter();
|
|
||||||
// void otherLeave();
|
|
||||||
//
|
|
||||||
// void fastHide();
|
|
||||||
//
|
|
||||||
// bool animStep(float64 ms);
|
|
||||||
//
|
|
||||||
// bool eventFilter(QObject *obj, QEvent *e);
|
|
||||||
//
|
|
||||||
//public slots:
|
|
||||||
//
|
|
||||||
// void hideStart();
|
|
||||||
// void hideFinish();
|
|
||||||
//
|
|
||||||
// void showStart();
|
|
||||||
//
|
|
||||||
//signals:
|
|
||||||
//
|
|
||||||
// void stickerSelected(DocumentData *sticker);
|
|
||||||
//
|
|
||||||
//private:
|
|
||||||
//
|
|
||||||
// void showAll();
|
|
||||||
// void hideAll();
|
|
||||||
//
|
|
||||||
// int32 _width, _height;
|
|
||||||
// bool _hiding;
|
|
||||||
// QPixmap _cache;
|
|
||||||
//
|
|
||||||
// anim::fvalue a_opacity;
|
|
||||||
//
|
|
||||||
// QTimer _hideTimer;
|
|
||||||
//
|
|
||||||
// BoxShadow _shadow;
|
|
||||||
//
|
|
||||||
// EmojiPtr _emoji;
|
|
||||||
// ScrollArea _scroll;
|
|
||||||
// StickerPanInner _inner;
|
|
||||||
//
|
|
||||||
//};
|
|
||||||
|
|
|
@ -20,11 +20,14 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
#include "boxshadow.h"
|
#include "boxshadow.h"
|
||||||
|
|
||||||
BoxShadow::BoxShadow(const style::rect &topLeft) : _size(topLeft.width() / cIntRetinaFactor()) {
|
BoxShadow::BoxShadow(const style::rect &topLeft) : _size(topLeft.width() / cIntRetinaFactor()) {
|
||||||
|
if (!_size) return;
|
||||||
|
|
||||||
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);
|
||||||
p.drawPixmap(QPoint(0, 0), App::sprite(), topLeft);
|
p.drawPixmap(QPoint(rtl() ? _size : 0, 0), App::sprite(), topLeft);
|
||||||
}
|
}
|
||||||
|
if (rtl()) cornersImage = cornersImage.mirrored(true, false);
|
||||||
uchar *bits = cornersImage.bits();
|
uchar *bits = cornersImage.bits();
|
||||||
if (bits) {
|
if (bits) {
|
||||||
for (
|
for (
|
||||||
|
@ -58,6 +61,8 @@ BoxShadow::BoxShadow(const style::rect &topLeft) : _size(topLeft.width() / cIntR
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxShadow::paint(QPainter &p, const QRect &box, const QPoint &shift, int32 flags) {
|
void BoxShadow::paint(QPainter &p, const QRect &box, const QPoint &shift, int32 flags) {
|
||||||
|
if (!_size) return;
|
||||||
|
|
||||||
int32 count = _colors.size(), minus = _size - count + 1;
|
int32 count = _colors.size(), minus = _size - count + 1;
|
||||||
bool left = (flags & Left), top = (flags & Top), right = (flags & Right), bottom = (flags & Bottom);
|
bool left = (flags & Left), top = (flags & Top), right = (flags & Right), bottom = (flags & Bottom);
|
||||||
if (left && top) p.drawPixmap(box.left() - _size + minus + shift.x(), box.top() - _size + minus + shift.y(), _corners, 0, 0, _size, _size);
|
if (left && top) p.drawPixmap(box.left() - _size + minus + shift.x(), box.top() - _size + minus + shift.y(), _corners, 0, 0, _size, _size);
|
||||||
|
|
|
@ -77,6 +77,7 @@ void Button::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setOver(bool over, ButtonStateChangeSource source) {
|
void Button::setOver(bool over, ButtonStateChangeSource source) {
|
||||||
|
// LOG(("Set over: %1, by: %2 AT %3").arg(logBool(over)).arg(source).arg(dynamic_cast<IconedButton*>(this) ? dynamic_cast<IconedButton*>(this)->getText() : qsl("Unknown")));
|
||||||
if (over && !(_state & StateOver)) {
|
if (over && !(_state & StateOver)) {
|
||||||
int oldState = _state;
|
int oldState = _state;
|
||||||
_state |= StateOver;
|
_state |= StateOver;
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
|
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
ContextMenu::ContextMenu(QWidget *parent, const style::iconedButton &st) : TWidget(0),
|
ContextMenu::ContextMenu(QWidget *parent, const style::dropdown &st, const style::iconedButton &btnst) : TWidget(0),
|
||||||
_hiding(false), _buttonStyle(st), _shadow(st::dropdownShadow), _selected(-1), a_opacity(0), _deleteOnHide(false) {
|
_width(st.width), _hiding(false), _st(st), _btnst(btnst), _shadow(_st.shadow), _selected(-1), a_opacity(0), _deleteOnHide(false) {
|
||||||
resetActions();
|
resetActions();
|
||||||
|
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint | Qt::WindowStaysOnTopHint);
|
setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
|
@ -43,13 +43,13 @@ QAction *ContextMenu::addAction(const QString &text, const QObject *receiver, co
|
||||||
connect(a, SIGNAL(changed()), this, SLOT(actionChanged()));
|
connect(a, SIGNAL(changed()), this, SLOT(actionChanged()));
|
||||||
|
|
||||||
IconedButton *b = 0;
|
IconedButton *b = 0;
|
||||||
_buttons.push_back(b = new IconedButton(this, _buttonStyle, a->text()));
|
_buttons.push_back(b = new IconedButton(this, _btnst, a->text()));
|
||||||
connect(b, SIGNAL(clicked()), this, SLOT(hideStart()));
|
connect(b, SIGNAL(clicked()), this, SLOT(hideStart()));
|
||||||
connect(b, SIGNAL(clicked()), a, SIGNAL(triggered()));
|
connect(b, SIGNAL(clicked()), a, SIGNAL(triggered()));
|
||||||
connect(b, SIGNAL(stateChanged(int,ButtonStateChangeSource)), this, SLOT(buttonStateChanged(int,ButtonStateChangeSource)));
|
connect(b, SIGNAL(stateChanged(int,ButtonStateChangeSource)), this, SLOT(buttonStateChanged(int,ButtonStateChangeSource)));
|
||||||
|
|
||||||
_width = qMax(_width, int(st::dropdownPadding.left() + st::dropdownPadding.right() + b->width()));
|
_width = qMax(_width, int(_st.padding.left() + _st.padding.right() + b->width()));
|
||||||
for (int32 i = 0, l = _buttons.size(); i < l; ++i) _buttons[i]->resize(_width - int(st::dropdownPadding.left() + st::dropdownPadding.right()), _buttons[i]->height());
|
for (int32 i = 0, l = _buttons.size(); i < l; ++i) _buttons[i]->resize(_width - int(_st.padding.left() + _st.padding.right()), _buttons[i]->height());
|
||||||
_height += b->height();
|
_height += b->height();
|
||||||
|
|
||||||
resize(_width, _height);
|
resize(_width, _height);
|
||||||
|
@ -64,8 +64,8 @@ ContextMenu::Actions &ContextMenu::actions() {
|
||||||
void ContextMenu::actionChanged() {
|
void ContextMenu::actionChanged() {
|
||||||
for (int32 i = 0, l = _actions.size(); i < l; ++i) {
|
for (int32 i = 0, l = _actions.size(); i < l; ++i) {
|
||||||
_buttons[i]->setText(_actions[i]->text());
|
_buttons[i]->setText(_actions[i]->text());
|
||||||
_width = qMax(_width, int(st::dropdownPadding.left() + st::dropdownPadding.right() + _buttons[i]->width()));
|
_width = qMax(_width, int(_st.padding.left() + _st.padding.right() + _buttons[i]->width()));
|
||||||
_buttons[i]->resize(_width - int(st::dropdownPadding.left() + st::dropdownPadding.right()), _buttons[i]->height());
|
_buttons[i]->resize(_width - int(_st.padding.left() + _st.padding.right()), _buttons[i]->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ void ContextMenu::buttonStateChanged(int oldState, ButtonStateChangeSource sourc
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu::resetActions() {
|
void ContextMenu::resetActions() {
|
||||||
_width = st::dropdownPadding.left() + st::dropdownPadding.right();
|
_width = qMax(_st.padding.left() + _st.padding.right(), int(_st.width));
|
||||||
_height = st::dropdownPadding.top() + st::dropdownPadding.bottom();
|
_height = _st.padding.top() + _st.padding.bottom();
|
||||||
resize(_width, _height);
|
resize(_width, _height);
|
||||||
|
|
||||||
clearActions();
|
clearActions();
|
||||||
|
@ -122,9 +122,9 @@ void ContextMenu::clearActions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu::resizeEvent(QResizeEvent *e) {
|
void ContextMenu::resizeEvent(QResizeEvent *e) {
|
||||||
int32 top = st::dropdownPadding.top();
|
int32 top = _st.padding.top();
|
||||||
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
for (Buttons::const_iterator i = _buttons.cbegin(), e = _buttons.cend(); i != e; ++i) {
|
||||||
(*i)->move(st::dropdownPadding.left(), top);
|
(*i)->move(_st.padding.left(), top);
|
||||||
top += (*i)->height();
|
top += (*i)->height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void ContextMenu::paintEvent(QPaintEvent *e) {
|
||||||
p.setOpacity(a_opacity.current());
|
p.setOpacity(a_opacity.current());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect r(st::dropdownPadding.left(), st::dropdownPadding.top(), _width - st::dropdownPadding.left() - st::dropdownPadding.right(), _height - st::dropdownPadding.top() - st::dropdownPadding.bottom());
|
QRect r(_st.padding.left(), _st.padding.top(), _width - _st.padding.left() - _st.padding.right(), _height - _st.padding.top() - _st.padding.bottom());
|
||||||
// draw shadow
|
// draw shadow
|
||||||
_shadow.paint(p, r);
|
_shadow.paint(p, r);
|
||||||
}
|
}
|
||||||
|
@ -245,13 +245,19 @@ void ContextMenu::deleteOnHide() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu::popup(const QPoint &p) {
|
void ContextMenu::popup(const QPoint &p) {
|
||||||
QPoint w = p - QPoint(st::dropdownPadding.left(), st::dropdownPadding.top());
|
QPoint w = p - QPoint(_st.padding.left(), _st.padding.top());
|
||||||
QRect r = App::app() ? App::app()->desktop()->screenGeometry(p) : QDesktopWidget().screenGeometry(p);
|
QRect r = App::app() ? App::app()->desktop()->screenGeometry(p) : QDesktopWidget().screenGeometry(p);
|
||||||
if (w.x() + width() - st::dropdownPadding.right() > r.x() + r.width()) {
|
if (rtl()) {
|
||||||
w.setX(r.x() + r.width() - width() + st::dropdownPadding.right());
|
if (w.x() - width() + 2 * _st.padding.left() < r.x() - _st.padding.left()) {
|
||||||
|
w.setX(r.x() - _st.padding.left());
|
||||||
|
} else {
|
||||||
|
w.setX(w.x() - width() + 2 * _st.padding.left());
|
||||||
|
}
|
||||||
|
} else if (w.x() + width() - _st.padding.right() > r.x() + r.width()) {
|
||||||
|
w.setX(r.x() + r.width() - width() + _st.padding.right());
|
||||||
}
|
}
|
||||||
if (w.y() + height() - st::dropdownPadding.bottom() > r.y() + r.height()) {
|
if (w.y() + height() - _st.padding.bottom() > r.y() + r.height()) {
|
||||||
w.setY(p.y() - height() + st::dropdownPadding.bottom());
|
w.setY(p.y() - height() + _st.padding.bottom());
|
||||||
}
|
}
|
||||||
if (w.y() < r.y()) {
|
if (w.y() < r.y()) {
|
||||||
w.setY(r.y());
|
w.setY(r.y());
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ContextMenu : public TWidget, public Animated {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ContextMenu(QWidget *parent, const style::iconedButton &st = st::btnContext);
|
ContextMenu(QWidget *parent, const style::dropdown &st = st::dropdownDef, const style::iconedButton &btnst = st::btnContext);
|
||||||
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
|
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
|
||||||
void resetActions();
|
void resetActions();
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ private:
|
||||||
int32 _width, _height;
|
int32 _width, _height;
|
||||||
bool _hiding;
|
bool _hiding;
|
||||||
|
|
||||||
const style::iconedButton &_buttonStyle;
|
const style::dropdown &_st;
|
||||||
|
const style::iconedButton &_btnst;
|
||||||
|
|
||||||
BoxShadow _shadow;
|
BoxShadow _shadow;
|
||||||
int32 _selected;
|
int32 _selected;
|
||||||
|
|
|
@ -172,16 +172,26 @@ void IconedButton::setText(const QString &text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IconedButton::getText() const {
|
||||||
|
return _text;
|
||||||
|
}
|
||||||
|
|
||||||
bool IconedButton::animStep(float64 ms) {
|
bool IconedButton::animStep(float64 ms) {
|
||||||
float64 dt = ms / _st.duration;
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
if (dt >= 1) {
|
if (_st.duration <= 1) {
|
||||||
a_opacity.finish();
|
a_opacity.finish();
|
||||||
a_bg.finish();
|
a_bg.finish();
|
||||||
res = false;
|
res = false;
|
||||||
} else {
|
} else {
|
||||||
a_opacity.update(dt, anim::linear);
|
float64 dt = ms / _st.duration;
|
||||||
a_bg.update(dt, anim::linear);
|
if (dt >= 1) {
|
||||||
|
a_opacity.finish();
|
||||||
|
a_bg.finish();
|
||||||
|
res = false;
|
||||||
|
} else {
|
||||||
|
a_opacity.update(dt, anim::linear);
|
||||||
|
a_bg.update(dt, anim::linear);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -100,6 +100,7 @@ public:
|
||||||
void setOpacity(float64 o);
|
void setOpacity(float64 o);
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
QString getText() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
|
|
@ -197,14 +197,17 @@ inline bool operator!=(const Font &a, const Font &b) {
|
||||||
typedef QMap<uint32, ColorData*> ColorDatas;
|
typedef QMap<uint32, ColorData*> ColorDatas;
|
||||||
extern ColorDatas _colorsMap;
|
extern ColorDatas _colorsMap;
|
||||||
|
|
||||||
|
extern int _spriteWidth;
|
||||||
|
|
||||||
typedef float64 number;
|
typedef float64 number;
|
||||||
typedef QString string;
|
typedef QString string;
|
||||||
typedef QRect rect;
|
typedef QRect rect;
|
||||||
class sprite : public rect {
|
|
||||||
|
class sprite : public rect {
|
||||||
public:
|
public:
|
||||||
sprite() {
|
sprite() {
|
||||||
}
|
}
|
||||||
sprite(int left, int top, int width, int height) : rect(left, top, width, height) {
|
sprite(int left, int top, int width, int height) : rect(rtl() ? (_spriteWidth - left - width) : left, top, width, height) {
|
||||||
}
|
}
|
||||||
inline int pxWidth() const {
|
inline int pxWidth() const {
|
||||||
return rect::width() / cIntRetinaFactor();
|
return rect::width() / cIntRetinaFactor();
|
||||||
|
|
|
@ -21,34 +21,54 @@ void rtl(bool is);
|
||||||
bool rtl();
|
bool rtl();
|
||||||
Qt::LayoutDirection langDir();
|
Qt::LayoutDirection langDir();
|
||||||
|
|
||||||
|
inline QRect rtlrect(int x, int y, int w, int h, int outerw) {
|
||||||
|
return rtl() ? QRect(outerw - x - w, y, w, h) : QRect(x, y, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
class Widget : public QWidget {
|
class Widget : public QWidget {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Widget(QWidget *parent = 0) : QWidget(parent) {
|
Widget(QWidget *parent = 0) : QWidget(parent) {
|
||||||
}
|
}
|
||||||
void moveToLeft(int x, int y, int w) {
|
void moveToLeft(int x, int y, int outerw) {
|
||||||
move(rtl() ? (x + w - width()) : x, y);
|
move(rtl() ? (outerw - x - width()) : x, y);
|
||||||
}
|
}
|
||||||
void moveToRight(int x, int y, int w) {
|
void moveToRight(int x, int y, int outerw) {
|
||||||
move(rtl() ? x : (x + w - width()), y);
|
move(rtl() ? x : (outerw - x - width()), y);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace App {
|
||||||
|
const QPixmap &sprite();
|
||||||
|
}
|
||||||
|
|
||||||
class Painter : public QPainter {
|
class Painter : public QPainter {
|
||||||
public:
|
public:
|
||||||
explicit Painter(QPaintDevice *device) : QPainter(device) {
|
explicit Painter(QPaintDevice *device) : QPainter(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTextLeft(int x, int y, int w, const QString &text, int textWidth = -1) {
|
void drawTextLeft(int x, int y, int outerw, const QString &text, int textWidth = -1) {
|
||||||
QFontMetrics m(fontMetrics());
|
QFontMetrics m(fontMetrics());
|
||||||
if (rtl() && textWidth < 0) textWidth = m.width(text);
|
if (rtl() && textWidth < 0) textWidth = m.width(text);
|
||||||
drawText(x + (rtl() ? (w - textWidth) : 0), y + m.ascent(), text);
|
drawText(rtl() ? (outerw - x - textWidth) : x, y + m.ascent(), text);
|
||||||
}
|
}
|
||||||
void drawTextRight(int x, int y, int w, const QString &text, int textWidth = -1) {
|
void drawTextRight(int x, int y, int outerw, const QString &text, int textWidth = -1) {
|
||||||
QFontMetrics m(fontMetrics());
|
QFontMetrics m(fontMetrics());
|
||||||
if (!rtl() && textWidth < 0) textWidth = m.width(text);
|
if (!rtl() && textWidth < 0) textWidth = m.width(text);
|
||||||
drawText(x + (rtl() ? 0 : (w - textWidth)), y + m.ascent(), text);
|
drawText(rtl() ? x : (outerw - x - textWidth), y + m.ascent(), text);
|
||||||
|
}
|
||||||
|
void drawPixmapLeft(int x, int y, int outerw, const QPixmap &pix, const QRect &from) {
|
||||||
|
drawPixmap(QPoint(rtl() ? (outerw - x - (from.width() / pix.devicePixelRatio())) : x, y), pix, from);
|
||||||
|
}
|
||||||
|
void drawPixmapRight(int x, int y, int outerw, const QPixmap &pix, const QRect &from) {
|
||||||
|
drawPixmap(QPoint(rtl() ? x : (outerw - x - (from.width() / pix.devicePixelRatio())), y), pix, from);
|
||||||
|
}
|
||||||
|
void drawSpriteLeft(int x, int y, int outerw, const QRect &sprite) {
|
||||||
|
return drawPixmapLeft(x, y, outerw, App::sprite(), sprite);
|
||||||
|
}
|
||||||
|
void drawSpriteRight(int x, int y, int outerw, const QRect &sprite) {
|
||||||
|
return drawPixmapRight(x, y, outerw, App::sprite(), sprite);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,10 +100,12 @@ protected:
|
||||||
void enterEvent(QEvent *e) {
|
void enterEvent(QEvent *e) {
|
||||||
TWidget *p(tparent());
|
TWidget *p(tparent());
|
||||||
if (p) p->leaveToChildEvent(e);
|
if (p) p->leaveToChildEvent(e);
|
||||||
|
return Widget::enterEvent(e);
|
||||||
}
|
}
|
||||||
void leaveEvent(QEvent *e) {
|
void leaveEvent(QEvent *e) {
|
||||||
TWidget *p(tparent());
|
TWidget *p(tparent());
|
||||||
if (p) p->enterFromChildEvent(e);
|
if (p) p->enterFromChildEvent(e);
|
||||||
|
return Widget::leaveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -3257,17 +3257,19 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!data->description.isEmpty()) {
|
if (!data->description.isEmpty()) {
|
||||||
|
QString text = textClean(data->description);
|
||||||
|
if (!_asArticle) text += textcmdSkipBlock(parent->timeWidth(), st::msgDateFont->height - st::msgDateDelta.y());
|
||||||
|
const TextParseOptions *opts = &_webpageDescriptionOptions;
|
||||||
if (data->siteName == QLatin1String("Twitter")) {
|
if (data->siteName == QLatin1String("Twitter")) {
|
||||||
_description.setText(st::webPageDescriptionFont, textClean(data->description), _twitterDescriptionOptions);
|
opts = &_twitterDescriptionOptions;
|
||||||
} else if (data->siteName == QLatin1String("Instagram")) {
|
} else if (data->siteName == QLatin1String("Instagram")) {
|
||||||
_description.setText(st::webPageDescriptionFont, textClean(data->description), _instagramDescriptionOptions);
|
opts = &_instagramDescriptionOptions;
|
||||||
} else {
|
|
||||||
_description.setText(st::webPageDescriptionFont, textClean(data->description), _webpageDescriptionOptions);
|
|
||||||
}
|
}
|
||||||
|
_description.setText(st::webPageDescriptionFont, text, *opts);
|
||||||
if (_asArticle) {
|
if (_asArticle) {
|
||||||
_maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth() + st::webPagePhotoDelta + st::webPagePhotoSize));
|
_maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth() + st::webPagePhotoDelta + st::webPagePhotoSize));
|
||||||
} else {
|
} else {
|
||||||
_maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth() + parent->timeWidth()));
|
_maxw = qMax(_maxw, int32(st::webPageLeft + _description.maxWidth()));
|
||||||
_minh += qMin(_description.minHeight(), 3 * st::webPageTitleFont->height);
|
_minh += qMin(_description.minHeight(), 3 * st::webPageTitleFont->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4443,7 +4445,7 @@ HistoryMedia *HistoryMessage::getMedia(bool inOverview) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::setMedia(const MTPmessageMedia &media) {
|
void HistoryMessage::setMedia(const MTPmessageMedia &media) {
|
||||||
if (!_media && media.type() == mtpc_messageMediaEmpty) return;
|
if ((!_media || _media->isImageLink()) && media.type() == mtpc_messageMediaEmpty) return;
|
||||||
if (_media) {
|
if (_media) {
|
||||||
delete _media;
|
delete _media;
|
||||||
_media = 0;
|
_media = 0;
|
||||||
|
|
|
@ -802,6 +802,10 @@ public:
|
||||||
virtual void updateFrom(const MTPMessageMedia &media) {
|
virtual void updateFrom(const MTPMessageMedia &media) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isImageLink() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool updateStickerEmoji() {
|
virtual bool updateStickerEmoji() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1167,6 +1171,10 @@ public:
|
||||||
void getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
void getState(TextLinkPtr &lnk, bool &inText, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||||
HistoryMedia *clone() const;
|
HistoryMedia *clone() const;
|
||||||
|
|
||||||
|
bool isImageLink() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageLinkData *data;
|
ImageLinkData *data;
|
||||||
TextLinkPtr link;
|
TextLinkPtr link;
|
||||||
|
|
|
@ -1402,7 +1402,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||||
if (reader.supportsAnimation() && reader.imageCount() > 1 && item) {
|
if (reader.supportsAnimation() && reader.imageCount() > 1 && item) {
|
||||||
startGif(item, already);
|
startGif(item, already);
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(document, QPixmap::fromImage(App::readImage(already, 0, false), Qt::ColorOnly), item);
|
App::wnd()->showDocument(document, item);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
psOpenFile(already);
|
psOpenFile(already);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -17,6 +17,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "dropdown.h"
|
||||||
|
|
||||||
class MediaView : public TWidget, public RPCSender, public Animated {
|
class MediaView : public TWidget, public RPCSender, public Animated {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -41,24 +43,38 @@ public:
|
||||||
|
|
||||||
void showPhoto(PhotoData *photo, HistoryItem *context);
|
void showPhoto(PhotoData *photo, HistoryItem *context);
|
||||||
void showPhoto(PhotoData *photo, PeerData *context);
|
void showPhoto(PhotoData *photo, PeerData *context);
|
||||||
void showDocument(DocumentData *doc, QPixmap pix, HistoryItem *context);
|
void showDocument(DocumentData *doc, HistoryItem *context);
|
||||||
void moveToScreen();
|
void moveToScreen();
|
||||||
void moveToPhoto(int32 delta);
|
void moveToNext(int32 delta);
|
||||||
void preloadPhotos(int32 delta);
|
void preloadData(int32 delta);
|
||||||
|
|
||||||
|
void leaveToChildEvent(QEvent *e) { // e -- from enterEvent() of child TWidget
|
||||||
|
updateOverState(OverNone);
|
||||||
|
}
|
||||||
|
void enterFromChildEvent(QEvent *e) { // e -- from leaveEvent() of child TWidget
|
||||||
|
updateOver(mapFromGlobal(QCursor::pos()));
|
||||||
|
}
|
||||||
|
|
||||||
void mediaOverviewUpdated(PeerData *peer);
|
void mediaOverviewUpdated(PeerData *peer);
|
||||||
void changingMsgId(HistoryItem *row, MsgId newId);
|
void changingMsgId(HistoryItem *row, MsgId newId);
|
||||||
void updateControls();
|
void updateControls();
|
||||||
|
void updateDropdown();
|
||||||
|
|
||||||
bool animStep(float64 dt);
|
bool animStep(float64 dt);
|
||||||
|
|
||||||
void showSaveMsgFile();
|
void showSaveMsgFile();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
void activateControls();
|
||||||
|
|
||||||
~MediaView();
|
~MediaView();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onClose();
|
void onHideControls(bool force = false);
|
||||||
|
void onDropdownHiding();
|
||||||
|
|
||||||
|
void onToMessage();
|
||||||
void onSave();
|
void onSave();
|
||||||
void onDownload();
|
void onDownload();
|
||||||
void onShowInFolder();
|
void onShowInFolder();
|
||||||
|
@ -69,6 +85,8 @@ public slots:
|
||||||
void onMenuDestroy(QObject *obj);
|
void onMenuDestroy(QObject *obj);
|
||||||
void receiveMouse();
|
void receiveMouse();
|
||||||
|
|
||||||
|
void onDropdown();
|
||||||
|
|
||||||
void onCheckActive();
|
void onCheckActive();
|
||||||
void onTouchTimer();
|
void onTouchTimer();
|
||||||
|
|
||||||
|
@ -76,29 +94,31 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void showPhoto(PhotoData *photo);
|
void displayPhoto(PhotoData *photo);
|
||||||
void loadPhotosBack();
|
void displayDocument(DocumentData *doc, HistoryItem *item);
|
||||||
|
void findCurrent();
|
||||||
|
void loadBack();
|
||||||
|
|
||||||
void photosLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req);
|
void photosLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req);
|
||||||
void userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mtpRequestId req);
|
void userPhotosLoaded(UserData *u, const MTPphotos_Photos &photos, mtpRequestId req);
|
||||||
|
void filesLoaded(History *h, const MTPmessages_Messages &msgs, mtpRequestId req);
|
||||||
|
|
||||||
void updateHeader();
|
void updateHeader();
|
||||||
void updatePolaroid();
|
|
||||||
void snapXY();
|
void snapXY();
|
||||||
|
|
||||||
QBrush _transparentBrush;
|
QBrush _transparentBrush;
|
||||||
|
|
||||||
QTimer _timer;
|
|
||||||
PhotoData *_photo;
|
PhotoData *_photo;
|
||||||
DocumentData *_doc;
|
DocumentData *_doc;
|
||||||
QRect _avail, _leftNav, _rightNav, _bottomBar, _nameNav, _dateNav, _polaroidOut, _polaroidIn;
|
MediaOverviewType _overview;
|
||||||
int32 _availBottom;
|
QRect _closeNav, _leftNav, _rightNav, _headerNav, _nameNav, _dateNav, _saveNav, _moreNav;
|
||||||
bool _leftNavVisible, _rightNavVisible;
|
bool _leftNavVisible, _rightNavVisible, _saveVisible, _headerHasLink;
|
||||||
QString _dateText;
|
QString _dateText;
|
||||||
|
QString _headerText;
|
||||||
|
|
||||||
uint64 _animStarted;
|
uint64 _animStarted;
|
||||||
|
|
||||||
int32 _maxWidth, _maxHeight, _width, _x, _y, _w, _h, _xStart, _yStart;
|
int32 _width, _x, _y, _w, _h, _xStart, _yStart;
|
||||||
int32 _zoom; // < 0 - out, 0 - none, > 0 - in
|
int32 _zoom; // < 0 - out, 0 - none, > 0 - in
|
||||||
float64 _zoomToScreen; // for documents
|
float64 _zoomToScreen; // for documents
|
||||||
QPoint _mStart;
|
QPoint _mStart;
|
||||||
|
@ -107,14 +127,24 @@ private:
|
||||||
QPixmap _current;
|
QPixmap _current;
|
||||||
int32 _full; // -1 - thumb, 0 - medium, 1 - full
|
int32 _full; // -1 - thumb, 0 - medium, 1 - full
|
||||||
|
|
||||||
History *_history; // if conversation photos overview
|
style::sprite _docIcon;
|
||||||
PeerData *_peer;
|
QString _docName, _docSize;
|
||||||
UserData *_user, *_from; // if user profile photos overview
|
int32 _docNameWidth, _docSizeWidth;
|
||||||
Text _fromName;
|
QRect _docRect;
|
||||||
int32 _index; // index in photos array, -1 if just photo
|
int32 _docThumbx, _docThumby, _docThumbw;
|
||||||
MsgId _msgid; // msgId of current photo
|
uint64 _docRadialFirst, _docRadialStart, _docRadialLast;
|
||||||
|
QPen _docRadialPen;
|
||||||
|
anim::fvalue a_docRadial, a_docRadialStart;
|
||||||
|
|
||||||
QString _header;
|
History *_history; // if conversation photos or files overview
|
||||||
|
PeerData *_peer;
|
||||||
|
UserData *_user; // if user profile photos overview
|
||||||
|
|
||||||
|
UserData *_from;
|
||||||
|
Text _fromName;
|
||||||
|
|
||||||
|
int32 _index; // index in photos or files array, -1 if just photo
|
||||||
|
MsgId _msgid; // msgId of current photo or file
|
||||||
|
|
||||||
mtpRequestId _loadRequest;
|
mtpRequestId _loadRequest;
|
||||||
|
|
||||||
|
@ -122,14 +152,33 @@ private:
|
||||||
OverNone,
|
OverNone,
|
||||||
OverLeftNav,
|
OverLeftNav,
|
||||||
OverRightNav,
|
OverRightNav,
|
||||||
|
OverClose,
|
||||||
|
OverHeader,
|
||||||
OverName,
|
OverName,
|
||||||
OverDate
|
OverDate,
|
||||||
|
OverSave,
|
||||||
|
OverMore,
|
||||||
};
|
};
|
||||||
OverState _over, _down;
|
OverState _over, _down;
|
||||||
QPoint _lastAction;
|
QPoint _lastAction, _lastMouseMovePos;
|
||||||
|
bool _ignoringDropdown;
|
||||||
|
|
||||||
|
enum ControlsState {
|
||||||
|
ControlsShowing,
|
||||||
|
ControlsShown,
|
||||||
|
ControlsHiding,
|
||||||
|
ControlsHidden,
|
||||||
|
};
|
||||||
|
ControlsState _controlsState;
|
||||||
|
uint64 _controlsAnimStarted;
|
||||||
|
QTimer _controlsHideTimer;
|
||||||
|
anim::fvalue a_cOpacity;
|
||||||
|
|
||||||
IconedButton _close, _save, _forward, _delete, _overview;
|
|
||||||
ContextMenu *_menu;
|
ContextMenu *_menu;
|
||||||
|
Dropdown _dropdown;
|
||||||
|
IconedButton *_btnToMessage, *_btnShowInFolder, *_btnSaveAs, *_btnCopy, *_btnForward, *_btnDelete, *_btnViewAll;
|
||||||
|
QList<IconedButton*> _btns;
|
||||||
|
|
||||||
bool _receiveMouse;
|
bool _receiveMouse;
|
||||||
|
|
||||||
bool _touchPress, _touchMove, _touchRightButton;
|
bool _touchPress, _touchMove, _touchRightButton;
|
||||||
|
|
|
@ -159,6 +159,7 @@ namespace {
|
||||||
QPainter p(&cornersImage);
|
QPainter p(&cornersImage);
|
||||||
p.drawPixmap(QPoint(0, 0), App::sprite(), topLeft);
|
p.drawPixmap(QPoint(0, 0), App::sprite(), topLeft);
|
||||||
}
|
}
|
||||||
|
if (rtl()) cornersImage = cornersImage.mirrored(true, false);
|
||||||
uchar *bits = cornersImage.bits();
|
uchar *bits = cornersImage.bits();
|
||||||
if (bits) {
|
if (bits) {
|
||||||
for (
|
for (
|
||||||
|
|
|
@ -470,7 +470,7 @@ void DocumentOpenLink::onClick(Qt::MouseButton button) const {
|
||||||
if (reader.supportsAnimation() && reader.imageCount() > 1 && App::hoveredLinkItem()) {
|
if (reader.supportsAnimation() && reader.imageCount() > 1 && App::hoveredLinkItem()) {
|
||||||
startGif(App::hoveredLinkItem(), already);
|
startGif(App::hoveredLinkItem(), already);
|
||||||
} else {
|
} else {
|
||||||
App::wnd()->showDocument(data, QPixmap::fromImage(App::readImage(already, 0, false), Qt::ColorOnly), App::hoveredLinkItem());
|
App::wnd()->showDocument(data, App::hoveredLinkItem());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
psOpenFile(already);
|
psOpenFile(already);
|
||||||
|
|
|
@ -739,9 +739,9 @@ void Window::showPhoto(PhotoData *photo, PeerData *peer) {
|
||||||
_mediaView->setFocus();
|
_mediaView->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::showDocument(DocumentData *doc, QPixmap pix, HistoryItem *item) {
|
void Window::showDocument(DocumentData *doc, HistoryItem *item) {
|
||||||
layerHidden();
|
layerHidden();
|
||||||
_mediaView->showDocument(doc, pix, item);
|
_mediaView->showDocument(doc, item);
|
||||||
_mediaView->activateWindow();
|
_mediaView->activateWindow();
|
||||||
_mediaView->setFocus();
|
_mediaView->setFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ public:
|
||||||
void showPhoto(const PhotoLink *lnk, HistoryItem *item = 0);
|
void showPhoto(const PhotoLink *lnk, HistoryItem *item = 0);
|
||||||
void showPhoto(PhotoData *photo, HistoryItem *item);
|
void showPhoto(PhotoData *photo, HistoryItem *item);
|
||||||
void showPhoto(PhotoData *photo, PeerData *item);
|
void showPhoto(PhotoData *photo, PeerData *item);
|
||||||
void showDocument(DocumentData *doc, QPixmap pix, HistoryItem *item);
|
void showDocument(DocumentData *doc, HistoryItem *item);
|
||||||
void showLayer(LayeredWidget *w, bool fast = false);
|
void showLayer(LayeredWidget *w, bool fast = false);
|
||||||
void replaceLayer(LayeredWidget *w);
|
void replaceLayer(LayeredWidget *w);
|
||||||
void hideLayer(bool fast = false);
|
void hideLayer(bool fast = false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue