mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
almost all boxes done
This commit is contained in:
@@ -27,7 +27,62 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
#include "mainwidget.h"
|
||||
#include "window.h"
|
||||
|
||||
AbstractBox::AbstractBox(int32 w) : _maxHeight(0), _hiding(false), a_opacity(0, 1) {
|
||||
void BlueTitleShadow::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
QRect r(e->rect());
|
||||
p.drawPixmap(QRect(r.left(), 0, r.width(), height()), App::sprite(), st::boxBlueShadow);
|
||||
}
|
||||
|
||||
BlueTitleClose::BlueTitleClose(QWidget *parent) : Button(parent)
|
||||
, a_iconFg(st::boxBlueCloseBg->c)
|
||||
, _a_over(animFunc(this, &BlueTitleClose::animStep_over)) {
|
||||
resize(st::boxTitleHeight, st::boxTitleHeight);
|
||||
setCursor(style::cur_pointer);
|
||||
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
|
||||
}
|
||||
|
||||
void BlueTitleClose::onStateChange(int oldState, ButtonStateChangeSource source) {
|
||||
if ((oldState & StateOver) != (_state & StateOver)) {
|
||||
a_iconFg.start(((_state & StateOver) ? st::white : st::boxBlueCloseBg)->c);
|
||||
_a_over.start();
|
||||
}
|
||||
}
|
||||
|
||||
bool BlueTitleClose::animStep_over(float64 ms) {
|
||||
float64 dt = ms / st::boxBlueCloseDuration;
|
||||
bool res = true;
|
||||
if (dt >= 1) {
|
||||
res = false;
|
||||
a_iconFg.finish();
|
||||
} else {
|
||||
a_iconFg.update(dt, anim::linear);
|
||||
}
|
||||
update((st::boxTitleHeight - st::boxBlueCloseIcon.pxWidth()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.pxHeight()) / 2, st::boxBlueCloseIcon.pxWidth(), st::boxBlueCloseIcon.pxHeight());
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
void BlueTitleClose::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
QRect r(e->rect()), s((st::boxTitleHeight - st::boxBlueCloseIcon.pxWidth()) / 2, (st::boxTitleHeight - st::boxBlueCloseIcon.pxHeight()) / 2, st::boxBlueCloseIcon.pxWidth(), st::boxBlueCloseIcon.pxHeight());
|
||||
if (!s.contains(r)) {
|
||||
p.fillRect(r, st::boxBlueTitleBg->b);
|
||||
}
|
||||
if (s.intersects(r)) {
|
||||
p.fillRect(s.intersected(r), a_iconFg.current());
|
||||
p.drawSprite(s.topLeft(), st::boxBlueCloseIcon);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractBox::AbstractBox(int32 w) : LayeredWidget()
|
||||
, _maxHeight(0)
|
||||
, _hiding(false)
|
||||
, a_opacity(0, 1)
|
||||
, _blueTitle(false)
|
||||
, _blueClose(0)
|
||||
, _blueShadow(0) {
|
||||
resize(w, 0);
|
||||
}
|
||||
|
||||
@@ -45,6 +100,16 @@ void AbstractBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractBox::resizeEvent(QResizeEvent *e) {
|
||||
if (_blueClose) {
|
||||
_blueClose->moveToRight(0, 0);
|
||||
}
|
||||
if (_blueShadow) {
|
||||
_blueShadow->moveToLeft(0, st::boxTitleHeight);
|
||||
_blueShadow->resize(width(), st::boxBlueShadow.pxHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractBox::parentResized() {
|
||||
int32 newHeight = countHeight();
|
||||
setGeometry((App::wnd()->width() - width()) / 2, (App::wnd()->height() - newHeight) / 2, width(), newHeight);
|
||||
@@ -57,7 +122,7 @@ bool AbstractBox::paint(QPainter &p) {
|
||||
result = (_hiding && a_opacity.current() < 0.01);
|
||||
|
||||
// fill bg
|
||||
p.fillRect(rect(), st::boxBG->b);
|
||||
p.fillRect(rect(), st::boxBg->b);
|
||||
} else {
|
||||
p.setOpacity(a_opacity.current());
|
||||
p.drawPixmap(0, 0, _cache);
|
||||
@@ -65,48 +130,26 @@ bool AbstractBox::paint(QPainter &p) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void AbstractBox::paintOldTitle(Painter &p, const QString &title, bool withShadow) {
|
||||
if (withShadow) {
|
||||
// paint shadow
|
||||
p.fillRect(0, st::old_boxTitleHeight, width(), st::scrollDef.topsh, st::scrollDef.shColor->b);
|
||||
}
|
||||
|
||||
// paint box title
|
||||
p.setFont(st::old_boxTitleFont->f);
|
||||
p.setPen(st::black->p);
|
||||
p.drawTextLeft(st::old_boxTitlePos.x(), st::old_boxTitlePos.y(), width(), title);
|
||||
}
|
||||
|
||||
void AbstractBox::paintTitle(Painter &p, const QString &title) {
|
||||
// paint box title
|
||||
void AbstractBox::paintTitle(Painter &p, const QString &title, const QString &additional) {
|
||||
p.setFont(st::boxTitleFont);
|
||||
p.setPen(st::black);
|
||||
p.drawTextLeft(st::boxTitlePosition.x(), st::boxTitlePosition.y(), width(), title);
|
||||
}
|
||||
if (_blueTitle) {
|
||||
p.fillRect(0, 0, width(), st::boxTitleHeight, st::boxBlueTitleBg->b);
|
||||
p.setPen(st::white);
|
||||
|
||||
void AbstractBox::paintBlueTitle(Painter &p, const QString &title, const QString &additional) {
|
||||
// paint box title
|
||||
p.fillRect(0, 0, width(), st::boxBlueTitleHeight, st::boxBlueTitleBg->b);
|
||||
p.setFont(st::boxTitleFont);
|
||||
p.setPen(st::white);
|
||||
int32 titleWidth = st::boxTitleFont->width(title);
|
||||
p.drawTextLeft(st::boxBlueTitlePosition.x(), st::boxBlueTitlePosition.y(), width(), title, titleWidth);
|
||||
|
||||
int32 titleWidth = st::boxTitleFont->width(title);
|
||||
p.drawTextLeft(st::boxBlueTitlePosition.x(), st::boxBlueTitlePosition.y(), width(), title, titleWidth);
|
||||
|
||||
if (!additional.isEmpty()) {
|
||||
p.setFont(st::boxTextFont);
|
||||
p.setPen(st::boxBlueTitleAdditionalFg);
|
||||
p.drawTextLeft(st::boxBlueTitlePosition.x() + titleWidth + st::boxBlueTitleAdditionalSkip, st::boxBlueTitlePosition.y(), width(), additional);
|
||||
if (!additional.isEmpty()) {
|
||||
p.setFont(st::boxTextFont);
|
||||
p.setPen(st::boxBlueTitleAdditionalFg);
|
||||
p.drawTextLeft(st::boxBlueTitlePosition.x() + titleWidth + st::boxBlueTitleAdditionalSkip, st::boxBlueTitlePosition.y(), width(), additional);
|
||||
}
|
||||
} else {
|
||||
p.setPen(st::boxTitleFg);
|
||||
p.drawTextLeft(st::boxTitlePosition.x(), st::boxTitlePosition.y(), width(), title);
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractBox::paintGrayTitle(QPainter &p, const QString &title) {
|
||||
// draw box title
|
||||
p.setFont(st::boxFont->f);
|
||||
p.setPen(st::boxGrayTitle->p);
|
||||
p.drawText(QRect(st::old_boxTitlePos.x(), st::old_boxTitlePos.y(), width() - 2 * st::old_boxTitlePos.x(), st::boxFont->height), title, style::al_top);
|
||||
}
|
||||
|
||||
void AbstractBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
if (paint(p)) return;
|
||||
@@ -159,12 +202,35 @@ void AbstractBox::startHide() {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||
}
|
||||
|
||||
ScrollableBox::ScrollableBox(const style::flatScroll &scroll) : AbstractBox(),
|
||||
_scroll(this, scroll), _innerPtr(0), _topSkip(st::old_boxTitleHeight), _bottomSkip(0) {
|
||||
void AbstractBox::setBlueTitle(bool blue) {
|
||||
_blueTitle = blue;
|
||||
delete _blueShadow;
|
||||
_blueShadow = new BlueTitleShadow(this);
|
||||
delete _blueClose;
|
||||
_blueClose = new BlueTitleClose(this);
|
||||
_blueClose->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
connect(_blueClose, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
}
|
||||
|
||||
void AbstractBox::raiseShadow() {
|
||||
if (_blueShadow) {
|
||||
_blueShadow->raise();
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollableBoxShadow::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
p.fillRect(e->rect(), st::boxScrollShadowBg->b);
|
||||
}
|
||||
|
||||
ScrollableBox::ScrollableBox(const style::flatScroll &scroll, int32 w) : AbstractBox(w),
|
||||
_scroll(this, scroll), _innerPtr(0), _topSkip(st::boxTitleHeight), _bottomSkip(st::boxScrollSkip) {
|
||||
setBlueTitle(true);
|
||||
}
|
||||
|
||||
void ScrollableBox::resizeEvent(QResizeEvent *e) {
|
||||
_scroll.setGeometry(0, _topSkip, width(), height() - _topSkip - _bottomSkip);
|
||||
AbstractBox::resizeEvent(e);
|
||||
}
|
||||
|
||||
void ScrollableBox::init(QWidget *inner, int32 bottomSkip, int32 topSkip) {
|
||||
@@ -178,12 +244,14 @@ void ScrollableBox::init(QWidget *inner, int32 bottomSkip, int32 topSkip) {
|
||||
|
||||
void ScrollableBox::hideAll() {
|
||||
_scroll.hide();
|
||||
AbstractBox::hideAll();
|
||||
}
|
||||
|
||||
void ScrollableBox::showAll() {
|
||||
_scroll.show();
|
||||
AbstractBox::showAll();
|
||||
}
|
||||
|
||||
ItemListBox::ItemListBox(const style::flatScroll &scroll) : ScrollableBox(scroll) {
|
||||
ItemListBox::ItemListBox(const style::flatScroll &scroll, int32 w) : ScrollableBox(scroll, w) {
|
||||
setMaxHeight(st::boxMaxListHeight);
|
||||
}
|
||||
|
@@ -22,6 +22,31 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "layerwidget.h"
|
||||
|
||||
class BlueTitleShadow : public TWidget {
|
||||
public:
|
||||
BlueTitleShadow(QWidget *parent) : TWidget(parent) {
|
||||
}
|
||||
void paintEvent(QPaintEvent *e);
|
||||
};
|
||||
|
||||
class BlueTitleClose : public Button {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BlueTitleClose(QWidget *parent);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
void onStateChange(int oldState, ButtonStateChangeSource source);
|
||||
|
||||
private:
|
||||
bool animStep_over(float64 ms);
|
||||
anim::cvalue a_iconFg;
|
||||
Animation _a_over;
|
||||
|
||||
};
|
||||
|
||||
class AbstractBox : public LayeredWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -31,8 +56,12 @@ public:
|
||||
void parentResized();
|
||||
void animStep(float64 ms);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void startHide();
|
||||
|
||||
void setBlueTitle(bool blue);
|
||||
void raiseShadow();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -42,18 +71,19 @@ protected:
|
||||
|
||||
void prepare();
|
||||
bool paint(QPainter &p);
|
||||
void paintTitle(Painter &p, const QString &title);
|
||||
void paintBlueTitle(Painter &p, const QString &title, const QString &additional = QString());
|
||||
void paintOldTitle(Painter &p, const QString &title, bool withShadow);
|
||||
void paintGrayTitle(QPainter &p, const QString &title);
|
||||
void paintTitle(Painter &p, const QString &title, const QString &additional = QString());
|
||||
void setMaxHeight(int32 maxHeight);
|
||||
void resizeMaxHeight(int32 newWidth, int32 maxHeight);
|
||||
|
||||
virtual void closePressed() {
|
||||
}
|
||||
virtual void hideAll() {
|
||||
if (_blueClose) _blueClose->hide();
|
||||
if (_blueShadow) _blueShadow->hide();
|
||||
}
|
||||
virtual void showAll() {
|
||||
if (_blueClose) _blueClose->show();
|
||||
if (_blueShadow) _blueShadow->show();
|
||||
}
|
||||
virtual void showDone() {
|
||||
setFocus();
|
||||
@@ -68,17 +98,28 @@ private:
|
||||
QPixmap _cache;
|
||||
|
||||
anim::fvalue a_opacity;
|
||||
|
||||
bool _blueTitle;
|
||||
BlueTitleClose *_blueClose;
|
||||
BlueTitleShadow *_blueShadow;
|
||||
};
|
||||
|
||||
class ScrollableBoxShadow : public TWidget {
|
||||
public:
|
||||
ScrollableBoxShadow(QWidget *parent) : TWidget(parent) {
|
||||
}
|
||||
void paintEvent(QPaintEvent *e);
|
||||
};
|
||||
|
||||
class ScrollableBox : public AbstractBox {
|
||||
public:
|
||||
|
||||
ScrollableBox(const style::flatScroll &scroll);
|
||||
ScrollableBox(const style::flatScroll &scroll, int32 w = st::boxWideWidth);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
protected:
|
||||
|
||||
void init(QWidget *inner, int32 bottomSkip = 0, int32 topSkip = st::old_boxTitleHeight);
|
||||
void init(QWidget *inner, int32 bottomSkip = st::boxScrollSkip, int32 topSkip = st::boxTitleHeight);
|
||||
|
||||
virtual void hideAll();
|
||||
virtual void showAll();
|
||||
@@ -95,6 +136,12 @@ private:
|
||||
class ItemListBox : public ScrollableBox {
|
||||
public:
|
||||
|
||||
ItemListBox(const style::flatScroll &scroll);
|
||||
ItemListBox(const style::flatScroll &scroll, int32 w = st::boxWideWidth);
|
||||
|
||||
};
|
||||
|
||||
enum CreatingGroupType {
|
||||
CreatingGroupNone,
|
||||
CreatingGroupGroup,
|
||||
CreatingGroupChannel,
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -28,18 +28,18 @@ class AddContactBox : public AbstractBox, public RPCSender {
|
||||
public:
|
||||
|
||||
AddContactBox(QString fname = QString(), QString lname = QString(), QString phone = QString());
|
||||
AddContactBox(PeerData *peer);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
AddContactBox(UserData *user);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void setInnerFocus() {
|
||||
_firstInput.setFocus();
|
||||
_first.setFocus();
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void onSend();
|
||||
void onSubmit();
|
||||
void onSave();
|
||||
void onRetry();
|
||||
|
||||
protected:
|
||||
@@ -52,20 +52,17 @@ private:
|
||||
|
||||
void onImportDone(const MTPcontacts_ImportedContacts &res);
|
||||
|
||||
void onSaveSelfDone(const MTPUser &user);
|
||||
bool onSaveSelfFail(const RPCError &error);
|
||||
|
||||
void onSaveChatDone(const MTPUpdates &updates);
|
||||
void onSaveUserDone(const MTPcontacts_ImportedContacts &res);
|
||||
bool onSaveFail(const RPCError &e);
|
||||
bool onSaveUserFail(const RPCError &e);
|
||||
|
||||
void initBox();
|
||||
|
||||
PeerData *_peer;
|
||||
UserData *_user;
|
||||
QString _boxTitle;
|
||||
|
||||
FlatButton _addButton, _retryButton, _cancelButton;
|
||||
FlatInput _firstInput, _lastInput, _phoneInput;
|
||||
BoxButton _save, _cancel, _retry;
|
||||
InputField _first, _last;
|
||||
PhoneInput _phone;
|
||||
|
||||
bool _invertOrder;
|
||||
|
||||
@@ -75,6 +72,169 @@ private:
|
||||
QString _sentName;
|
||||
};
|
||||
|
||||
class NewGroupBox : public AbstractBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
NewGroupBox();
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
void onNext();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
Radiobutton _group, _channel;
|
||||
int32 _aboutGroupWidth, _aboutGroupHeight;
|
||||
Text _aboutGroup, _aboutChannel;
|
||||
BoxButton _next, _cancel;
|
||||
|
||||
};
|
||||
|
||||
class GroupInfoBox : public AbstractBox, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
bool animStep_photoOver(float64 ms);
|
||||
|
||||
void setInnerFocus() {
|
||||
_title.setFocus();
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void onPhoto();
|
||||
void onPhotoReady(const QImage &img);
|
||||
|
||||
void onNext();
|
||||
void onNameSubmit();
|
||||
void onDescriptionResized();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
QRect photoRect() const;
|
||||
|
||||
void updateMaxHeight();
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
CreatingGroupType _creating;
|
||||
|
||||
anim::fvalue a_photoOver;
|
||||
Animation _a_photoOver;
|
||||
bool _photoOver;
|
||||
|
||||
InputField _title;
|
||||
InputArea _description;
|
||||
|
||||
QImage _photoBig;
|
||||
QPixmap _photoSmall;
|
||||
BoxButton _next, _cancel;
|
||||
|
||||
// channel creation
|
||||
int32 _creationRequestId;
|
||||
ChannelData *_createdChannel;
|
||||
|
||||
void creationDone(const MTPUpdates &updates);
|
||||
bool creationFail(const RPCError &e);
|
||||
void exportDone(const MTPExportedChatInvite &result);
|
||||
};
|
||||
|
||||
class SetupChannelBox : public AbstractBox, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SetupChannelBox(ChannelData *channel, bool existing = false);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
void closePressed();
|
||||
|
||||
void setInnerFocus() {
|
||||
if (_link.isHidden()) {
|
||||
setFocus();
|
||||
} else {
|
||||
_link.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void onSave();
|
||||
void onChange();
|
||||
void onCheck();
|
||||
|
||||
void onPrivacyChange();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
bool animStep_goodFade(float64 ms);
|
||||
|
||||
void onUpdateDone(const MTPBool &result);
|
||||
bool onUpdateFail(const RPCError &error);
|
||||
|
||||
void onCheckDone(const MTPBool &result);
|
||||
bool onCheckFail(const RPCError &error);
|
||||
bool onFirstCheckFail(const RPCError &error);
|
||||
|
||||
ChannelData *_channel;
|
||||
bool _existing;
|
||||
|
||||
Radiobutton _public, _private;
|
||||
Checkbox _comments;
|
||||
int32 _aboutPublicWidth, _aboutPublicHeight;
|
||||
Text _aboutPublic, _aboutPrivate, _aboutComments;
|
||||
UsernameInput _link;
|
||||
QRect _invitationLink;
|
||||
bool _linkOver;
|
||||
BoxButton _save, _skip;
|
||||
|
||||
bool _tooMuchUsernames;
|
||||
|
||||
mtpRequestId _saveRequestId, _checkRequestId;
|
||||
QString _sentUsername, _checkUsername, _errorText, _goodText;
|
||||
|
||||
QString _goodTextLink;
|
||||
anim::fvalue a_goodOpacity;
|
||||
Animation _a_goodFade;
|
||||
|
||||
QTimer _checkTimer;
|
||||
};
|
||||
|
||||
class EditNameTitleBox : public AbstractBox, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -28,6 +28,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
BackgroundInner::BackgroundInner() :
|
||||
_bgCount(0), _rows(0), _over(-1), _overDown(-1) {
|
||||
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update()));
|
||||
if (App::cServerBackgrounds().isEmpty()) {
|
||||
resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
|
||||
MTP::send(MTPaccount_GetWallPapers(), rpcDone(&BackgroundInner::gotWallpapers));
|
||||
@@ -174,39 +175,21 @@ BackgroundInner::~BackgroundInner() {
|
||||
void BackgroundInner::resizeEvent(QResizeEvent *e) {
|
||||
}
|
||||
|
||||
BackgroundBox::BackgroundBox() : ItemListBox(st::boxScroll), _inner(),
|
||||
_close(this, lang(lng_cancel), st::contactsClose) {
|
||||
BackgroundBox::BackgroundBox() : ItemListBox(st::backgroundScroll)
|
||||
, _inner() {
|
||||
|
||||
init(&_inner, _close.height(), st::boxFont->height + st::old_newGroupNamePadding.top() + st::old_newGroupNamePadding.bottom());
|
||||
init(&_inner);
|
||||
|
||||
connect(&_close, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
connect(&_inner, SIGNAL(backgroundChosen(int)), this, SLOT(onBackgroundChosen(int)));
|
||||
|
||||
prepare();
|
||||
}
|
||||
|
||||
void BackgroundBox::hideAll() {
|
||||
ItemListBox::hideAll();
|
||||
_close.hide();
|
||||
}
|
||||
|
||||
void BackgroundBox::showAll() {
|
||||
ItemListBox::showAll();
|
||||
_close.show();
|
||||
_close.raise();
|
||||
}
|
||||
|
||||
void BackgroundBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintGrayTitle(p, lang(lng_backgrounds_header));
|
||||
}
|
||||
|
||||
void BackgroundBox::resizeEvent(QResizeEvent *e) {
|
||||
ItemListBox::resizeEvent(e);
|
||||
_inner.resize(width(), _inner.height());
|
||||
_close.move(0, height() - _close.height());
|
||||
paintTitle(p, lang(lng_backgrounds_header));
|
||||
}
|
||||
|
||||
void BackgroundBox::onBackgroundChosen(int index) {
|
||||
|
@@ -58,19 +58,13 @@ public:
|
||||
|
||||
BackgroundBox();
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
void onBackgroundChosen(int index);
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
|
||||
private:
|
||||
|
||||
BackgroundInner _inner;
|
||||
BottomButton _close;
|
||||
|
||||
};
|
||||
|
@@ -38,7 +38,7 @@ ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const style
|
||||
_informative(false),
|
||||
_text(100),
|
||||
_confirm(this, doneText.isEmpty() ? lang(lng_box_ok) : doneText, doneStyle),
|
||||
_cancel(this, cancelText.isEmpty() ? lang(lng_box_cancel) : cancelText, cancelStyle) {
|
||||
_cancel(this, cancelText.isEmpty() ? lang(lng_cancel) : cancelText, cancelStyle) {
|
||||
init(text);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ void ConfirmBox::init(const QString &text) {
|
||||
_text.setText(st::boxTextFont, text, _informative ? _confirmBoxTextOptions : _textPlainOptions);
|
||||
|
||||
textstyleSet(&st::boxTextStyle);
|
||||
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
|
||||
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
|
||||
_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());
|
||||
textstyleRestore();
|
||||
@@ -189,14 +189,14 @@ void ConfirmLinkBox::onOpenLink() {
|
||||
|
||||
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth),
|
||||
_close(this, lang(lng_box_ok), st::defaultBoxButton),
|
||||
_text(st::boxTextFont, lng_participant_invite_sorry(lt_count, cMaxGroupCount()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxPadding.right()),
|
||||
_text(st::boxTextFont, lng_participant_invite_sorry(lt_count, cMaxGroupCount()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()),
|
||||
_link(link), _linkOver(false),
|
||||
a_goodOpacity(0, 0), a_good(animFunc(this, &MaxInviteBox::goodAnimStep)) {
|
||||
setMouseTracking(true);
|
||||
|
||||
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
|
||||
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
|
||||
_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() + _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()));
|
||||
|
||||
@@ -277,5 +277,5 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
|
||||
|
||||
void MaxInviteBox::resizeEvent(QResizeEvent *e) {
|
||||
_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::boxButtonPadding.right() - (st::defaultBoxButton.width / 2)), 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);
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ _httpProxyRadio(this, qsl("conn_type"), dbictHttpProxy, lang(lng_connection_http
|
||||
_tcpProxyRadio(this, qsl("conn_type"), dbictTcpProxy, lang(lng_connection_tcp_proxy_rb), (cConnectionType() == dbictTcpProxy)),
|
||||
_tryIPv6(this, lang(lng_connection_try_ipv6), cTryIPv6()),
|
||||
_save(this, lang(lng_connection_save), st::defaultBoxButton),
|
||||
_cancel(this, lang(lng_box_cancel), st::cancelBoxButton) {
|
||||
_cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
||||
|
||||
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
@@ -51,8 +51,6 @@ _cancel(this, lang(lng_box_cancel), st::cancelBoxButton) {
|
||||
connect(&_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
||||
connect(&_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit()));
|
||||
|
||||
_passwordInput.setEchoMode(QLineEdit::Password);
|
||||
|
||||
prepare();
|
||||
}
|
||||
|
||||
@@ -128,9 +126,9 @@ void ConnectionBox::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
if (inputy) {
|
||||
_hostInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), inputy);
|
||||
_portInput.moveToRight(st::boxButtonPadding.right() - (st::defaultBoxButton.width / 2), 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());
|
||||
_passwordInput.moveToRight(st::boxButtonPadding.right() - (st::defaultBoxButton.width / 2), _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;
|
||||
|
@@ -48,7 +48,7 @@ private:
|
||||
InputField _hostInput;
|
||||
PortInput _portInput;
|
||||
InputField _userInput;
|
||||
MaskedInputField _passwordInput;
|
||||
PasswordField _passwordInput;
|
||||
Radiobutton _autoRadio, _httpProxyRadio, _tcpProxyRadio;
|
||||
Checkbox _tryIPv6;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -22,12 +22,6 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "abstractbox.h"
|
||||
|
||||
enum CreatingGroupType {
|
||||
CreatingGroupNone,
|
||||
CreatingGroupGroup,
|
||||
CreatingGroupChannel,
|
||||
};
|
||||
|
||||
enum MembersFilter {
|
||||
MembersFilterRecent,
|
||||
MembersFilterAdmins,
|
||||
@@ -96,6 +90,7 @@ signals:
|
||||
void searchByUsername();
|
||||
void chosenChanged();
|
||||
void adminAdded();
|
||||
void addRequested();
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -115,6 +110,9 @@ private:
|
||||
void addAdminDone(const MTPBool &result, mtpRequestId req);
|
||||
bool addAdminFail(const RPCError &error, mtpRequestId req);
|
||||
|
||||
int32 _rowHeight, _newItemHeight;
|
||||
bool _newItemSel;
|
||||
|
||||
ChatData *_chat;
|
||||
ChannelData *_channel;
|
||||
MembersFilter _channelFilter;
|
||||
@@ -194,9 +192,10 @@ signals:
|
||||
public slots:
|
||||
|
||||
void onFilterUpdate();
|
||||
void onFilterCancel();
|
||||
void onChosenChanged();
|
||||
void onScroll();
|
||||
|
||||
void onAdd();
|
||||
void onInvite();
|
||||
void onCreate();
|
||||
|
||||
@@ -214,12 +213,14 @@ private:
|
||||
void init();
|
||||
|
||||
ContactsInner _inner;
|
||||
FlatButton _addContact;
|
||||
FlatInput _filter;
|
||||
InputField _filter;
|
||||
IconedButton _filterCancel;
|
||||
|
||||
FlatButton _next, _cancel;
|
||||
BoxButton _next, _cancel;
|
||||
MembersFilter _membersFilter;
|
||||
|
||||
ScrollableBoxShadow _topShadow, *_bottomShadow;
|
||||
|
||||
void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req);
|
||||
bool peopleFailed(const RPCError &error, mtpRequestId req);
|
||||
|
||||
@@ -286,7 +287,7 @@ public:
|
||||
signals:
|
||||
|
||||
void mustScrollTo(int ymin, int ymax);
|
||||
|
||||
void addRequested();
|
||||
void loaded();
|
||||
|
||||
public slots:
|
||||
@@ -314,6 +315,9 @@ private:
|
||||
|
||||
void clear();
|
||||
|
||||
int32 _rowHeight, _newItemHeight;
|
||||
bool _newItemSel;
|
||||
|
||||
ChannelData *_channel;
|
||||
MembersFilter _filter;
|
||||
|
||||
@@ -374,7 +378,6 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
void onLoaded();
|
||||
void onScroll();
|
||||
|
||||
void onAdd();
|
||||
@@ -382,179 +385,13 @@ public slots:
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
MembersInner _inner;
|
||||
FlatButton _add, _done;
|
||||
|
||||
ContactsBox *_addBox;
|
||||
|
||||
SingleTimer _loadTimer;
|
||||
};
|
||||
|
||||
class NewGroupBox : public AbstractBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
NewGroupBox();
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
public slots:
|
||||
|
||||
void onNext();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
Radiobutton _group, _channel;
|
||||
int32 _aboutGroupWidth, _aboutGroupHeight;
|
||||
Text _aboutGroup, _aboutChannel;
|
||||
BoxButton _next, _cancel;
|
||||
|
||||
};
|
||||
|
||||
class GroupInfoBox : public AbstractBox, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
bool animStep_photoOver(float64 ms);
|
||||
|
||||
void setInnerFocus() {
|
||||
_title.setFocus();
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void onPhoto();
|
||||
void onPhotoReady(const QImage &img);
|
||||
|
||||
void onNext();
|
||||
void onNameSubmit();
|
||||
void onDescriptionResized();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
QRect photoRect() const;
|
||||
|
||||
void updateMaxHeight();
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
CreatingGroupType _creating;
|
||||
|
||||
anim::fvalue a_photoOver;
|
||||
Animation _a_photoOver;
|
||||
bool _photoOver;
|
||||
|
||||
InputField _title;
|
||||
InputArea _description;
|
||||
|
||||
QImage _photoBig;
|
||||
QPixmap _photoSmall;
|
||||
BoxButton _next, _cancel;
|
||||
|
||||
// channel creation
|
||||
int32 _creationRequestId;
|
||||
ChannelData *_createdChannel;
|
||||
|
||||
void creationDone(const MTPUpdates &updates);
|
||||
bool creationFail(const RPCError &e);
|
||||
void exportDone(const MTPExportedChatInvite &result);
|
||||
};
|
||||
|
||||
class SetupChannelBox : public AbstractBox, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SetupChannelBox(ChannelData *channel, bool existing = false);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
void closePressed();
|
||||
|
||||
void setInnerFocus() {
|
||||
if (_link.isHidden()) {
|
||||
setFocus();
|
||||
} else {
|
||||
_link.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
void onSave();
|
||||
void onChange();
|
||||
void onCheck();
|
||||
|
||||
void onPrivacyChange();
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||
bool animStep_goodFade(float64 ms);
|
||||
|
||||
void onUpdateDone(const MTPBool &result);
|
||||
bool onUpdateFail(const RPCError &error);
|
||||
|
||||
void onCheckDone(const MTPBool &result);
|
||||
bool onCheckFail(const RPCError &error);
|
||||
bool onFirstCheckFail(const RPCError &error);
|
||||
|
||||
ChannelData *_channel;
|
||||
bool _existing;
|
||||
|
||||
Radiobutton _public, _private;
|
||||
Checkbox _comments;
|
||||
int32 _aboutPublicWidth, _aboutPublicHeight;
|
||||
Text _aboutPublic, _aboutPrivate, _aboutComments;
|
||||
UsernameInput _link;
|
||||
QRect _invitationLink;
|
||||
bool _linkOver;
|
||||
BoxButton _save, _skip;
|
||||
|
||||
bool _tooMuchUsernames;
|
||||
|
||||
mtpRequestId _saveRequestId, _checkRequestId;
|
||||
QString _sentUsername, _checkUsername, _errorText, _goodText;
|
||||
|
||||
QString _goodTextLink;
|
||||
anim::fvalue a_goodOpacity;
|
||||
Animation _a_goodFade;
|
||||
|
||||
QTimer _checkTimer;
|
||||
};
|
||||
|
@@ -33,7 +33,7 @@ DownloadPathBox::DownloadPathBox() :
|
||||
_dir(this, qsl("dir_type"), 2, lang(lng_download_path_dir_radio), !_path.isEmpty() && _path != qsl("tmp")),
|
||||
_pathLink(this, QString(), st::defaultBoxLinkButton),
|
||||
_save(this, lang(lng_connection_save), st::defaultBoxButton),
|
||||
_cancel(this, lang(lng_box_cancel), st::cancelBoxButton) {
|
||||
_cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
||||
|
||||
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
@@ -143,6 +143,6 @@ void DownloadPathBox::onSave() {
|
||||
}
|
||||
|
||||
void DownloadPathBox::setPathText(const QString &text) {
|
||||
int32 availw = st::boxWideWidth - st::boxPadding.left() - st::defaultRadiobutton.textPosition.x() - (st::boxButtonPadding.right() - (st::defaultBoxButton.width / 2));
|
||||
int32 availw = st::boxWideWidth - st::boxPadding.left() - st::defaultRadiobutton.textPosition.x() - st::boxPadding.right();
|
||||
_pathLink.setText(st::boxTextFont->elided(text, availw));
|
||||
}
|
||||
|
@@ -71,14 +71,14 @@ namespace {
|
||||
const uint32 replacesCount = sizeof(replaces) / sizeof(EmojiReplace), replacesInRow = 7;
|
||||
}
|
||||
|
||||
EmojiBox::EmojiBox() : _esize(EmojiSizes[EIndex + 1]), _done(this, lang(lng_about_done), st::aboutCloseButton) {
|
||||
EmojiBox::EmojiBox() : _esize(EmojiSizes[EIndex + 1]) {
|
||||
setBlueTitle(true);
|
||||
|
||||
fillBlocks();
|
||||
|
||||
_blockHeight = st::emojiReplaceInnerHeight;
|
||||
|
||||
resizeMaxHeight(_blocks[0].size() * st::emojiReplaceWidth + (st::emojiReplaceWidth - _esize), st::boxPadding.top() + st::boxFont->height + _blocks.size() * st::emojiReplaceHeight + (st::emojiReplaceHeight - _blockHeight) + _done.height());
|
||||
|
||||
connect(&_done, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
resizeMaxHeight(_blocks[0].size() * st::emojiReplaceWidth + 2 * st::emojiReplacePadding, st::boxTitleHeight + st::emojiReplacePadding + _blocks.size() * st::emojiReplaceHeight + (st::emojiReplaceHeight - _blockHeight) + st::emojiReplacePadding);
|
||||
|
||||
prepare();
|
||||
}
|
||||
@@ -113,14 +113,6 @@ void EmojiBox::fillBlocks() {
|
||||
}
|
||||
}
|
||||
|
||||
void EmojiBox::hideAll() {
|
||||
_done.hide();
|
||||
}
|
||||
|
||||
void EmojiBox::showAll() {
|
||||
_done.show();
|
||||
}
|
||||
|
||||
void EmojiBox::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||
onClose();
|
||||
@@ -130,14 +122,14 @@ void EmojiBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void EmojiBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintGrayTitle(p, lang(lng_settings_emoji_list));
|
||||
paintTitle(p, lang(lng_settings_emoji_list));
|
||||
|
||||
p.setFont(st::emojiTextFont->f);
|
||||
p.setPen(st::black->p);
|
||||
int32 top = st::boxPadding.top() + st::boxFont->height + (st::emojiReplaceHeight - _blockHeight) / 2;
|
||||
int32 top = st::boxTitleHeight + st::emojiReplacePadding + (st::emojiReplaceHeight - _blockHeight) / 2;
|
||||
for (Blocks::const_iterator i = _blocks.cbegin(), e = _blocks.cend(); i != e; ++i) {
|
||||
int32 rowSize = i->size(), left = (width() - rowSize * st::emojiReplaceWidth) / 2;
|
||||
for (BlockRow::const_iterator j = i->cbegin(), en = i->cend(); j != en; ++j) {
|
||||
@@ -151,7 +143,3 @@ void EmojiBox::paintEvent(QPaintEvent *e) {
|
||||
top += st::emojiReplaceHeight;
|
||||
}
|
||||
}
|
||||
|
||||
void EmojiBox::resizeEvent(QResizeEvent *e) {
|
||||
_done.setGeometry(0, height() - _done.height(), width(), _done.height());
|
||||
}
|
||||
|
@@ -30,19 +30,12 @@ public:
|
||||
EmojiBox();
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
protected:
|
||||
|
||||
void hideAll();
|
||||
void showAll();
|
||||
|
||||
private:
|
||||
|
||||
void fillBlocks();
|
||||
|
||||
int32 _esize;
|
||||
BottomButton _done;
|
||||
|
||||
int32 _blockHeight;
|
||||
struct Block {
|
||||
|
@@ -112,15 +112,15 @@ void LanguageBox::onChange() {
|
||||
if (_langs[i]->checked() && langId != cLang()) {
|
||||
LangLoaderResult result;
|
||||
if (langId > 0) {
|
||||
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[langId] + qsl(".strings"), LangLoaderRequest(lng_sure_save_language, lng_box_cancel, lng_box_ok));
|
||||
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[langId] + qsl(".strings"), LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_box_ok));
|
||||
result = loader.found();
|
||||
} else if (langId == languageTest) {
|
||||
LangLoaderPlain loader(cLangFile(), LangLoaderRequest(lng_sure_save_language, lng_box_cancel, lng_box_ok));
|
||||
LangLoaderPlain loader(cLangFile(), LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_box_ok));
|
||||
result = loader.found();
|
||||
}
|
||||
QString text = result.value(lng_sure_save_language, langOriginal(lng_sure_save_language)),
|
||||
save = result.value(lng_box_ok, langOriginal(lng_box_ok)),
|
||||
cancel = result.value(lng_box_cancel, langOriginal(lng_box_cancel));
|
||||
cancel = result.value(lng_cancel, langOriginal(lng_cancel));
|
||||
ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onSave()));
|
||||
connect(box, SIGNAL(closed()), this, SLOT(onRestore()));
|
||||
|
@@ -29,14 +29,14 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
PasscodeBox::PasscodeBox(bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(false),
|
||||
_setRequest(0), _hasRecovery(false), _skipEmailWarning(false), _aboutHeight(0),
|
||||
_about(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_oldPasscode(this, st::inpAddContact, lang(lng_passcode_enter_old)),
|
||||
_newPasscode(this, st::inpAddContact, lang(cHasPasscode() ? lng_passcode_enter_new : lng_passcode_enter_first)),
|
||||
_reenterPasscode(this, st::inpAddContact, lang(lng_passcode_confirm_new)),
|
||||
_passwordHint(this, st::inpAddContact, lang(lng_cloud_password_hint)),
|
||||
_recoverEmail(this, st::inpAddContact, lang(lng_cloud_password_email)),
|
||||
_about(st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::defaultBoxButton),
|
||||
_cancelButton(this, lang(lng_cancel), st::cancelBoxButton),
|
||||
_oldPasscode(this, st::defaultInputField, lang(lng_passcode_enter_old)),
|
||||
_newPasscode(this, st::defaultInputField, lang(cHasPasscode() ? lng_passcode_enter_new : lng_passcode_enter_first)),
|
||||
_reenterPasscode(this, st::defaultInputField, lang(lng_passcode_confirm_new)),
|
||||
_passwordHint(this, st::defaultInputField, lang(lng_cloud_password_hint)),
|
||||
_recoverEmail(this, st::defaultInputField, lang(lng_cloud_password_email)),
|
||||
_recover(this, lang(lng_signin_recover)) {
|
||||
init();
|
||||
prepare();
|
||||
@@ -44,14 +44,14 @@ _recover(this, lang(lng_signin_recover)) {
|
||||
|
||||
PasscodeBox::PasscodeBox(const QByteArray &newSalt, const QByteArray &curSalt, bool hasRecovery, const QString &hint, bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(true),
|
||||
_setRequest(0), _newSalt(newSalt), _curSalt(curSalt), _hasRecovery(hasRecovery), _skipEmailWarning(false), _hint(hint), _aboutHeight(0),
|
||||
_about(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_oldPasscode(this, st::inpAddContact, lang(lng_cloud_password_enter_old)),
|
||||
_newPasscode(this, st::inpAddContact, lang(curSalt.isEmpty() ? lng_cloud_password_enter_first : lng_cloud_password_enter_new)),
|
||||
_reenterPasscode(this, st::inpAddContact, lang(lng_cloud_password_confirm_new)),
|
||||
_passwordHint(this, st::inpAddContact, lang(lng_cloud_password_hint)),
|
||||
_recoverEmail(this, st::inpAddContact, lang(lng_cloud_password_email)),
|
||||
_about(st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right()),
|
||||
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::defaultBoxButton),
|
||||
_cancelButton(this, lang(lng_cancel), st::cancelBoxButton),
|
||||
_oldPasscode(this, st::defaultInputField, lang(lng_cloud_password_enter_old)),
|
||||
_newPasscode(this, st::defaultInputField, lang(curSalt.isEmpty() ? lng_cloud_password_enter_first : lng_cloud_password_enter_new)),
|
||||
_reenterPasscode(this, st::defaultInputField, lang(lng_cloud_password_confirm_new)),
|
||||
_passwordHint(this, st::defaultInputField, lang(lng_cloud_password_hint)),
|
||||
_recoverEmail(this, st::defaultInputField, lang(lng_cloud_password_email)),
|
||||
_recover(this, lang(lng_signin_recover)) {
|
||||
init();
|
||||
prepare();
|
||||
@@ -60,24 +60,24 @@ _recover(this, lang(lng_signin_recover)) {
|
||||
void PasscodeBox::init() {
|
||||
_about.setRichText(st::normalFont, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
|
||||
if (!_hint.isEmpty()) _hintText.setText(st::normalFont, lng_signin_hint(lt_password_hint, _hint));
|
||||
_aboutHeight = _about.countHeight(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right());
|
||||
_aboutHeight = _about.countHeight(st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right());
|
||||
_oldPasscode.setEchoMode(QLineEdit::Password);
|
||||
_newPasscode.setEchoMode(QLineEdit::Password);
|
||||
_reenterPasscode.setEchoMode(QLineEdit::Password);
|
||||
if (_turningOff) {
|
||||
_oldPasscode.show();
|
||||
_boxTitle = lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove);
|
||||
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 1 * _oldPasscode.height() + st::usernameSkip + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
|
||||
setMaxHeight(st::boxTitleHeight + st::contactPadding.top() + 1 * _oldPasscode.height() + st::usernameSkip + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::contactPadding.bottom() + _saveButton.height());
|
||||
} else {
|
||||
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
|
||||
if (has) {
|
||||
_oldPasscode.show();
|
||||
_boxTitle = lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change);
|
||||
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 3 * _oldPasscode.height() + st::usernameSkip * 2 + 1 * st::addContactSkip + (_cloudPwd ? _passwordHint.height() + st::addContactSkip : 0) + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
|
||||
setMaxHeight(st::boxTitleHeight + st::contactPadding.top() + 3 * _oldPasscode.height() + st::usernameSkip * 2 + 1 * st::contactSkip + (_cloudPwd ? _passwordHint.height() + st::contactSkip : 0) + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::contactPadding.bottom() + _saveButton.height());
|
||||
} else {
|
||||
_oldPasscode.hide();
|
||||
_boxTitle = lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create);
|
||||
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 2 * _oldPasscode.height() + st::usernameSkip + 1 * st::addContactSkip + (_cloudPwd ? _passwordHint.height() + st::addContactSkip : 0) + _aboutHeight + (_cloudPwd ? st::addContactSkip + _recoverEmail.height() + st::usernameSkip : st::addContactPadding.bottom()) + _saveButton.height());
|
||||
setMaxHeight(st::boxTitleHeight + st::contactPadding.top() + 2 * _oldPasscode.height() + st::usernameSkip + 1 * st::contactSkip + (_cloudPwd ? _passwordHint.height() + st::contactSkip : 0) + _aboutHeight + (_cloudPwd ? st::contactSkip + _recoverEmail.height() + st::usernameSkip : st::contactPadding.bottom()) + _saveButton.height());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,12 +158,12 @@ void PasscodeBox::keyPressEvent(QKeyEvent *e) {
|
||||
} else if (_reenterPasscode.hasFocus()) {
|
||||
if (has && _oldPasscode.text().isEmpty()) {
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
_oldPasscode.showError();
|
||||
} else if (_newPasscode.text().isEmpty()) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newPasscode.showError();
|
||||
} else if (_reenterPasscode.text().isEmpty()) {
|
||||
_reenterPasscode.notaBene();
|
||||
_reenterPasscode.showError();
|
||||
} else if (!_passwordHint.isHidden()) {
|
||||
_passwordHint.setFocus();
|
||||
} else {
|
||||
@@ -187,19 +187,16 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintOldTitle(p, _boxTitle, true);
|
||||
paintTitle(p, _boxTitle);
|
||||
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
|
||||
int32 w = width() - st::addContactPadding.left() - st::addContactPadding.right();
|
||||
int32 abouty = (_passwordHint.isHidden() ? (_reenterPasscode.isHidden() ? _oldPasscode : _reenterPasscode).y() + st::usernameSkip : _passwordHint.y() + st::addContactSkip) + _oldPasscode.height();
|
||||
int32 w = width() - st::boxPadding.left() - st::boxPadding.right();
|
||||
int32 abouty = (_passwordHint.isHidden() ? (_reenterPasscode.isHidden() ? _oldPasscode : _reenterPasscode).y() + st::usernameSkip : _passwordHint.y() + st::contactSkip) + _oldPasscode.height();
|
||||
p.setPen(st::black);
|
||||
_about.draw(p, st::addContactPadding.left(), abouty, w);
|
||||
_about.draw(p, st::boxPadding.left(), abouty, w);
|
||||
|
||||
if (!_hint.isEmpty() && _oldError.isEmpty()) {
|
||||
p.setPen(st::black->p);
|
||||
_hintText.drawElided(p, st::addContactPadding.left(), _oldPasscode.y() + _oldPasscode.height() + ((st::usernameSkip - st::normalFont->height) / 2), w, 1, style::al_top);
|
||||
_hintText.drawElided(p, st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height() + ((st::usernameSkip - st::normalFont->height) / 2), w, 1, style::al_top);
|
||||
}
|
||||
|
||||
if (!_oldError.isEmpty()) {
|
||||
@@ -216,25 +213,22 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
|
||||
p.setPen(st::setErrColor->p);
|
||||
p.drawText(QRect(0, _recoverEmail.y() + _recoverEmail.height(), width(), st::usernameSkip), _emailError, style::al_center);
|
||||
}
|
||||
|
||||
// paint button sep
|
||||
p.fillRect(st::btnSelectCancel.width, size().height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
|
||||
}
|
||||
|
||||
void PasscodeBox::resizeEvent(QResizeEvent *e) {
|
||||
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
|
||||
_oldPasscode.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _oldPasscode.height());
|
||||
_newPasscode.setGeometry(st::addContactPadding.left(), _oldPasscode.y() + ((_turningOff || has) ? (_oldPasscode.height() + st::usernameSkip) : 0), _oldPasscode.width(), _oldPasscode.height());
|
||||
_reenterPasscode.setGeometry(st::addContactPadding.left(), _newPasscode.y() + _newPasscode.height() + st::addContactSkip, _newPasscode.width(), _newPasscode.height());
|
||||
_passwordHint.setGeometry(st::addContactPadding.left(), _reenterPasscode.y() + _reenterPasscode.height() + st::usernameSkip, _reenterPasscode.width(), _reenterPasscode.height());
|
||||
_oldPasscode.setGeometry(st::boxPadding.left(), st::boxTitleHeight + st::contactPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), _oldPasscode.height());
|
||||
_newPasscode.setGeometry(st::boxPadding.left(), _oldPasscode.y() + ((_turningOff || has) ? (_oldPasscode.height() + st::usernameSkip) : 0), _oldPasscode.width(), _oldPasscode.height());
|
||||
_reenterPasscode.setGeometry(st::boxPadding.left(), _newPasscode.y() + _newPasscode.height() + st::contactSkip, _newPasscode.width(), _newPasscode.height());
|
||||
_passwordHint.setGeometry(st::boxPadding.left(), _reenterPasscode.y() + _reenterPasscode.height() + st::usernameSkip, _reenterPasscode.width(), _reenterPasscode.height());
|
||||
|
||||
_recoverEmail.setGeometry(st::addContactPadding.left(), _passwordHint.y() + _passwordHint.height() + st::addContactSkip + _aboutHeight + st::addContactSkip, _passwordHint.width(), _passwordHint.height());
|
||||
_recoverEmail.setGeometry(st::boxPadding.left(), _passwordHint.y() + _passwordHint.height() + st::contactSkip + _aboutHeight + st::contactSkip, _passwordHint.width(), _passwordHint.height());
|
||||
|
||||
if (!_recover.isHidden()) {
|
||||
if (_turningOff) {
|
||||
_recover.move((width() - _recover.width()) / 2, _oldPasscode.y() + _oldPasscode.height() + st::usernameSkip + _aboutHeight + ((st::usernameSkip - _recover.height()) / 2));
|
||||
} else {
|
||||
_recover.move((width() - _recover.width()) / 2, _passwordHint.y() + _passwordHint.height() + st::addContactSkip + _aboutHeight + ((st::usernameSkip - _recover.height()) / 2));
|
||||
_recover.move((width() - _recover.width()) / 2, _passwordHint.y() + _passwordHint.height() + st::contactSkip + _aboutHeight + ((st::usernameSkip - _recover.height()) / 2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +268,7 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||
}
|
||||
} else if (err == "NEW_PASSWORD_BAD") {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newPasscode.showError();
|
||||
_newError = lang(lng_cloud_password_bad);
|
||||
update();
|
||||
} else if (err == "NEW_SALT_INVALID") {
|
||||
@@ -283,7 +277,7 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||
} else if (err == "EMAIL_INVALID") {
|
||||
_emailError = lang(lng_cloud_password_bad_email);
|
||||
_recoverEmail.setFocus();
|
||||
_recoverEmail.notaBene();
|
||||
_recoverEmail.showError();
|
||||
update();
|
||||
} else if (err == "EMAIL_UNCONFIRMED") {
|
||||
App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_almost)));
|
||||
@@ -293,7 +287,7 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
|
||||
|
||||
_oldPasscode.selectAll();
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
_oldPasscode.showError();
|
||||
_oldError = lang(lng_flood_error);
|
||||
}
|
||||
return true;
|
||||
@@ -308,7 +302,7 @@ void PasscodeBox::onSave(bool force) {
|
||||
if (!passcodeCanTry()) {
|
||||
_oldError = lang(lng_flood_error);
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
_oldPasscode.showError();
|
||||
update();
|
||||
return;
|
||||
}
|
||||
@@ -325,13 +319,13 @@ void PasscodeBox::onSave(bool force) {
|
||||
}
|
||||
if (!_turningOff && pwd.isEmpty()) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newPasscode.showError();
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
return;
|
||||
}
|
||||
if (pwd != conf) {
|
||||
_reenterPasscode.setFocus();
|
||||
_reenterPasscode.notaBene();
|
||||
_reenterPasscode.showError();
|
||||
if (!conf.isEmpty()) {
|
||||
_newError = lang(_cloudPwd ? lng_cloud_password_differ : lng_passcode_differ);
|
||||
update();
|
||||
@@ -339,15 +333,15 @@ void PasscodeBox::onSave(bool force) {
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
} else if (!_turningOff && has && old == pwd) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newPasscode.showError();
|
||||
_newError = lang(_cloudPwd ? lng_cloud_password_is_same : lng_passcode_is_same);
|
||||
update();
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
} else if (_cloudPwd) {
|
||||
QString hint = _passwordHint.text(), email = _recoverEmail.text().trimmed();
|
||||
QString hint = _passwordHint.getLastText(), email = _recoverEmail.getLastText().trimmed();
|
||||
if (_cloudPwd && pwd == hint && !_passwordHint.isHidden() && !_newPasscode.isHidden()) {
|
||||
_newPasscode.setFocus();
|
||||
_newPasscode.notaBene();
|
||||
_newPasscode.showError();
|
||||
_newError = lang(lng_cloud_password_bad);
|
||||
update();
|
||||
if (isHidden() && _replacedBy && !_replacedBy->isHidden()) _replacedBy->onClose();
|
||||
@@ -392,7 +386,7 @@ void PasscodeBox::onSave(bool force) {
|
||||
void PasscodeBox::onBadOldPasscode() {
|
||||
_oldPasscode.selectAll();
|
||||
_oldPasscode.setFocus();
|
||||
_oldPasscode.notaBene();
|
||||
_oldPasscode.showError();
|
||||
_oldError = lang(_cloudPwd ? lng_cloud_password_wrong : lng_passcode_wrong);
|
||||
update();
|
||||
}
|
||||
@@ -465,11 +459,11 @@ bool PasscodeBox::recoverStartFail(const RPCError &error) {
|
||||
}
|
||||
|
||||
RecoverBox::RecoverBox(const QString &pattern) :
|
||||
_submitRequest(0), _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right())),
|
||||
_saveButton(this, lang(lng_passcode_submit), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_recoverCode(this, st::inpAddContact, lang(lng_signin_code)) {
|
||||
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + st::usernameSkip + _recoverCode.height() + st::usernameSkip + st::addContactPadding.bottom() + _saveButton.height());
|
||||
_submitRequest(0), _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right())),
|
||||
_saveButton(this, lang(lng_passcode_submit), st::defaultBoxButton),
|
||||
_cancelButton(this, lang(lng_cancel), st::cancelBoxButton),
|
||||
_recoverCode(this, st::defaultInputField, lang(lng_signin_code)) {
|
||||
setMaxHeight(st::boxTitleHeight + st::contactPadding.top() + st::usernameSkip + _recoverCode.height() + st::usernameSkip + st::contactPadding.bottom() + _saveButton.height());
|
||||
|
||||
connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSubmit()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
@@ -493,9 +487,9 @@ void RecoverBox::showAll() {
|
||||
|
||||
void RecoverBox::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||
if (_recoverCode.text().isEmpty()) {
|
||||
if (_recoverCode.getLastText().isEmpty()) {
|
||||
_recoverCode.setFocus();
|
||||
_recoverCode.notaBene();
|
||||
_recoverCode.showError();
|
||||
} else {
|
||||
onSubmit();
|
||||
}
|
||||
@@ -508,26 +502,20 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintOldTitle(p, lang(lng_signin_recover), true);
|
||||
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
paintTitle(p, lang(lng_signin_recover));
|
||||
|
||||
p.setFont(st::normalFont->f);
|
||||
int32 w = width() - st::addContactPadding.left() - st::addContactPadding.right();
|
||||
p.drawText(QRect(st::addContactPadding.left(), _recoverCode.y() - st::usernameSkip - st::addContactPadding.top(), w, st::addContactPadding.top() + st::usernameSkip), _pattern, style::al_center);
|
||||
int32 w = width() - st::boxPadding.left() - st::boxPadding.right();
|
||||
p.drawText(QRect(st::boxPadding.left(), _recoverCode.y() - st::usernameSkip - st::contactPadding.top(), w, st::contactPadding.top() + st::usernameSkip), _pattern, style::al_center);
|
||||
|
||||
if (!_error.isEmpty()) {
|
||||
p.setPen(st::setErrColor->p);
|
||||
p.drawText(QRect(0, _recoverCode.y() + _recoverCode.height(), width(), st::usernameSkip), _error, style::al_center);
|
||||
}
|
||||
|
||||
// paint button sep
|
||||
p.fillRect(st::btnSelectCancel.width, size().height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
|
||||
}
|
||||
|
||||
void RecoverBox::resizeEvent(QResizeEvent *e) {
|
||||
_recoverCode.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top() + st::usernameSkip, width() - st::addContactPadding.left() - st::addContactPadding.right(), _recoverCode.height());
|
||||
_recoverCode.setGeometry(st::boxPadding.left(), st::boxTitleHeight + st::contactPadding.top() + st::usernameSkip, width() - st::boxPadding.left() - st::boxPadding.right(), _recoverCode.height());
|
||||
|
||||
int32 buttonTop = height() - _cancelButton.height();
|
||||
_cancelButton.move(0, buttonTop);
|
||||
@@ -541,9 +529,9 @@ void RecoverBox::showDone() {
|
||||
void RecoverBox::onSubmit() {
|
||||
if (_submitRequest) return;
|
||||
|
||||
QString code = _recoverCode.text().trimmed();
|
||||
QString code = _recoverCode.getLastText().trimmed();
|
||||
if (code.isEmpty()) {
|
||||
_recoverCode.notaBene();
|
||||
_recoverCode.showError();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -580,12 +568,12 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) {
|
||||
} else if (err == "CODE_INVALID") {
|
||||
_error = lang(lng_signin_wrong_code);
|
||||
update();
|
||||
_recoverCode.notaBene();
|
||||
_recoverCode.showError();
|
||||
return true;
|
||||
} else if (mtpIsFlood(error)) {
|
||||
_error = lang(lng_flood_error);
|
||||
update();
|
||||
_recoverCode.notaBene();
|
||||
_recoverCode.showError();
|
||||
return true;
|
||||
}
|
||||
if (cDebug()) { // internal server error
|
||||
|
@@ -80,8 +80,9 @@ private:
|
||||
QString _boxTitle;
|
||||
Text _about, _hintText;
|
||||
|
||||
FlatButton _saveButton, _cancelButton;
|
||||
FlatInput _oldPasscode, _newPasscode, _reenterPasscode, _passwordHint, _recoverEmail;
|
||||
BoxButton _saveButton, _cancelButton;
|
||||
PasswordField _oldPasscode, _newPasscode, _reenterPasscode;
|
||||
InputField _passwordHint, _recoverEmail;
|
||||
LinkButton _recover;
|
||||
|
||||
QString _oldError, _newError, _emailError;
|
||||
@@ -122,8 +123,8 @@ private:
|
||||
|
||||
QString _pattern;
|
||||
|
||||
FlatButton _saveButton, _cancelButton;
|
||||
FlatInput _recoverCode;
|
||||
BoxButton _saveButton, _cancelButton;
|
||||
InputField _recoverCode;
|
||||
|
||||
QString _error;
|
||||
};
|
||||
|
@@ -27,11 +27,12 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
#include "photocropbox.h"
|
||||
#include "fileuploader.h"
|
||||
|
||||
PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) : _downState(0),
|
||||
_sendButton(this, lang(lng_settings_save), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_img(img), _peerId(peer) {
|
||||
|
||||
PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) : AbstractBox()
|
||||
, _downState(0)
|
||||
, _done(this, lang(lng_settings_save), st::defaultBoxButton)
|
||||
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
|
||||
, _img(img)
|
||||
, _peerId(peer) {
|
||||
if (peerIsChannel(_peerId)) {
|
||||
_title = lang(lng_create_channel_crop);
|
||||
} else if (peerIsChat(_peerId)) {
|
||||
@@ -40,13 +41,13 @@ PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) :
|
||||
_title = lang(lng_settings_crop_profile);
|
||||
}
|
||||
|
||||
connect(&_sendButton, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
connect(&_done, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
if (_peerId && upload) {
|
||||
connect(this, SIGNAL(ready(const QImage &)), this, SLOT(onReady(const QImage &)));
|
||||
connect(this, SIGNAL(ready(const QImage&)), this, SLOT(onReady(const QImage&)));
|
||||
}
|
||||
|
||||
int32 s = st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right();
|
||||
int32 s = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
|
||||
_thumb = QPixmap::fromImage(img.scaled(s, s, Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly);
|
||||
_thumbw = _thumb.width();
|
||||
_thumbh = _thumb.height();
|
||||
@@ -59,10 +60,10 @@ PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) :
|
||||
_cropy = (_thumbh - _cropw) / 2;
|
||||
|
||||
_thumbx = (st::boxWideWidth - _thumbw) / 2;
|
||||
_thumby = st::boxPadding.top() * 2 + st::boxFont->height;
|
||||
_thumby = st::boxPhotoPadding.top();
|
||||
setMouseTracking(true);
|
||||
|
||||
resizeMaxHeight(st::boxWideWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.top() + st::boxPadding.bottom() + _sendButton.height());
|
||||
resizeMaxHeight(st::boxWideWidth, st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + st::boxTextFont->height + st::cropSkip + st::boxButtonPadding.top() + _done.height() + st::boxButtonPadding.bottom());
|
||||
}
|
||||
|
||||
void PhotoCropBox::mousePressEvent(QMouseEvent *e) {
|
||||
@@ -211,16 +212,12 @@ void PhotoCropBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
|
||||
void PhotoCropBox::paintEvent(QPaintEvent *e) {
|
||||
QPainter p(this);
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
|
||||
// paint button sep
|
||||
p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
|
||||
|
||||
paintGrayTitle(p, _title);
|
||||
p.setFont(st::boxTextFont);
|
||||
p.setPen(st::boxPhotoTextFg);
|
||||
p.drawText(QRect(st::boxPhotoPadding.left(), st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom(), width() - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), st::boxTextFont->height), _title, style::al_top);
|
||||
|
||||
p.translate(_thumbx, _thumby);
|
||||
p.drawPixmap(0, 0, _thumb);
|
||||
@@ -246,8 +243,8 @@ void PhotoCropBox::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
void PhotoCropBox::resizeEvent(QResizeEvent *e) {
|
||||
_sendButton.move(width() - _sendButton.width(), height() - _sendButton.height());
|
||||
_cancelButton.move(0, height() - _cancelButton.height());
|
||||
_done.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _done.height());
|
||||
_cancel.moveToRight(st::boxButtonPadding.right() + _done.width() + st::boxButtonPadding.left(), _done.y());
|
||||
}
|
||||
|
||||
void PhotoCropBox::onSend() {
|
||||
@@ -288,11 +285,11 @@ void PhotoCropBox::onReady(const QImage &tosend) {
|
||||
}
|
||||
|
||||
void PhotoCropBox::hideAll() {
|
||||
_sendButton.hide();
|
||||
_cancelButton.hide();
|
||||
_done.hide();
|
||||
_cancel.hide();
|
||||
}
|
||||
|
||||
void PhotoCropBox::showAll() {
|
||||
_sendButton.show();
|
||||
_cancelButton.show();
|
||||
_done.show();
|
||||
_cancel.show();
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ private:
|
||||
int32 _thumbx, _thumby, _thumbw, _thumbh;
|
||||
int32 _cropx, _cropy, _cropw;
|
||||
int32 _fromposx, _fromposy, _fromcropx, _fromcropy, _fromcropw;
|
||||
FlatButton _sendButton, _cancelButton;
|
||||
BoxButton _done, _cancel;
|
||||
QImage _img;
|
||||
QPixmap _thumb;
|
||||
PeerId _peerId;
|
||||
|
@@ -27,14 +27,21 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
#include "mainwidget.h"
|
||||
#include "photosendbox.h"
|
||||
|
||||
PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedia(img)),
|
||||
_thumbx(0), _thumby(0), _thumbw(0), _thumbh(0), _namew(0), _textw(0),
|
||||
_compressed(this, lang(lng_send_image_compressed), cCompressPastedImage()),
|
||||
_sendButton(this, lang(lng_send_button), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_replyTo(img.replyTo) {
|
||||
connect(&_sendButton, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : AbstractBox(st::boxWideWidth)
|
||||
, _img(new ReadyLocalMedia(img))
|
||||
, _thumbx(0)
|
||||
, _thumby(0)
|
||||
, _thumbw(0)
|
||||
, _thumbh(0)
|
||||
, _namew(0)
|
||||
, _textw(0)
|
||||
, _caption(this, st::confirmCaptionArea, lang(lng_photo_caption))
|
||||
, _compressed(this, lang(lng_send_image_compressed), cCompressPastedImage())
|
||||
, _send(this, lang(lng_send_button), st::defaultBoxButton)
|
||||
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
|
||||
, _replyTo(img.replyTo) {
|
||||
connect(&_send, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
|
||||
if (_img->type == ToPreparePhoto) {
|
||||
int32 maxW = 0, maxH = 0;
|
||||
@@ -49,7 +56,7 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedi
|
||||
if (!tw || !th) {
|
||||
tw = th = 1;
|
||||
}
|
||||
_thumbw = width() - st::boxPadding.left() - st::boxPadding.right();
|
||||
_thumbw = width() - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
|
||||
if (_thumb.width() < _thumbw) {
|
||||
_thumbw = (_thumb.width() > 20) ? _thumb.width() : 20;
|
||||
}
|
||||
@@ -62,7 +69,7 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedi
|
||||
_thumbw = 10;
|
||||
}
|
||||
}
|
||||
resizeMaxHeight(st::boxWideWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::boxPadding.bottom() + _compressed.height() + _sendButton.height());
|
||||
_thumbx = (width() - _thumbw) / 2;
|
||||
|
||||
_thumb = QPixmap::fromImage(_thumb.toImage().scaled(_thumbw * cIntRetinaFactor(), _thumbh * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly);
|
||||
_thumb.setDevicePixelRatio(cRetinaFactor());
|
||||
@@ -87,24 +94,37 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedi
|
||||
_thumb = QPixmap::fromImage(_thumb.toImage().scaledToWidth(_thumbw * cIntRetinaFactor(), Qt::SmoothTransformation), Qt::ColorOnly);
|
||||
_thumb.setDevicePixelRatio(cRetinaFactor());
|
||||
}
|
||||
resizeMaxHeight(st::boxWideWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
|
||||
|
||||
_name = _img->filename;
|
||||
_namew = st::mediaFont->width(_name);
|
||||
_size = formatSizeText(_img->filesize);
|
||||
_textw = qMax(_namew, st::mediaFont->width(_size));
|
||||
}
|
||||
updateBoxSize();
|
||||
_caption.setMaxLength(MaxPhotoCaption);
|
||||
_caption.setCtrlEnterSubmit(false);
|
||||
connect(&_compressed, SIGNAL(changed()), this, SLOT(onCompressedChange()));
|
||||
connect(&_caption, SIGNAL(resized()), this, SLOT(onCaptionResized()));
|
||||
connect(&_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
|
||||
connect(&_caption, SIGNAL(cancelled()), this, SLOT(onClose()));
|
||||
prepare();
|
||||
}
|
||||
|
||||
PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QString &lname, MsgId replyTo) : _img(0),
|
||||
_thumbx(0), _thumby(0), _thumbw(0), _thumbh(0), _namew(0), _textw(0),
|
||||
_compressed(this, lang(lng_send_image_compressed), true),
|
||||
_sendButton(this, lang(lng_send_button), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_phone(phone), _fname(fname), _lname(lname), _replyTo(replyTo) {
|
||||
connect(&_sendButton, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QString &lname, MsgId replyTo) : AbstractBox(st::boxWideWidth)
|
||||
, _img(0)
|
||||
, _thumbx(0)
|
||||
, _thumby(0)
|
||||
, _thumbw(0)
|
||||
, _thumbh(0)
|
||||
, _namew(0)
|
||||
, _textw(0)
|
||||
, _caption(this, st::confirmCaptionArea, lang(lng_photo_caption))
|
||||
, _compressed(this, lang(lng_send_image_compressed), true)
|
||||
, _send(this, lang(lng_send_button), st::defaultBoxButton)
|
||||
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
|
||||
, _phone(phone), _fname(fname), _lname(lname), _replyTo(replyTo) {
|
||||
connect(&_send, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
|
||||
_compressed.hide();
|
||||
|
||||
@@ -113,10 +133,35 @@ _phone(phone), _fname(fname), _lname(lname), _replyTo(replyTo) {
|
||||
_size = _phone;
|
||||
_textw = qMax(_namew, st::mediaFont->width(_size));
|
||||
|
||||
resizeMaxHeight(st::boxWideWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
|
||||
updateBoxSize();
|
||||
prepare();
|
||||
}
|
||||
|
||||
void PhotoSendBox::onCompressedChange() {
|
||||
showAll();
|
||||
if (_caption.isHidden()) {
|
||||
setFocus();
|
||||
} else {
|
||||
_caption.setFocus();
|
||||
}
|
||||
updateBoxSize();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
}
|
||||
|
||||
void PhotoSendBox::onCaptionResized() {
|
||||
updateBoxSize();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
}
|
||||
|
||||
void PhotoSendBox::updateBoxSize() {
|
||||
if (_img && _img->type == ToPreparePhoto) {
|
||||
setMaxHeight(st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + st::boxPhotoCompressedPadding.top() + _compressed.height() + (_compressed.checked() ? (st::boxPhotoCompressedPadding.bottom() + _caption.height()) : 0) + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom());
|
||||
} else {
|
||||
setMaxHeight(st::boxPhotoPadding.top() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom());
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoSendBox::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||
@@ -130,26 +175,23 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
|
||||
// paint button sep
|
||||
p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
|
||||
|
||||
if (_img && _img->type == ToPreparePhoto) {
|
||||
paintGrayTitle(p, lang(lng_really_send_image));
|
||||
p.drawPixmap((width() - _thumbw) / 2, st::boxPadding.top() * 2 + st::boxFont->height, _thumb);
|
||||
if (_thumbx > st::boxPhotoPadding.left()) {
|
||||
p.fillRect(st::boxPhotoPadding.left(), st::boxPhotoPadding.top(), _thumbx - st::boxPhotoPadding.left(), _thumbh, st::confirmBg->b);
|
||||
}
|
||||
if (_thumbx + _thumbw < width() - st::boxPhotoPadding.right()) {
|
||||
p.fillRect(_thumbx + _thumbw, st::boxPhotoPadding.top(), width() - st::boxPhotoPadding.right() - _thumbx - _thumbw, _thumbh, st::confirmBg->b);
|
||||
}
|
||||
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), _thumb);
|
||||
} else {
|
||||
paintGrayTitle(p, lang(_img ? lng_really_send_file : lng_really_share_contact));
|
||||
|
||||
int32 w = width() - st::boxPadding.left() - st::boxPadding.right(), h = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
int32 w = width() - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), h = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
|
||||
int32 twidth = w - tleft - st::mediaPadding.right();
|
||||
if (twidth > _textw) {
|
||||
w -= (twidth - _textw);
|
||||
twidth = _textw;
|
||||
}
|
||||
int32 x = (width() - w) / 2, y = st::boxPadding.top() * 2 + st::boxFont->height;
|
||||
int32 x = (width() - w) / 2, y = st::boxPhotoPadding.top();
|
||||
|
||||
App::roundRect(p, x, y, w, h, st::msgOutBg, MessageOutCorners, &st::msgOutShadow);
|
||||
if (_thumbw) {
|
||||
@@ -175,9 +217,11 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
void PhotoSendBox::resizeEvent(QResizeEvent *e) {
|
||||
_sendButton.move(width() - _sendButton.width(), height() - _sendButton.height());
|
||||
_cancelButton.move(0, height() - _cancelButton.height());
|
||||
_compressed.move((width() - _compressed.width()) / 2, height() - _cancelButton.height() - _compressed.height() - st::confirmCompressedSkip);
|
||||
_send.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _send.height());
|
||||
_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.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());
|
||||
}
|
||||
|
||||
void PhotoSendBox::closePressed() {
|
||||
@@ -185,21 +229,32 @@ void PhotoSendBox::closePressed() {
|
||||
}
|
||||
|
||||
void PhotoSendBox::hideAll() {
|
||||
_sendButton.hide();
|
||||
_cancelButton.hide();
|
||||
_send.hide();
|
||||
_cancel.hide();
|
||||
_caption.hide();
|
||||
_compressed.hide();
|
||||
}
|
||||
|
||||
void PhotoSendBox::showAll() {
|
||||
_sendButton.show();
|
||||
_cancelButton.show();
|
||||
_send.show();
|
||||
_cancel.show();
|
||||
if (_img && _img->type == ToPreparePhoto) {
|
||||
_compressed.show();
|
||||
if (_compressed.checked()) {
|
||||
_caption.show();
|
||||
} else {
|
||||
_caption.hide();
|
||||
}
|
||||
} else {
|
||||
_caption.hide();
|
||||
_compressed.hide();
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoSendBox::showDone() {
|
||||
setInnerFocus();
|
||||
}
|
||||
|
||||
void PhotoSendBox::onSend(bool ctrlShiftEnter) {
|
||||
if (!_img) {
|
||||
if (App::main()) App::main()->confirmShareContact(ctrlShiftEnter, _phone, _fname, _lname, _replyTo);
|
||||
@@ -212,6 +267,7 @@ void PhotoSendBox::onSend(bool ctrlShiftEnter) {
|
||||
}
|
||||
if (_compressed.isHidden() || _compressed.checked()) {
|
||||
_img->ctrlShiftEnter = ctrlShiftEnter;
|
||||
_img->caption = _caption.isHidden() ? QString() : _caption.getLastText();
|
||||
if (App::main()) App::main()->confirmSendImage(*_img);
|
||||
} else {
|
||||
if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter, _replyTo);
|
||||
|
@@ -33,6 +33,15 @@ public:
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
void setInnerFocus() {
|
||||
if (_caption.isHidden()) {
|
||||
setFocus();
|
||||
} else {
|
||||
_caption.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
~PhotoSendBox();
|
||||
|
||||
signals:
|
||||
@@ -41,6 +50,8 @@ signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void onCompressedChange();
|
||||
void onCaptionResized();
|
||||
void onSend(bool ctrlShiftEnter = false);
|
||||
|
||||
protected:
|
||||
@@ -48,15 +59,19 @@ protected:
|
||||
void closePressed();
|
||||
void hideAll();
|
||||
void showAll();
|
||||
void showDone();
|
||||
|
||||
private:
|
||||
|
||||
void updateBoxSize();
|
||||
|
||||
ReadyLocalMedia *_img;
|
||||
int32 _thumbx, _thumby, _thumbw, _thumbh;
|
||||
QString _name, _size;
|
||||
int32 _namew, _textw;
|
||||
FlatCheckbox _compressed;
|
||||
FlatButton _sendButton, _cancelButton;
|
||||
InputArea _caption;
|
||||
Checkbox _compressed;
|
||||
BoxButton _send, _cancel;
|
||||
QPixmap _thumb;
|
||||
|
||||
QString _phone, _fname, _lname;
|
||||
|
@@ -164,7 +164,7 @@ _terminateAll(this, lang(lng_sessions_terminate_all)), _terminateBox(0), _shortP
|
||||
connect(App::wnd(), SIGNAL(newAuthorization()), this, SLOT(onNewAuthorization()));
|
||||
connect(&_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations()));
|
||||
|
||||
init(&_inner, _done.height(), st::old_boxTitleHeight + st::sessionHeight + st::old_boxTitleHeight);
|
||||
init(&_inner, _done.height(), st::boxTitleHeight + st::sessionHeight + st::boxTitleHeight);
|
||||
_inner.resize(width(), st::noContactsHeight);
|
||||
|
||||
prepare();
|
||||
@@ -176,7 +176,7 @@ _terminateAll(this, lang(lng_sessions_terminate_all)), _terminateBox(0), _shortP
|
||||
void SessionsBox::resizeEvent(QResizeEvent *e) {
|
||||
ScrollableBox::resizeEvent(e);
|
||||
_done.move(0, height() - _done.height());
|
||||
_terminateAll.moveToRight(st::sessionPadding.left(), st::old_boxTitleHeight + st::sessionHeight + st::old_boxTitlePos.y() + st::old_boxTitleFont->ascent - st::linkFont->ascent);
|
||||
_terminateAll.moveToRight(st::sessionPadding.left(), st::boxTitleHeight + st::sessionHeight + st::boxTitlePosition.y() + st::boxTitleFont->ascent - st::linkFont->ascent);
|
||||
}
|
||||
|
||||
void SessionsBox::hideAll() {
|
||||
@@ -204,8 +204,8 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintOldTitle(p, lang(lng_sessions_header), true);
|
||||
p.translate(0, st::old_boxTitleHeight);
|
||||
paintTitle(p, lang(lng_sessions_header));
|
||||
p.translate(0, st::boxTitleHeight);
|
||||
|
||||
if (_loading) {
|
||||
p.setFont(st::noContactsFont->f);
|
||||
@@ -230,16 +230,16 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
|
||||
p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, _current.ip, _current.ipWidth);
|
||||
p.translate(0, st::sessionHeight);
|
||||
if (_list.isEmpty()) {
|
||||
paintOldTitle(p, lang(lng_sessions_no_other), true);
|
||||
paintTitle(p, lang(lng_sessions_no_other));
|
||||
|
||||
p.setFont(st::sessionInfoFont->f);
|
||||
p.setPen(st::sessionInfoColor->p);
|
||||
p.drawText(QRect(st::sessionPadding.left(), st::old_boxTitleHeight + st::old_boxTitlePos.y(), width() - st::sessionPadding.left() - st::sessionPadding.right(), _scroll.height()), lang(lng_sessions_other_desc), style::al_topleft);
|
||||
p.drawText(QRect(st::sessionPadding.left(), st::boxTitleHeight + st::boxTitlePosition.y(), width() - st::sessionPadding.left() - st::sessionPadding.right(), _scroll.height()), lang(lng_sessions_other_desc), style::al_topleft);
|
||||
|
||||
// paint shadow
|
||||
p.fillRect(0, height() - st::sessionsCloseButton.height - st::scrollDef.bottomsh - st::sessionHeight - st::old_boxTitleHeight, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
p.fillRect(0, height() - st::sessionsCloseButton.height - st::scrollDef.bottomsh - st::sessionHeight - st::boxTitleHeight, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
|
||||
} else {
|
||||
paintOldTitle(p, lang(lng_sessions_other_header), false);
|
||||
paintTitle(p, lang(lng_sessions_other_header));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,14 +29,10 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "localstorage.h"
|
||||
|
||||
void StickerSetPanel::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
p.fillRect(e->rect(), st::emojiPanHeaderBg->b);
|
||||
}
|
||||
|
||||
StickerSetInner::StickerSetInner(const MTPInputStickerSet &set) :
|
||||
_loaded(false), _setId(0), _setAccess(0), _setCount(0), _setHash(0), _setFlags(0), _bottom(0),
|
||||
_input(set), _installRequest(0), _panel(0) {
|
||||
_input(set), _installRequest(0) {
|
||||
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update()));
|
||||
switch (set.type()) {
|
||||
case mtpc_inputStickerSetID: _setId = set.c_inputStickerSetID().vid.v; _setAccess = set.c_inputStickerSetID().vaccess_hash.v; break;
|
||||
case mtpc_inputStickerSetShortName: _setShortName = qs(set.c_inputStickerSetShortName().vshort_name); break;
|
||||
@@ -61,7 +57,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
if (d.vset.type() == mtpc_stickerSet) {
|
||||
const MTPDstickerSet &s(d.vset.c_stickerSet());
|
||||
_setTitle = qs(s.vtitle);
|
||||
_title = st::old_boxTitleFont->elided(_setTitle, width() - st::btnStickersClose.width - st::old_boxTitlePos.x());
|
||||
_title = st::boxTitleFont->elided(_setTitle, width() - st::boxTitlePosition.x() - st::boxTitleHeight);
|
||||
_setShortName = qs(s.vshort_name);
|
||||
_setId = s.vid.v;
|
||||
_setAccess = s.vaccess_hash.v;
|
||||
@@ -75,10 +71,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found)));
|
||||
} else {
|
||||
int32 rows = _pack.size() / StickerPanPerRow + ((_pack.size() % StickerPanPerRow) ? 1 : 0);
|
||||
resize(st::stickersPadding + StickerPanPerRow * st::stickersSize.width(), rows * st::stickersSize.height() + st::stickersAddOrShare);
|
||||
_panel = new StickerSetPanel(parentWidget());
|
||||
_panel->setGeometry(0, parentWidget()->height() - st::stickersAddOrShare, width(), st::stickersAddOrShare);
|
||||
_panel->show();
|
||||
resize(st::stickersPadding.left() + StickerPanPerRow * st::stickersSize.width(), st::stickersPadding.top() + rows * st::stickersSize.height() + st::stickersPadding.bottom());
|
||||
}
|
||||
_loaded = true;
|
||||
|
||||
@@ -157,7 +150,7 @@ void StickerSetInner::paintEvent(QPaintEvent *e) {
|
||||
if (index >= _pack.size()) break;
|
||||
|
||||
DocumentData *doc = _pack.at(index);
|
||||
QPoint pos(st::stickerPanPadding + j * st::stickersSize.width(), i * st::stickersSize.height());
|
||||
QPoint pos(st::stickersPadding.left() + j * st::stickersSize.width(), st::stickersPadding.top() + i * st::stickersSize.height());
|
||||
|
||||
bool goodThumb = !doc->thumb->isNull() && ((doc->thumb->width() >= 128) || (doc->thumb->height() >= 128));
|
||||
if (goodThumb) {
|
||||
@@ -225,21 +218,20 @@ void StickerSetInner::install() {
|
||||
StickerSetInner::~StickerSetInner() {
|
||||
}
|
||||
|
||||
StickerSetBox::StickerSetBox(const MTPInputStickerSet &set) : ScrollableBox(st::stickersScroll), _inner(set),
|
||||
_close(this, st::btnStickersClose),
|
||||
_addStickers(this, lng_stickers_add_pack(lt_count, 0), st::btnStickersAdd),
|
||||
_shareStickers(this, lang(lng_stickers_share_pack), st::btnStickersAdd),
|
||||
_closeStickers(this, lang(lng_close), st::btnStickersAdd) {
|
||||
resize(st::stickersWidth, height());
|
||||
StickerSetBox::StickerSetBox(const MTPInputStickerSet &set) : ScrollableBox(st::stickersScroll)
|
||||
, _inner(set)
|
||||
, _shadow(this)
|
||||
, _add(this, lang(lng_stickers_add_pack), st::defaultBoxButton)
|
||||
, _share(this, lang(lng_stickers_share_pack), st::defaultBoxButton)
|
||||
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
|
||||
setMaxHeight(st::stickersMaxHeight);
|
||||
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
|
||||
|
||||
init(&_inner, 0, st::boxFont->height + st::old_newGroupNamePadding.top() + st::old_newGroupNamePadding.bottom());
|
||||
init(&_inner, st::boxButtonPadding.bottom() + _cancel.height() + st::boxButtonPadding.top());
|
||||
|
||||
connect(&_close, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
connect(&_addStickers, SIGNAL(clicked()), this, SLOT(onAddStickers()));
|
||||
connect(&_shareStickers, SIGNAL(clicked()), this, SLOT(onShareStickers()));
|
||||
connect(&_closeStickers, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
connect(&_add, SIGNAL(clicked()), this, SLOT(onAddStickers()));
|
||||
connect(&_share, SIGNAL(clicked()), this, SLOT(onShareStickers()));
|
||||
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
|
||||
|
||||
connect(&_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons()));
|
||||
connect(&_scroll, SIGNAL(scrolled()), this, SLOT(onScroll()));
|
||||
@@ -268,7 +260,9 @@ void StickerSetBox::onShareStickers() {
|
||||
}
|
||||
|
||||
void StickerSetBox::onUpdateButtons() {
|
||||
if (!_close.isHidden()) showAll();
|
||||
if (!_cancel.isHidden()) {
|
||||
showAll();
|
||||
}
|
||||
}
|
||||
|
||||
void StickerSetBox::onScroll() {
|
||||
@@ -277,37 +271,35 @@ void StickerSetBox::onScroll() {
|
||||
|
||||
void StickerSetBox::hideAll() {
|
||||
ScrollableBox::hideAll();
|
||||
_close.hide();
|
||||
_addStickers.hide();
|
||||
_shareStickers.hide();
|
||||
_shadow.hide();
|
||||
_cancel.hide();
|
||||
_add.hide();
|
||||
_share.hide();
|
||||
}
|
||||
|
||||
void StickerSetBox::showAll() {
|
||||
ScrollableBox::showAll();
|
||||
_close.show();
|
||||
_shadow.show();
|
||||
_cancel.show();
|
||||
int32 cnt = _inner.notInstalled();
|
||||
if (_inner.loaded()) {
|
||||
if (_inner.official()) {
|
||||
_addStickers.hide();
|
||||
_shareStickers.hide();
|
||||
_closeStickers.show();
|
||||
_add.hide();
|
||||
_share.hide();
|
||||
} else if (_inner.notInstalled()) {
|
||||
_addStickers.setText(lng_stickers_add_pack(lt_count, cnt));
|
||||
_addStickers.show();
|
||||
_addStickers.raise();
|
||||
_shareStickers.hide();
|
||||
_closeStickers.hide();
|
||||
_add.show();
|
||||
_add.raise();
|
||||
_share.hide();
|
||||
} else {
|
||||
_shareStickers.show();
|
||||
_shareStickers.raise();
|
||||
_addStickers.hide();
|
||||
_closeStickers.hide();
|
||||
_share.show();
|
||||
_share.raise();
|
||||
_add.hide();
|
||||
}
|
||||
} else {
|
||||
_addStickers.hide();
|
||||
_shareStickers.hide();
|
||||
_closeStickers.hide();
|
||||
_add.hide();
|
||||
_share.hide();
|
||||
}
|
||||
resizeEvent(0);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -315,14 +307,20 @@ void StickerSetBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintOldTitle(p, _inner.title(), false);
|
||||
paintTitle(p, _inner.title());
|
||||
}
|
||||
|
||||
void StickerSetBox::resizeEvent(QResizeEvent *e) {
|
||||
ScrollableBox::resizeEvent(e);
|
||||
_inner.resize(width(), _inner.height());
|
||||
_close.moveToRight(0, 0);
|
||||
_addStickers.move((width() - _addStickers.width()) / 2, height() - (st::stickersAddOrShare + _addStickers.height()) / 2);
|
||||
_shareStickers.move((width() - _shareStickers.width()) / 2, height() - (st::stickersAddOrShare + _shareStickers.height()) / 2);
|
||||
_closeStickers.move((width() - _closeStickers.width()) / 2, height() - (st::stickersAddOrShare + _closeStickers.height()) / 2);
|
||||
_shadow.setGeometry(0, height() - st::boxButtonPadding.bottom() - _cancel.height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth);
|
||||
_add.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _add.height());
|
||||
_share.moveToRight(st::boxButtonPadding.right(), _add.y());
|
||||
if (_add.isHidden() && _share.isHidden()) {
|
||||
_cancel.moveToRight(st::boxButtonPadding.right(), _add.y());
|
||||
} else if (_add.isHidden()) {
|
||||
_cancel.moveToRight(st::boxButtonPadding.right() + _share.width() + st::boxButtonPadding.left(), _add.y());
|
||||
} else {
|
||||
_cancel.moveToRight(st::boxButtonPadding.right() + _add.width() + st::boxButtonPadding.left(), _add.y());
|
||||
}
|
||||
}
|
||||
|
@@ -22,15 +22,6 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "abstractbox.h"
|
||||
|
||||
class StickerSetPanel : public TWidget {
|
||||
public:
|
||||
|
||||
StickerSetPanel(QWidget *parent) : TWidget(parent) {
|
||||
}
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
};
|
||||
|
||||
class StickerSetInner : public TWidget, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -51,6 +42,8 @@ public:
|
||||
void setScrollBottom(int32 bottom);
|
||||
void install();
|
||||
|
||||
QString getTitle() const;
|
||||
|
||||
~StickerSetInner();
|
||||
|
||||
signals:
|
||||
@@ -76,8 +69,6 @@ private:
|
||||
MTPInputStickerSet _input;
|
||||
|
||||
mtpRequestId _installRequest;
|
||||
|
||||
StickerSetPanel *_panel;
|
||||
};
|
||||
|
||||
class StickerSetBox : public ScrollableBox, public RPCSender {
|
||||
@@ -111,6 +102,7 @@ protected:
|
||||
private:
|
||||
|
||||
StickerSetInner _inner;
|
||||
IconedButton _close;
|
||||
FlatButton _addStickers, _shareStickers, _closeStickers;
|
||||
ScrollableBoxShadow _shadow;
|
||||
BoxButton _add, _share, _cancel;
|
||||
QString _title;
|
||||
};
|
||||
|
@@ -28,16 +28,18 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
||||
|
||||
UsernameBox::UsernameBox() : AbstractBox(st::boxWidth),
|
||||
_save(this, lang(lng_settings_save), st::defaultBoxButton),
|
||||
_cancel(this, lang(lng_box_cancel), st::cancelBoxButton),
|
||||
_cancel(this, lang(lng_cancel), st::cancelBoxButton),
|
||||
_username(this, st::usernameField, qsl("@username"), App::self()->username, false),
|
||||
_link(this, QString(), st::defaultBoxLinkButton),
|
||||
_saveRequestId(0), _checkRequestId(0),
|
||||
_about(st::boxWidth - st::usernamePadding.left()) {
|
||||
setBlueTitle(true);
|
||||
|
||||
_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);
|
||||
|
||||
textstyleSet(&st::usernameTextStyle);
|
||||
_about.setRichText(st::boxTextFont, lang(lng_username_about));
|
||||
resizeMaxHeight(st::boxWidth, st::boxBlueTitleHeight + st::usernamePadding.top() + _username.height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left() - st::usernamePadding.right()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
|
||||
resizeMaxHeight(st::boxWidth, st::boxTitleHeight + st::usernamePadding.top() + _username.height() + st::usernameSkip + _about.countHeight(st::boxWidth - st::usernamePadding.left() - st::usernamePadding.right()) + 3 * st::usernameTextStyle.lineHeight + st::usernamePadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom());
|
||||
textstyleRestore();
|
||||
|
||||
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
|
||||
@@ -58,6 +60,8 @@ void UsernameBox::hideAll() {
|
||||
_save.hide();
|
||||
_cancel.hide();
|
||||
_link.hide();
|
||||
|
||||
AbstractBox::hideAll();
|
||||
}
|
||||
|
||||
void UsernameBox::showAll() {
|
||||
@@ -65,6 +69,8 @@ void UsernameBox::showAll() {
|
||||
_save.show();
|
||||
_cancel.show();
|
||||
updateLinkText();
|
||||
|
||||
AbstractBox::showAll();
|
||||
}
|
||||
|
||||
void UsernameBox::showDone() {
|
||||
@@ -75,7 +81,7 @@ void UsernameBox::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
if (paint(p)) return;
|
||||
|
||||
paintBlueTitle(p, lang(lng_username_title));
|
||||
paintTitle(p, lang(lng_username_title));
|
||||
|
||||
if (!_copiedTextLink.isEmpty()) {
|
||||
p.setPen(st::usernameDefaultFg);
|
||||
@@ -112,7 +118,7 @@ void UsernameBox::paintEvent(QPaintEvent *e) {
|
||||
|
||||
void UsernameBox::resizeEvent(QResizeEvent *e) {
|
||||
_username.resize(width() - st::usernamePadding.left() - st::usernamePadding.right(), _username.height());
|
||||
_username.moveToLeft(st::usernamePadding.left(), st::boxBlueTitleHeight + st::usernamePadding.top());
|
||||
_username.moveToLeft(st::usernamePadding.left(), st::boxTitleHeight + st::usernamePadding.top());
|
||||
|
||||
textstyleSet(&st::usernameTextStyle);
|
||||
int32 availw = st::boxWidth - st::usernamePadding.left(), h = _about.countHeight(availw);
|
||||
@@ -122,6 +128,8 @@ void UsernameBox::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
|
||||
_cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y());
|
||||
|
||||
AbstractBox::resizeEvent(e);
|
||||
}
|
||||
|
||||
void UsernameBox::onSave() {
|
||||
|
Reference in New Issue
Block a user