Group and channel create box photo select button improved.

This commit is contained in:
John Preston 2016-11-19 17:47:28 +03:00
parent 2ada4d841f
commit 8a0c275658
55 changed files with 185 additions and 351 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 B

After

Width:  |  Height:  |  Size: 221 B

View File

@ -31,7 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/labels.h"
#include "styles/style_boxes.h"
AboutBox::AboutBox() : AbstractBox(st::aboutWidth)
AboutBox::AboutBox() : AbstractBox(st::aboutWidth, qsl("Telegram Desktop"))
, _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cAlphaVersion() ? " alpha" : "") + (cBetaVersion() ? qsl(" beta %1").arg(cBetaVersion()) : QString())), st::aboutVersionLink)
, _text1(this, lang(lng_about_text_1), Ui::FlatLabel::InitType::Rich, st::aboutLabel, st::aboutTextStyle)
, _text2(this, lang(lng_about_text_2), Ui::FlatLabel::InitType::Rich, st::aboutLabel, st::aboutTextStyle)
@ -86,13 +86,6 @@ void AboutBox::keyPressEvent(QKeyEvent *e) {
}
}
void AboutBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, qsl("Telegram Desktop"));
}
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
QString _getCrashReportFile(const QMimeData *m) {
if (!m || m->urls().size() != 1 || !m->urls().at(0).isLocalFile()) return QString();

View File

@ -40,7 +40,6 @@ public slots:
protected:
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void dragEnterEvent(QDragEnterEvent *e) override;
void dropEvent(QDropEvent *e) override;

View File

@ -29,11 +29,22 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "mainwidget.h"
#include "mainwindow.h"
AbstractBox::AbstractBox(int w) : LayerWidget(App::wnd()->bodyWidget()) {
AbstractBox::AbstractBox(int w, const QString &title) : LayerWidget(App::wnd()->bodyWidget())
, _title(title) {
setAttribute(Qt::WA_OpaquePaintEvent);
resize((w > 0) ? w : st::boxWideWidth, 0);
}
void AbstractBox::setTitleText(const QString &title) {
_title = title;
update();
}
void AbstractBox::setAdditionalTitle(const QString &additionalTitle) {
_additionalTitle = additionalTitle;
update();
}
void AbstractBox::prepare() {
raiseShadow();
}
@ -63,11 +74,6 @@ void AbstractBox::parentResized() {
update();
}
bool AbstractBox::paint(QPainter &p) {
p.fillRect(rect(), st::boxBg);
return false;
}
int AbstractBox::titleHeight() const {
return _blockTitle ? st::boxBlockTitleHeight : st::boxTitleHeight;
}
@ -95,8 +101,11 @@ void AbstractBox::paintTitle(Painter &p, const QString &title, const QString &ad
}
void AbstractBox::paintEvent(QPaintEvent *e) {
QPainter p(this);
if (paint(p)) return;
Painter p(this);
p.fillRect(e->rect(), st::boxBg);
if (!_title.isEmpty()) {
paintTitle(p, _title, _additionalTitle);
}
}
void AbstractBox::setMaxHeight(int32 maxHeight) {

View File

@ -33,9 +33,11 @@ class AbstractBox : public LayerWidget, protected base::Subscriber {
Q_OBJECT
public:
AbstractBox(int w = 0);
AbstractBox(int w = 0, const QString &title = QString());
void parentResized() override;
void setTitleText(const QString &title);
void setAdditionalTitle(const QString &additionalTitle);
void setBlockTitle(bool block);
void raiseShadow();
@ -48,7 +50,6 @@ protected:
void paintEvent(QPaintEvent *e) override;
void prepare();
bool paint(QPainter &p);
int titleHeight() const;
void paintTitle(Painter &p, const QString &title, const QString &additional = QString());
void setMaxHeight(int32 maxHeight);
@ -63,6 +64,8 @@ private:
bool _closed = false;
QString _title;
QString _additionalTitle;
bool _blockTitle = false;
ChildWidget<Ui::IconButton> _blockClose = { nullptr };
ChildWidget<Ui::GradientShadow> _blockShadow = { nullptr };

View File

@ -33,6 +33,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/labels.h"
#include "ui/buttons/peer_avatar_button.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "apiwrap.h"
@ -71,10 +72,10 @@ void AddContactBox::initBox() {
setTabOrder(_last, _first);
}
if (_user) {
_boxTitle = lang(lng_edit_contact_title);
setTitleText(lang(lng_edit_contact_title));
} else {
bool readyToAdd = !_phone->getLastText().isEmpty() && (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty());
_boxTitle = lang(readyToAdd ? lng_confirm_contact_data : lng_enter_contact_data);
setTitleText(lang(readyToAdd ? lng_confirm_contact_data : lng_enter_contact_data));
}
setMaxHeight(titleHeight() + st::contactPadding.top() + _first->height() + st::contactSkip + _last->height() + st::contactPhoneSkip + _phone->height() + st::contactPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom());
_retry->hide();
@ -99,11 +100,9 @@ void AddContactBox::doSetInnerFocus() {
}
void AddContactBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
paintTitle(p, _boxTitle);
if (_retry->isHidden()) {
st::contactUserIcon.paint(p, st::boxPadding.left(), _first->y() + st::contactIconTop, width());
st::contactPhoneIcon.paint(p, st::boxPadding.left(), _phone->y() + st::contactIconTop, width());
@ -251,16 +250,13 @@ void AddContactBox::onRetry() {
update();
}
GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : AbstractBox(),
_creating(creating),
a_photoOver(0, 0),
_a_photoOver(animation(this, &GroupInfoBox::step_photoOver)),
_photoOver(false),
_title(this, st::defaultInputField, lang(_creating == CreatingGroupChannel ? lng_dlg_new_channel_name : lng_dlg_new_group_name)),
_description(this, st::newGroupDescription, lang(lng_create_group_description)),
_next(this, lang(_creating == CreatingGroupChannel ? lng_create_group_create : lng_create_group_next), st::defaultBoxButton),
_cancel(this, lang(fromTypeChoose ? lng_create_group_back : lng_cancel), st::cancelBoxButton),
_creationRequestId(0), _createdChannel(0) {
GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : AbstractBox()
, _creating(creating)
, _photo(this, st::newGroupPhotoSize)
, _title(this, st::defaultInputField, lang(_creating == CreatingGroupChannel ? lng_dlg_new_channel_name : lng_dlg_new_group_name))
, _description(this, st::newGroupDescription, lang(lng_create_group_description))
, _next(this, lang(_creating == CreatingGroupChannel ? lng_create_group_create : lng_create_group_next), st::defaultBoxButton)
, _cancel(this, lang(fromTypeChoose ? lng_create_group_back : lng_cancel), st::cancelBoxButton) {
setMouseTracking(true);
@ -284,6 +280,12 @@ _creationRequestId(0), _createdChannel(0) {
notifyFileQueryUpdated(update);
});
_photo->setClickedCallback([this] {
auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_images), filter);
});
prepare();
}
@ -291,38 +293,9 @@ void GroupInfoBox::doSetInnerFocus() {
_title->setFocus();
}
void GroupInfoBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
QRect phRect(photoRect());
if (phRect.intersects(e->rect())) {
if (_photoSmall.isNull()) {
float64 o = a_photoOver.current();
if (o > 0) {
if (o < 1) {
QColor c;
c.setRedF(st::newGroupPhotoBg->c.redF() * (1. - o) + st::newGroupPhotoBgOver->c.redF() * o);
c.setGreenF(st::newGroupPhotoBg->c.greenF() * (1. - o) + st::newGroupPhotoBgOver->c.greenF() * o);
c.setBlueF(st::newGroupPhotoBg->c.blueF() * (1. - o) + st::newGroupPhotoBgOver->c.blueF() * o);
p.fillRect(phRect, c);
} else {
p.fillRect(phRect, st::newGroupPhotoBgOver->b);
}
} else {
p.fillRect(phRect, st::newGroupPhotoBg->b);
}
st::newGroupPhotoIcon.paint(p, phRect.topLeft() + st::newGroupPhotoIconPosition, width());
} else {
p.drawPixmap(phRect.topLeft(), _photoSmall);
}
if (phRect.contains(e->rect())) {
return;
}
}
}
void GroupInfoBox::resizeEvent(QResizeEvent *e) {
_photo->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxPadding.top() + st::newGroupInfoPadding.top());
int32 nameLeft = st::newGroupPhotoSize + st::newGroupNamePosition.x();
_title->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right() - nameLeft, _title->height());
_title->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left() + nameLeft, st::boxPadding.top() + st::newGroupInfoPadding.top() + st::newGroupNamePosition.y());
@ -334,47 +307,6 @@ void GroupInfoBox::resizeEvent(QResizeEvent *e) {
AbstractBox::resizeEvent(e);
}
void GroupInfoBox::mouseMoveEvent(QMouseEvent *e) {
updateSelected(e->globalPos());
}
void GroupInfoBox::updateSelected(const QPoint &cursorGlobalPosition) {
QPoint p(mapFromGlobal(cursorGlobalPosition));
bool photoOver = photoRect().contains(p);
if (photoOver != _photoOver) {
_photoOver = photoOver;
if (_photoSmall.isNull()) {
a_photoOver.start(_photoOver ? 1 : 0);
_a_photoOver.start();
}
}
setCursor(_photoOver ? style::cur_pointer : style::cur_default);
}
void GroupInfoBox::mousePressEvent(QMouseEvent *e) {
mouseMoveEvent(e);
if (_photoOver) {
onPhoto();
}
}
void GroupInfoBox::leaveEvent(QEvent *e) {
updateSelected(QCursor::pos());
}
void GroupInfoBox::step_photoOver(float64 ms, bool timer) {
float64 dt = ms / st::newGroupPhotoDuration;
if (dt >= 1) {
_a_photoOver.stop();
a_photoOver.finish();
} else {
a_photoOver.update(dt, anim::linear);
}
if (timer) update(photoRect());
}
void GroupInfoBox::onNameSubmit() {
if (_title->getLastText().trimmed().isEmpty()) {
_title->setFocus();
@ -396,7 +328,7 @@ void GroupInfoBox::onNext() {
return;
}
if (_creating == CreatingGroupGroup) {
Ui::showLayer(new ContactsBox(title, _photoBig), KeepOtherLayers);
Ui::showLayer(new ContactsBox(title, _photoImage), KeepOtherLayers);
} else {
bool mega = false;
MTPchannels_CreateChannel::Flags flags = mega ? MTPchannels_CreateChannel::Flag::f_megagroup : MTPchannels_CreateChannel::Flag::f_broadcast;
@ -418,8 +350,8 @@ void GroupInfoBox::creationDone(const MTPUpdates &updates) {
if (v && !v->isEmpty() && v->front().type() == mtpc_channel) {
channel = App::channel(v->front().c_channel().vid.v);
if (channel) {
if (!_photoBig.isNull()) {
App::app()->uploadProfilePhoto(_photoBig, channel->id);
if (!_photoImage.isNull()) {
App::app()->uploadProfilePhoto(_photoImage, channel->id);
}
_createdChannel = channel;
_creationRequestId = MTP::send(MTPchannels_ExportInvite(_createdChannel->inputChannel), rpcDone(&GroupInfoBox::exportDone));
@ -460,10 +392,6 @@ void GroupInfoBox::onDescriptionResized() {
update();
}
QRect GroupInfoBox::photoRect() const {
return myrtlrect(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxPadding.top() + st::newGroupInfoPadding.top(), st::newGroupPhotoSize, st::newGroupPhotoSize);
}
void GroupInfoBox::updateMaxHeight() {
int32 h = st::boxPadding.top() + st::newGroupInfoPadding.top() + st::newGroupPhotoSize + st::boxPadding.bottom() + st::newGroupInfoPadding.bottom() + st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom();
if (_creating == CreatingGroupChannel) {
@ -472,12 +400,6 @@ void GroupInfoBox::updateMaxHeight() {
setMaxHeight(h);
}
void GroupInfoBox::onPhoto() {
auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_images), filter);
}
void GroupInfoBox::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update) {
if (_setPhotoFileQueryId != update.queryId) {
return;
@ -502,9 +424,8 @@ void GroupInfoBox::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update)
}
void GroupInfoBox::onPhotoReady(const QImage &img) {
_photoBig = img;
_photoSmall = App::pixmapFromImageInPlace(img.scaled(st::newGroupPhotoSize * cIntRetinaFactor(), st::newGroupPhotoSize * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_photoSmall.setDevicePixelRatio(cRetinaFactor());
_photoImage = img;
_photo->setImage(_photoImage);
}
SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : AbstractBox()
@ -576,8 +497,8 @@ void SetupChannelBox::keyPressEvent(QKeyEvent *e) {
void SetupChannelBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
p.fillRect(e->rect(), st::boxBg);
p.setPen(st::newGroupAboutFg);
QRect aboutPublic(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _public->y() + _public->height(), _aboutPublicWidth, _aboutPublicHeight);
@ -891,10 +812,10 @@ _invertOrder(!peer->isChat() && langFirstNameGoesSecond()) {
int32 h = titleHeight() + st::contactPadding.top() + _first->height();
if (_peer->isUser()) {
_boxTitle = lang(_peer == App::self() ? lng_edit_self_title : lng_edit_contact_title);
setTitleText(lang(_peer == App::self() ? lng_edit_self_title : lng_edit_contact_title));
h += st::contactSkip + _last->height();
} else if (_peer->isChat()) {
_boxTitle = lang(lng_edit_group_title);
setTitleText(lang(lng_edit_group_title));
}
h += st::boxPadding.bottom() + st::contactPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom();
setMaxHeight(h);
@ -938,13 +859,6 @@ void EditNameTitleBox::onSubmit() {
}
}
void EditNameTitleBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, _boxTitle);
}
void EditNameTitleBox::resizeEvent(QResizeEvent *e) {
_first->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _first->height());
_last->resize(_first->size());
@ -1050,6 +964,8 @@ EditChannelBox::EditChannelBox(ChannelData *channel) : AbstractBox()
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
connect(App::main(), SIGNAL(peerNameChanged(PeerData*,const PeerData::Names&,const PeerData::NameFirstChars&)), this, SLOT(peerUpdated(PeerData*)));
setTitleText(lang(_channel->isMegagroup() ? lng_edit_group : lng_edit_channel_title));
setMouseTracking(true);
_title->setMaxLength(MaxGroupChannelTitle);
@ -1086,13 +1002,6 @@ void EditChannelBox::keyPressEvent(QKeyEvent *e) {
}
}
void EditChannelBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(_channel->isMegagroup() ? lng_edit_group : lng_edit_channel_title));
}
void EditChannelBox::peerUpdated(PeerData *peer) {
if (peer == _channel) {
_publicLink->setText(lang(_channel->isPublic() ? lng_profile_edit_public_link : lng_profile_create_public_link));
@ -1317,9 +1226,9 @@ void RevokePublicLinkBox::mouseReleaseEvent(QMouseEvent *e) {
}
void RevokePublicLinkBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
Painter p(this);
p.translate(0, _rowsTop);
for_const (auto &row, _rows) {
paintChat(p, row, (row.peer == _selected), (row.peer == _pressed));

View File

@ -35,6 +35,7 @@ class Checkbox;
class Radiobutton;
class LinkButton;
class RoundButton;
class NewAvatarButton;
} // namespace Ui
class AddContactBox : public AbstractBox, public RPCSender {
@ -64,7 +65,6 @@ private:
void initBox();
UserData *_user = nullptr;
QString _boxTitle;
ChildWidget<Ui::InputField> _first;
ChildWidget<Ui::InputField> _last;
@ -89,7 +89,6 @@ public:
GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose);
public slots:
void onPhoto();
void onPhotoReady(const QImage &img);
void onNext();
@ -97,41 +96,29 @@ public slots:
void onDescriptionResized();
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void leaveEvent(QEvent *e) override;
void doSetInnerFocus() override;
private:
void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update);
void step_photoOver(float64 ms, bool timer);
QRect photoRect() const;
void updateMaxHeight();
void updateSelected(const QPoint &cursorGlobalPosition);
CreatingGroupType _creating;
anim::fvalue a_photoOver;
Animation _a_photoOver;
bool _photoOver;
ChildWidget<Ui::NewAvatarButton> _photo;
ChildWidget<Ui::InputField> _title;
ChildWidget<Ui::InputArea> _description;
QImage _photoBig;
QPixmap _photoSmall;
QImage _photoImage;
ChildWidget<Ui::RoundButton> _next;
ChildWidget<Ui::RoundButton> _cancel;
// channel creation
int32 _creationRequestId;
ChannelData *_createdChannel;
mtpRequestId _creationRequestId = 0;
ChannelData *_createdChannel = nullptr;
FileDialog::QueryId _setPhotoFileQueryId = 0;
@ -220,7 +207,6 @@ public slots:
void onSubmit();
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void doSetInnerFocus() override;
@ -233,7 +219,6 @@ private:
bool onSaveChatFail(const RPCError &e);
PeerData *_peer;
QString _boxTitle;
ChildWidget<Ui::InputField> _first;
ChildWidget<Ui::InputField> _last;
@ -263,7 +248,6 @@ public slots:
protected:
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void doSetInnerFocus() override;

View File

@ -30,8 +30,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/buttons.h"
#include "styles/style_boxes.h"
AutoLockBox::AutoLockBox() :
_close(this, lang(lng_box_ok), st::defaultBoxButton) {
AutoLockBox::AutoLockBox() : _close(this, lang(lng_box_ok), st::defaultBoxButton) {
setTitleText(lang(lng_passcode_autolock));
bool haveTestLang = (cLang() == languageTest);
@ -55,13 +55,6 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) {
prepare();
}
void AutoLockBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_passcode_autolock));
}
void AutoLockBox::onChange() {
if (isHidden()) return;

View File

@ -36,9 +36,6 @@ public:
public slots:
void onChange();
protected:
void paintEvent(QPaintEvent *e) override;
private:
QVector<Ui::Radiobutton*> _options;
ChildWidget<Ui::RoundButton> _close;

View File

@ -31,19 +31,13 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
BackgroundBox::BackgroundBox() : ItemListBox(st::backgroundScroll)
, _inner(this) {
init(_inner);
setTitleText(lang(lng_backgrounds_header));
connect(_inner, SIGNAL(backgroundChosen(int)), this, SLOT(onBackgroundChosen(int)));
prepare();
}
void BackgroundBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_backgrounds_header));
}
void BackgroundBox::onBackgroundChosen(int index) {
if (index >= 0 && index < App::cServerBackgrounds().size()) {
const App::WallPaper &paper(App::cServerBackgrounds().at(index));

View File

@ -32,9 +32,6 @@ public:
public slots:
void onBackgroundChosen(int index);
protected:
void paintEvent(QPaintEvent *e) override;
private:
class Inner;
ChildWidget<Inner> _inner;

View File

@ -154,8 +154,9 @@ void ConfirmBox::keyPressEvent(QKeyEvent *e) {
}
void ConfirmBox::paintEvent(QPaintEvent *e) {
QPainter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
Painter p(this);
// draw box title / text
p.setPen(st::boxTextFg);
@ -261,8 +262,9 @@ void MaxInviteBox::step_good(float64 ms, bool timer) {
}
void MaxInviteBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
// draw box title / text
p.setPen(st::boxTextFg);
@ -288,7 +290,7 @@ void MaxInviteBox::resizeEvent(QResizeEvent *e) {
AbstractBox::resizeEvent(e);
}
ConvertToSupergroupBox::ConvertToSupergroupBox(ChatData *chat) : AbstractBox(st::boxWideWidth)
ConvertToSupergroupBox::ConvertToSupergroupBox(ChatData *chat) : AbstractBox(st::boxWideWidth, lang(lng_profile_convert_title))
, _chat(chat)
, _text(100)
, _note(100)
@ -358,10 +360,9 @@ void ConvertToSupergroupBox::keyPressEvent(QKeyEvent *e) {
}
void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_profile_convert_title));
Painter p(this);
// draw box title / text
p.setPen(st::boxTextFg);
@ -553,8 +554,9 @@ void ConfirmInviteBox::resizeEvent(QResizeEvent *e) {
}
void ConfirmInviteBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
p.drawPixmap((width() - st::confirmInvitePhotoSize) / 2, st::confirmInvitePhotoTop, _photo->pixCircled(st::confirmInvitePhotoSize, st::confirmInvitePhotoSize));

View File

@ -45,7 +45,7 @@ void ConfirmPhoneBox::start(const QString &phone, const QString &hash) {
}
}
ConfirmPhoneBox::ConfirmPhoneBox(QWidget *parent, const QString &phone, const QString &hash) : AbstractBox(st::boxWidth)
ConfirmPhoneBox::ConfirmPhoneBox(QWidget *parent, const QString &phone, const QString &hash) : AbstractBox(st::boxWidth, lang(lng_confirm_phone_title))
, _phone(phone)
, _hash(hash) {
setParent(parent);
@ -248,10 +248,9 @@ void ConfirmPhoneBox::showError(const QString &error) {
}
void ConfirmPhoneBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_confirm_phone_title));
Painter p(this);
p.setFont(st::boxTextFont);
auto callText = getCallText();

View File

@ -31,7 +31,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "history/history_location_manager.h"
#include "styles/style_boxes.h"
ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth)
ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth, lang(lng_connection_header))
, _hostInput(this, st::connectionHostInputField, lang(lng_connection_host_ph), Global::ConnectionProxy().host)
, _portInput(this, st::connectionPortInputField, lang(lng_connection_port_ph), QString::number(Global::ConnectionProxy().port))
, _userInput(this, st::connectionUserInputField, lang(lng_connection_user_ph), Global::ConnectionProxy().user)
@ -85,13 +85,6 @@ void ConnectionBox::doSetInnerFocus() {
}
}
void ConnectionBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_connection_header));
}
void ConnectionBox::resizeEvent(QResizeEvent *e) {
_autoRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), titleHeight() + st::boxOptionListPadding.top());
_httpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio->y() + _autoRadio->height() + st::boxOptionListPadding.top());
@ -230,8 +223,9 @@ AutoDownloadBox::AutoDownloadBox() : AbstractBox(st::boxWidth)
}
void AutoDownloadBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
p.setPen(st::boxTextFg);
p.setFont(st::semiboldFont);

View File

@ -43,7 +43,6 @@ public slots:
void onSave();
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void doSetInnerFocus() override;

View File

@ -275,8 +275,9 @@ void ContactsBox::keyPressEvent(QKeyEvent *e) {
}
void ContactsBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
bool addingAdmin = _inner->channel() && _inner->membersFilter() == MembersFilter::Admins;
if (_inner->chat() && _inner->membersFilter() == MembersFilter::Admins) {

View File

@ -38,6 +38,7 @@ DownloadPathBox::DownloadPathBox() : AbstractBox()
, _pathLink(this, QString(), st::boxLinkButton)
, _save(this, lang(lng_connection_save), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
setTitleText(lang(lng_download_path_header));
connect(_save, SIGNAL(clicked()), this, SLOT(onSave()));
connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
@ -65,13 +66,6 @@ void DownloadPathBox::updateControlsVisibility() {
setMaxHeight(h);
}
void DownloadPathBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_download_path_header));
}
void DownloadPathBox::resizeEvent(QResizeEvent *e) {
_default->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), titleHeight() + st::boxOptionListPadding.top());
_temp->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _default->y() + _default->height() + st::boxOptionListPadding.top());

View File

@ -41,7 +41,6 @@ public slots:
void onSave();
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:

View File

@ -72,6 +72,7 @@ namespace {
}
EmojiBox::EmojiBox() : _esize(EmojiSizes[EIndex + 1]) {
setTitleText(lang(lng_settings_emoji_list));
setBlockTitle(true);
fillBlocks();
@ -122,10 +123,9 @@ void EmojiBox::keyPressEvent(QKeyEvent *e) {
}
void EmojiBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_settings_emoji_list));
Painter p(this);
p.setFont(st::emojiTextFont);
p.setPen(st::boxTextFg);

View File

@ -33,6 +33,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
LanguageBox::LanguageBox() :
_close(this, lang(lng_box_ok), st::defaultBoxButton) {
setTitleText(lang(lng_languages));
bool haveTestLang = (cLang() == languageTest);
@ -84,13 +85,6 @@ void LanguageBox::mousePressEvent(QMouseEvent *e) {
}
}
void LanguageBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_languages));
}
void LanguageBox::onChange() {
if (isHidden()) return;

View File

@ -40,7 +40,6 @@ public slots:
protected:
void mousePressEvent(QMouseEvent *e) override;
void paintEvent(QPaintEvent *e) override;
private:
QVector<Ui::Radiobutton*> _langs;

View File

@ -30,6 +30,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
LocalStorageBox::LocalStorageBox() : AbstractBox()
, _clear(this, lang(lng_local_storage_clear), st::boxLinkButton)
, _close(this, lang(lng_box_ok), st::defaultBoxButton) {
setTitleText(lang(lng_local_storage_title));
connect(_clear, SIGNAL(clicked()), this, SLOT(onClear()));
connect(_close, SIGNAL(clicked()), this, SLOT(onClose()));
@ -72,10 +74,9 @@ void LocalStorageBox::checkLocalStoredCounts() {
}
void LocalStorageBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_local_storage_title));
Painter p(this);
p.setFont(st::boxTextFont);
p.setPen(st::windowFg);

View File

@ -64,6 +64,7 @@ MembersBox::MembersBox(ChannelData *channel, MembersFilter filter) : ItemListBox
, _inner(this, channel, filter) {
ItemListBox::init(_inner);
setTitleText(lang(_inner->filter() == MembersFilter::Recent ? lng_channel_members : lng_channel_admins));
if (channel->amCreator() && (channel->membersCount() < (channel->isMegagroup() ? Global::MegagroupSizeMax() : Global::ChatSizeMax()) || (!channel->isMegagroup() && !channel->isPublic()) || filter == MembersFilter::Admins)) {
_add.create(this, st::contactsAdd);
_add->setClickedCallback([this] { onAdd(); });
@ -91,14 +92,6 @@ void MembersBox::keyPressEvent(QKeyEvent *e) {
}
}
void MembersBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
QString title(lang(_inner->filter() == MembersFilter::Recent ? lng_channel_members : lng_channel_admins));
paintTitle(p, title);
}
void MembersBox::resizeEvent(QResizeEvent *e) {
ItemListBox::resizeEvent(e);
_inner->resize(width(), _inner->height());

View File

@ -62,7 +62,6 @@ public slots:
protected:
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:

View File

@ -132,8 +132,9 @@ NotificationsBox::NotificationsBox() : AbstractBox()
}
void NotificationsBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
auto contentLeft = getContentLeft();

View File

@ -74,17 +74,17 @@ void PasscodeBox::init() {
textstyleRestore();
if (_turningOff) {
_oldPasscode->show();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove);
setTitleText(lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove));
setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
} else {
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : Global::LocalPasscode();
if (has) {
_oldPasscode->show();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change);
setTitleText(lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change));
setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _newPasscode->height() + st::contactSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::contactSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
} else {
_oldPasscode->hide();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create);
setTitleText(lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create));
setMaxHeight(titleHeight() + st::passcodePadding.top() + _newPasscode->height() + st::contactSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::contactSkip : 0) + _aboutHeight + (_cloudPwd ? st::contactSkip + _recoverEmail->height() + st::passcodeSkip : st::passcodePadding.bottom()) + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
}
}
@ -153,10 +153,9 @@ void PasscodeBox::onSubmit() {
}
void PasscodeBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, _boxTitle);
Painter p(this);
textstyleSet(&st::usernameTextStyle);
@ -448,7 +447,7 @@ bool PasscodeBox::recoverStartFail(const RPCError &error) {
return true;
}
RecoverBox::RecoverBox(const QString &pattern) : AbstractBox(st::boxWidth)
RecoverBox::RecoverBox(const QString &pattern) : AbstractBox(st::boxWidth, lang(lng_signin_recover_title))
, _submitRequest(0)
, _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5))
, _saveButton(this, lang(lng_passcode_submit), st::defaultBoxButton)
@ -468,10 +467,9 @@ RecoverBox::RecoverBox(const QString &pattern) : AbstractBox(st::boxWidth)
}
void RecoverBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_signin_recover_title));
Painter p(this);
p.setFont(st::normalFont);
p.setPen(st::boxTextFg);

View File

@ -79,7 +79,6 @@ private:
int _aboutHeight = 0;
QString _boxTitle;
Text _about, _hintText;
ChildWidget<Ui::RoundButton> _saveButton;

View File

@ -228,8 +228,9 @@ void PhotoCropBox::keyPressEvent(QKeyEvent *e) {
}
void PhotoCropBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
p.setFont(st::boxTextFont);
p.setPen(st::boxPhotoTextFg);

View File

@ -219,8 +219,9 @@ void PhotoSendBox::keyPressEvent(QKeyEvent *e) {
}
void PhotoSendBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
if (_file && (_file->type == PreparePhoto || _animated)) {
if (_thumbx > st::boxPhotoPadding.left()) {
@ -526,8 +527,9 @@ void EditCaptionBox::updateBoxSize() {
}
void EditCaptionBox::paintEvent(QPaintEvent *e) {
AbstractBox::paintEvent(e);
Painter p(this);
if (paint(p)) return;
if (_photo || _animated) {
if (_thumbx > st::boxPhotoPadding.left()) {

View File

@ -38,6 +38,8 @@ ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth)
, _reasonOther(this, qsl("report_reason"), ReasonOther, lang(lng_report_reason_other))
, _report(this, lang(lng_report_button), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton) {
setTitleText(lang(_channel->isMegagroup() ? lng_report_group_title : lng_report_title));
connect(_report, SIGNAL(clicked()), this, SLOT(onReport()));
connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
@ -51,13 +53,6 @@ ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth)
prepare();
}
void ReportBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(_channel->isMegagroup() ? lng_report_group_title : lng_report_title));
}
void ReportBox::resizeEvent(QResizeEvent *e) {
_reasonSpam->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), titleHeight() + st::boxOptionListPadding.top());
_reasonViolence->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _reasonSpam->y() + _reasonSpam->height() + st::boxOptionListPadding.top());

View File

@ -40,7 +40,6 @@ private slots:
void onDescriptionResized();
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void doSetInnerFocus() override;

View File

@ -38,6 +38,7 @@ SessionsBox::SessionsBox() : ScrollableBox(st::sessionsScroll)
, _done(this, lang(lng_about_done), st::defaultBoxButton)
, _shortPollRequest(0) {
setMaxHeight(st::sessionsHeight);
setTitleText(lang(lng_sessions_other_header));
connect(_done, SIGNAL(clicked()), this, SLOT(onClose()));
connect(_inner, SIGNAL(oneTerminated()), this, SLOT(onOneTerminated()));
@ -71,10 +72,10 @@ void SessionsBox::resizeEvent(QResizeEvent *e) {
}
void SessionsBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
Painter p(this);
paintTitle(p, lang(lng_sessions_other_header));
p.translate(0, titleHeight());
if (_loading) {

View File

@ -51,6 +51,7 @@ ShareBox::ShareBox(CopyCallback &&copyCallback, SubmitCallback &&submitCallback,
, _bottomShadow(this) {
_select->resizeToWidth(st::boxWideWidth);
myEnsureResized(_select);
setTitleText(lang(lng_share_title));
auto topSkip = getTopScrollSkip();
auto bottomSkip = st::boxButtonPadding.top() + _share->height() + st::boxButtonPadding.bottom();
@ -177,13 +178,6 @@ void ShareBox::doSetInnerFocus() {
_select->setInnerFocus();
}
void ShareBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_share_title));
}
void ShareBox::resizeEvent(QResizeEvent *e) {
ItemListBox::resizeEvent(e);

View File

@ -64,7 +64,6 @@ private slots:
void onMustScrollTo(int top, int bottom);
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;

View File

@ -151,6 +151,7 @@ void StickersBox::setup() {
MTPmessages_GetArchivedStickers::Flags flags = 0;
_archivedRequestId = MTP::send(MTPmessages_GetArchivedStickers(MTP_flags(flags), MTP_long(0), MTP_int(kArchivedLimitFirstRequest)), rpcDone(&StickersBox::getArchivedDone, 0ULL));
}
setTitleText(lang(lng_stickers_packs));
} else if (_section == Section::Archived) {
// Reload the archived list.
MTPmessages_GetArchivedStickers::Flags flags = 0;
@ -166,6 +167,9 @@ void StickersBox::setup() {
}
}
App::api()->requestStickerSets();
setTitleText(lang(lng_stickers_archived));
} else {
setTitleText(lang(lng_stickers_featured));
}
int bottomSkip = st::boxPadding.bottom();
@ -297,18 +301,10 @@ bool StickersBox::reorderFail(const RPCError &result) {
}
void StickersBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
Painter p(this);
auto title = ([this]() {
if (_section == Section::Installed) {
return lang(lng_stickers_packs);
} else if (_section == Section::Featured) {
return lang(lng_stickers_featured);
}
return lang(lng_stickers_archived);
})();
paintTitle(p, title);
p.translate(0, titleHeight());
if (_aboutHeight > 0) {

View File

@ -41,6 +41,8 @@ StickerSetBox::StickerSetBox(const MTPInputStickerSet &set) : ScrollableBox(st::
, _share(this, lang(lng_stickers_share_pack), st::defaultBoxButton)
, _cancel(this, lang(lng_cancel), st::cancelBoxButton)
, _done(this, lang(lng_about_done), st::defaultBoxButton) {
setTitleText(lang(lng_contacts_loading));
setMaxHeight(st::stickersMaxHeight);
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
@ -84,6 +86,7 @@ void StickerSetBox::onShareStickers() {
}
void StickerSetBox::onUpdateButtons() {
setTitleText(_inner->title());
if (!_cancel->isHidden() || !_done->isHidden()) {
updateControlsVisibility();
}
@ -125,13 +128,6 @@ void StickerSetBox::updateControlsVisibility() {
update();
}
void StickerSetBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, _inner->title());
}
void StickerSetBox::resizeEvent(QResizeEvent *e) {
ScrollableBox::resizeEvent(e);
_inner->resize(width(), _inner->height());

View File

@ -51,7 +51,6 @@ signals:
void installed(uint64 id);
protected:
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:

View File

@ -29,7 +29,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/input_fields.h"
#include "styles/style_boxes.h"
UsernameBox::UsernameBox() : AbstractBox(st::boxWidth),
UsernameBox::UsernameBox() : AbstractBox(st::boxWidth, lang(lng_username_title)),
_save(this, lang(lng_settings_save), st::defaultBoxButton),
_cancel(this, lang(lng_cancel), st::cancelBoxButton),
_username(this, st::defaultInputField, qsl("@username"), App::self()->username, false),
@ -65,10 +65,9 @@ void UsernameBox::doSetInnerFocus() {
}
void UsernameBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
AbstractBox::paintEvent(e);
paintTitle(p, lang(lng_username_title));
Painter p(this);
p.setFont(st::boxTextFont);
if (!_copiedTextLink.isEmpty()) {

View File

@ -284,7 +284,6 @@ QString Generator::typeToString(structure::Type type) const {
case Tag::Color: return "style::color";
case Tag::Point: return "style::point";
case Tag::Size: return "style::size";
case Tag::Cursor: return "style::cursor";
case Tag::Align: return "style::align";
case Tag::Margins: return "style::margins";
case Tag::Font: return "style::font";
@ -305,7 +304,6 @@ QString Generator::typeToDefaultValue(structure::Type type) const {
case Tag::Color: return "{ Qt::Uninitialized }";
case Tag::Point: return "{ 0, 0 }";
case Tag::Size: return "{ 0, 0 }";
case Tag::Cursor: return "style::cur_default";
case Tag::Align: return "style::al_topleft";
case Tag::Margins: return "{ 0, 0, 0, 0 }";
case Tag::Font: return "{ Qt::Uninitialized }";
@ -355,7 +353,6 @@ QString Generator::valueAssignmentCode(structure::Value value) const {
auto v(value.Size());
return QString("{ %1, %2 }").arg(pxValueName(v.width)).arg(pxValueName(v.height));
} break;
case Tag::Cursor: return QString("style::cur_%1").arg(value.String().c_str());
case Tag::Align: return QString("style::al_%1").arg(value.String().c_str());
case Tag::Margins: {
auto v(value.Margins());
@ -1120,7 +1117,6 @@ bool Generator::collectUniqueValues() {
case Tag::Double:
case Tag::String:
case Tag::Color:
case Tag::Cursor:
case Tag::Align: break;
case Tag::Pixels: pxValues_.insert(value.Int(), true); break;
case Tag::Point: {

View File

@ -120,7 +120,6 @@ std::string logType(const structure::Type &type) {
{ structure::TypeTag::Color , "color" },
{ structure::TypeTag::Point , "point" },
{ structure::TypeTag::Size , "size" },
{ structure::TypeTag::Cursor , "cursor" },
{ structure::TypeTag::Align , "align" },
{ structure::TypeTag::Margins , "margins" },
{ structure::TypeTag::Font , "font" },
@ -137,10 +136,6 @@ bool validateAnsiString(const QString &value) {
return true;
}
bool validateCursorString(const QString &value) {
return QRegularExpression("^[a-z_]+$").match(value).hasMatch();
}
bool validateAlignString(const QString &value) {
return QRegularExpression("^[a-z_]+$").match(value).hasMatch();
}
@ -308,8 +303,6 @@ structure::Value ParsedFile::readValue() {
return pointValue;
} else if (auto sizeValue = readSizeValue()) {
return sizeValue;
} else if (auto cursorValue = readCursorValue()) {
return cursorValue;
} else if (auto alignValue = readAlignValue()) {
return alignValue;
} else if (auto marginsValue = readMarginsValue()) {
@ -599,26 +592,6 @@ structure::Value ParsedFile::readSizeValue() {
return {};
}
structure::Value ParsedFile::readCursorValue() {
if (auto font = file_.getToken(BasicType::Name)) {
if (tokenValue(font) == "cursor") {
assertNextToken(BasicType::LeftParenthesis);
auto cursor = tokenValue(assertNextToken(BasicType::Name));
assertNextToken(BasicType::RightParenthesis);
if (validateCursorString(cursor)) {
return { structure::TypeTag::Cursor, cursor.toStdString() };
} else {
logError(kErrorBadString) << "bad cursor string";
}
}
file_.putBack();
}
return {};
}
structure::Value ParsedFile::readAlignValue() {
if (auto font = file_.getToken(BasicType::Name)) {
if (tokenValue(font) == "align") {

View File

@ -93,7 +93,6 @@ private:
structure::Value readColorValue();
structure::Value readPointValue();
structure::Value readSizeValue();
structure::Value readCursorValue();
structure::Value readAlignValue();
structure::Value readMarginsValue();
structure::Value readFontValue();
@ -130,7 +129,6 @@ private:
{ "color" , { structure::TypeTag::Color } },
{ "point" , { structure::TypeTag::Point } },
{ "size" , { structure::TypeTag::Size } },
{ "cursor" , { structure::TypeTag::Cursor } },
{ "align" , { structure::TypeTag::Align } },
{ "margins" , { structure::TypeTag::Margins } },
{ "font" , { structure::TypeTag::Font } },

View File

@ -179,7 +179,6 @@ Value::Value(TypeTag type, int value) : Value(type, std::make_shared<DataTypes::
Value::Value(TypeTag type, std::string value) : Value(type, std::make_shared<DataTypes::TString>(value)) {
if (type_.tag != TypeTag::String &&
type_.tag != TypeTag::Cursor &&
type_.tag != TypeTag::Align) {
type_.tag = TypeTag::Invalid;
data_ = std::make_shared<DataBase>();
@ -196,7 +195,6 @@ Value::Value(Type type, Qt::Initialization) : type_(type) {
case TypeTag::Color: data_ = std::make_shared<DataTypes::TColor>(data::color { 0, 0, 0, 255 }); break;
case TypeTag::Point: data_ = std::make_shared<DataTypes::TPoint>(data::point { 0, 0 }); break;
case TypeTag::Size: data_ = std::make_shared<DataTypes::TSize>(data::size { 0, 0 }); break;
case TypeTag::Cursor: data_ = std::make_shared<DataTypes::TString>("default"); break;
case TypeTag::Align: data_ = std::make_shared<DataTypes::TString>("topleft"); break;
case TypeTag::Margins: data_ = std::make_shared<DataTypes::TMargins>(data::margins { 0, 0, 0, 0 }); break;
case TypeTag::Font: data_ = std::make_shared<DataTypes::TFont>(data::font { "", 13, 0 }); break;

View File

@ -48,7 +48,6 @@ enum class TypeTag {
Color,
Point,
Size,
Cursor,
Align,
Margins,
Font,
@ -135,7 +134,7 @@ public:
// Can be int / pixels.
Value(TypeTag type, int value);
// Can be string / transition / cursor / align.
// Can be string / align.
Value(TypeTag type, std::string value);
// Default constructed value (uninitialized).

View File

@ -160,7 +160,6 @@ historyViewsSendingInvertedIcon: icon {{ "dialogs_sending", #ffffffc8, point(3p
dialogsUpdateButton: FlatButton {
duration: 0;
cursor: cursor(pointer);
color: activeButtonFg;
overColor: activeButtonFgOver;

View File

@ -174,7 +174,6 @@ historyComposeField: FlatTextarea {
align: align(left);
textMrg: margins(5px, 5px, 5px, 5px);
font: msgFont;
cursor: cursor(text);
phColor: #999999;
phFocusColor: #aaaaaa;
@ -191,7 +190,6 @@ historySendRight: 2px;
historyComposeButton: FlatButton {
duration: 200;
cursor: cursor(pointer);
color: btnYesColor;
overColor: btnYesHover;
@ -334,7 +332,6 @@ historyInlineBotCancel: IconButton(historyReplyCancel) {
reportSpamHide: FlatButton {
duration: 200;
cursor: cursor(pointer);
color: btnYesColor;
overColor: btnYesHover;

View File

@ -36,6 +36,7 @@ public:
};
AbstractButton(QWidget *parent) : TWidget(parent) {
setCursor(style::cur_pointer);
}
enum {

View File

@ -22,6 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/buttons/peer_avatar_button.h"
#include "structs.h"
#include "ui/effects/ripple_animation.h"
#include "styles/style_boxes.h"
namespace Ui {
@ -38,4 +40,37 @@ void PeerAvatarButton::paintEvent(QPaintEvent *e) {
}
}
NewAvatarButton::NewAvatarButton(QWidget *parent, int size) : RippleButton(parent, st::defaultActiveButton.ripple) {
resize(size, size);
}
void NewAvatarButton::paintEvent(QPaintEvent *e) {
Painter p(this);
if (!_image.isNull()) {
p.drawPixmap(0, 0, _image);
return;
}
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setPen(Qt::NoPen);
p.setBrush((_state & StateOver) ? st::defaultActiveButton.textBgOver : st::defaultActiveButton.textBg);
p.drawEllipse(rect());
paintRipple(p, 0, 0, getms());
st::newGroupPhotoIcon.paint(p, st::newGroupPhotoIconPosition, width());
}
void NewAvatarButton::setImage(const QImage &image) {
auto small = image.scaled(size() * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
imageCircle(small);
_image = App::pixmapFromImageInPlace(std_::move(small));
_image.setDevicePixelRatio(cRetinaFactor());
update();
}
QImage NewAvatarButton::prepareRippleMask() const {
return Ui::RippleAnimation::ellipseMask(size());
}
} // namespace Ui

View File

@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "ui/abstract_button.h"
#include "ui/widgets/buttons.h"
#include "styles/style_window.h"
class PeerData;
@ -45,4 +45,20 @@ private:
};
class NewAvatarButton : public RippleButton {
public:
NewAvatarButton(QWidget *parent, int size);
void setImage(const QImage &image);
protected:
void paintEvent(QPaintEvent *e) override;
QImage prepareRippleMask() const override;
private:
QPixmap _image;
};
} // namespace Ui

View File

@ -200,6 +200,7 @@ CountrySelectBox::CountrySelectBox() : ItemListBox(st::countriesScroll, st::boxW
, _select(this, st::contactsMultiSelect, lang(lng_country_ph))
, _topShadow(this) {
_select->resizeToWidth(st::boxWidth);
setTitleText(lang(lng_country_select));
ItemListBox::init(_inner, st::boxScrollSkip, titleHeight() + _select->height());
@ -229,13 +230,6 @@ void CountrySelectBox::keyPressEvent(QKeyEvent *e) {
}
}
void CountrySelectBox::paintEvent(QPaintEvent *e) {
Painter p(this);
if (paint(p)) return;
paintTitle(p, lang(lng_country_select));
}
void CountrySelectBox::resizeEvent(QResizeEvent *e) {
ItemListBox::resizeEvent(e);

View File

@ -79,7 +79,6 @@ public slots:
protected:
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void doSetInnerFocus() override;

View File

@ -30,6 +30,7 @@ enum class ImageRoundRadius {
QImage imageBlur(QImage img);
void imageRound(QImage &img, ImageRoundRadius radius);
void imageCircle(QImage &img);
inline uint32 packInt(int32 a) {
return (a < 0) ? uint32(int64(a) + 0x100000000LL) : uint32(a);

View File

@ -142,7 +142,6 @@ FlatButton::FlatButton(QWidget *parent, const QString &text, const style::FlatBu
_width = _st.width;
}
resize(_width, _st.height);
setCursor(_st.cursor);
}
void FlatButton::setOpacity(float64 o) {

View File

@ -140,6 +140,7 @@ FlatTextarea::FlatTextarea(QWidget *parent, const style::FlatTextarea &st, const
, _a_appearance(animation(this, &FlatTextarea::step_appearance))
, _lastTextWithTags { v, tags }
, _st(st) {
setCursor(style::cur_text);
setAcceptRichText(false);
resize(_st.width, _st.font->height);
@ -1489,6 +1490,7 @@ FlatInput::FlatInput(QWidget *parent, const style::FlatInput &st, const QString
, _a_appearance(animation(this, &FlatInput::step_appearance))
, _notingBene(0)
, _st(st) {
setCursor(style::cur_text);
resize(_st.width, _st.height);
setFont(_st.font->f);

View File

@ -65,7 +65,6 @@ FlatButton {
font: font;
overFont: font;
duration: int;
cursor: cursor;
ripple: RippleAnimation;
}
@ -164,7 +163,6 @@ FlatTextarea {
textMrg: margins;
align: align;
font: font;
cursor: cursor;
phColor: color;
phFocusColor: color;
@ -183,7 +181,6 @@ FlatInput {
textMrg: margins;
align: align;
font: font;
cursor: cursor;
icon: icon;
@ -549,7 +546,6 @@ defaultFlatInput: FlatInput {
align: align(left);
textMrg: margins(5px, 5px, 5px, 5px);
font: defaultInputFont;
cursor: cursor(text);
borderWidth: 2px;
borderColor: #f2f2f2;