Old sprites removed completely. Only #rrggbb and #rrggbbaa in styles.

Also moved Checkbox and Radiobutton to Ui namespace.
Also child widgets in many boxes were wrapped in ChildWidget<>.
This commit is contained in:
John Preston 2016-10-28 12:20:24 +03:00
parent 42e544abff
commit 2e4426aac0
70 changed files with 876 additions and 1726 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -31,15 +31,15 @@ emojiSize: 18px;
emojiPadding: 0px; emojiPadding: 0px;
counterBG: #f23c34; counterBG: #f23c34;
counterMuteBG: #888; counterMuteBG: #888888;
counterColor: #fff; counterColor: #ffffff;
counterMacInvColor: #ffffff01; counterMacInvColor: #ffffff01;
lineWidth: 1px; lineWidth: 1px;
transparent: #fff0; transparent: #ffffff00;
white: #fff; white: #ffffff;
black: #000; black: #000000;
wndMinWidth: 380px; wndMinWidth: 380px;
@ -163,8 +163,8 @@ defaultInputArea: InputArea {
textFg: black; textFg: black;
textMargins: margins(5px, 6px, 5px, 4px); textMargins: margins(5px, 6px, 5px, 4px);
placeholderFg: #999; placeholderFg: #999999;
placeholderFgActive: #aaa; placeholderFgActive: #aaaaaa;
placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderMargins: margins(2px, 0px, 2px, 0px);
placeholderAlign: align(topleft); placeholderAlign: align(topleft);
placeholderShift: 50px; placeholderShift: 50px;
@ -189,8 +189,8 @@ defaultInputField: InputField {
textMargins: margins(0px, 6px, 0px, 4px); textMargins: margins(0px, 6px, 0px, 4px);
textAlign: align(topleft); textAlign: align(topleft);
placeholderFg: #999; placeholderFg: #999999;
placeholderFgActive: #aaa; placeholderFgActive: #aaaaaa;
placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderMargins: margins(2px, 0px, 2px, 0px);
placeholderAlign: align(topleft); placeholderAlign: align(topleft);
placeholderShift: 50px; placeholderShift: 50px;
@ -267,7 +267,7 @@ solidScroll: flatScroll {
topsh: 0px; topsh: 0px;
bottomsh: 0px; bottomsh: 0px;
shColor: rgba(0, 0, 0, 18); shColor: #00000012;
duration: 150; duration: 150;
hiding: 0; hiding: 0;
@ -307,17 +307,17 @@ titlePos: point(44px, 29px);
titleMenuOffset: 36px; titleMenuOffset: 36px;
titleRed: #ee4928; titleRed: #ee4928;
titleGray: #777; titleGray: #777777;
titleGreen: #41a903; titleGreen: #41a903;
titleStatusFg: #999; titleStatusFg: #999999;
titleStatusActiveFg: #0080c0; titleStatusActiveFg: #0080c0;
titleTypingFg: #0080c0; titleTypingFg: #0080c0;
statusFont: font(fsize); statusFont: font(fsize);
versionColor: #777; versionColor: #777777;
shadowColor: rgba(0, 0, 0, 24); shadowColor: #00000018;
shadowToggleDuration: 200; shadowToggleDuration: 200;
slideDuration: 240; slideDuration: 240;
@ -326,22 +326,6 @@ slideFadeOut: 0.3;
slideShadow: icon {{ "slide_shadow", #000000 }}; slideShadow: icon {{ "slide_shadow", #000000 }};
slideFunction: transition(easeOutCirc); slideFunction: transition(easeOutCirc);
btnDefIconed: iconedButton {
color: white;
bgColor: white;
overBgColor: white;
font: font(fsize);
opacity: 0.78;
overOpacity: 1.;
textPos: point(0px, 0px);
downTextPos: point(0px, 0px);
duration: 150;
cursor: cursor(pointer);
}
titleButtonFg: #c4d8e9; titleButtonFg: #c4d8e9;
titleButtonActiveFg: #ffffff; titleButtonActiveFg: #ffffff;
titleButtonDuration: 150; titleButtonDuration: 150;
@ -378,12 +362,12 @@ btnBoxWhiteHover: #fafafa;
btnYesColor: #0080c0; btnYesColor: #0080c0;
btnYesHover: #0073ad; btnYesHover: #0073ad;
btnNoColor: #8b8b8b; btnNoColor: #8b8b8b;
btnNoHover: #777; btnNoHover: #777777;
titleTextButton: flatButton { titleTextButton: flatButton {
color: #d4e3ef; color: #d4e3ef;
overColor: #fff; overColor: #ffffff;
downColor: #fff; downColor: #ffffff;
bgColor: transparent; bgColor: transparent;
overBgColor: transparent; overBgColor: transparent;
downBgColor: transparent; downBgColor: transparent;
@ -445,9 +429,9 @@ btnDefLink: linkButton {
inpDefFont: font(17px); inpDefFont: font(17px);
inpDefFlat: flatInput { inpDefFlat: flatInput {
textColor: #000; textColor: #000000;
bgColor: #FFF; bgColor: #ffffff;
bgActive: #FFF; bgActive: #ffffff;
width: 210px; width: 210px;
height: 40px; height: 40px;
align: align(left); align: align(left);
@ -461,7 +445,7 @@ inpDefFlat: flatInput {
borderError: black; borderError: black;
phColor: #949494; phColor: #949494;
phFocusColor: #AAA; phFocusColor: #aaaaaa;
phAlign: align(left); phAlign: align(left);
phPos: point(2px, 0px); phPos: point(2px, 0px);
phShift: 50px; phShift: 50px;
@ -481,15 +465,15 @@ inpDefGray: flatInput(inpDefFlat) {
} }
taDefFlat: flatTextarea { taDefFlat: flatTextarea {
textColor: #000; textColor: #000000;
bgColor: #FFF; bgColor: #ffffff;
align: align(left); align: align(left);
textMrg: margins(5px, 5px, 5px, 5px); textMrg: margins(5px, 5px, 5px, 5px);
font: inpDefFont; font: inpDefFont;
cursor: cursor(text); cursor: cursor(text);
phColor: #999; phColor: #999999;
phFocusColor: #AAA; phFocusColor: #aaaaaa;
phAlign: align(topleft); phAlign: align(topleft);
phPos: point(2px, 0px); phPos: point(2px, 0px);
phShift: 50px; phShift: 50px;
@ -500,10 +484,10 @@ taDefFlat: flatTextarea {
} }
scrollDef: flatScroll { scrollDef: flatScroll {
barColor: rgba(0, 0, 0, 83); barColor: #00000053;
bgColor: rgba(0, 0, 0, 26); bgColor: #0000001a;
barOverColor: rgba(0, 0, 0, 122); barOverColor: #0000007a;
bgOverColor: rgba(0, 0, 0, 44); bgOverColor: #0000002c;
round: 2px; round: 2px;
@ -515,7 +499,7 @@ scrollDef: flatScroll {
topsh: 2px; topsh: 2px;
bottomsh: 2px; bottomsh: 2px;
shColor: rgba(0, 0, 0, 18); shColor: #00000012;
duration: 150; duration: 150;
hiding: 1000; hiding: 1000;
@ -557,7 +541,7 @@ introPointHoverHeight: 10px;
introPointLeft: 3px; introPointLeft: 3px;
introPointTop: 3px; introPointTop: 3px;
introPointDelta: 10px; introPointDelta: 10px;
introPointColor: rgb(0, 0, 0); introPointColor: #000000;
introPointAlpha: 0.5; introPointAlpha: 0.5;
introPointHoverColor: #86b4e3; introPointHoverColor: #86b4e3;
introPointStepT: transition(sineInOut); introPointStepT: transition(sineInOut);
@ -677,7 +661,7 @@ setGoodColor: #4ab44a;
noContactsHeight: 100px; noContactsHeight: 100px;
noContactsFont: font(fsize); noContactsFont: font(fsize);
noContactsColor: #777; noContactsColor: #777777;
fieldSearchIcon: icon {{ "box_search", #aaaaaa, point(10px, 9px) }}; fieldSearchIcon: icon {{ "box_search", #aaaaaa, point(10px, 9px) }};
dlgFilter: flatInput(inpDefGray) { dlgFilter: flatInput(inpDefGray) {
@ -770,7 +754,7 @@ msgMargin: margins(13px, 10px, 53px, 2px);
msgMarginTopAttached: 3px; msgMarginTopAttached: 3px;
msgLnkPadding: 2px; // for media open / save links msgLnkPadding: 2px; // for media open / save links
msgBorder: #f0f0f0; msgBorder: #f0f0f0;
msgInBg: #fff; msgInBg: #ffffff;
msgInBgSelected: #c2dcf2; // #358cd4 with 30% opacity msgInBgSelected: #c2dcf2; // #358cd4 with 30% opacity
msgOutBg: #effdde; msgOutBg: #effdde;
msgOutBgSelected: #b7dbdb; msgOutBgSelected: #b7dbdb;
@ -813,12 +797,12 @@ msgBotKbButton: botKeyboardButton {
msgServiceBg: #89a0b47f; msgServiceBg: #89a0b47f;
msgServiceSelectBg: #bbc8d4a2; msgServiceSelectBg: #bbc8d4a2;
msgServiceColor: #FFF; msgServiceColor: #ffffff;
msgServicePadding: margins(12px, 3px, 12px, 4px); msgServicePadding: margins(12px, 3px, 12px, 4px);
msgServiceMargin: margins(10px, 10px, 80px, 2px); msgServiceMargin: margins(10px, 10px, 80px, 2px);
msgColor: #000; msgColor: #000000;
msgDateColor: #000; msgDateColor: #000000;
msgLinkColor: #2a6dc2; msgLinkColor: #2a6dc2;
msgPressedLinkColor: #004bad; msgPressedLinkColor: #004bad;
msgSkip: 40px; msgSkip: 40px;
@ -830,7 +814,7 @@ msgDateSpace: 12px;
msgDateDelta: point(2px, 5px); msgDateDelta: point(2px, 5px);
msgDateImgDelta: 4px; msgDateImgDelta: 4px;
msgDateImgColor: #fff; msgDateImgColor: #ffffff;
msgDateImgBg: #00000054; msgDateImgBg: #00000054;
msgDateImgBgOver: #00000074; msgDateImgBgOver: #00000074;
msgDateImgBgSelected: #1c4a7187; msgDateImgBgSelected: #1c4a7187;
@ -860,7 +844,7 @@ defaultTextStyle: textStyle {
linkFlagsOver: font(fsize underline); linkFlagsOver: font(fsize underline);
linkFg: btnYesColor; linkFg: btnYesColor;
linkFgDown: btnYesHover; linkFgDown: btnYesHover;
monoFg: #777; monoFg: #777777;
selectBg: msgInBgSelected; selectBg: msgInBgSelected;
selectOverlay: msgSelectOverlay; selectOverlay: msgSelectOverlay;
lineHeight: 0px; lineHeight: 0px;
@ -927,7 +911,7 @@ mediaInFg: msgInDateFg;
mediaInFgSelected: msgInDateFgSelected; mediaInFgSelected: msgInDateFgSelected;
mediaOutFg: msgOutDateFg; mediaOutFg: msgOutDateFg;
mediaOutFgSelected: msgOutDateFgSelected; mediaOutFgSelected: msgOutDateFgSelected;
mediaInUnreadFg: #999; mediaInUnreadFg: #999999;
mediaInUnreadFgSelected: #7b95aa; mediaInUnreadFgSelected: #7b95aa;
mediaOutUnreadFg: #6aad60; mediaOutUnreadFg: #6aad60;
mediaOutUnreadFgSelected: #5aa382; mediaOutUnreadFgSelected: #5aa382;
@ -1077,7 +1061,7 @@ reportSpamButton: flatButton(reportSpamHide) {
width: -50px; width: -50px;
height: 30px; height: 30px;
bgColor: #888; bgColor: #888888;
overBgColor: #7b7b7b; overBgColor: #7b7b7b;
downBgColor: #7b7b7b; downBgColor: #7b7b7b;
} }
@ -1157,7 +1141,7 @@ membersPadding: margins(0px, 10px, 0px, 10px);
forwardMargins: margins(30px, 10px, 30px, 10px); forwardMargins: margins(30px, 10px, 30px, 10px);
forwardFont: font(16px); forwardFont: font(16px);
forwardBg: rgba(0, 0, 0, 76); forwardBg: #0000004c;
newGroupAboutFg: #808080; newGroupAboutFg: #808080;
newGroupPadding: margins(4px, 6px, 4px, 3px); newGroupPadding: margins(4px, 6px, 4px, 3px);
@ -1203,9 +1187,9 @@ aboutIcon: icon {{ "intro_logo", #008ed5 }};
aboutWidth: 390px; aboutWidth: 390px;
aboutVersionTop: -3px; aboutVersionTop: -3px;
aboutVersionLink: linkButton(btnDefLink) { aboutVersionLink: linkButton(btnDefLink) {
color: #999; color: #999999;
overColor: #999; overColor: #999999;
downColor: #999; downColor: #999999;
} }
aboutTextTop: 34px; aboutTextTop: 34px;
aboutSkip: 14px; aboutSkip: 14px;
@ -1224,13 +1208,13 @@ emojiReplaceHeight: 56px;
emojiReplaceInnerHeight: 42px; emojiReplaceInnerHeight: 42px;
emojiReplacePadding: 14px; emojiReplacePadding: 14px;
connectingBG: #fffe; connectingBG: #ffffffee;
connectingColor: #777; connectingColor: #777777;
connectingPadding: margins(5px, 5px, 5px, 5px); connectingPadding: margins(5px, 5px, 5px, 5px);
dragFont: font(28px semibold); dragFont: font(28px semibold);
dragSubfont: font(20px semibold); dragSubfont: font(20px semibold);
dragColor: #777; dragColor: #777777;
dragDropColor: btnYesColor; dragDropColor: btnYesColor;
dragMargin: margins(0px, 10px, 0px, 10px); dragMargin: margins(0px, 10px, 0px, 10px);
@ -1239,7 +1223,7 @@ dragPadding: margins(20px, 10px, 20px, 10px);
dragHeight: 72px; dragHeight: 72px;
dpiActive: black; dpiActive: black;
dpiInactive: #999; dpiInactive: #999999;
dpiFont1: linkFont; dpiFont1: linkFont;
dpiFont2: linkFont; dpiFont2: linkFont;
dpiFont3: linkFont; dpiFont3: linkFont;
@ -1282,7 +1266,7 @@ maxStickerSize: 256px;
maxGifSize: 320px; maxGifSize: 320px;
maxSignatureSize: 144px; maxSignatureSize: 144px;
mvBgColor: #222; mvBgColor: #222222;
mvBgOpacity: 0.92; mvBgOpacity: 0.92;
mvThickFont: semiboldFont; mvThickFont: semiboldFont;
mvFont: font(fsize); mvFont: font(fsize);
@ -1371,7 +1355,7 @@ usernameSkip: 49px;
usernameTextStyle: textStyle(defaultTextStyle) { usernameTextStyle: textStyle(defaultTextStyle) {
lineHeight: 20px; lineHeight: 20px;
} }
usernameDefaultFg: #777; usernameDefaultFg: #777777;
youtubeIcon: icon { youtubeIcon: icon {
{ "media_youtube_play_bg", #e83131c8 }, { "media_youtube_play_bg", #e83131c8 },
@ -1426,7 +1410,7 @@ mentionTop: 11px;
mentionFont: linkFont; mentionFont: linkFont;
mentionPhotoSize: msgPhotoSize; mentionPhotoSize: msgPhotoSize;
mentionBgOver: #f5f5f5; mentionBgOver: #f5f5f5;
mentionFg: #777; mentionFg: #777777;
mentionFgOver: #707070; mentionFgOver: #707070;
mentionFgActive: #0080c0; mentionFgActive: #0080c0;
mentionFgOverActive: #0077b3; mentionFgOverActive: #0077b3;
@ -1468,7 +1452,7 @@ toastFont: normalFont;
toastMaxWidth: 480px; toastMaxWidth: 480px;
toastMinMargin: 13px; toastMinMargin: 13px;
toastBg: medviewSaveMsg; toastBg: medviewSaveMsg;
toastFg: #FFF; toastFg: #ffffff;
toastPadding: margins(19px, 13px, 19px, 12px); toastPadding: margins(19px, 13px, 19px, 12px);
toastFadeInDuration: 200; toastFadeInDuration: 200;
toastFadeOutDuration: 1000; toastFadeOutDuration: 1000;

View File

@ -70,55 +70,6 @@ flatButton {
radius: pixels; radius: pixels;
} }
iconedButton {
icon: sprite;
iconPos: point;
downIcon: sprite;
downIconPos: point;
color: color;
bgColor: color;
overBgColor: color;
width: pixels;
height: pixels;
font: font;
opacity: double;
overOpacity: double;
textPos: point;
downTextPos: point;
duration: int;
cursor: cursor;
}
flatCheckbox {
textColor: color;
bgColor: color;
disColor: color;
width: pixels;
height: pixels;
textTop: pixels;
textLeft: pixels;
font: font;
duration: int;
bgFunc: transition;
cursor: cursor;
disabledCursor: cursor;
imageRect: sprite;
chkImageRect: sprite;
overImageRect: sprite;
chkOverImageRect: sprite;
disImageRect: sprite;
chkDisImageRect: sprite;
imagePos: point;
}
flatInput { flatInput {
textColor: color; textColor: color;
bgColor: color; bgColor: color;

View File

@ -6,10 +6,6 @@
<file>art/newmsg.wav</file> <file>art/newmsg.wav</file>
<file>art/bg.jpg</file> <file>art/bg.jpg</file>
<file>art/bg0.png</file> <file>art/bg0.png</file>
<file>art/sprite.png</file>
<file>art/sprite_125x.png</file>
<file>art/sprite_150x.png</file>
<file>art/sprite_200x.png</file>
<file>art/icon256.png</file> <file>art/icon256.png</file>
<file>art/iconbig256.png</file> <file>art/iconbig256.png</file>
</qresource> </qresource>

View File

@ -2370,10 +2370,6 @@ namespace {
return ::monofont; return ::monofont;
} }
const QPixmap &sprite() {
return style::spritePixmap();
}
const QPixmap &emoji() { const QPixmap &emoji() {
return *::emoji; return *::emoji;
} }

View File

@ -212,7 +212,6 @@ namespace App {
void clearMousedItems(); void clearMousedItems();
const style::font &monofont(); const style::font &monofont();
const QPixmap &sprite();
const QPixmap &emoji(); const QPixmap &emoji();
const QPixmap &emojiLarge(); const QPixmap &emojiLarge();
const QPixmap &emojiSingle(EmojiPtr emoji, int32 fontHeight); const QPixmap &emojiSingle(EmojiPtr emoji, int32 fontHeight);

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
class FlatLabel; class FlatLabel;
class ConfirmBox; class ConfirmBox;
namespace Ui {
class Checkbox;
class Radiobutton;
} // namespace Ui
class AddContactBox : public AbstractBox, public RPCSender { class AddContactBox : public AbstractBox, public RPCSender {
Q_OBJECT Q_OBJECT
@ -57,9 +62,13 @@ private:
UserData *_user = nullptr; UserData *_user = nullptr;
QString _boxTitle; QString _boxTitle;
BoxButton _save, _cancel, _retry; ChildWidget<InputField> _first;
InputField _first, _last; ChildWidget<InputField> _last;
PhoneInput _phone; ChildWidget<PhoneInput> _phone;
ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
ChildWidget<BoxButton> _retry;
bool _invertOrder; bool _invertOrder;
@ -86,10 +95,14 @@ protected:
void showAll() override; void showAll() override;
private: private:
Radiobutton _group, _channel; ChildWidget<Ui::Radiobutton> _group;
ChildWidget<Ui::Radiobutton> _channel;
int32 _aboutGroupWidth, _aboutGroupHeight; int32 _aboutGroupWidth, _aboutGroupHeight;
Text _aboutGroup, _aboutChannel; Text _aboutGroup, _aboutChannel;
BoxButton _next, _cancel;
ChildWidget<BoxButton> _next;
ChildWidget<BoxButton> _cancel;
}; };
@ -132,12 +145,14 @@ private:
Animation _a_photoOver; Animation _a_photoOver;
bool _photoOver; bool _photoOver;
InputField _title; ChildWidget<InputField> _title;
InputArea _description; ChildWidget<InputArea> _description;
QImage _photoBig; QImage _photoBig;
QPixmap _photoSmall; QPixmap _photoSmall;
BoxButton _next, _cancel;
ChildWidget<BoxButton> _next;
ChildWidget<BoxButton> _cancel;
// channel creation // channel creation
int32 _creationRequestId; int32 _creationRequestId;
@ -194,13 +209,17 @@ private:
ChannelData *_channel; ChannelData *_channel;
bool _existing; bool _existing;
Radiobutton _public, _private; ChildWidget<Ui::Radiobutton> _public, _private;
int32 _aboutPublicWidth, _aboutPublicHeight; int32 _aboutPublicWidth, _aboutPublicHeight;
Text _aboutPublic, _aboutPrivate; Text _aboutPublic, _aboutPrivate;
UsernameInput _link;
ChildWidget<UsernameInput> _link;
QRect _invitationLink; QRect _invitationLink;
bool _linkOver; bool _linkOver;
BoxButton _save, _skip;
ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _skip;
bool _tooMuchUsernames = false; bool _tooMuchUsernames = false;
@ -243,8 +262,11 @@ private:
PeerData *_peer; PeerData *_peer;
QString _boxTitle; QString _boxTitle;
BoxButton _save, _cancel; ChildWidget<InputField> _first;
InputField _first, _last; ChildWidget<InputField> _last;
ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
bool _invertOrder; bool _invertOrder;
@ -287,14 +309,19 @@ private:
ChannelData *_channel; ChannelData *_channel;
BoxButton _save, _cancel; ChildWidget<InputField> _title;
InputField _title; ChildWidget<InputArea> _description;
InputArea _description; ChildWidget<Ui::Checkbox> _sign;
Checkbox _sign;
LinkButton _publicLink; ChildWidget<LinkButton> _publicLink;
ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
mtpRequestId _saveTitleRequestId;
mtpRequestId _saveDescriptionRequestId;
mtpRequestId _saveSignRequestId;
mtpRequestId _saveTitleRequestId, _saveDescriptionRequestId, _saveSignRequestId;
QString _sentTitle, _sentDescription; QString _sentTitle, _sentDescription;
}; };

View File

@ -27,6 +27,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "confirmbox.h" #include "confirmbox.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui/buttons/checkbox.h"
AutoLockBox::AutoLockBox() : AutoLockBox::AutoLockBox() :
_close(this, lang(lng_box_ok), st::defaultBoxButton) { _close(this, lang(lng_box_ok), st::defaultBoxButton) {
@ -41,7 +42,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) {
_options.reserve(cnt); _options.reserve(cnt);
for (int32 i = 0; i < cnt; ++i) { for (int32 i = 0; i < cnt; ++i) {
int32 v = opts[i]; int32 v = opts[i];
_options.push_back(new Radiobutton(this, qsl("autolock"), v, (v % 3600) ? lng_passcode_autolock_minutes(lt_count, v / 60) : lng_passcode_autolock_hours(lt_count, v / 3600), (Global::AutoLock() == v), st::langsButton)); _options.push_back(new Ui::Radiobutton(this, qsl("autolock"), v, (v % 3600) ? lng_passcode_autolock_minutes(lt_count, v / 60) : lng_passcode_autolock_hours(lt_count, v / 3600), (Global::AutoLock() == v), st::langsButton));
_options.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); _options.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y);
y += _options.back()->height() + st::boxOptionListPadding.top(); y += _options.back()->height() + st::boxOptionListPadding.top();
connect(_options.back(), SIGNAL(changed()), this, SLOT(onChange())); connect(_options.back(), SIGNAL(changed()), this, SLOT(onChange()));

View File

@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
namespace Ui {
class Radiobutton;
} // namespace Ui
class AutoLockBox : public AbstractBox { class AutoLockBox : public AbstractBox {
Q_OBJECT Q_OBJECT
@ -37,7 +41,7 @@ protected:
void showAll() override; void showAll() override;
private: private:
QVector<Radiobutton*> _options; QVector<Ui::Radiobutton*> _options;
BoxButton _close; BoxButton _close;
}; };

View File

@ -120,8 +120,8 @@ contactsMultiSelect: MultiSelect {
textBg: transparent; textBg: transparent;
textMargins: margins(2px, 7px, 2px, 0px); textMargins: margins(2px, 7px, 2px, 0px);
placeholderFg: #999; placeholderFg: #999999;
placeholderFgActive: #aaa; placeholderFgActive: #aaaaaa;
placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderMargins: margins(2px, 0px, 2px, 0px);
border: 0px; border: 0px;
@ -203,7 +203,7 @@ notificationSampleTextFg: #d7d7d7;
notificationSampleNameFg: #939393; notificationSampleNameFg: #939393;
membersAboutPadding: margins(0px, 12px, 0px, 12px); membersAboutPadding: margins(0px, 12px, 0px, 12px);
membersAboutFg: #777; membersAboutFg: #777777;
sessionsScroll: flatScroll(boxScroll) { sessionsScroll: flatScroll(boxScroll) {
round: 2px; round: 2px;
@ -217,7 +217,7 @@ sessionCurrentHeight: 118px;
sessionPadding: margins(21px, 10px, 21px, 0px); sessionPadding: margins(21px, 10px, 21px, 0px);
sessionNameFont: msgNameFont; sessionNameFont: msgNameFont;
sessionActiveFont: msgDateFont; sessionActiveFont: msgDateFont;
sessionActiveColor: #aaa; sessionActiveColor: #aaaaaa;
sessionInfoFont: msgFont; sessionInfoFont: msgFont;
sessionInfoColor: #888888; sessionInfoColor: #888888;
sessionTerminateTop: 30px; sessionTerminateTop: 30px;

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "application.h" #include "application.h"
#include "ui/buttons/checkbox.h"
#include "core/click_handler_types.h" #include "core/click_handler_types.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "localstorage.h" #include "localstorage.h"
@ -56,10 +57,10 @@ ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const style
void ConfirmBox::init(const QString &text) { void ConfirmBox::init(const QString &text) {
_text.setText(st::boxTextFont, text, _informative ? _confirmBoxTextOptions : _textPlainOptions); _text.setText(st::boxTextFont, text, _informative ? _confirmBoxTextOptions : _textPlainOptions);
connect(&_confirm, SIGNAL(clicked()), this, SLOT(onConfirmPressed())); connect(_confirm, SIGNAL(clicked()), this, SLOT(onConfirmPressed()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onCancel())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onCancel()));
if (_informative) { if (_informative) {
_cancel.hide(); _cancel->hide();
connect(this, SIGNAL(confirmed()), this, SLOT(onCancel())); connect(this, SIGNAL(confirmed()), this, SLOT(onCancel()));
} }
onTextUpdated(); onTextUpdated();
@ -78,7 +79,7 @@ void ConfirmBox::onTextUpdated() {
textstyleSet(&st::boxTextStyle); textstyleSet(&st::boxTextStyle);
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight)); _textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
setMaxHeight(st::boxPadding.top() + _textHeight + st::boxPadding.bottom() + st::boxButtonPadding.top() + _confirm.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPadding.top() + _textHeight + st::boxPadding.bottom() + st::boxButtonPadding.top() + _confirm->height() + st::boxButtonPadding.bottom());
textstyleRestore(); textstyleRestore();
setMouseTracking(_text.hasLinks()); setMouseTracking(_text.hasLinks());
@ -144,10 +145,10 @@ void ConfirmBox::closePressed() {
void ConfirmBox::showAll() { void ConfirmBox::showAll() {
if (_informative) { if (_informative) {
_confirm.show(); _confirm->show();
} else { } else {
_confirm.show(); _confirm->show();
_cancel.show(); _cancel->show();
} }
} }
@ -171,8 +172,8 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
} }
void ConfirmBox::resizeEvent(QResizeEvent *e) { void ConfirmBox::resizeEvent(QResizeEvent *e) {
_confirm.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm.height()); _confirm->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _confirm.width() + st::boxButtonPadding.left(), _confirm.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _confirm->width() + st::boxButtonPadding.left(), _confirm->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
@ -219,9 +220,9 @@ MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth)
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight)); _textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
setMaxHeight(st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _close.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _close->height() + st::boxButtonPadding.bottom());
connect(&_close, SIGNAL(clicked()), this, SLOT(onClose())); connect(_close, SIGNAL(clicked()), this, SLOT(onClose()));
prepare(); prepare();
} }
@ -267,7 +268,7 @@ void MaxInviteBox::step_good(float64 ms, bool timer) {
} }
void MaxInviteBox::showAll() { void MaxInviteBox::showAll() {
_close.show(); _close->show();
} }
void MaxInviteBox::paintEvent(QPaintEvent *e) { void MaxInviteBox::paintEvent(QPaintEvent *e) {
@ -287,13 +288,13 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
p.setOpacity(a_goodOpacity.current()); p.setOpacity(a_goodOpacity.current());
p.setPen(st::setGoodColor); p.setPen(st::setGoodColor);
p.setFont(st::boxTextFont); p.setFont(st::boxTextFont);
p.drawTextLeft(st::boxPadding.left(), height() - st::boxButtonPadding.bottom() - _close.height() + st::defaultBoxButton.textTop + st::defaultBoxButton.font->ascent - st::boxTextFont->ascent, width(), _goodTextLink); p.drawTextLeft(st::boxPadding.left(), height() - st::boxButtonPadding.bottom() - _close->height() + st::defaultBoxButton.textTop + st::defaultBoxButton.font->ascent - st::boxTextFont->ascent, width(), _goodTextLink);
p.setOpacity(1); p.setOpacity(1);
} }
} }
void MaxInviteBox::resizeEvent(QResizeEvent *e) { void MaxInviteBox::resizeEvent(QResizeEvent *e) {
_close.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close.height()); _close->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close->height());
_invitationLink = myrtlrect(st::boxPadding.left(), st::boxPadding.top() + _textHeight + st::boxTextFont->height, width() - st::boxPadding.left() - st::boxPadding.right(), 2 * st::boxTextFont->height); _invitationLink = myrtlrect(st::boxPadding.left(), st::boxPadding.top() + _textHeight + st::boxTextFont->height, width() - st::boxPadding.left() - st::boxPadding.right(), 2 * st::boxTextFont->height);
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
@ -315,11 +316,11 @@ ConvertToSupergroupBox::ConvertToSupergroupBox(ChatData *chat) : AbstractBox(st:
_note.setText(st::boxTextFont, lng_profile_convert_warning(lt_bold_start, textcmdStartSemibold(), lt_bold_end, textcmdStopSemibold()), _confirmBoxTextOptions); _note.setText(st::boxTextFont, lng_profile_convert_warning(lt_bold_start, textcmdStartSemibold(), lt_bold_end, textcmdStopSemibold()), _confirmBoxTextOptions);
_textWidth = st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textWidth = st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right();
_textHeight = _text.countHeight(_textWidth); _textHeight = _text.countHeight(_textWidth);
setMaxHeight(st::boxTitleHeight + _textHeight + st::boxPadding.bottom() + _note.countHeight(_textWidth) + st::boxButtonPadding.top() + _convert.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxTitleHeight + _textHeight + st::boxPadding.bottom() + _note.countHeight(_textWidth) + st::boxButtonPadding.top() + _convert->height() + st::boxButtonPadding.bottom());
textstyleRestore(); textstyleRestore();
connect(&_convert, SIGNAL(clicked()), this, SLOT(onConvert())); connect(_convert, SIGNAL(clicked()), this, SLOT(onConvert()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
prepare(); prepare();
} }
@ -360,8 +361,8 @@ bool ConvertToSupergroupBox::convertFail(const RPCError &error) {
} }
void ConvertToSupergroupBox::showAll() { void ConvertToSupergroupBox::showAll() {
_convert.show(); _convert->show();
_cancel.show(); _cancel->show();
} }
void ConvertToSupergroupBox::keyPressEvent(QKeyEvent *e) { void ConvertToSupergroupBox::keyPressEvent(QKeyEvent *e) {
@ -387,8 +388,8 @@ void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) {
} }
void ConvertToSupergroupBox::resizeEvent(QResizeEvent *e) { void ConvertToSupergroupBox::resizeEvent(QResizeEvent *e) {
_convert.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _convert.height()); _convert->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _convert->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _convert.width() + st::boxButtonPadding.left(), _convert.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _convert->width() + st::boxButtonPadding.left(), _convert->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
@ -399,18 +400,18 @@ PinMessageBox::PinMessageBox(ChannelData *channel, MsgId msgId) : AbstractBox(st
, _notify(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox) , _notify(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox)
, _pin(this, lang(lng_pinned_pin), st::defaultBoxButton) , _pin(this, lang(lng_pinned_pin), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) { , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
_text.resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); _text->resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right());
setMaxHeight(st::boxPadding.top() + _text.height() + st::boxMediumSkip + _notify.height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _pin.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPadding.top() + _text->height() + st::boxMediumSkip + _notify->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _pin->height() + st::boxButtonPadding.bottom());
connect(&_pin, SIGNAL(clicked()), this, SLOT(onPin())); connect(_pin, SIGNAL(clicked()), this, SLOT(onPin()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
} }
void PinMessageBox::resizeEvent(QResizeEvent *e) { void PinMessageBox::resizeEvent(QResizeEvent *e) {
_text.moveToLeft(st::boxPadding.left(), st::boxPadding.top()); _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
_notify.moveToLeft(st::boxPadding.left(), _text.y() + _text.height() + st::boxMediumSkip); _notify->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip);
_pin.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _pin.height()); _pin->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _pin->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _pin.width() + st::boxButtonPadding.left(), _pin.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _pin->width() + st::boxButtonPadding.left(), _pin->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
@ -418,17 +419,17 @@ void PinMessageBox::onPin() {
if (_requestId) return; if (_requestId) return;
MTPchannels_UpdatePinnedMessage::Flags flags = 0; MTPchannels_UpdatePinnedMessage::Flags flags = 0;
if (!_notify.checked()) { if (!_notify->checked()) {
flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent; flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent;
} }
_requestId = MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(flags), _channel->inputChannel, MTP_int(_msgId)), rpcDone(&PinMessageBox::pinDone), rpcFail(&PinMessageBox::pinFail)); _requestId = MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(flags), _channel->inputChannel, MTP_int(_msgId)), rpcDone(&PinMessageBox::pinDone), rpcFail(&PinMessageBox::pinFail));
} }
void PinMessageBox::showAll() { void PinMessageBox::showAll() {
_text.show(); _text->show();
_notify.show(); _notify->show();
_pin.show(); _pin->show();
_cancel.show(); _cancel->show();
} }
void PinMessageBox::pinDone(const MTPUpdates &updates) { void PinMessageBox::pinDone(const MTPUpdates &updates) {
@ -456,31 +457,31 @@ RichDeleteMessageBox::RichDeleteMessageBox(ChannelData *channel, UserData *from,
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) { , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
t_assert(_channel != nullptr); t_assert(_channel != nullptr);
_text.resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); _text->resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right());
setMaxHeight(st::boxPadding.top() + _text.height() + st::boxMediumSkip + _banUser.height() + st::boxLittleSkip + _reportSpam.height() + st::boxLittleSkip + _deleteAll.height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _delete.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPadding.top() + _text->height() + st::boxMediumSkip + _banUser->height() + st::boxLittleSkip + _reportSpam->height() + st::boxLittleSkip + _deleteAll->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _delete->height() + st::boxButtonPadding.bottom());
connect(&_delete, SIGNAL(clicked()), this, SLOT(onDelete())); connect(_delete, SIGNAL(clicked()), this, SLOT(onDelete()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
} }
void RichDeleteMessageBox::resizeEvent(QResizeEvent *e) { void RichDeleteMessageBox::resizeEvent(QResizeEvent *e) {
_text.moveToLeft(st::boxPadding.left(), st::boxPadding.top()); _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
_banUser.moveToLeft(st::boxPadding.left(), _text.y() + _text.height() + st::boxMediumSkip); _banUser->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip);
_reportSpam.moveToLeft(st::boxPadding.left(), _banUser.y() + _banUser.height() + st::boxLittleSkip); _reportSpam->moveToLeft(st::boxPadding.left(), _banUser->y() + _banUser->height() + st::boxLittleSkip);
_deleteAll.moveToLeft(st::boxPadding.left(), _reportSpam.y() + _reportSpam.height() + st::boxLittleSkip); _deleteAll->moveToLeft(st::boxPadding.left(), _reportSpam->y() + _reportSpam->height() + st::boxLittleSkip);
_delete.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _delete.height()); _delete->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _delete->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _delete.width() + st::boxButtonPadding.left(), _delete.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _delete->width() + st::boxButtonPadding.left(), _delete->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
void RichDeleteMessageBox::onDelete() { void RichDeleteMessageBox::onDelete() {
if (_banUser.checked()) { if (_banUser->checked()) {
MTP::send(MTPchannels_KickFromChannel(_channel->inputChannel, _from->inputUser, MTP_boolTrue()), App::main()->rpcDone(&MainWidget::sentUpdatesReceived)); MTP::send(MTPchannels_KickFromChannel(_channel->inputChannel, _from->inputUser, MTP_boolTrue()), App::main()->rpcDone(&MainWidget::sentUpdatesReceived));
} }
if (_reportSpam.checked()) { if (_reportSpam->checked()) {
MTP::send(MTPchannels_ReportSpam(_channel->inputChannel, _from->inputUser, MTP_vector<MTPint>(1, MTP_int(_msgId)))); MTP::send(MTPchannels_ReportSpam(_channel->inputChannel, _from->inputUser, MTP_vector<MTPint>(1, MTP_int(_msgId))));
} }
if (_deleteAll.checked()) { if (_deleteAll->checked()) {
App::main()->deleteAllFromUser(_channel, _from); App::main()->deleteAllFromUser(_channel, _from);
} }
if (HistoryItem *item = App::histItemById(_channel ? peerToChannel(_channel->id) : 0, _msgId)) { if (HistoryItem *item = App::histItemById(_channel ? peerToChannel(_channel->id) : 0, _msgId)) {
@ -497,12 +498,12 @@ void RichDeleteMessageBox::onDelete() {
} }
void RichDeleteMessageBox::showAll() { void RichDeleteMessageBox::showAll() {
_text.show(); _text->show();
_banUser.show(); _banUser->show();
_reportSpam.show(); _reportSpam->show();
_deleteAll.show(); _deleteAll->show();
_delete.show(); _delete->show();
_cancel.show(); _cancel->show();
} }
KickMemberBox::KickMemberBox(PeerData *chat, UserData *member) KickMemberBox::KickMemberBox(PeerData *chat, UserData *member)

View File

@ -24,6 +24,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/flatlabel.h" #include "ui/flatlabel.h"
#include "core/lambda_wrap.h" #include "core/lambda_wrap.h"
namespace Ui {
class Checkbox;
} // namespace Ui
class InformBox; class InformBox;
class ConfirmBox : public AbstractBox, public ClickHandlerHost { class ConfirmBox : public AbstractBox, public ClickHandlerHost {
Q_OBJECT Q_OBJECT
@ -81,7 +85,8 @@ private:
QPoint _lastMousePos; QPoint _lastMousePos;
BoxButton _confirm, _cancel; ChildWidget<BoxButton> _confirm;
ChildWidget<BoxButton> _cancel;
base::lambda_unique<void()> _confirmedCallback; base::lambda_unique<void()> _confirmedCallback;
@ -159,7 +164,8 @@ private:
void updateSelected(const QPoint &cursorGlobalPosition); void updateSelected(const QPoint &cursorGlobalPosition);
void step_good(float64 ms, bool timer); void step_good(float64 ms, bool timer);
BoxButton _close; ChildWidget<BoxButton> _close;
Text _text; Text _text;
int32 _textWidth, _textHeight; int32 _textWidth, _textHeight;
@ -199,7 +205,8 @@ private:
Text _text, _note; Text _text, _note;
int32 _textWidth, _textHeight; int32 _textWidth, _textHeight;
BoxButton _convert, _cancel; ChildWidget<BoxButton> _convert;
ChildWidget<BoxButton> _cancel;
}; };
@ -224,10 +231,11 @@ private:
ChannelData *_channel; ChannelData *_channel;
MsgId _msgId; MsgId _msgId;
FlatLabel _text; ChildWidget<FlatLabel> _text;
Checkbox _notify; ChildWidget<Ui::Checkbox> _notify;
BoxButton _pin, _cancel; ChildWidget<BoxButton> _pin;
ChildWidget<BoxButton> _cancel;
mtpRequestId _requestId = 0; mtpRequestId _requestId = 0;
@ -252,10 +260,13 @@ private:
UserData *_from; UserData *_from;
MsgId _msgId; MsgId _msgId;
FlatLabel _text; ChildWidget<FlatLabel> _text;
Checkbox _banUser, _reportSpam, _deleteAll; ChildWidget<Ui::Checkbox> _banUser;
ChildWidget<Ui::Checkbox> _reportSpam;
ChildWidget<Ui::Checkbox> _deleteAll;
BoxButton _delete, _cancel; ChildWidget<BoxButton> _delete;
ChildWidget<BoxButton> _cancel;
}; };

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "connectionbox.h" #include "connectionbox.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui/buttons/checkbox.h"
#include "history/history_location_manager.h" #include "history/history_location_manager.h"
ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth) ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth)
@ -40,51 +41,51 @@ ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth)
, _save(this, lang(lng_connection_save), st::defaultBoxButton) , _save(this, lang(lng_connection_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) { , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); connect(_save, SIGNAL(clicked()), this, SLOT(onSave()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
connect(&_autoRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(_autoRadio, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); connect(_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_hostInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); connect(_hostInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
connect(&_portInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); connect(_portInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
connect(&_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); connect(_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
connect(&_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); connect(_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
prepare(); prepare();
} }
void ConnectionBox::showAll() { void ConnectionBox::showAll() {
_autoRadio.show(); _autoRadio->show();
_httpProxyRadio.show(); _httpProxyRadio->show();
_tcpProxyRadio.show(); _tcpProxyRadio->show();
_tryIPv6.show(); _tryIPv6->show();
int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _autoRadio.height() + st::boxOptionListPadding.top() + _httpProxyRadio.height() + st::boxOptionListPadding.top() + _tcpProxyRadio.height() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6.height() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _autoRadio->height() + st::boxOptionListPadding.top() + _httpProxyRadio->height() + st::boxOptionListPadding.top() + _tcpProxyRadio->height() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6->height() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom();
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) {
h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput.height(); h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput->height();
_hostInput.show(); _hostInput->show();
_portInput.show(); _portInput->show();
_userInput.show(); _userInput->show();
_passwordInput.show(); _passwordInput->show();
} else { } else {
_hostInput.hide(); _hostInput->hide();
_portInput.hide(); _portInput->hide();
_userInput.hide(); _userInput->hide();
_passwordInput.hide(); _passwordInput->hide();
} }
_save.show(); _save->show();
_cancel.show(); _cancel->show();
setMaxHeight(h); setMaxHeight(h);
resizeEvent(0); resizeEvent(0);
} }
void ConnectionBox::doSetInnerFocus() { void ConnectionBox::doSetInnerFocus() {
if (!_hostInput.isHidden()) { if (!_hostInput->isHidden()) {
_hostInput.setFocus(); _hostInput->setFocus();
} }
} }
@ -96,70 +97,70 @@ void ConnectionBox::paintEvent(QPaintEvent *e) {
} }
void ConnectionBox::resizeEvent(QResizeEvent *e) { void ConnectionBox::resizeEvent(QResizeEvent *e) {
_autoRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); _autoRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top());
_httpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio.y() + _autoRadio.height() + st::boxOptionListPadding.top()); _httpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio->y() + _autoRadio->height() + st::boxOptionListPadding.top());
int32 inputy = 0; int32 inputy = 0;
if (_httpProxyRadio.checked()) { if (_httpProxyRadio->checked()) {
inputy = _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top(); inputy = _httpProxyRadio->y() + _httpProxyRadio->height() + st::boxOptionListPadding.top();
_tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput.height() + st::boxOptionListPadding.top()); _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput->height() + st::boxOptionListPadding.top());
} else { } else {
_tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top()); _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio->y() + _httpProxyRadio->height() + st::boxOptionListPadding.top());
if (_tcpProxyRadio.checked()) { if (_tcpProxyRadio->checked()) {
inputy = _tcpProxyRadio.y() + _tcpProxyRadio.height() + st::boxOptionListPadding.top(); inputy = _tcpProxyRadio->y() + _tcpProxyRadio->height() + st::boxOptionListPadding.top();
} }
} }
if (inputy) { if (inputy) {
_hostInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), inputy); _hostInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), inputy);
_portInput.moveToRight(st::boxPadding.right(), inputy); _portInput->moveToRight(st::boxPadding.right(), inputy);
_userInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput.y() + _hostInput.height() + st::boxOptionListPadding.top()); _userInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput->y() + _hostInput->height() + st::boxOptionListPadding.top());
_passwordInput.moveToRight(st::boxPadding.right(), _userInput.y()); _passwordInput->moveToRight(st::boxPadding.right(), _userInput->y());
} }
int32 tryipv6y = (_tcpProxyRadio.checked() ? (_userInput.y() + _userInput.height()) : (_tcpProxyRadio.y() + _tcpProxyRadio.height())) + st::boxOptionListPadding.top() + st::connectionIPv6Skip; int32 tryipv6y = (_tcpProxyRadio->checked() ? (_userInput->y() + _userInput->height()) : (_tcpProxyRadio->y() + _tcpProxyRadio->height())) + st::boxOptionListPadding.top() + st::connectionIPv6Skip;
_tryIPv6.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y); _tryIPv6->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y);
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
void ConnectionBox::onChange() { void ConnectionBox::onChange() {
showAll(); showAll();
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) {
_hostInput.setFocus(); _hostInput->setFocus();
if (_httpProxyRadio.checked() && !_portInput.getLastText().toInt()) { if (_httpProxyRadio->checked() && !_portInput->getLastText().toInt()) {
_portInput.setText(qsl("80")); _portInput->setText(qsl("80"));
_portInput.updatePlaceholder(); _portInput->updatePlaceholder();
} }
} }
update(); update();
} }
void ConnectionBox::onSubmit() { void ConnectionBox::onSubmit() {
if (_hostInput.hasFocus()) { if (_hostInput->hasFocus()) {
if (!_hostInput.getLastText().trimmed().isEmpty()) { if (!_hostInput->getLastText().trimmed().isEmpty()) {
_portInput.setFocus(); _portInput->setFocus();
} else { } else {
_hostInput.showError(); _hostInput->showError();
} }
} else if (_portInput.hasFocus()) { } else if (_portInput->hasFocus()) {
if (_portInput.getLastText().trimmed().toInt() > 0) { if (_portInput->getLastText().trimmed().toInt() > 0) {
_userInput.setFocus(); _userInput->setFocus();
} else { } else {
_portInput.showError(); _portInput->showError();
} }
} else if (_userInput.hasFocus()) { } else if (_userInput->hasFocus()) {
_passwordInput.setFocus(); _passwordInput->setFocus();
} else if (_passwordInput.hasFocus()) { } else if (_passwordInput->hasFocus()) {
if (_hostInput.getLastText().trimmed().isEmpty()) { if (_hostInput->getLastText().trimmed().isEmpty()) {
_hostInput.setFocus(); _hostInput->setFocus();
_hostInput.showError(); _hostInput->showError();
} else if (_portInput.getLastText().trimmed().toInt() <= 0) { } else if (_portInput->getLastText().trimmed().toInt() <= 0) {
_portInput.setFocus(); _portInput->setFocus();
_portInput.showError(); _portInput->showError();
} else { } else {
onSave(); onSave();
} }
@ -167,20 +168,20 @@ void ConnectionBox::onSubmit() {
} }
void ConnectionBox::onSave() { void ConnectionBox::onSave() {
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) {
ProxyData p; ProxyData p;
p.host = _hostInput.getLastText().trimmed(); p.host = _hostInput->getLastText().trimmed();
p.user = _userInput.getLastText().trimmed(); p.user = _userInput->getLastText().trimmed();
p.password = _passwordInput.getLastText().trimmed(); p.password = _passwordInput->getLastText().trimmed();
p.port = _portInput.getLastText().toInt(); p.port = _portInput->getLastText().toInt();
if (p.host.isEmpty()) { if (p.host.isEmpty()) {
_hostInput.setFocus(); _hostInput->setFocus();
return; return;
} else if (!p.port) { } else if (!p.port) {
_portInput.setFocus(); _portInput->setFocus();
return; return;
} }
if (_httpProxyRadio.checked()) { if (_httpProxyRadio->checked()) {
Global::SetConnectionType(dbictHttpProxy); Global::SetConnectionType(dbictHttpProxy);
} else { } else {
Global::SetConnectionType(dbictTcpProxy); Global::SetConnectionType(dbictTcpProxy);
@ -194,8 +195,8 @@ void ConnectionBox::onSave() {
QNetworkProxyFactory::setUseSystemConfiguration(true); QNetworkProxyFactory::setUseSystemConfiguration(true);
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY #endif // !TDESKTOP_DISABLE_NETWORK_PROXY
} }
if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6.checked()) { if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6->checked()) {
Global::SetTryIPv6(_tryIPv6.checked()); Global::SetTryIPv6(_tryIPv6->checked());
Local::writeSettings(); Local::writeSettings();
Global::RefConnectionTypeChanged().notify(); Global::RefConnectionTypeChanged().notify();
@ -203,7 +204,7 @@ void ConnectionBox::onSave() {
cSetRestartingToSettings(true); cSetRestartingToSettings(true);
App::quit(); App::quit();
} else { } else {
Global::SetTryIPv6(_tryIPv6.checked()); Global::SetTryIPv6(_tryIPv6->checked());
Local::writeSettings(); Local::writeSettings();
Global::RefConnectionTypeChanged().notify(); Global::RefConnectionTypeChanged().notify();
@ -226,25 +227,25 @@ AutoDownloadBox::AutoDownloadBox() : AbstractBox(st::boxWidth)
, _save(this, lang(lng_connection_save), st::defaultBoxButton) , _save(this, lang(lng_connection_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) { , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
setMaxHeight(3 * _sectionHeight + st::setLittleSkip + _gifPlay.height() + st::setLittleSkip + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom()); setMaxHeight(3 * _sectionHeight + st::setLittleSkip + _gifPlay->height() + st::setLittleSkip + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom());
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); connect(_save, SIGNAL(clicked()), this, SLOT(onSave()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
prepare(); prepare();
} }
void AutoDownloadBox::showAll() { void AutoDownloadBox::showAll() {
_photoPrivate.show(); _photoPrivate->show();
_photoGroups.show(); _photoGroups->show();
_audioPrivate.show(); _audioPrivate->show();
_audioGroups.show(); _audioGroups->show();
_gifPrivate.show(); _gifPrivate->show();
_gifGroups.show(); _gifGroups->show();
_gifPlay.show(); _gifPlay->show();
_save.show(); _save->show();
_cancel.show(); _cancel->show();
} }
void AutoDownloadBox::paintEvent(QPaintEvent *e) { void AutoDownloadBox::paintEvent(QPaintEvent *e) {
@ -259,25 +260,25 @@ void AutoDownloadBox::paintEvent(QPaintEvent *e) {
} }
void AutoDownloadBox::resizeEvent(QResizeEvent *e) { void AutoDownloadBox::resizeEvent(QResizeEvent *e) {
_photoPrivate.moveToLeft(st::boxTitlePosition.x(), st::boxTitleHeight + st::setLittleSkip); _photoPrivate->moveToLeft(st::boxTitlePosition.x(), st::boxTitleHeight + st::setLittleSkip);
_photoGroups.moveToLeft(st::boxTitlePosition.x(), _photoPrivate.y() + _photoPrivate.height() + st::setLittleSkip); _photoGroups->moveToLeft(st::boxTitlePosition.x(), _photoPrivate->y() + _photoPrivate->height() + st::setLittleSkip);
_audioPrivate.moveToLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitleHeight + st::setLittleSkip); _audioPrivate->moveToLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitleHeight + st::setLittleSkip);
_audioGroups.moveToLeft(st::boxTitlePosition.x(), _audioPrivate.y() + _audioPrivate.height() + st::setLittleSkip); _audioGroups->moveToLeft(st::boxTitlePosition.x(), _audioPrivate->y() + _audioPrivate->height() + st::setLittleSkip);
_gifPrivate.moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitleHeight + st::setLittleSkip); _gifPrivate->moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitleHeight + st::setLittleSkip);
_gifGroups.moveToLeft(st::boxTitlePosition.x(), _gifPrivate.y() + _gifPrivate.height() + st::setLittleSkip); _gifGroups->moveToLeft(st::boxTitlePosition.x(), _gifPrivate->y() + _gifPrivate->height() + st::setLittleSkip);
_gifPlay.moveToLeft(st::boxTitlePosition.x(), _gifGroups.y() + _gifGroups.height() + st::setLittleSkip); _gifPlay->moveToLeft(st::boxTitlePosition.x(), _gifGroups->y() + _gifGroups->height() + st::setLittleSkip);
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
void AutoDownloadBox::onSave() { void AutoDownloadBox::onSave() {
bool changed = false; bool changed = false;
int32 autoDownloadPhoto = (_photoPrivate.checked() ? 0 : dbiadNoPrivate) | (_photoGroups.checked() ? 0 : dbiadNoGroups); int32 autoDownloadPhoto = (_photoPrivate->checked() ? 0 : dbiadNoPrivate) | (_photoGroups->checked() ? 0 : dbiadNoGroups);
if (cAutoDownloadPhoto() != autoDownloadPhoto) { if (cAutoDownloadPhoto() != autoDownloadPhoto) {
bool enabledPrivate = ((cAutoDownloadPhoto() & dbiadNoPrivate) && !(autoDownloadPhoto & dbiadNoPrivate)); bool enabledPrivate = ((cAutoDownloadPhoto() & dbiadNoPrivate) && !(autoDownloadPhoto & dbiadNoPrivate));
bool enabledGroups = ((cAutoDownloadPhoto() & dbiadNoGroups) && !(autoDownloadPhoto & dbiadNoGroups)); bool enabledGroups = ((cAutoDownloadPhoto() & dbiadNoGroups) && !(autoDownloadPhoto & dbiadNoGroups));
@ -290,7 +291,7 @@ void AutoDownloadBox::onSave() {
} }
changed = true; changed = true;
} }
int32 autoDownloadAudio = (_audioPrivate.checked() ? 0 : dbiadNoPrivate) | (_audioGroups.checked() ? 0 : dbiadNoGroups); int32 autoDownloadAudio = (_audioPrivate->checked() ? 0 : dbiadNoPrivate) | (_audioGroups->checked() ? 0 : dbiadNoGroups);
if (cAutoDownloadAudio() != autoDownloadAudio) { if (cAutoDownloadAudio() != autoDownloadAudio) {
bool enabledPrivate = ((cAutoDownloadAudio() & dbiadNoPrivate) && !(autoDownloadAudio & dbiadNoPrivate)); bool enabledPrivate = ((cAutoDownloadAudio() & dbiadNoPrivate) && !(autoDownloadAudio & dbiadNoPrivate));
bool enabledGroups = ((cAutoDownloadAudio() & dbiadNoGroups) && !(autoDownloadAudio & dbiadNoGroups)); bool enabledGroups = ((cAutoDownloadAudio() & dbiadNoGroups) && !(autoDownloadAudio & dbiadNoGroups));
@ -305,7 +306,7 @@ void AutoDownloadBox::onSave() {
} }
changed = true; changed = true;
} }
int32 autoDownloadGif = (_gifPrivate.checked() ? 0 : dbiadNoPrivate) | (_gifGroups.checked() ? 0 : dbiadNoGroups); int32 autoDownloadGif = (_gifPrivate->checked() ? 0 : dbiadNoPrivate) | (_gifGroups->checked() ? 0 : dbiadNoGroups);
if (cAutoDownloadGif() != autoDownloadGif) { if (cAutoDownloadGif() != autoDownloadGif) {
bool enabledPrivate = ((cAutoDownloadGif() & dbiadNoPrivate) && !(autoDownloadGif & dbiadNoPrivate)); bool enabledPrivate = ((cAutoDownloadGif() & dbiadNoPrivate) && !(autoDownloadGif & dbiadNoPrivate));
bool enabledGroups = ((cAutoDownloadGif() & dbiadNoGroups) && !(autoDownloadGif & dbiadNoGroups)); bool enabledGroups = ((cAutoDownloadGif() & dbiadNoGroups) && !(autoDownloadGif & dbiadNoGroups));
@ -320,8 +321,8 @@ void AutoDownloadBox::onSave() {
} }
changed = true; changed = true;
} }
if (cAutoPlayGif() != _gifPlay.checked()) { if (cAutoPlayGif() != _gifPlay->checked()) {
cSetAutoPlayGif(_gifPlay.checked()); cSetAutoPlayGif(_gifPlay->checked());
if (!cAutoPlayGif()) { if (!cAutoPlayGif()) {
App::stopGifItems(); App::stopGifItems();
} }

View File

@ -22,6 +22,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
namespace Ui {
class Checkbox;
class Radiobutton;
} // namespace Ui
class ConnectionBox : public AbstractBox { class ConnectionBox : public AbstractBox {
Q_OBJECT Q_OBJECT
@ -41,14 +46,17 @@ protected:
void doSetInnerFocus() override; void doSetInnerFocus() override;
private: private:
InputField _hostInput; ChildWidget<InputField> _hostInput;
PortInput _portInput; ChildWidget<PortInput> _portInput;
InputField _userInput; ChildWidget<InputField> _userInput;
PasswordField _passwordInput; ChildWidget<PasswordField> _passwordInput;
Radiobutton _autoRadio, _httpProxyRadio, _tcpProxyRadio; ChildWidget<Ui::Radiobutton> _autoRadio;
Checkbox _tryIPv6; ChildWidget<Ui::Radiobutton> _httpProxyRadio;
ChildWidget<Ui::Radiobutton> _tcpProxyRadio;
ChildWidget<Ui::Checkbox> _tryIPv6;
BoxButton _save, _cancel; ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
}; };
@ -68,12 +76,17 @@ protected:
void showAll() override; void showAll() override;
private: private:
Checkbox _photoPrivate, _photoGroups; ChildWidget<Ui::Checkbox> _photoPrivate;
Checkbox _audioPrivate, _audioGroups; ChildWidget<Ui::Checkbox> _photoGroups;
Checkbox _gifPrivate, _gifGroups, _gifPlay; ChildWidget<Ui::Checkbox> _audioPrivate;
ChildWidget<Ui::Checkbox> _audioGroups;
ChildWidget<Ui::Checkbox> _gifPrivate;
ChildWidget<Ui::Checkbox> _gifGroups;
ChildWidget<Ui::Checkbox> _gifPlay;
int32 _sectionHeight; int _sectionHeight;
BoxButton _save, _cancel; ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
}; };

View File

@ -30,6 +30,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "application.h" #include "application.h"
#include "ui/buttons/checkbox.h"
#include "ui/filedialog.h" #include "ui/filedialog.h"
#include "ui/widgets/multi_select.h" #include "ui/widgets/multi_select.h"
#include "ui/effects/widget_slide_wrap.h" #include "ui/effects/widget_slide_wrap.h"
@ -104,7 +105,7 @@ void ContactsBox::init() {
auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat(); auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat();
auto topSkip = getTopScrollSkip(); auto topSkip = getTopScrollSkip();
auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next.height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip;
ItemListBox::init(_inner, bottomSkip, topSkip); ItemListBox::init(_inner, bottomSkip, topSkip);
connect(_inner, SIGNAL(addRequested()), App::wnd(), SLOT(onShowAddContact())); connect(_inner, SIGNAL(addRequested()), App::wnd(), SLOT(onShowAddContact()));
@ -127,22 +128,22 @@ void ContactsBox::init() {
}); });
if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) { if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) {
_next.hide(); _next->hide();
_cancel.hide(); _cancel->hide();
} else if (_inner->chat() && _inner->membersFilter() == MembersFilter::Admins) { } else if (_inner->chat() && _inner->membersFilter() == MembersFilter::Admins) {
connect(&_next, SIGNAL(clicked()), this, SLOT(onSaveAdmins())); connect(_next, SIGNAL(clicked()), this, SLOT(onSaveAdmins()));
_bottomShadow = new ScrollableBoxShadow(this); _bottomShadow.create(this);
} else if (_inner->chat() || _inner->channel()) { } else if (_inner->chat() || _inner->channel()) {
connect(&_next, SIGNAL(clicked()), this, SLOT(onInvite())); connect(_next, SIGNAL(clicked()), this, SLOT(onInvite()));
_bottomShadow = new ScrollableBoxShadow(this); _bottomShadow.create(this);
} else if (_inner->creating() != CreatingGroupNone) { } else if (_inner->creating() != CreatingGroupNone) {
connect(&_next, SIGNAL(clicked()), this, SLOT(onCreate())); connect(_next, SIGNAL(clicked()), this, SLOT(onCreate()));
_bottomShadow = new ScrollableBoxShadow(this); _bottomShadow.create(this);
} else { } else {
_next.hide(); _next->hide();
_cancel.hide(); _cancel->hide();
} }
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
connect(scrollArea(), SIGNAL(scrolled()), this, SLOT(onScroll())); connect(scrollArea(), SIGNAL(scrolled()), this, SLOT(onScroll()));
_select->entity()->setQueryChangedCallback([this](const QString &query) { onFilterUpdate(query); }); _select->entity()->setQueryChangedCallback([this](const QString &query) { onFilterUpdate(query); });
_select->entity()->setItemRemovedCallback([this](uint64 itemId) { _select->entity()->setItemRemovedCallback([this](uint64 itemId) {
@ -237,19 +238,19 @@ void ContactsBox::showAll() {
_select->showFast(); _select->showFast();
} }
if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) { if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) {
_next.hide(); _next->hide();
_cancel.hide(); _cancel->hide();
} else if (_inner->chat() || _inner->channel()) { } else if (_inner->chat() || _inner->channel()) {
_next.show(); _next->show();
_cancel.show(); _cancel->show();
} else if (_inner->creating() != CreatingGroupNone) { } else if (_inner->creating() != CreatingGroupNone) {
_next.show(); _next->show();
_cancel.show(); _cancel->show();
} else { } else {
_next.hide(); _next->hide();
_cancel.hide(); _cancel->hide();
} }
_topShadow.show(); _topShadow->show();
if (_bottomShadow) _bottomShadow->show(); if (_bottomShadow) _bottomShadow->show();
ItemListBox::showAll(); ItemListBox::showAll();
} }
@ -317,14 +318,14 @@ void ContactsBox::updateScrollSkips() {
auto oldScrollHeight = scrollArea()->height(); auto oldScrollHeight = scrollArea()->height();
auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat(); auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat();
auto topSkip = getTopScrollSkip(); auto topSkip = getTopScrollSkip();
auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next.height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip;
setScrollSkips(bottomSkip, topSkip); setScrollSkips(bottomSkip, topSkip);
auto scrollHeightDelta = scrollArea()->height() - oldScrollHeight; auto scrollHeightDelta = scrollArea()->height() - oldScrollHeight;
if (scrollHeightDelta) { if (scrollHeightDelta) {
scrollArea()->scrollToY(scrollArea()->scrollTop() - scrollHeightDelta); scrollArea()->scrollToY(scrollArea()->scrollTop() - scrollHeightDelta);
} }
_topShadow.setGeometry(0, topSkip, width(), st::lineWidth); _topShadow->setGeometry(0, topSkip, width(), st::lineWidth);
} }
void ContactsBox::resizeEvent(QResizeEvent *e) { void ContactsBox::resizeEvent(QResizeEvent *e) {
@ -336,9 +337,9 @@ void ContactsBox::resizeEvent(QResizeEvent *e) {
updateScrollSkips(); updateScrollSkips();
_inner->resize(width(), _inner->height()); _inner->resize(width(), _inner->height());
_next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height()); _next->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _next->width() + st::boxButtonPadding.left(), _next->y());
if (_bottomShadow) _bottomShadow->setGeometry(0, height() - st::boxButtonPadding.bottom() - _next.height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth); if (_bottomShadow) _bottomShadow->setGeometry(0, height() - st::boxButtonPadding.bottom() - _next->height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth);
} }
void ContactsBox::closePressed() { void ContactsBox::closePressed() {
@ -647,8 +648,8 @@ ContactsBox::Inner::Inner(QWidget *parent, UserData *bot) : TWidget(parent)
void ContactsBox::Inner::init() { void ContactsBox::Inner::init() {
subscribe(FileDownload::ImageLoaded(), [this] { update(); }); subscribe(FileDownload::ImageLoaded(), [this] { update(); });
connect(&_addContactLnk, SIGNAL(clicked()), App::wnd(), SLOT(onShowAddContact())); connect(_addContactLnk, SIGNAL(clicked()), App::wnd(), SLOT(onShowAddContact()));
connect(&_allAdmins, SIGNAL(changed()), this, SLOT(onAllAdminsChanged())); connect(_allAdmins, SIGNAL(changed()), this, SLOT(onAllAdminsChanged()));
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
@ -676,7 +677,7 @@ void ContactsBox::Inner::initList() {
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
if (i.key()->id == peerFromUser(_chat->creator)) continue; if (i.key()->id == peerFromUser(_chat->creator)) continue;
if (!_allAdmins.checked() && _chat->admins.contains(i.key())) { if (!_allAdmins->checked() && _chat->admins.contains(i.key())) {
admins.push_back(i.key()); admins.push_back(i.key());
if (!_checkedContacts.contains(i.key())) { if (!_checkedContacts.contains(i.key())) {
_checkedContacts.insert(i.key()); _checkedContacts.insert(i.key());
@ -743,8 +744,8 @@ void ContactsBox::Inner::onNoAddAdminBox(QObject *obj) {
} }
void ContactsBox::Inner::onAllAdminsChanged() { void ContactsBox::Inner::onAllAdminsChanged() {
if (_saving && _allAdmins.checked() != _allAdminsChecked) { if (_saving && _allAdmins->checked() != _allAdminsChecked) {
_allAdmins.setChecked(_allAdminsChecked); _allAdmins->setChecked(_allAdminsChecked);
} else if (_allAdminsChangedCallback) { } else if (_allAdminsChangedCallback) {
_allAdminsChangedCallback(); _allAdminsChangedCallback();
} }
@ -797,7 +798,7 @@ bool ContactsBox::Inner::addAdminFail(const RPCError &error, mtpRequestId req) {
void ContactsBox::Inner::saving(bool flag) { void ContactsBox::Inner::saving(bool flag) {
_saving = flag; _saving = flag;
_allAdminsChecked = _allAdmins.checked(); _allAdminsChecked = _allAdmins->checked();
update(); update();
} }
@ -933,7 +934,7 @@ void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, Cont
UserData *user = peer->asUser(); UserData *user = peer->asUser();
if (_chat && _membersFilter == MembersFilter::Admins) { if (_chat && _membersFilter == MembersFilter::Admins) {
if (_allAdmins.checked() || peer->id == peerFromUser(_chat->creator) || _saving) { if (_allAdmins->checked() || peer->id == peerFromUser(_chat->creator) || _saving) {
sel = false; sel = false;
} }
} else { } else {
@ -944,7 +945,7 @@ void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, Cont
auto paintDisabledCheck = data->disabledChecked; auto paintDisabledCheck = data->disabledChecked;
if (_chat && _membersFilter == MembersFilter::Admins) { if (_chat && _membersFilter == MembersFilter::Admins) {
if (peer->id == peerFromUser(_chat->creator) || _allAdmins.checked()) { if (peer->id == peerFromUser(_chat->creator) || _allAdmins->checked()) {
paintDisabledCheck = true; paintDisabledCheck = true;
} }
} }
@ -1059,7 +1060,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
p.setPen(st::black); p.setPen(st::black);
p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins)); p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins));
int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right(); int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right();
(_allAdmins.checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); (_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw);
} else { } else {
p.fillRect(0, 0, width(), st::contactsNewItemHeight, (_newItemSel ? st::contactsBgOver : st::white)->b); p.fillRect(0, 0, width(), st::contactsNewItemHeight, (_newItemSel ? st::contactsBgOver : st::white)->b);
p.setFont(st::contactsNameFont); p.setFont(st::contactsNameFont);
@ -1114,7 +1115,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
p.setPen(st::black); p.setPen(st::black);
p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins)); p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins));
int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right(); int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right();
(_allAdmins.checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); (_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw);
p.translate(0, _newItemHeight); p.translate(0, _newItemHeight);
} else if (cContactsReceived() && !_searching) { } else if (cContactsReceived() && !_searching) {
text = lang(lng_no_contacts); text = lang(lng_no_contacts);
@ -1383,7 +1384,7 @@ void ContactsBox::Inner::changeCheckState(Dialogs::Row *row) {
void ContactsBox::Inner::changeCheckState(ContactData *data, PeerData *peer) { void ContactsBox::Inner::changeCheckState(ContactData *data, PeerData *peer) {
t_assert(usingMultiSelect()); t_assert(usingMultiSelect());
if (_chat && _membersFilter == MembersFilter::Admins && _allAdmins.checked()) { if (_chat && _membersFilter == MembersFilter::Admins && _allAdmins->checked()) {
} else if (data->checkbox->checked()) { } else if (data->checkbox->checked()) {
changePeerCheckState(data, peer, false); changePeerCheckState(data, peer, false);
} else if (selectedCount() < ((_channel && _channel->isMegagroup()) ? Global::MegagroupSizeMax() : Global::ChatSizeMax())) { } else if (selectedCount() < ((_channel && _channel->isMegagroup()) ? Global::MegagroupSizeMax() : Global::ChatSizeMax())) {
@ -1499,8 +1500,8 @@ void ContactsBox::Inner::updateFilter(QString filter) {
_sel = 0; _sel = 0;
refresh(); refresh();
} else { } else {
if (!_addContactLnk.isHidden()) _addContactLnk.hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
if (!_allAdmins.isHidden()) _allAdmins.hide(); if (!_allAdmins->isHidden()) _allAdmins->hide();
QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi;
_filtered.clear(); _filtered.clear();
@ -1678,28 +1679,28 @@ void ContactsBox::Inner::peopleReceived(const QString &query, const QVector<MTPP
void ContactsBox::Inner::refresh() { void ContactsBox::Inner::refresh() {
if (_filter.isEmpty()) { if (_filter.isEmpty()) {
if (_chat && _membersFilter == MembersFilter::Admins) { if (_chat && _membersFilter == MembersFilter::Admins) {
if (_allAdmins.isHidden()) _allAdmins.show(); if (_allAdmins->isHidden()) _allAdmins->show();
} else { } else {
if (!_allAdmins.isHidden()) _allAdmins.hide(); if (!_allAdmins->isHidden()) _allAdmins->hide();
} }
if (!_contacts->isEmpty() || !_byUsername.isEmpty()) { if (!_contacts->isEmpty() || !_byUsername.isEmpty()) {
if (!_addContactLnk.isHidden()) _addContactLnk.hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
resize(width(), _newItemHeight + (_contacts->size() * _rowHeight) + (_byUsername.isEmpty() ? 0 : (st::searchedBarHeight + _byUsername.size() * _rowHeight))); resize(width(), _newItemHeight + (_contacts->size() * _rowHeight) + (_byUsername.isEmpty() ? 0 : (st::searchedBarHeight + _byUsername.size() * _rowHeight)));
} else if (_chat && _membersFilter == MembersFilter::Admins) { } else if (_chat && _membersFilter == MembersFilter::Admins) {
if (!_addContactLnk.isHidden()) _addContactLnk.hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
resize(width(), _newItemHeight + st::noContactsHeight); resize(width(), _newItemHeight + st::noContactsHeight);
} else { } else {
if (cContactsReceived() && !bot()) { if (cContactsReceived() && !bot()) {
if (_addContactLnk.isHidden()) _addContactLnk.show(); if (_addContactLnk->isHidden()) _addContactLnk->show();
} else { } else {
if (!_addContactLnk.isHidden()) _addContactLnk.hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
} }
resize(width(), st::noContactsHeight); resize(width(), st::noContactsHeight);
} }
} else { } else {
if (!_allAdmins.isHidden()) _allAdmins.hide(); if (!_allAdmins->isHidden()) _allAdmins->hide();
if (_filtered.isEmpty() && _byUsernameFiltered.isEmpty()) { if (_filtered.isEmpty() && _byUsernameFiltered.isEmpty()) {
if (!_addContactLnk.isHidden()) _addContactLnk.hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
resize(width(), st::noContactsHeight); resize(width(), st::noContactsHeight);
} else { } else {
resize(width(), (_filtered.size() * _rowHeight) + (_byUsernameFiltered.isEmpty() ? 0 : (st::searchedBarHeight + _byUsernameFiltered.size() * _rowHeight))); resize(width(), (_filtered.size() * _rowHeight) + (_byUsernameFiltered.isEmpty() ? 0 : (st::searchedBarHeight + _byUsernameFiltered.size() * _rowHeight)));
@ -1745,8 +1746,8 @@ ContactsBox::Inner::~Inner() {
} }
void ContactsBox::Inner::resizeEvent(QResizeEvent *e) { void ContactsBox::Inner::resizeEvent(QResizeEvent *e) {
_addContactLnk.move((width() - _addContactLnk.width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2); _addContactLnk->move((width() - _addContactLnk->width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2);
_allAdmins.moveToLeft(st::contactsPadding.left(), st::contactsNewItemTop); _allAdmins->moveToLeft(st::contactsPadding.left(), st::contactsNewItemTop);
} }
void ContactsBox::Inner::selectSkip(int32 dir) { void ContactsBox::Inner::selectSkip(int32 dir) {
@ -1940,3 +1941,7 @@ QVector<MTPInputUser> ContactsBox::Inner::selectedInputs() {
} }
return result; return result;
} }
bool ContactsBox::Inner::allAdmins() const {
return _allAdmins->checked();
}

View File

@ -31,6 +31,7 @@ class IndexedList;
} // namespace Dialogs } // namespace Dialogs
namespace Ui { namespace Ui {
class Checkbox;
class MultiSelect; class MultiSelect;
template <typename Widget> template <typename Widget>
class WidgetSlideWrap; class WidgetSlideWrap;
@ -91,11 +92,12 @@ private:
ChildWidget<Inner> _inner; ChildWidget<Inner> _inner;
ChildWidget<Ui::WidgetSlideWrap<Ui::MultiSelect>> _select; ChildWidget<Ui::WidgetSlideWrap<Ui::MultiSelect>> _select;
BoxButton _next, _cancel; ChildWidget<BoxButton> _next;
ChildWidget<BoxButton> _cancel;
MembersFilter _membersFilter; MembersFilter _membersFilter;
ScrollableBoxShadow _topShadow; ChildWidget<ScrollableBoxShadow> _topShadow;
ScrollableBoxShadow *_bottomShadow = nullptr; ChildWidget<ScrollableBoxShadow> _bottomShadow = { nullptr };
void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req); void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req);
bool peopleFailed(const RPCError &error, mtpRequestId req); bool peopleFailed(const RPCError &error, mtpRequestId req);
@ -152,9 +154,7 @@ public:
QVector<UserData*> selected(); QVector<UserData*> selected();
QVector<MTPInputUser> selectedInputs(); QVector<MTPInputUser> selectedInputs();
bool allAdmins() const { bool allAdmins() const;
return _allAdmins.checked();
}
void setAllAdminsChangedCallback(base::lambda_unique<void()> allAdminsChangedCallback) { void setAllAdminsChangedCallback(base::lambda_unique<void()> allAdminsChangedCallback) {
_allAdminsChangedCallback = std_::move(allAdminsChangedCallback); _allAdminsChangedCallback = std_::move(allAdminsChangedCallback);
} }
@ -263,7 +263,7 @@ private:
CreatingGroupType _creating = CreatingGroupNone; CreatingGroupType _creating = CreatingGroupNone;
MembersAlreadyIn _already; MembersAlreadyIn _already;
Checkbox _allAdmins; ChildWidget<Ui::Checkbox> _allAdmins;
int32 _aboutWidth; int32 _aboutWidth;
Text _aboutAllAdmins, _aboutAdmins; Text _aboutAllAdmins, _aboutAdmins;
base::lambda_unique<void()> _allAdminsChangedCallback; base::lambda_unique<void()> _allAdminsChangedCallback;
@ -301,7 +301,7 @@ private:
int _byUsernameSel = -1; int _byUsernameSel = -1;
QPoint _lastMousePos; QPoint _lastMousePos;
LinkButton _addContactLnk; ChildWidget<LinkButton> _addContactLnk;
bool _saving = false; bool _saving = false;
bool _allAdminsChecked = false; bool _allAdminsChecked = false;

View File

@ -19,12 +19,12 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "boxes/downloadpathbox.h"
#include "lang.h" #include "lang.h"
#include "localstorage.h" #include "localstorage.h"
#include "downloadpathbox.h"
#include "ui/filedialog.h" #include "ui/filedialog.h"
#include "ui/buttons/checkbox.h"
#include "pspecific.h" #include "pspecific.h"
DownloadPathBox::DownloadPathBox() : AbstractBox() DownloadPathBox::DownloadPathBox() : AbstractBox()
@ -37,14 +37,14 @@ DownloadPathBox::DownloadPathBox() : AbstractBox()
, _save(this, lang(lng_connection_save), st::defaultBoxButton) , _save(this, lang(lng_connection_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) { , _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); connect(_save, SIGNAL(clicked()), this, SLOT(onSave()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
connect(&_default, SIGNAL(changed()), this, SLOT(onChange())); connect(_default, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_temp, SIGNAL(changed()), this, SLOT(onChange())); connect(_temp, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_dir, SIGNAL(changed()), this, SLOT(onChange())); connect(_dir, SIGNAL(changed()), this, SLOT(onChange()));
connect(&_pathLink, SIGNAL(clicked()), this, SLOT(onEditPath())); connect(_pathLink, SIGNAL(clicked()), this, SLOT(onEditPath()));
if (!_path.isEmpty() && _path != qsl("tmp")) { if (!_path.isEmpty() && _path != qsl("tmp")) {
setPathText(QDir::toNativeSeparators(_path)); setPathText(QDir::toNativeSeparators(_path));
} }
@ -52,22 +52,22 @@ DownloadPathBox::DownloadPathBox() : AbstractBox()
} }
void DownloadPathBox::showAll() { void DownloadPathBox::showAll() {
_default.show(); _default->show();
_temp.show(); _temp->show();
_dir.show(); _dir->show();
if (_dir.checked()) { if (_dir->checked()) {
_pathLink.show(); _pathLink->show();
} else { } else {
_pathLink.hide(); _pathLink->hide();
} }
_save.show(); _save->show();
_cancel.show(); _cancel->show();
int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _default.height() + st::boxOptionListPadding.top() + _temp.height() + st::boxOptionListPadding.top() + _dir.height(); int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _default->height() + st::boxOptionListPadding.top() + _temp->height() + st::boxOptionListPadding.top() + _dir->height();
if (_dir.checked()) h += st::downloadPathSkip + _pathLink.height(); if (_dir->checked()) h += st::downloadPathSkip + _pathLink->height();
h += st::boxOptionListPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); h += st::boxOptionListPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom();
setMaxHeight(h); setMaxHeight(h);
} }
@ -80,31 +80,31 @@ void DownloadPathBox::paintEvent(QPaintEvent *e) {
} }
void DownloadPathBox::resizeEvent(QResizeEvent *e) { void DownloadPathBox::resizeEvent(QResizeEvent *e) {
_default.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); _default->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top());
_temp.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _default.y() + _default.height() + st::boxOptionListPadding.top()); _temp->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _default->y() + _default->height() + st::boxOptionListPadding.top());
_dir.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _temp.y() + _temp.height() + st::boxOptionListPadding.top()); _dir->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _temp->y() + _temp->height() + st::boxOptionListPadding.top());
int32 inputx = st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x(); int32 inputx = st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x();
int32 inputy = _dir.y() + _dir.height() + st::downloadPathSkip; int32 inputy = _dir->y() + _dir->height() + st::downloadPathSkip;
_pathLink.moveToLeft(inputx, inputy); _pathLink->moveToLeft(inputx, inputy);
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
void DownloadPathBox::onChange() { void DownloadPathBox::onChange() {
if (_dir.checked()) { if (_dir->checked()) {
if (_path.isEmpty() || _path == qsl("tmp")) { if (_path.isEmpty() || _path == qsl("tmp")) {
(_path.isEmpty() ? _default : _temp).setChecked(true); (_path.isEmpty() ? _default : _temp)->setChecked(true);
onEditPath(); onEditPath();
if (!_path.isEmpty() && _path != qsl("tmp")) { if (!_path.isEmpty() && _path != qsl("tmp")) {
_dir.setChecked(true); _dir->setChecked(true);
} }
} else { } else {
setPathText(QDir::toNativeSeparators(_path)); setPathText(QDir::toNativeSeparators(_path));
} }
} else if (_temp.checked()) { } else if (_temp->checked()) {
_path = qsl("tmp"); _path = qsl("tmp");
} else { } else {
_path = QString(); _path = QString();
@ -130,8 +130,8 @@ void DownloadPathBox::onEditPath() {
} }
void DownloadPathBox::onSave() { void DownloadPathBox::onSave() {
Global::SetDownloadPath(_default.checked() ? QString() : (_temp.checked() ? qsl("tmp") : _path)); Global::SetDownloadPath(_default->checked() ? QString() : (_temp->checked() ? qsl("tmp") : _path));
Global::SetDownloadPathBookmark((_default.checked() || _temp.checked()) ? QByteArray() : _pathBookmark); Global::SetDownloadPathBookmark((_default->checked() || _temp->checked()) ? QByteArray() : _pathBookmark);
Local::writeUserSettings(); Local::writeUserSettings();
Global::RefDownloadPathChanged().notify(); Global::RefDownloadPathChanged().notify();
onClose(); onClose();
@ -139,5 +139,5 @@ void DownloadPathBox::onSave() {
void DownloadPathBox::setPathText(const QString &text) { void DownloadPathBox::setPathText(const QString &text) {
int32 availw = st::boxWideWidth - st::boxPadding.left() - st::defaultRadiobutton.textPosition.x() - st::boxPadding.right(); int32 availw = st::boxWideWidth - st::boxPadding.left() - st::defaultRadiobutton.textPosition.x() - st::boxPadding.right();
_pathLink.setText(st::boxTextFont->elided(text, availw)); _pathLink->setText(st::boxTextFont->elided(text, availw));
} }

View File

@ -23,6 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
#include "core/observer.h" #include "core/observer.h"
namespace Ui {
class Radiobutton;
} // namespace Ui
class DownloadPathBox : public AbstractBox { class DownloadPathBox : public AbstractBox {
Q_OBJECT Q_OBJECT
@ -46,8 +50,12 @@ private:
QString _path; QString _path;
QByteArray _pathBookmark; QByteArray _pathBookmark;
Radiobutton _default, _temp, _dir; ChildWidget<Ui::Radiobutton> _default;
LinkButton _pathLink; ChildWidget<Ui::Radiobutton> _temp;
BoxButton _save, _cancel; ChildWidget<Ui::Radiobutton> _dir;
ChildWidget<LinkButton> _pathLink;
ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
}; };

View File

@ -19,15 +19,14 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "boxes/languagebox.h"
#include "lang.h" #include "lang.h"
#include "ui/buttons/checkbox.h"
#include "localstorage.h" #include "localstorage.h"
#include "boxes/confirmbox.h"
#include "languagebox.h"
#include "confirmbox.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "langloaderplain.h" #include "langloaderplain.h"
LanguageBox::LanguageBox() : LanguageBox::LanguageBox() :
@ -38,7 +37,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) {
int32 y = st::boxTitleHeight + st::boxOptionListPadding.top(); int32 y = st::boxTitleHeight + st::boxOptionListPadding.top();
_langs.reserve(languageCount + (haveTestLang ? 1 : 0)); _langs.reserve(languageCount + (haveTestLang ? 1 : 0));
if (haveTestLang) { if (haveTestLang) {
_langs.push_back(new Radiobutton(this, qsl("lang"), languageTest, qsl("Custom Lang"), (cLang() == languageTest), st::langsButton)); _langs.push_back(new Ui::Radiobutton(this, qsl("lang"), languageTest, qsl("Custom Lang"), (cLang() == languageTest), st::langsButton));
_langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); _langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y);
y += _langs.back()->height() + st::boxOptionListPadding.top(); y += _langs.back()->height() + st::boxOptionListPadding.top();
connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange())); connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange()));
@ -51,7 +50,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) {
} else { } else {
result.insert(lng_language_name, langOriginal(lng_language_name)); result.insert(lng_language_name, langOriginal(lng_language_name));
} }
_langs.push_back(new Radiobutton(this, qsl("lang"), i, result.value(lng_language_name, LanguageCodes[i].c_str() + qsl(" language")), (cLang() == i), st::langsButton)); _langs.push_back(new Ui::Radiobutton(this, qsl("lang"), i, result.value(lng_language_name, LanguageCodes[i].c_str() + qsl(" language")), (cLang() == i), st::langsButton));
_langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); _langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y);
y += _langs.back()->height() + st::boxOptionListPadding.top(); y += _langs.back()->height() + st::boxOptionListPadding.top();
connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange())); connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange()));

View File

@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
namespace Ui {
class Radiobutton;
} // namespace Ui
class LanguageBox : public AbstractBox { class LanguageBox : public AbstractBox {
Q_OBJECT Q_OBJECT
@ -40,7 +44,7 @@ protected:
void showAll() override; void showAll() override;
private: private:
QVector<Radiobutton*> _langs; QVector<Ui::Radiobutton*> _langs;
BoxButton _close; BoxButton _close;
}; };

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mainwidget.h" #include "mainwidget.h"
#include "photosendbox.h" #include "photosendbox.h"
#include "history/history_media_types.h" #include "history/history_media_types.h"
#include "ui/buttons/checkbox.h"
#include "styles/style_history.h" #include "styles/style_history.h"
PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxWideWidth) PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxWideWidth)
@ -44,8 +45,8 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW
, _isImage(false) , _isImage(false)
, _replyTo(_file->to.replyTo) , _replyTo(_file->to.replyTo)
, _confirmed(false) { , _confirmed(false) {
connect(&_send, SIGNAL(clicked()), this, SLOT(onSend())); connect(_send, SIGNAL(clicked()), this, SLOT(onSend()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
_animated = false; _animated = false;
QSize dimensions; QSize dimensions;
@ -134,16 +135,16 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW
_isImage = fileIsImage(_file->filename, _file->filemime); _isImage = fileIsImage(_file->filename, _file->filemime);
} }
if (_file->type != PreparePhoto) { if (_file->type != PreparePhoto) {
_compressed.hide(); _compressed->hide();
} }
updateBoxSize(); updateBoxSize();
_caption.setMaxLength(MaxPhotoCaption); _caption->setMaxLength(MaxPhotoCaption);
_caption.setCtrlEnterSubmit(CtrlEnterSubmitBoth); _caption->setCtrlEnterSubmit(CtrlEnterSubmitBoth);
connect(&_compressed, SIGNAL(changed()), this, SLOT(onCompressedChange())); connect(_compressed, SIGNAL(changed()), this, SLOT(onCompressedChange()));
connect(&_caption, SIGNAL(resized()), this, SLOT(onCaptionResized())); connect(_caption, SIGNAL(resized()), this, SLOT(onCaptionResized()));
connect(&_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool))); connect(_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
connect(&_caption, SIGNAL(cancelled()), this, SLOT(onClose())); connect(_caption, SIGNAL(cancelled()), this, SLOT(onClose()));
prepare(); prepare();
} }
@ -164,10 +165,10 @@ PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QSt
, _lname(lname) , _lname(lname)
, _replyTo(replyTo) , _replyTo(replyTo)
, _confirmed(false) { , _confirmed(false) {
connect(&_send, SIGNAL(clicked()), this, SLOT(onSend())); connect(_send, SIGNAL(clicked()), this, SLOT(onSend()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
_compressed.hide(); _compressed->hide();
_name.setText(st::semiboldFont, lng_full_name(lt_first_name, _fname, lt_last_name, _lname), _textNameOptions); _name.setText(st::semiboldFont, lng_full_name(lt_first_name, _fname, lt_last_name, _lname), _textNameOptions);
_status = _phone; _status = _phone;
@ -179,10 +180,10 @@ PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QSt
void PhotoSendBox::onCompressedChange() { void PhotoSendBox::onCompressedChange() {
showAll(); showAll();
if (_caption.isHidden()) { if (_caption->isHidden()) {
setFocus(); setFocus();
} else { } else {
_caption.setFocus(); _caption->setFocus();
} }
updateBoxSize(); updateBoxSize();
resizeEvent(0); resizeEvent(0);
@ -197,11 +198,11 @@ void PhotoSendBox::onCaptionResized() {
void PhotoSendBox::updateBoxSize() { void PhotoSendBox::updateBoxSize() {
if (_file && (_file->type == PreparePhoto || _animated)) { if (_file && (_file->type == PreparePhoto || _animated)) {
setMaxHeight(st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + (_animated ? 0 : (st::boxPhotoCompressedPadding.top() + _compressed.height())) + st::boxPhotoCompressedPadding.bottom() + _caption.height() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + (_animated ? 0 : (st::boxPhotoCompressedPadding.top() + _compressed->height())) + st::boxPhotoCompressedPadding.bottom() + _caption->height() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom());
} else if (_thumbw) { } else if (_thumbw) {
setMaxHeight(st::boxPhotoPadding.top() + st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption.height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPhotoPadding.top() + st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption->height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom());
} else { } else {
setMaxHeight(st::boxPhotoPadding.top() + st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption.height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); setMaxHeight(st::boxPhotoPadding.top() + st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption->height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom());
} }
} }
@ -291,11 +292,11 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
} }
void PhotoSendBox::resizeEvent(QResizeEvent *e) { void PhotoSendBox::resizeEvent(QResizeEvent *e) {
_send.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _send.height()); _send->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _send->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _send.width() + st::boxButtonPadding.left(), _send.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _send->width() + st::boxButtonPadding.left(), _send->y());
_caption.resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _caption.height()); _caption->resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _caption->height());
_caption.moveToLeft(st::boxPhotoPadding.left(), _send.y() - st::boxButtonPadding.top() - _caption.height()); _caption->moveToLeft(st::boxPhotoPadding.left(), _send->y() - st::boxButtonPadding.top() - _caption->height());
_compressed.moveToLeft(st::boxPhotoPadding.left(), st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + st::boxPhotoCompressedPadding.top()); _compressed->moveToLeft(st::boxPhotoPadding.left(), st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + st::boxPhotoCompressedPadding.top());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
@ -310,47 +311,47 @@ void PhotoSendBox::closePressed() {
} }
void PhotoSendBox::showAll() { void PhotoSendBox::showAll() {
_send.show(); _send->show();
_cancel.show(); _cancel->show();
if (_file) { if (_file) {
if (_file->type == PreparePhoto) { if (_file->type == PreparePhoto) {
_compressed.show(); _compressed->show();
} }
_caption.show(); _caption->show();
} else { } else {
_caption.hide(); _caption->hide();
_compressed.hide(); _compressed->hide();
} }
} }
void PhotoSendBox::doSetInnerFocus() { void PhotoSendBox::doSetInnerFocus() {
if (_caption.isHidden()) { if (_caption->isHidden()) {
setFocus(); setFocus();
} else { } else {
_caption.setFocus(); _caption->setFocus();
} }
} }
void PhotoSendBox::onSend(bool ctrlShiftEnter) { void PhotoSendBox::onSend(bool ctrlShiftEnter) {
if (App::main()) { if (App::main()) {
if (_file) { if (_file) {
if (_compressed.isHidden()) { if (_compressed->isHidden()) {
if (_file->type == PrepareAuto) { if (_file->type == PrepareAuto) {
_file->type = PrepareDocument; _file->type = PrepareDocument;
} }
} else { } else {
if (_compressedFromSettings && _compressed.checked() != cCompressPastedImage()) { if (_compressedFromSettings && _compressed->checked() != cCompressPastedImage()) {
cSetCompressPastedImage(_compressed.checked()); cSetCompressPastedImage(_compressed->checked());
Local::writeUserSettings(); Local::writeUserSettings();
} }
if (_compressed.checked()) { if (_compressed->checked()) {
_file->type = PreparePhoto; _file->type = PreparePhoto;
} else { } else {
_file->type = PrepareDocument; _file->type = PrepareDocument;
} }
} }
if (!_caption.isHidden()) { if (!_caption->isHidden()) {
_file->caption = prepareText(_caption.getLastText(), true); _file->caption = prepareText(_caption->getLastText(), true);
} }
App::main()->onSendFileConfirm(_file, ctrlShiftEnter); App::main()->onSendFileConfirm(_file, ctrlShiftEnter);
} else { } else {
@ -366,7 +367,6 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth)
, _animated(false) , _animated(false)
, _photo(false) , _photo(false)
, _doc(false) , _doc(false)
, _field(0)
, _save(this, lang(lng_settings_save), st::defaultBoxButton) , _save(this, lang(lng_settings_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton)
, _thumbx(0) , _thumbx(0)
@ -377,8 +377,8 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth)
, _isImage(false) , _isImage(false)
, _previewCancelled(false) , _previewCancelled(false)
, _saveRequestId(0) { , _saveRequestId(0) {
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); connect(_save, SIGNAL(clicked()), this, SLOT(onSave()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
QSize dimensions; QSize dimensions;
ImagePtr image; ImagePtr image;
@ -490,13 +490,13 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth)
} }
if (_animated || _photo || _doc) { if (_animated || _photo || _doc) {
_field = new InputArea(this, st::confirmCaptionArea, lang(lng_photo_caption), caption); _field.create(this, st::confirmCaptionArea, lang(lng_photo_caption), caption);
_field->setMaxLength(MaxPhotoCaption); _field->setMaxLength(MaxPhotoCaption);
_field->setCtrlEnterSubmit(CtrlEnterSubmitBoth); _field->setCtrlEnterSubmit(CtrlEnterSubmitBoth);
} else { } else {
auto original = msg->originalText(); auto original = msg->originalText();
QString text = textApplyEntities(original.text, original.entities); QString text = textApplyEntities(original.text, original.entities);
_field = new InputArea(this, st::editTextArea, lang(lng_photo_caption), text); _field.create(this, st::editTextArea, lang(lng_photo_caption), text);
// _field->setMaxLength(MaxMessageSize); // entities can make text in input field larger but still valid // _field->setMaxLength(MaxMessageSize); // entities can make text in input field larger but still valid
_field->setCtrlEnterSubmit(cCtrlEnter() ? CtrlEnterSubmitCtrlEnter : CtrlEnterSubmitEnter); _field->setCtrlEnterSubmit(cCtrlEnter() ? CtrlEnterSubmitCtrlEnter : CtrlEnterSubmitEnter);
} }
@ -523,7 +523,7 @@ void EditCaptionBox::onCaptionResized() {
} }
void EditCaptionBox::updateBoxSize() { void EditCaptionBox::updateBoxSize() {
int32 bottomh = st::boxPhotoCompressedPadding.bottom() + _field->height() + st::normalFont->height + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); int32 bottomh = st::boxPhotoCompressedPadding.bottom() + _field->height() + st::normalFont->height + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom();
if (_photo || _animated) { if (_photo || _animated) {
setMaxHeight(st::boxPhotoPadding.top() + _thumbh + bottomh); setMaxHeight(st::boxPhotoPadding.top() + _thumbh + bottomh);
} else if (_thumbw) { } else if (_thumbw) {
@ -620,16 +620,16 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
} }
void EditCaptionBox::resizeEvent(QResizeEvent *e) { void EditCaptionBox::resizeEvent(QResizeEvent *e) {
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height());
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); _cancel->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y());
_field->resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _field->height()); _field->resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _field->height());
_field->moveToLeft(st::boxPhotoPadding.left(), _save.y() - st::boxButtonPadding.top() - st::normalFont->height - _field->height()); _field->moveToLeft(st::boxPhotoPadding.left(), _save->y() - st::boxButtonPadding.top() - st::normalFont->height - _field->height());
AbstractBox::resizeEvent(e); AbstractBox::resizeEvent(e);
} }
void EditCaptionBox::showAll() { void EditCaptionBox::showAll() {
_save.show(); _save->show();
_cancel.show(); _cancel->show();
_field->show(); _field->show();
} }

View File

@ -23,6 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
#include "localimageloader.h" #include "localimageloader.h"
namespace Ui {
class Checkbox;
} // namespace Ui
class PhotoSendBox : public AbstractBox { class PhotoSendBox : public AbstractBox {
Q_OBJECT Q_OBJECT
@ -52,10 +56,12 @@ private:
QPixmap _thumb; QPixmap _thumb;
InputArea _caption; ChildWidget<InputArea> _caption;
bool _compressedFromSettings; bool _compressedFromSettings;
Checkbox _compressed; ChildWidget<Ui::Checkbox> _compressed;
BoxButton _send, _cancel;
ChildWidget<BoxButton> _send;
ChildWidget<BoxButton> _cancel;
int32 _thumbx, _thumby, _thumbw, _thumbh; int32 _thumbx, _thumby, _thumbw, _thumbh;
Text _name; Text _name;
@ -101,8 +107,9 @@ private:
QPixmap _thumb; QPixmap _thumb;
InputArea *_field; ChildWidget<InputArea> _field = { nullptr };
BoxButton _save, _cancel; ChildWidget<BoxButton> _save;
ChildWidget<BoxButton> _cancel;
int32 _thumbx, _thumby, _thumbw, _thumbh; int32 _thumbx, _thumby, _thumbw, _thumbh;
Text _name; Text _name;

View File

@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "lang.h" #include "lang.h"
#include "styles/style_profile.h" #include "styles/style_profile.h"
#include "boxes/confirmbox.h" #include "boxes/confirmbox.h"
#include "ui/buttons/checkbox.h"
#include "mainwindow.h" #include "mainwindow.h"
ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth) ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth)

View File

@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "abstractbox.h" #include "abstractbox.h"
namespace Ui {
class Radiobutton;
} // namespace Ui
class ReportBox : public AbstractBox, public RPCSender { class ReportBox : public AbstractBox, public RPCSender {
Q_OBJECT Q_OBJECT
@ -50,10 +54,10 @@ private:
ChannelData *_channel; ChannelData *_channel;
ChildWidget<Radiobutton> _reasonSpam; ChildWidget<Ui::Radiobutton> _reasonSpam;
ChildWidget<Radiobutton> _reasonViolence; ChildWidget<Ui::Radiobutton> _reasonViolence;
ChildWidget<Radiobutton> _reasonPornography; ChildWidget<Ui::Radiobutton> _reasonPornography;
ChildWidget<Radiobutton> _reasonOther; ChildWidget<Ui::Radiobutton> _reasonOther;
ChildWidget<InputArea> _reasonOtherText = { nullptr }; ChildWidget<InputArea> _reasonOtherText = { nullptr };
ChildWidget<BoxButton> _report, _cancel; ChildWidget<BoxButton> _report, _cancel;

View File

@ -194,7 +194,6 @@ QString Generator::typeToString(structure::Type type) const {
case Tag::String: return "QString"; case Tag::String: return "QString";
case Tag::Color: return "style::color"; case Tag::Color: return "style::color";
case Tag::Point: return "style::point"; case Tag::Point: return "style::point";
case Tag::Sprite: return "style::sprite";
case Tag::Size: return "style::size"; case Tag::Size: return "style::size";
case Tag::Transition: return "style::transition"; case Tag::Transition: return "style::transition";
case Tag::Cursor: return "style::cursor"; case Tag::Cursor: return "style::cursor";
@ -217,7 +216,6 @@ QString Generator::typeToDefaultValue(structure::Type type) const {
case Tag::String: return "QString()"; case Tag::String: return "QString()";
case Tag::Color: return "{ Qt::Uninitialized }"; case Tag::Color: return "{ Qt::Uninitialized }";
case Tag::Point: return "{ 0, 0 }"; case Tag::Point: return "{ 0, 0 }";
case Tag::Sprite: return "{ 0, 0, 0, 0 }";
case Tag::Size: return "{ 0, 0 }"; case Tag::Size: return "{ 0, 0 }";
case Tag::Transition: return "anim::linear"; case Tag::Transition: return "anim::linear";
case Tag::Cursor: return "style::cur_default"; case Tag::Cursor: return "style::cur_default";
@ -260,10 +258,6 @@ QString Generator::valueAssignmentCode(structure::Value value) const {
auto v(value.Point()); auto v(value.Point());
return QString("{ %1, %2 }").arg(pxValueName(v.x)).arg(pxValueName(v.y)); return QString("{ %1, %2 }").arg(pxValueName(v.x)).arg(pxValueName(v.y));
} break; } break;
case Tag::Sprite: {
auto v(value.Sprite());
return QString("{ %1, %2, %3, %4 }").arg(pxValueName(v.left)).arg(pxValueName(v.top)).arg(pxValueName(v.width)).arg(pxValueName(v.height));
} break;
case Tag::Size: { case Tag::Size: {
auto v(value.Size()); auto v(value.Size());
return QString("{ %1, %2 }").arg(pxValueName(v.width)).arg(pxValueName(v.height)); return QString("{ %1, %2 }").arg(pxValueName(v.width)).arg(pxValueName(v.height));
@ -694,13 +688,6 @@ bool Generator::collectUniqueValues() {
pxValues_.insert(v.x, true); pxValues_.insert(v.x, true);
pxValues_.insert(v.y, true); pxValues_.insert(v.y, true);
} break; } break;
case Tag::Sprite: {
auto v(value.Sprite());
pxValues_.insert(v.left, true);
pxValues_.insert(v.top, true);
pxValues_.insert(v.width, true);
pxValues_.insert(v.height, true);
} break;
case Tag::Size: { case Tag::Size: {
auto v(value.Size()); auto v(value.Size());
pxValues_.insert(v.width, true); pxValues_.insert(v.width, true);
@ -722,7 +709,7 @@ bool Generator::collectUniqueValues() {
} break; } break;
case Tag::Icon: { case Tag::Icon: {
auto v(value.Icon()); auto v(value.Icon());
for (const auto &part : v.parts) { for (auto &part : v.parts) {
pxValues_.insert(part.offset.Point().x, true); pxValues_.insert(part.offset.Point().x, true);
pxValues_.insert(part.offset.Point().y, true); pxValues_.insert(part.offset.Point().y, true);
if (!iconMasks_.contains(part.filename)) { if (!iconMasks_.contains(part.filename)) {

View File

@ -49,14 +49,6 @@ Options parseOptions() {
if (arg == "--rebuild") { if (arg == "--rebuild") {
result.rebuildDependencies = true; result.rebuildDependencies = true;
// Skip generating style modules
} else if (arg == "--skip-styles") {
result.skipStyles = true;
// Skip generating sprite_125x.png and sprite_150x.png
} else if (arg == "--skip-sprites") {
result.skipSprites = true;
// Include paths // Include paths
} else if (arg == "-I") { } else if (arg == "-I") {
if (++i == count) { if (++i == count) {

View File

@ -31,8 +31,6 @@ struct Options {
QString outputPath = "."; QString outputPath = ".";
QString inputPath; QString inputPath;
bool rebuildDependencies = false; bool rebuildDependencies = false;
bool skipStyles = false;
bool skipSprites = false;
}; };
// Parsing failed if inputPath is empty in the result. // Parsing failed if inputPath is empty in the result.

View File

@ -64,7 +64,7 @@ QString tokenValue(const BasicToken &token) {
bool isValidColor(const QString &str) { bool isValidColor(const QString &str) {
auto len = str.size(); auto len = str.size();
if (len != 3 && len != 4 && len != 6 && len != 8) { if (len != 6 && len != 8) {
return false; return false;
} }
@ -89,17 +89,11 @@ uchar readHexUchar(QChar char1, QChar char2) {
structure::data::color convertWebColor(const QString &str) { structure::data::color convertWebColor(const QString &str) {
uchar r = 0, g = 0, b = 0, a = 255; uchar r = 0, g = 0, b = 0, a = 255;
if (isValidColor(str)) { if (isValidColor(str)) {
auto len = str.size(); r = readHexUchar(str.at(0), str.at(1));
if (len == 3 || len == 4) { g = readHexUchar(str.at(2), str.at(3));
r = readHexUchar(str.at(0), str.at(0)); b = readHexUchar(str.at(4), str.at(5));
g = readHexUchar(str.at(1), str.at(1)); if (str.size() == 8) {
b = readHexUchar(str.at(2), str.at(2)); a = readHexUchar(str.at(6), str.at(7));
if (len == 4) a = readHexUchar(str.at(3), str.at(3));
} else {
r = readHexUchar(str.at(0), str.at(1));
g = readHexUchar(str.at(2), str.at(3));
b = readHexUchar(str.at(4), str.at(5));
if (len == 8) a = readHexUchar(str.at(6), str.at(7));
} }
} }
return { r, g, b, a }; return { r, g, b, a };
@ -120,7 +114,6 @@ std::string logType(const structure::Type &type) {
{ structure::TypeTag::String , "string" }, { structure::TypeTag::String , "string" },
{ structure::TypeTag::Color , "color" }, { structure::TypeTag::Color , "color" },
{ structure::TypeTag::Point , "point" }, { structure::TypeTag::Point , "point" },
{ structure::TypeTag::Sprite , "sprite" },
{ structure::TypeTag::Size , "size" }, { structure::TypeTag::Size , "size" },
{ structure::TypeTag::Transition, "transition" }, { structure::TypeTag::Transition, "transition" },
{ structure::TypeTag::Cursor , "cursor" }, { structure::TypeTag::Cursor , "cursor" },
@ -285,8 +278,6 @@ structure::Value ParsedFile::readValue() {
return colorValue; return colorValue;
} else if (auto pointValue = readPointValue()) { } else if (auto pointValue = readPointValue()) {
return pointValue; return pointValue;
} else if (auto spriteValue = readSpriteValue()) {
return spriteValue;
} else if (auto sizeValue = readSizeValue()) { } else if (auto sizeValue = readSizeValue()) {
return sizeValue; return sizeValue;
} else if (auto transitionValue = readTransitionValue()) { } else if (auto transitionValue = readTransitionValue()) {
@ -509,41 +500,6 @@ structure::Value ParsedFile::readColorValue() {
} else { } else {
logErrorUnexpectedToken() << "color value in #ccc, #ccca, #cccccc or #ccccccaa format"; logErrorUnexpectedToken() << "color value in #ccc, #ccca, #cccccc or #ccccccaa format";
} }
} else if (auto rgbaToken = file_.getToken(BasicType::Name)) {
if (tokenValue(rgbaToken) == "rgba") {
assertNextToken(BasicType::LeftParenthesis);
auto r = readNumericValue(); assertNextToken(BasicType::Comma);
auto g = readNumericValue(); assertNextToken(BasicType::Comma);
auto b = readNumericValue(); assertNextToken(BasicType::Comma);
auto a = readNumericValue();
if (r.type().tag != structure::TypeTag::Int || r.Int() < 0 || r.Int() > 255 ||
g.type().tag != structure::TypeTag::Int || g.Int() < 0 || g.Int() > 255 ||
b.type().tag != structure::TypeTag::Int || b.Int() < 0 || b.Int() > 255 ||
a.type().tag != structure::TypeTag::Int || a.Int() < 0 || a.Int() > 255) {
logErrorTypeMismatch() << "expected four 0-255 values for the rgba color";
}
assertNextToken(BasicType::RightParenthesis);
return { convertIntColor(r.Int(), g.Int(), b.Int(), a.Int()) };
} else if (tokenValue(rgbaToken) == "rgb") {
assertNextToken(BasicType::LeftParenthesis);
auto r = readNumericValue(); assertNextToken(BasicType::Comma);
auto g = readNumericValue(); assertNextToken(BasicType::Comma);
auto b = readNumericValue();
if (r.type().tag != structure::TypeTag::Int || r.Int() < 0 || r.Int() > 255 ||
g.type().tag != structure::TypeTag::Int || g.Int() < 0 || g.Int() > 255 ||
b.type().tag != structure::TypeTag::Int || b.Int() < 0 || b.Int() > 255) {
logErrorTypeMismatch() << "expected three int values for the rgb color";
}
assertNextToken(BasicType::RightParenthesis);
return { convertIntColor(r.Int(), g.Int(), b.Int(), 255) };
}
file_.putBack();
} }
return {}; return {};
} }
@ -569,31 +525,6 @@ structure::Value ParsedFile::readPointValue() {
return {}; return {};
} }
structure::Value ParsedFile::readSpriteValue() {
if (auto font = file_.getToken(BasicType::Name)) {
if (tokenValue(font) == "sprite") {
assertNextToken(BasicType::LeftParenthesis);
auto x = readNumericValue(); assertNextToken(BasicType::Comma);
auto y = readNumericValue(); assertNextToken(BasicType::Comma);
auto w = readNumericValue(); assertNextToken(BasicType::Comma);
auto h = readNumericValue();
if (x.type().tag != structure::TypeTag::Pixels ||
y.type().tag != structure::TypeTag::Pixels ||
w.type().tag != structure::TypeTag::Pixels ||
h.type().tag != structure::TypeTag::Pixels) {
logErrorTypeMismatch() << "expected four px values for the sprite";
}
assertNextToken(BasicType::RightParenthesis);
return { structure::data::sprite { x.Int(), y.Int(), w.Int(), h.Int() } };
}
file_.putBack();
}
return {};
}
structure::Value ParsedFile::readSizeValue() { structure::Value ParsedFile::readSizeValue() {
if (auto font = file_.getToken(BasicType::Name)) { if (auto font = file_.getToken(BasicType::Name)) {
if (tokenValue(font) == "size") { if (tokenValue(font) == "size") {

View File

@ -88,7 +88,6 @@ private:
structure::Value readStringValue(); structure::Value readStringValue();
structure::Value readColorValue(); structure::Value readColorValue();
structure::Value readPointValue(); structure::Value readPointValue();
structure::Value readSpriteValue();
structure::Value readSizeValue(); structure::Value readSizeValue();
structure::Value readTransitionValue(); structure::Value readTransitionValue();
structure::Value readCursorValue(); structure::Value readCursorValue();
@ -127,7 +126,6 @@ private:
{ "string" , { structure::TypeTag::String } }, { "string" , { structure::TypeTag::String } },
{ "color" , { structure::TypeTag::Color } }, { "color" , { structure::TypeTag::Color } },
{ "point" , { structure::TypeTag::Point } }, { "point" , { structure::TypeTag::Point } },
{ "sprite" , { structure::TypeTag::Sprite } },
{ "size" , { structure::TypeTag::Size } }, { "size" , { structure::TypeTag::Size } },
{ "transition", { structure::TypeTag::Transition } }, { "transition", { structure::TypeTag::Transition } },
{ "cursor" , { structure::TypeTag::Cursor } }, { "cursor" , { structure::TypeTag::Cursor } },

View File

@ -25,7 +25,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "codegen/common/cpp_file.h" #include "codegen/common/cpp_file.h"
#include "codegen/style/parsed_file.h" #include "codegen/style/parsed_file.h"
#include "codegen/style/generator.h" #include "codegen/style/generator.h"
#include "codegen/style/sprite_generator.h"
namespace codegen { namespace codegen {
namespace style { namespace style {
@ -66,38 +65,28 @@ int Processor::launch() {
bool Processor::write(const structure::Module &module) const { bool Processor::write(const structure::Module &module) const {
bool forceReGenerate = false; bool forceReGenerate = false;
bool onlyStyles = options_.skipSprites; QDir dir(options_.outputPath);
bool onlySprites = options_.skipStyles; if (!dir.mkpath(".")) {
if (!onlyStyles) { common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString();
SpriteGenerator spriteGenerator(module, forceReGenerate); return false;
if (!spriteGenerator.writeSprites()) {
return false;
}
} }
if (!onlySprites) {
QDir dir(options_.outputPath);
if (!dir.mkpath(".")) {
common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString();
return false;
}
QFileInfo srcFile(module.filepath()); QFileInfo srcFile(module.filepath());
QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module); QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module);
common::ProjectInfo project = { common::ProjectInfo project = {
"codegen_style", "codegen_style",
srcFile.fileName(), srcFile.fileName(),
"stdafx.h", "stdafx.h",
forceReGenerate forceReGenerate
}; };
Generator generator(module, dstFilePath, project); Generator generator(module, dstFilePath, project);
if (!generator.writeHeader()) { if (!generator.writeHeader()) {
return false; return false;
} }
if (!generator.writeSource()) { if (!generator.writeSource()) {
return false; return false;
}
} }
return true; return true;
} }

View File

@ -1,180 +0,0 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#include "codegen/style/sprite_generator.h"
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QBuffer>
#include <QtGui/QPainter>
#include <QtGui/QColor>
#include <functional>
#include "codegen/style/parsed_file.h"
using Module = codegen::style::structure::Module;
using Struct = codegen::style::structure::Struct;
using Variable = codegen::style::structure::Variable;
using Tag = codegen::style::structure::TypeTag;
namespace codegen {
namespace style {
using structure::logFullName;
namespace {
constexpr int kErrorSpritesIntersect = 841;
constexpr int kErrorCouldNotGenerate = 842;
constexpr int kErrorCouldNotSerialize = 843;
constexpr int kErrorCouldNotOpen = 844;
constexpr int kErrorCouldNotWrite = 845;
} // namespace
SpriteGenerator::SpriteGenerator(const structure::Module &module, bool forceReGenerate)
: module_(module)
, forceReGenerate_(forceReGenerate)
, basePath_(QFileInfo(module.filepath()).dir().absolutePath()) {
}
bool SpriteGenerator::writeSprites() {
if (!collectSprites()) {
return false;
}
if (sprites_.isEmpty()) {
return true;
}
sprite2x_ = QImage(basePath_ + "/art/sprite_200x.png");
if (sprite2x_.isNull()) {
common::logError(common::kErrorFileNotFound, "/art/sprite_200x.png") << "sprite file was not found";
return false;
}
std::vector<int> sizes = { 5, 6 };
std::vector<const char *> postfixes = { "125", "150" };
for (int i = 0, l = sizes.size(); i < l; ++i) {
auto sprite = generateSprite(sizes[i]);
QString filepath = basePath_ + "/art/sprite_" + postfixes[i] + "x.png";
if (sprite.isNull()) {
common::logError(kErrorCouldNotGenerate, filepath) << "could not generate sprite file";
return false;
}
QByteArray spriteData;
{
QBuffer spriteBuffer(&spriteData);
if (!sprite.save(&spriteBuffer, "PNG")) {
common::logError(kErrorCouldNotSerialize, filepath) << "could not serialize sprite file";
return false;
}
}
QFile file(filepath);
if (!forceReGenerate_ && file.open(QIODevice::ReadOnly)) {
if (file.readAll() == spriteData) {
continue;
}
file.close();
}
if (!file.open(QIODevice::WriteOnly)) {
common::logError(kErrorCouldNotOpen, filepath) << "could not open sprite file for write";
return false;
}
if (file.write(spriteData) != spriteData.size()) {
common::logError(kErrorCouldNotWrite, filepath) << "could not write sprite file";
return false;
}
// Touch resource file.
filepath = basePath_ + "/telegram.qrc";
QFile qrc(filepath);
if (qrc.open(QIODevice::ReadOnly)) {
auto qrcContent = qrc.readAll();
qrc.close();
if (!qrc.open(QIODevice::WriteOnly)) {
common::logError(kErrorCouldNotOpen, filepath) << "could not open .qrc file for write";
return false;
}
if (qrc.write(qrcContent) != qrcContent.size()) {
common::logError(kErrorCouldNotWrite, filepath) << "could not write .qrc file";
return false;
}
}
}
return true;
}
bool SpriteGenerator::collectSprites() {
std::function<bool(const Variable&)> collector = [this, &collector](const Variable &variable) {
auto value = variable.value;
if (value.type().tag == Tag::Sprite) {
auto v(value.Sprite());
if (!v.width || !v.height) return true;
QRect vRect(v.left, v.top, v.width, v.height);
bool found = false;
for (auto var : sprites_) {
auto sprite = var.value.Sprite();
QRect spriteRect(sprite.left, sprite.top, sprite.width, sprite.height);
if (spriteRect == vRect) {
found = true;
} else if (spriteRect.intersects(vRect)) {
common::logError(kErrorSpritesIntersect, module_.filepath()) << "sprite '" << logFullName(variable.name) << "' intersects with '" << logFullName(var.name) << "'";
return false;
}
}
if (!found) {
sprites_.push_back(variable);
}
} else if (value.type().tag == Tag::Struct) {
auto fields = variable.value.Fields();
if (!fields) {
return false;
}
for (auto field : *fields) {
if (!collector(field.variable)) {
return false;
}
}
}
return true;
};
return module_.enumVariables(collector);
}
QImage SpriteGenerator::generateSprite(int scale) {
auto convert = [scale](int value) -> int { return structure::data::pxAdjust(value, scale); };
QImage result(convert(sprite2x_.width() / 2), convert(sprite2x_.height() / 2), sprite2x_.format());
{
QPainter p(&result);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(0, 0, result.width(), result.height(), QColor(0, 0, 0, 0));
for (auto variable : sprites_) {
auto sprite = variable.value.Sprite();
auto copy = sprite2x_.copy(sprite.left * 2, sprite.top * 2, sprite.width * 2, sprite.height * 2);
copy = copy.scaled(convert(sprite.width), convert(sprite.height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
p.drawImage(convert(sprite.left), convert(sprite.top), copy);
}
}
return result;
}
} // namespace style
} // namespace codegen

View File

@ -1,57 +0,0 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include <memory>
#include <QtCore/QString>
#include <QtCore/QSet>
#include <QtGui/QImage>
#include "codegen/style/structure_types.h"
namespace codegen {
namespace style {
namespace structure {
class Module;
} // namespace structure
class SpriteGenerator {
public:
SpriteGenerator(const structure::Module &module, bool forceReGenerate);
SpriteGenerator(const SpriteGenerator &other) = delete;
SpriteGenerator &operator=(const SpriteGenerator &other) = delete;
bool writeSprites();
private:
bool collectSprites();
QImage generateSprite(int scale); // scale = 5 for 125% and 6 for 150%.
const structure::Module &module_;
bool forceReGenerate_;
QString basePath_;
QImage sprite2x_;
QList<structure::Variable> sprites_;
};
} // namespace style
} // namespace codegen

View File

@ -69,17 +69,6 @@ struct Value::DataTypes {
}; };
class TSprite : public DataBase {
public:
TSprite(data::sprite value) : value_(value) {
}
data::sprite Sprite() const override { return value_; }
private:
data::sprite value_;
};
class TSize : public DataBase { class TSize : public DataBase {
public: public:
TSize(data::size value) : value_(value) { TSize(data::size value) : value_(value) {
@ -154,9 +143,6 @@ Value::Value() : Value(TypeTag::Invalid, std::make_shared<DataBase>()) {
Value::Value(data::point value) : Value(TypeTag::Point, std::make_shared<DataTypes::TPoint>(value)) { Value::Value(data::point value) : Value(TypeTag::Point, std::make_shared<DataTypes::TPoint>(value)) {
} }
Value::Value(data::sprite value) : Value(TypeTag::Sprite, std::make_shared<DataTypes::TSprite>(value)) {
}
Value::Value(data::size value) : Value(TypeTag::Size, std::make_shared<DataTypes::TSize>(value)) { Value::Value(data::size value) : Value(TypeTag::Size, std::make_shared<DataTypes::TSize>(value)) {
} }
@ -210,7 +196,6 @@ Value::Value(Type type, Qt::Initialization) : type_(type) {
case TypeTag::String: data_ = std::make_shared<DataTypes::TString>(""); break; case TypeTag::String: data_ = std::make_shared<DataTypes::TString>(""); break;
case TypeTag::Color: data_ = std::make_shared<DataTypes::TColor>(data::color { 0, 0, 0, 255 }); break; case TypeTag::Color: data_ = std::make_shared<DataTypes::TColor>(data::color { 0, 0, 0, 255 }); break;
case TypeTag::Point: data_ = std::make_shared<DataTypes::TPoint>(data::point { 0, 0 }); break; case TypeTag::Point: data_ = std::make_shared<DataTypes::TPoint>(data::point { 0, 0 }); break;
case TypeTag::Sprite: data_ = std::make_shared<DataTypes::TSprite>(data::sprite { 0, 0, 0, 0 }); break;
case TypeTag::Size: data_ = std::make_shared<DataTypes::TSize>(data::size { 0, 0 }); break; case TypeTag::Size: data_ = std::make_shared<DataTypes::TSize>(data::size { 0, 0 }); break;
case TypeTag::Transition: data_ = std::make_shared<DataTypes::TString>("linear"); break; case TypeTag::Transition: data_ = std::make_shared<DataTypes::TString>("linear"); break;
case TypeTag::Cursor: data_ = std::make_shared<DataTypes::TString>("default"); break; case TypeTag::Cursor: data_ = std::make_shared<DataTypes::TString>("default"); break;

View File

@ -47,7 +47,6 @@ enum class TypeTag {
String, String,
Color, Color,
Point, Point,
Sprite,
Size, Size,
Transition, Transition,
Cursor, Cursor,
@ -86,10 +85,6 @@ struct point {
int x, y; int x, y;
}; };
struct sprite {
int left, top, width, height;
};
struct size { struct size {
int width, height; int width, height;
}; };
@ -127,7 +122,6 @@ class Value {
public: public:
Value(); Value();
Value(data::point value); Value(data::point value);
Value(data::sprite value);
Value(data::size value); Value(data::size value);
Value(data::color value); Value(data::color value);
Value(data::margins value); Value(data::margins value);
@ -152,7 +146,6 @@ public:
double Double() const { return data_->Double(); } double Double() const { return data_->Double(); }
std::string String() const { return data_->String(); } std::string String() const { return data_->String(); }
data::point Point() const { return data_->Point(); } data::point Point() const { return data_->Point(); }
data::sprite Sprite() const { return data_->Sprite(); };
data::size Size() const { return data_->Size(); }; data::size Size() const { return data_->Size(); };
data::color Color() const { return data_->Color(); }; data::color Color() const { return data_->Color(); };
data::margins Margins() const { return data_->Margins(); }; data::margins Margins() const { return data_->Margins(); };
@ -182,7 +175,6 @@ private:
virtual double Double() const { return 0.; } virtual double Double() const { return 0.; }
virtual std::string String() const { return std::string(); } virtual std::string String() const { return std::string(); }
virtual data::point Point() const { return {}; }; virtual data::point Point() const { return {}; };
virtual data::sprite Sprite() const { return {}; };
virtual data::size Size() const { return {}; }; virtual data::size Size() const { return {}; };
virtual data::color Color() const { return {}; }; virtual data::color Color() const { return {}; };
virtual data::margins Margins() const { return {}; }; virtual data::margins Margins() const { return {}; };

View File

@ -44,7 +44,7 @@ dialogsDateFont: font(13px);
dialogsDateFgActive: #ffffff; dialogsDateFgActive: #ffffff;
dialogsDateFg: #a8a8a8; dialogsDateFg: #a8a8a8;
dialogsDateSkip: 5px; dialogsDateSkip: 5px;
dialogsNameFg: #000; dialogsNameFg: #000000;
dialogsNameTop: 2px; dialogsNameTop: 2px;
dialogsRowHeight: 62px; dialogsRowHeight: 62px;

View File

@ -26,7 +26,7 @@ historyPaddingBottom: 10px;
historyToDown: icon { historyToDown: icon {
{ "history_down_shadow", #00000040 }, { "history_down_shadow", #00000040 },
{ "history_down_circle", #fff, point(2px, 1px) }, { "history_down_circle", #ffffff, point(2px, 1px) },
}; };
historyToDownPosition: point(12px, 10px); historyToDownPosition: point(12px, 10px);
historyToDownArrow: icon { historyToDownArrow: icon {
@ -189,7 +189,7 @@ historyRecordVoiceActive: icon {{ "send_control_record", #58b2ed }};
historyRecordSignalColor: #f17077; historyRecordSignalColor: #f17077;
historyRecordSignalMin: 5px; historyRecordSignalMin: 5px;
historyRecordSignalMax: 12px; historyRecordSignalMax: 12px;
historyRecordCancel: #aaa; historyRecordCancel: #aaaaaa;
historyRecordCancelActive: #ec6466; historyRecordCancelActive: #ec6466;
historyRecordFont: font(13px); historyRecordFont: font(13px);
historyRecordTextTop: 14px; historyRecordTextTop: 14px;

View File

@ -116,10 +116,10 @@ mediaviewMenu: Menu(defaultMenu) {
itemBgOver: #505050; itemBgOver: #505050;
itemFg: white; itemFg: white;
itemFgOver: white; itemFgOver: white;
itemFgDisabled: #999; itemFgDisabled: #999999;
itemFgShortcut: #eee; itemFgShortcut: #eeeeee;
itemFgShortcutOver: #fff; itemFgShortcutOver: #ffffff;
itemFgShortcutDisabled: #999; itemFgShortcutDisabled: #999999;
separatorFg: #484848; separatorFg: #484848;
} }

View File

@ -42,7 +42,7 @@ OverviewFileLayout {
fileDateTop: pixels; fileDateTop: pixels;
} }
overviewCheckBg: #0006; overviewCheckBg: #00000066;
overviewCheckedBg: #2fa9e2; overviewCheckedBg: #2fa9e2;
overviewPhotoSkip: 10px; overviewPhotoSkip: 10px;
@ -50,11 +50,11 @@ overviewPhotoBg: #F1F1F1;
overviewPhotoMinSize: minPhotoSize; overviewPhotoMinSize: minPhotoSize;
overviewPhotoCheck: icon { overviewPhotoCheck: icon {
{ size(32px, 32px), overviewCheckBg }, { size(32px, 32px), overviewCheckBg },
{ "overview_photo_check", #fff, point(8px, 10px) }, { "overview_photo_check", #ffffff, point(8px, 10px) },
}; };
overviewPhotoChecked: icon { overviewPhotoChecked: icon {
{ size(32px, 32px), overviewCheckedBg }, { size(32px, 32px), overviewCheckedBg },
{ "overview_photo_check", #fff, point(8px, 10px) }, { "overview_photo_check", #ffffff, point(8px, 10px) },
}; };
overviewPhotoSelectOverlay: #0a7bb03f; overviewPhotoSelectOverlay: #0a7bb03f;
@ -104,9 +104,9 @@ linksPhotoSize: 46px;
linksPhotoPadding: 12px; linksPhotoPadding: 12px;
overviewLinksCheck: icon { overviewLinksCheck: icon {
{ "overview_links_check_bg", overviewCheckBg }, { "overview_links_check_bg", overviewCheckBg },
{ "overview_links_check", #fff, point(4px, 5px) }, { "overview_links_check", #ffffff, point(4px, 5px) },
}; };
overviewLinksChecked: icon { overviewLinksChecked: icon {
{ "overview_links_check_bg", overviewCheckedBg }, { "overview_links_check_bg", overviewCheckedBg },
{ "overview_links_check", #fff, point(4px, 5px) }, { "overview_links_check", #ffffff, point(4px, 5px) },
}; };

View File

@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "styles/style_profile.h" #include "styles/style_profile.h"
#include "ui/buttons/left_outline_button.h" #include "ui/buttons/left_outline_button.h"
#include "ui/flatcheckbox.h" #include "ui/buttons/checkbox.h"
#include "boxes/confirmbox.h" #include "boxes/confirmbox.h"
#include "boxes/contactsbox.h" #include "boxes/contactsbox.h"
#include "observer_peer.h" #include "observer_peer.h"
@ -114,7 +114,7 @@ void SettingsWidget::refreshEnableNotifications() {
} else { } else {
auto &notifySettings = peer()->notify; auto &notifySettings = peer()->notify;
bool enabled = (notifySettings == EmptyNotifySettings || notifySettings->mute < unixtime()); bool enabled = (notifySettings == EmptyNotifySettings || notifySettings->mute < unixtime());
_enableNotifications->setChecked(enabled, Checkbox::NotifyAboutChange::DontNotify); _enableNotifications->setChecked(enabled, Ui::Checkbox::NotifyAboutChange::DontNotify);
} }
} }

View File

@ -22,9 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "profile/profile_block_widget.h" #include "profile/profile_block_widget.h"
class Checkbox;
namespace Ui { namespace Ui {
class Checkbox;
class LeftOutlineButton; class LeftOutlineButton;
} // namespace Ui } // namespace Ui
@ -59,7 +58,7 @@ private:
void refreshManageAdminsButton(); void refreshManageAdminsButton();
void refreshInviteLinkButton(); void refreshInviteLinkButton();
ChildWidget<Checkbox> _enableNotifications; ChildWidget<Ui::Checkbox> _enableNotifications;
// In groups: creator of non-deactivated groups can see this link. // In groups: creator of non-deactivated groups can see this link.
// In channels: creator of supergroup can see this link. // In channels: creator of supergroup can see this link.

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mainwidget.h" #include "mainwidget.h"
#include "boxes/backgroundbox.h" #include "boxes/backgroundbox.h"
#include "ui/effects/widget_slide_wrap.h" #include "ui/effects/widget_slide_wrap.h"
#include "ui/buttons/checkbox.h"
#include "localstorage.h" #include "localstorage.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "window/chat_background.h" #include "window/chat_background.h"

View File

@ -25,8 +25,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/filedialog.h" #include "ui/filedialog.h"
class LinkButton; class LinkButton;
class Checkbox;
namespace Ui { namespace Ui {
class Checkbox;
template <typename Widget> template <typename Widget>
class WidgetSlideWrap; class WidgetSlideWrap;
} // namespace Ui; } // namespace Ui;
@ -84,8 +85,8 @@ private:
void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update); void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update);
ChildWidget<BackgroundRow> _background = { nullptr }; ChildWidget<BackgroundRow> _background = { nullptr };
ChildWidget<Checkbox> _tile = { nullptr }; ChildWidget<Ui::Checkbox> _tile = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _adaptive = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<Ui::Checkbox>> _adaptive = { nullptr };
FileDialog::QueryId _chooseFromFileQueryId = 0; FileDialog::QueryId _chooseFromFileQueryId = 0;

View File

@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "settings/settings_block_widget.h" #include "settings/settings_block_widget.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "ui/flatcheckbox.h" #include "ui/buttons/checkbox.h"
namespace Settings { namespace Settings {
@ -84,13 +84,13 @@ void BlockWidget::rowHeightUpdated() {
} }
} }
void BlockWidget::createChildRow(ChildWidget<Checkbox> &child, style::margins &margin, const QString &text, const char *slot, bool checked) { void BlockWidget::createChildRow(ChildWidget<Ui::Checkbox> &child, style::margins &margin, const QString &text, const char *slot, bool checked) {
child = new Checkbox(this, text, checked, st::defaultBoxCheckbox); child = new Ui::Checkbox(this, text, checked, st::defaultBoxCheckbox);
connect(child, SIGNAL(changed()), this, slot); connect(child, SIGNAL(changed()), this, slot);
} }
void BlockWidget::createChildRow(ChildWidget<Radiobutton> &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked) { void BlockWidget::createChildRow(ChildWidget<Ui::Radiobutton> &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked) {
child = new Radiobutton(this, group, value, text, checked, st::defaultRadiobutton); child = new Ui::Radiobutton(this, group, value, text, checked, st::defaultRadiobutton);
connect(child, SIGNAL(changed()), this, slot); connect(child, SIGNAL(changed()), this, slot);
} }

View File

@ -22,10 +22,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "core/observer.h" #include "core/observer.h"
namespace Ui {
class Checkbox; class Checkbox;
class Radiobutton; class Radiobutton;
namespace Ui {
template <typename Widget> template <typename Widget>
class WidgetSlideWrap; class WidgetSlideWrap;
} // namespace Ui } // namespace Ui
@ -87,8 +86,8 @@ private:
margin.setRight(margin.right() - padding.right()); margin.setRight(margin.right() - padding.right());
margin.setBottom(margin.bottom() - padding.bottom()); margin.setBottom(margin.bottom() - padding.bottom());
} }
void createChildRow(ChildWidget<Checkbox> &child, style::margins &margin, const QString &text, const char *slot, bool checked); void createChildRow(ChildWidget<Ui::Checkbox> &child, style::margins &margin, const QString &text, const char *slot, bool checked);
void createChildRow(ChildWidget<Radiobutton> &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked); void createChildRow(ChildWidget<Ui::Radiobutton> &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked);
void createChildRow(ChildWidget<LinkButton> &child, style::margins &margin, const QString &text, const char *slot, const style::linkButton &st = st::defaultBoxLinkButton); void createChildRow(ChildWidget<LinkButton> &child, style::margins &margin, const QString &text, const char *slot, const style::linkButton &st = st::defaultBoxLinkButton);
void addCreatedRow(TWidget *child, const style::margins &margin); void addCreatedRow(TWidget *child, const style::margins &margin);
@ -106,8 +105,8 @@ private:
template <typename Widget> template <typename Widget>
using NotImplementedYet = std_::enable_if_t< using NotImplementedYet = std_::enable_if_t<
!IsWidgetSlideWrap<Widget>::value && !IsWidgetSlideWrap<Widget>::value &&
!std_::is_same<Widget, Checkbox>::value && !std_::is_same<Widget, Ui::Checkbox>::value &&
!std_::is_same<Widget, Radiobutton>::value && !std_::is_same<Widget, Ui::Radiobutton>::value &&
!std_::is_same<Widget, LinkButton>::value>; !std_::is_same<Widget, LinkButton>::value>;
template <typename Widget, typename... Args, typename = NotImplementedYet<Widget>> template <typename Widget, typename... Args, typename = NotImplementedYet<Widget>>

View File

@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "lang.h" #include "lang.h"
#include "ui/effects/widget_slide_wrap.h" #include "ui/effects/widget_slide_wrap.h"
#include "ui/buttons/checkbox.h"
#include "ui/flatlabel.h" #include "ui/flatlabel.h"
#include "localstorage.h" #include "localstorage.h"
#include "mainwidget.h" #include "mainwidget.h"

View File

@ -105,12 +105,12 @@ private slots:
private: private:
void createControls(); void createControls();
ChildWidget<Checkbox> _replaceEmoji = { nullptr }; ChildWidget<Ui::Checkbox> _replaceEmoji = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<LinkButton>> _viewList = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<LinkButton>> _viewList = { nullptr };
ChildWidget<Checkbox> _dontAskDownloadPath = { nullptr }; ChildWidget<Ui::Checkbox> _dontAskDownloadPath = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<DownloadPathState>> _downloadPath = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<DownloadPathState>> _downloadPath = { nullptr };
ChildWidget<Radiobutton> _sendByEnter = { nullptr }; ChildWidget<Ui::Radiobutton> _sendByEnter = { nullptr };
ChildWidget<Radiobutton> _sendByCtrlEnter = { nullptr }; ChildWidget<Ui::Radiobutton> _sendByCtrlEnter = { nullptr };
ChildWidget<LinkButton> _automaticMediaDownloadSettings = { nullptr }; ChildWidget<LinkButton> _automaticMediaDownloadSettings = { nullptr };
ChildWidget<LinkButton> _manageStickerSets = { nullptr }; ChildWidget<LinkButton> _manageStickerSets = { nullptr };

View File

@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "lang.h" #include "lang.h"
#include "ui/effects/widget_slide_wrap.h" #include "ui/effects/widget_slide_wrap.h"
#include "ui/flatbutton.h" #include "ui/flatbutton.h"
#include "ui/flatcheckbox.h" #include "ui/buttons/checkbox.h"
#include "localstorage.h" #include "localstorage.h"
#include "pspecific.h" #include "pspecific.h"
#include "mainwindow.h" #include "mainwindow.h"

View File

@ -23,10 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "settings/settings_block_widget.h" #include "settings/settings_block_widget.h"
#include "ui/filedialog.h" #include "ui/filedialog.h"
class Checkbox;
class LinkButton; class LinkButton;
namespace Ui { namespace Ui {
class Checkbox;
template <typename Widget> template <typename Widget>
class WidgetSlideWrap; class WidgetSlideWrap;
} // namespace Ui } // namespace Ui
@ -116,14 +116,14 @@ private:
ChildWidget<LinkButton> _changeLanguage; ChildWidget<LinkButton> _changeLanguage;
#ifndef TDESKTOP_DISABLE_AUTOUPDATE #ifndef TDESKTOP_DISABLE_AUTOUPDATE
ChildWidget<Checkbox> _updateAutomatically = { nullptr }; ChildWidget<Ui::Checkbox> _updateAutomatically = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<UpdateStateRow>> _updateRow = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<UpdateStateRow>> _updateRow = { nullptr };
#endif // !TDESKTOP_DISABLE_AUTOUPDATE #endif // !TDESKTOP_DISABLE_AUTOUPDATE
ChildWidget<Checkbox> _enableTrayIcon = { nullptr }; ChildWidget<Ui::Checkbox> _enableTrayIcon = { nullptr };
ChildWidget<Checkbox> _enableTaskbarIcon = { nullptr }; ChildWidget<Ui::Checkbox> _enableTaskbarIcon = { nullptr };
ChildWidget<Checkbox> _autoStart = { nullptr }; ChildWidget<Ui::Checkbox> _autoStart = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _startMinimized = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<Ui::Checkbox>> _startMinimized = { nullptr };
ChildWidget<Checkbox> _addInSendTo = { nullptr }; ChildWidget<Ui::Checkbox> _addInSendTo = { nullptr };
FileDialog::QueryId _chooseLangFileQueryId = 0; FileDialog::QueryId _chooseLangFileQueryId = 0;
QString _testLanguage; QString _testLanguage;

View File

@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "lang.h" #include "lang.h"
#include "localstorage.h" #include "localstorage.h"
#include "ui/effects/widget_slide_wrap.h" #include "ui/effects/widget_slide_wrap.h"
#include "ui/flatcheckbox.h" #include "ui/buttons/checkbox.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "window/notifications_manager.h" #include "window/notifications_manager.h"
#include "boxes/notifications_box.h" #include "boxes/notifications_box.h"

View File

@ -45,12 +45,12 @@ private:
void desktopEnabledUpdated(); void desktopEnabledUpdated();
void viewParamUpdated(); void viewParamUpdated();
ChildWidget<Checkbox> _desktopNotifications = { nullptr }; ChildWidget<Ui::Checkbox> _desktopNotifications = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _showSenderName = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<Ui::Checkbox>> _showSenderName = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<Checkbox>> _showMessagePreview = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<Ui::Checkbox>> _showMessagePreview = { nullptr };
ChildWidget<Checkbox> _nativeNotifications = { nullptr }; ChildWidget<Ui::Checkbox> _nativeNotifications = { nullptr };
ChildWidget<Checkbox> _playSound = { nullptr }; ChildWidget<Ui::Checkbox> _playSound = { nullptr };
ChildWidget<Checkbox> _includeMuted = { nullptr }; ChildWidget<Ui::Checkbox> _includeMuted = { nullptr };
ChildWidget<Ui::WidgetSlideWrap<LinkButton>> _advanced = { nullptr }; ChildWidget<Ui::WidgetSlideWrap<LinkButton>> _advanced = { nullptr };
}; };

View File

@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "settings/settings_scale_widget.h" #include "settings/settings_scale_widget.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "ui/buttons/checkbox.h"
#include "lang.h" #include "lang.h"
#include "localstorage.h" #include "localstorage.h"
#include "mainwindow.h" #include "mainwindow.h"

View File

@ -22,9 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "settings/settings_block_widget.h" #include "settings/settings_block_widget.h"
class Checkbox;
namespace Ui { namespace Ui {
class Checkbox;
class DiscreteSlider; class DiscreteSlider;
} // namespace Ui } // namespace Ui
@ -45,7 +44,7 @@ private:
void createControls(); void createControls();
void setScale(DBIScale newScale); void setScale(DBIScale newScale);
ChildWidget<Checkbox> _auto = { nullptr }; ChildWidget<Ui::Checkbox> _auto = { nullptr };
ChildWidget<Ui::DiscreteSlider> _scale = { nullptr }; ChildWidget<Ui::DiscreteSlider> _scale = { nullptr };
}; };

View File

@ -2784,14 +2784,7 @@ void EmojiPan::paintEvent(QPaintEvent *e) {
p.drawPixmapLeft(x + (st::emojiCategory.width - s.pixw) / 2, _iconsTop + (st::emojiCategory.height - s.pixh) / 2, width(), pix); p.drawPixmapLeft(x + (st::emojiCategory.width - s.pixw) / 2, _iconsTop + (st::emojiCategory.height - s.pixh) / 2, width(), pix);
x += st::emojiCategory.width; x += st::emojiCategory.width;
} else { } else {
if (true || selxrel != x) { getSpecialSetIcon(s.setId, false)->paint(p, x + st::emojiCategory.iconPosition.x(), _iconsTop + st::emojiCategory.iconPosition.y(), width());
getSpecialSetIcon(s.setId, false)->paint(p, x + st::emojiCategory.iconPosition.x(), _iconsTop + st::emojiCategory.iconPosition.y(), width());
}
//if (selxrel < x + st::emojiCategory.width && selxrel > x - st::emojiCategory.width) {
// p.setOpacity(1 - (qAbs(selxrel - x) / float64(st::emojiCategory.width)));
// p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), getSpecialSetIcon(s.setId, true));
// p.setOpacity(1);
//}
if (s.setId == Stickers::FeaturedSetId) { if (s.setId == Stickers::FeaturedSetId) {
paintFeaturedStickerSetsBadge(p, x); paintFeaturedStickerSetsBadge(p, x);
} }

View File

@ -30,7 +30,7 @@ stickersTrendingHeaderFont: semiboldFont;
stickersTrendingHeaderFg: windowTextFg; stickersTrendingHeaderFg: windowTextFg;
stickersTrendingHeaderTop: 0px; stickersTrendingHeaderTop: 0px;
stickersTrendingSubheaderFont: normalFont; stickersTrendingSubheaderFont: normalFont;
stickersTrendingSubheaderFg: #777; stickersTrendingSubheaderFg: #777777;
stickersTrendingSubheaderTop: 20px; stickersTrendingSubheaderTop: 20px;
stickersTrendingAddTop: 3px; stickersTrendingAddTop: 3px;
@ -68,7 +68,7 @@ stickersScroll: flatScroll(boxScroll) {
deltab: 9px; deltab: 9px;
} }
stickersReorderPadding: margins(0px, 12px, 0px, 12px); stickersReorderPadding: margins(0px, 12px, 0px, 12px);
stickersReorderFg: #777; stickersReorderFg: #777777;
stickersRowDisabledOpacity: 0.4; stickersRowDisabledOpacity: 0.4;
stickersRowDuration: 200; stickersRowDuration: 200;
@ -131,7 +131,7 @@ emojiPanHover: #f0f4f7;
emojiPanHeader: 42px; emojiPanHeader: 42px;
emojiPanHeaderFont: semiboldFont; emojiPanHeaderFont: semiboldFont;
emojiPanHeaderColor: #999; emojiPanHeaderColor: #999999;
emojiPanHeaderLeft: 22px; emojiPanHeaderLeft: 22px;
emojiPanHeaderTop: 12px; emojiPanHeaderTop: 12px;
emojiPanHeaderBg: #fffffff2; emojiPanHeaderBg: #fffffff2;

View File

@ -19,126 +19,21 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "ui/flatcheckbox.h" #include "ui/buttons/checkbox.h"
#include "lang.h" #include "lang.h"
FlatCheckbox::FlatCheckbox(QWidget *parent, const QString &text, bool checked, const style::flatCheckbox &st) : Button(parent) namespace Ui {
, _st(st) namespace {
, a_over(0, 0)
, _a_appearance(animation(this, &FlatCheckbox::step_appearance))
, _text(text)
, _opacity(1)
, _checked(checked) {
connect(this, SIGNAL(clicked()), this, SLOT(onClicked()));
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
setCursor(_st.cursor);
int32 w = _st.width, h = _st.height;
if (w <= 0) w = _st.textLeft + _st.font->width(_text) + 2;
if (h <= 0) h = qMax(_st.font->height, _st.imageRect.pxHeight());
resize(QSize(w, h));
}
bool FlatCheckbox::checked() const { class RadiobuttonGroup : public QMap<Radiobutton*, bool> {
return _checked; using Parent = QMap<Radiobutton*, bool>;
}
void FlatCheckbox::setChecked(bool checked) {
if (_checked != checked) {
_checked = checked;
emit changed();
update();
}
}
void FlatCheckbox::setOpacity(float64 o) {
_opacity = o;
update();
}
void FlatCheckbox::onClicked() {
if (_state & StateDisabled) return;
setChecked(!checked());
}
void FlatCheckbox::onStateChange(int oldState, ButtonStateChangeSource source) {
if ((_state & StateOver) && !(oldState & StateOver)) {
a_over.start(1);
_a_appearance.start();
} else if (!(_state & StateOver) && (oldState & StateOver)) {
a_over.start(0);
_a_appearance.start();
}
if ((_state & StateDisabled) && !(oldState & StateDisabled)) {
setCursor(_st.disabledCursor);
_a_appearance.start();
} else if (!(_state & StateDisabled) && (oldState & StateDisabled)) {
setCursor(_st.cursor);
_a_appearance.start();
}
}
void FlatCheckbox::paintEvent(QPaintEvent *e) {
Painter p(this);
p.setOpacity(_opacity);
if (_st.bgColor != st::transparent) {
p.fillRect(rect(), _st.bgColor->b);
}
if (!_text.isEmpty()) {
p.setFont(_st.font->f);
p.setRenderHint(QPainter::TextAntialiasing);
p.setPen((_state & StateDisabled ? _st.disColor : _st.textColor)->p);
QRect tRect(rect());
tRect.setTop(_st.textTop);
tRect.setLeft(_st.textLeft);
// p.drawText(_st.textLeft, _st.textTop + _st.font->ascent, _text);
p.drawText(tRect, _text, QTextOption(style::al_topleft));
}
if (_state & StateDisabled) {
const style::sprite &sRect(_checked ? _st.chkDisImageRect : _st.disImageRect);
p.drawSprite(_st.imagePos, sRect);
} else if ((_checked && _st.chkImageRect == _st.chkOverImageRect) || (!_checked && _st.imageRect == _st.overImageRect)) {
p.setOpacity(_opacity);
const style::sprite &sRect(_checked ? _st.chkImageRect : _st.imageRect);
p.drawSprite(_st.imagePos, sRect);
} else {
if (a_over.current() < 1) {
const style::sprite &sRect(_checked ? _st.chkImageRect : _st.imageRect);
p.drawSprite(_st.imagePos, sRect);
}
if (a_over.current() > 0) {
p.setOpacity(_opacity * a_over.current());
const style::sprite &sRect(_checked ? _st.chkOverImageRect : _st.overImageRect);
p.drawSprite(_st.imagePos, sRect);
}
}
}
void FlatCheckbox::step_appearance(float64 ms, bool timer) {
float64 dt = ms / _st.duration;
if (dt >= 1) {
_a_appearance.stop();
a_over.finish();
} else {
a_over.update(dt, _st.bgFunc);
}
if (timer) update();
}
template <typename Type>
class TemplateRadiobuttonsGroup : public QMap<Type*, bool> {
typedef QMap<Type*, bool> Parent;
public: public:
TemplateRadiobuttonsGroup(const QString &name) : _name(name), _val(0) { RadiobuttonGroup(const QString &name) : _name(name) {
} }
void remove(Type * const &radio) { void remove(Radiobutton * const &radio);
}
int32 val() const { int32 val() const {
return _val; return _val;
} }
@ -148,23 +43,18 @@ public:
private: private:
QString _name; QString _name;
int32 _val; int _val = 0;
}; };
typedef TemplateRadiobuttonsGroup<FlatRadiobutton> FlatRadiobuttonGroup; class Radiobuttons : public QMap<QString, RadiobuttonGroup*> {
typedef TemplateRadiobuttonsGroup<Radiobutton> RadiobuttonGroup; using Parent = QMap<QString, RadiobuttonGroup*>;
template <typename Type>
class Radiobuttons : public QMap<QString, TemplateRadiobuttonsGroup<Type> *> {
typedef QMap<QString, TemplateRadiobuttonsGroup<Type> *> Parent;
public: public:
RadiobuttonGroup *reg(const QString &group) {
TemplateRadiobuttonsGroup<Type> *reg(const QString &group) {
typename Parent::const_iterator i = Parent::constFind(group); typename Parent::const_iterator i = Parent::constFind(group);
if (i == Parent::cend()) { if (i == Parent::cend()) {
i = Parent::insert(group, new TemplateRadiobuttonsGroup<Type>(group)); i = Parent::insert(group, new RadiobuttonGroup(group));
} }
return i.value(); return i.value();
} }
@ -186,55 +76,17 @@ public:
} }
}; };
namespace { Radiobuttons radiobuttons;
Radiobuttons<FlatRadiobutton> flatRadiobuttons;
Radiobuttons<Radiobutton> radiobuttons;
}
template <> } // namespace
void TemplateRadiobuttonsGroup<FlatRadiobutton>::remove(FlatRadiobutton * const &radio) {
Parent::remove(radio);
if (isEmpty()) {
flatRadiobuttons.remove(_name);
}
}
template <> void RadiobuttonGroup::remove(Radiobutton * const &radio) {
void TemplateRadiobuttonsGroup<Radiobutton>::remove(Radiobutton * const &radio) {
Parent::remove(radio); Parent::remove(radio);
if (isEmpty()) { if (isEmpty()) {
radiobuttons.remove(_name); radiobuttons.remove(_name);
} }
} }
FlatRadiobutton::FlatRadiobutton(QWidget *parent, const QString &group, int32 value, const QString &text, bool checked, const style::flatCheckbox &st) :
FlatCheckbox(parent, text, checked, st), _group(flatRadiobuttons.reg(group)), _value(value) {
reinterpret_cast<FlatRadiobuttonGroup*>(_group)->insert(this, true);
connect(this, SIGNAL(changed()), this, SLOT(onChanged()));
if (this->checked()) onChanged();
}
void FlatRadiobutton::onChanged() {
FlatRadiobuttonGroup *group = reinterpret_cast<FlatRadiobuttonGroup*>(_group);
if (checked()) {
int32 uncheck = group->val();
if (uncheck != _value) {
group->setVal(_value);
for (FlatRadiobuttonGroup::const_iterator i = group->cbegin(), e = group->cend(); i != e; ++i) {
if (i.key()->val() == uncheck) {
i.key()->setChecked(false);
}
}
}
} else if (group->val() == _value) {
setChecked(true);
}
}
FlatRadiobutton::~FlatRadiobutton() {
reinterpret_cast<FlatRadiobuttonGroup*>(_group)->remove(this);
}
Checkbox::Checkbox(QWidget *parent, const QString &text, bool checked, const style::Checkbox &st) : Button(parent) Checkbox::Checkbox(QWidget *parent, const QString &text, bool checked, const style::Checkbox &st) : Button(parent)
, _st(st) , _st(st)
, a_over(0) , a_over(0)
@ -564,3 +416,5 @@ void Radiobutton::onChanged() {
Radiobutton::~Radiobutton() { Radiobutton::~Radiobutton() {
reinterpret_cast<RadiobuttonGroup*>(_group)->remove(this); reinterpret_cast<RadiobuttonGroup*>(_group)->remove(this);
} }
} // namespace Ui

View File

@ -22,62 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/button.h" #include "ui/button.h"
class FlatCheckbox : public Button { namespace Ui {
Q_OBJECT
public:
FlatCheckbox(QWidget *parent, const QString &text, bool checked, const style::flatCheckbox &st);
bool checked() const;
void setChecked(bool checked);
void step_appearance(float64 ms, bool timer);
void paintEvent(QPaintEvent *e);
void setOpacity(float64 o);
public slots:
void onClicked();
void onStateChange(int oldState, ButtonStateChangeSource source);
signals:
void changed();
private:
style::flatCheckbox _st;
anim::fvalue a_over;
Animation _a_appearance;
QString _text;
style::font _font;
float64 _opacity;
bool _checked;
};
class FlatRadiobutton : public FlatCheckbox {
Q_OBJECT
public:
FlatRadiobutton(QWidget *parent, const QString &group, int32 value, const QString &text, bool checked, const style::flatCheckbox &st);
int32 val() const {
return _value;
}
~FlatRadiobutton();
public slots:
void onChanged();
private:
void *_group;
int32 _value;
};
class Checkbox : public Button { class Checkbox : public Button {
Q_OBJECT Q_OBJECT
@ -99,7 +44,7 @@ public:
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
public slots: public slots:
void onClicked(); void onClicked();
void onStateChange(int oldState, ButtonStateChangeSource source); void onStateChange(int oldState, ButtonStateChangeSource source);
@ -142,7 +87,7 @@ public:
~Radiobutton(); ~Radiobutton();
public slots: public slots:
void onClicked(); void onClicked();
void onStateChange(int oldState, ButtonStateChangeSource source); void onStateChange(int oldState, ButtonStateChangeSource source);
@ -166,3 +111,5 @@ private:
int32 _value; int32 _value;
}; };
} // namespace Ui

View File

@ -163,109 +163,6 @@ void LinkButton::onStateChange(int oldState, ButtonStateChangeSource source) {
LinkButton::~LinkButton() { LinkButton::~LinkButton() {
} }
IconedButton::IconedButton(QWidget *parent, const style::iconedButton &st, const QString &text) : Button(parent)
, _text(text)
, _st(st)
, _width(_st.width)
, a_opacity(_st.opacity)
, a_bg(_st.bgColor->c)
, _a_appearance(animation(this, &IconedButton::step_appearance))
, _opacity(1) {
if (_width < 0) {
_width = _st.font->width(text) - _width;
} else if (!_width) {
_width = _st.font->width(text) + _st.height - _st.font->height;
}
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
resize(_width, _st.height);
setCursor(_st.cursor);
}
void IconedButton::setOpacity(float64 opacity) {
_opacity = opacity;
update();
}
void IconedButton::setText(const QString &text) {
if (_text != text) {
_text = text;
if (_st.width < 0) {
_width = _st.font->width(text) - _st.width;
} else if (!_st.width) {
_width = _st.font->width(text) + _st.height - _st.font->height;
}
resize(_width, _st.height);
update();
}
}
QString IconedButton::getText() const {
return _text;
}
void IconedButton::step_appearance(float64 ms, bool timer) {
if (_st.duration <= 1) {
_a_appearance.stop();
a_opacity.finish();
a_bg.finish();
} else {
float64 dt = ms / _st.duration;
if (dt >= 1) {
_a_appearance.stop();
a_opacity.finish();
a_bg.finish();
} else {
a_opacity.update(dt, anim::linear);
a_bg.update(dt, anim::linear);
}
}
if (timer) update();
}
void IconedButton::onStateChange(int oldState, ButtonStateChangeSource source) {
a_opacity.start((_state & (StateOver | StateDown)) ? _st.overOpacity : _st.opacity);
a_bg.start(((_state & (StateOver | StateDown)) ? _st.overBgColor : _st.bgColor)->c);
if (source == ButtonByUser || source == ButtonByPress) {
_a_appearance.stop();
a_opacity.finish();
a_bg.finish();
update();
} else {
_a_appearance.start();
}
}
void IconedButton::paintEvent(QPaintEvent *e) {
Painter p(this);
p.setOpacity(_opacity);
p.fillRect(e->rect(), a_bg.current());
p.setOpacity(a_opacity.current() * _opacity);
if (!_text.isEmpty()) {
p.setFont(_st.font->f);
p.setRenderHint(QPainter::TextAntialiasing);
p.setPen(_st.color->p);
const QPoint &t((_state & StateDown) ? _st.downTextPos : _st.textPos);
p.drawText(t.x(), t.y() + _st.font->ascent, _text);
}
const style::sprite &i((_state & StateDown) ? _st.downIcon : _st.icon);
if (i.pxWidth()) {
QPoint t((_state & StateDown) ? _st.downIconPos : _st.iconPos);
if (t.x() < 0) {
t.setX((width() - i.pxWidth()) / 2);
}
if (t.y() < 0) {
t.setY((height() - i.pxHeight()) / 2);
}
p.drawSprite(t, i);
}
}
BoxButton::BoxButton(QWidget *parent, const QString &text, const style::RoundButton &st) : Button(parent) BoxButton::BoxButton(QWidget *parent, const QString &text, const style::RoundButton &st) : Button(parent)
, _text(text.toUpper()) , _text(text.toUpper())
, _fullText(text.toUpper()) , _fullText(text.toUpper())

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "ui/button.h" #include "ui/button.h"
#include "ui/flatcheckbox.h"
#include "ui/animation.h" #include "ui/animation.h"
class FlatButton : public Button { class FlatButton : public Button {
@ -84,36 +83,6 @@ private:
}; };
class IconedButton : public Button {
Q_OBJECT
public:
IconedButton(QWidget *parent, const style::iconedButton &st, const QString &text = QString());
void step_appearance(float64 ms, bool timer);
void paintEvent(QPaintEvent *e);
void setOpacity(float64 o);
void setText(const QString &text);
QString getText() const;
public slots:
void onStateChange(int oldState, ButtonStateChangeSource source);
protected:
QString _text;
style::iconedButton _st;
int32 _width;
anim::fvalue a_opacity;
anim::cvalue a_bg;
Animation _a_appearance;
float64 _opacity;
};
class BoxButton : public Button { class BoxButton : public Button {
Q_OBJECT Q_OBJECT

View File

@ -65,7 +65,6 @@ void startManager() {
} }
internal::registerFontFamily(qsl("Open Sans")); internal::registerFontFamily(qsl("Open Sans"));
internal::loadSprite();
internal::startModules(); internal::startModules();
} }
@ -74,7 +73,6 @@ void stopManager() {
internal::destroyFonts(); internal::destroyFonts();
internal::destroyColors(); internal::destroyColors();
internal::destroyIcons(); internal::destroyIcons();
internal::destroySprite();
} }
QImage colorizeImage(const QImage &src, const color &c, const QRect &r) { QImage colorizeImage(const QImage &src, const color &c, const QRect &r) {

View File

@ -77,7 +77,3 @@ inline QImage createInvertedCircleMask(int size) {
} }
} // namespace style } // namespace style
inline QRect centersprite(const QRect &inRect, const style::sprite &sprite) {
return centerrect(inRect, QRect(QPoint(0, 0), sprite.pxSize()));
}

View File

@ -22,46 +22,4 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/style/style_core_types.h" #include "ui/style/style_core_types.h"
namespace style { namespace style {
namespace internal {
namespace {
int spriteWidthValue = 0;
QPixmap *spriteData = nullptr;
} // namespace
void loadSprite() {
QString spriteFilePostfix;
if (cRetina() || cScale() == dbisTwo) {
spriteFilePostfix = qsl("_200x");
} else if (cScale() == dbisOneAndQuarter) {
spriteFilePostfix = qsl("_125x");
} else if (cScale() == dbisOneAndHalf) {
spriteFilePostfix = qsl("_150x");
}
QString spriteFile = qsl(":/gui/art/sprite") + spriteFilePostfix + qsl(".png");
if (rtl()) {
spriteData = new QPixmap(App::pixmapFromImageInPlace(QImage(spriteFile).mirrored(true, false)));
} else {
spriteData = new QPixmap(spriteFile);
}
if (cRetina()) spriteData->setDevicePixelRatio(cRetinaFactor());
spriteWidthValue = spriteData->width();
}
int spriteWidth() {
return spriteWidthValue;
}
void destroySprite() {
delete spriteData;
spriteData = nullptr;
}
} // namespace internal
const QPixmap &spritePixmap() {
return *internal::spriteData;
}
} // namespace style } // namespace style

View File

@ -33,50 +33,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/style/style_core_icon.h" #include "ui/style/style_core_icon.h"
namespace style { namespace style {
namespace internal {
void loadSprite();
int spriteWidth();
void destroySprite();
class Sprite {
public:
Sprite() {
}
Sprite(int left, int top, int width, int height)
: _rect(rtl() ? (spriteWidth() - left * cIntRetinaFactor() - width * cIntRetinaFactor()) : left * cIntRetinaFactor(),
top * cIntRetinaFactor(),
width * cIntRetinaFactor(),
height * cIntRetinaFactor()) {
}
int pxWidth() const {
return _rect.width() / cIntRetinaFactor();
}
int pxHeight() const {
return _rect.height() / cIntRetinaFactor();
}
QSize pxSize() const {
return _rect.size() / cIntRetinaFactor();
}
QRect rect() const {
return _rect;
}
bool isEmpty() const {
return _rect.isEmpty();
}
private:
QRect _rect;
};
inline bool operator==(const Sprite &a, const Sprite &b) {
return a.rect() == b.rect();
}
inline bool operator!=(const Sprite &a, const Sprite &b) {
return !(a == b);
}
} // namespace internal
using string = QString; using string = QString;
using rect = QRect; using rect = QRect;
@ -88,7 +44,6 @@ using align = Qt::Alignment;
using margins = QMargins; using margins = QMargins;
using font = internal::Font; using font = internal::Font;
using color = internal::Color; using color = internal::Color;
using sprite = internal::Sprite;
using icon = internal::Icon; using icon = internal::Icon;
static constexpr cursor cur_default = Qt::ArrowCursor; static constexpr cursor cur_default = Qt::ArrowCursor;
@ -111,6 +66,4 @@ static const align al_bottomleft = (Qt::AlignBottom | Qt::AlignLeft);
static const align al_left = (Qt::AlignVCenter | Qt::AlignLeft); static const align al_left = (Qt::AlignVCenter | Qt::AlignLeft);
static const align al_center = (Qt::AlignVCenter | Qt::AlignHCenter); static const align al_center = (Qt::AlignVCenter | Qt::AlignHCenter);
const QPixmap &spritePixmap();
} // namespace style } // namespace style

View File

@ -20,10 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
namespace App {
const QPixmap &sprite();
}
namespace Fonts { namespace Fonts {
void start(); void start();
} }
@ -79,45 +75,6 @@ public:
void drawPixmapRight(const QPoint &p, int outerw, const QPixmap &pix) { void drawPixmapRight(const QPoint &p, int outerw, const QPixmap &pix) {
return drawPixmapRight(p.x(), p.y(), outerw, pix); return drawPixmapRight(p.x(), p.y(), outerw, pix);
} }
void drawSprite(int x, int y, const style::sprite &sprite) {
return drawPixmap(QPoint(x, y), App::sprite(), sprite.rect());
}
void drawSprite(const QPoint &p, const style::sprite &sprite) {
return drawPixmap(p, App::sprite(), sprite.rect());
}
void drawSpriteLeft(int x, int y, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(x, y, outerw, App::sprite(), sprite.rect());
}
void drawSpriteLeft(const QPoint &p, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(p, outerw, App::sprite(), sprite.rect());
}
void drawSpriteLeft(int x, int y, int w, int h, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(x, y, w, h, outerw, App::sprite(), sprite.rect());
}
void drawSpriteLeft(const QRect &r, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(r, outerw, App::sprite(), sprite.rect());
}
void drawSpriteRight(int x, int y, int outerw, const style::sprite &sprite) {
return drawPixmapRight(x, y, outerw, App::sprite(), sprite.rect());
}
void drawSpriteRight(const QPoint &p, int outerw, const style::sprite &sprite) {
return drawPixmapRight(p, outerw, App::sprite(), sprite.rect());
}
void drawSpriteRight(int x, int y, int w, int h, int outerw, const style::sprite &sprite) {
return drawPixmapRight(x, y, w, h, outerw, App::sprite(), sprite.rect());
}
void drawSpriteRight(const QRect &r, int outerw, const style::sprite &sprite) {
return drawPixmapRight(r, outerw, App::sprite(), sprite.rect());
}
void drawSpriteCenter(const QRect &in, const style::sprite &sprite) {
return drawPixmap(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), App::sprite(), sprite.rect());
}
void drawSpriteCenterLeft(const QRect &in, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), outerw, App::sprite(), sprite.rect());
}
void drawSpriteCenterRight(const QRect &in, int outerw, const style::sprite &sprite) {
return drawPixmapRight(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), outerw, App::sprite(), sprite.rect());
}
}; };
#define T_WIDGET \ #define T_WIDGET \

View File

@ -195,10 +195,10 @@ defaultMenu: Menu {
itemBgOver: overBg; itemBgOver: overBg;
itemFg: black; itemFg: black;
itemFgOver: black; itemFgOver: black;
itemFgDisabled: #ccc; itemFgDisabled: #cccccc;
itemFgShortcut: #999; itemFgShortcut: #999999;
itemFgShortcutOver: #7c99b2; itemFgShortcutOver: #7c99b2;
itemFgShortcutDisabled: #ccc; itemFgShortcutDisabled: #cccccc;
itemIconPosition: point(0px, 0px); itemIconPosition: point(0px, 0px);
itemIconOpacity: 1.; itemIconOpacity: 1.;
itemIconOverOpacity: 1.; itemIconOverOpacity: 1.;

View File

@ -444,6 +444,8 @@
'<(src_loc)/stickers/emoji_pan.h', '<(src_loc)/stickers/emoji_pan.h',
'<(src_loc)/stickers/stickers.cpp', '<(src_loc)/stickers/stickers.cpp',
'<(src_loc)/stickers/stickers.h', '<(src_loc)/stickers/stickers.h',
'<(src_loc)/ui/buttons/checkbox.cpp',
'<(src_loc)/ui/buttons/checkbox.h',
'<(src_loc)/ui/buttons/history_down_button.cpp', '<(src_loc)/ui/buttons/history_down_button.cpp',
'<(src_loc)/ui/buttons/history_down_button.h', '<(src_loc)/ui/buttons/history_down_button.h',
'<(src_loc)/ui/buttons/icon_button.cpp', '<(src_loc)/ui/buttons/icon_button.cpp',
@ -522,8 +524,6 @@
'<(src_loc)/ui/filedialog.h', '<(src_loc)/ui/filedialog.h',
'<(src_loc)/ui/flatbutton.cpp', '<(src_loc)/ui/flatbutton.cpp',
'<(src_loc)/ui/flatbutton.h', '<(src_loc)/ui/flatbutton.h',
'<(src_loc)/ui/flatcheckbox.cpp',
'<(src_loc)/ui/flatcheckbox.h',
'<(src_loc)/ui/flatinput.cpp', '<(src_loc)/ui/flatinput.cpp',
'<(src_loc)/ui/flatinput.h', '<(src_loc)/ui/flatinput.h',
'<(src_loc)/ui/flatlabel.cpp', '<(src_loc)/ui/flatlabel.cpp',

View File

@ -83,8 +83,6 @@
'<(src_loc)/codegen/style/parsed_file.h', '<(src_loc)/codegen/style/parsed_file.h',
'<(src_loc)/codegen/style/processor.cpp', '<(src_loc)/codegen/style/processor.cpp',
'<(src_loc)/codegen/style/processor.h', '<(src_loc)/codegen/style/processor.h',
'<(src_loc)/codegen/style/sprite_generator.cpp',
'<(src_loc)/codegen/style/sprite_generator.h',
'<(src_loc)/codegen/style/structure_types.cpp', '<(src_loc)/codegen/style/structure_types.cpp',
'<(src_loc)/codegen/style/structure_types.h', '<(src_loc)/codegen/style/structure_types.h',
], ],

View File

@ -19,25 +19,6 @@
{ {
'actions': [{ 'actions': [{
'action_name': 'update_sprites',
'inputs': [
'<(PRODUCT_DIR)/codegen_style<(exe_ext)',
'<(res_loc)/basic.style',
'<(res_loc)/art/sprite.png',
'<(res_loc)/art/sprite_200x.png',
],
'outputs': [
'<(res_loc)/art/sprite_125x.png',
'<(res_loc)/art/sprite_150x.png',
],
'action': [
'<(PRODUCT_DIR)/codegen_style<(exe_ext)',
'-I<(res_loc)', '-I<(src_loc)',
'-w<(PRODUCT_DIR)/../..',
'--skip-styles', '<(res_loc)/basic.style',
],
'message': 'Updating sprites..',
}, {
'action_name': 'update_dependent_styles', 'action_name': 'update_dependent_styles',
'inputs': [ 'inputs': [
'<(DEPTH)/update_dependent.py', '<(DEPTH)/update_dependent.py',
@ -116,7 +97,7 @@
], ],
'action': [ 'action': [
'<(PRODUCT_DIR)/codegen_style<(exe_ext)', '<(PRODUCT_DIR)/codegen_style<(exe_ext)',
'-I<(res_loc)', '-I<(src_loc)', '--skip-sprites', '-I<(res_loc)', '-I<(src_loc)',
'-o<(SHARED_INTERMEDIATE_DIR)/styles', '-o<(SHARED_INTERMEDIATE_DIR)/styles',
'-w<(PRODUCT_DIR)/../..', '-w<(PRODUCT_DIR)/../..',