From 2e4426aac087be01f1b7b3cd4101520b1823d1b9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 28 Oct 2016 12:20:24 +0300 Subject: [PATCH] Old sprites removed completely. Only #rrggbb and #rrggbbaa in styles. Also moved Checkbox and Radiobutton to Ui namespace. Also child widgets in many boxes were wrapped in ChildWidget<>. --- Telegram/Resources/art/blank.gif | Bin 49 -> 0 bytes Telegram/Resources/art/sprite.png | Bin 775 -> 0 bytes Telegram/Resources/art/sprite_200x.png | Bin 2825 -> 0 bytes Telegram/Resources/basic.style | 120 ++-- Telegram/Resources/basic_types.style | 49 -- Telegram/Resources/telegram.qrc | 4 - Telegram/SourceFiles/app.cpp | 4 - Telegram/SourceFiles/app.h | 1 - Telegram/SourceFiles/boxes/addcontactbox.cpp | 533 +++++++++--------- Telegram/SourceFiles/boxes/addcontactbox.h | 65 ++- Telegram/SourceFiles/boxes/autolockbox.cpp | 3 +- Telegram/SourceFiles/boxes/autolockbox.h | 6 +- Telegram/SourceFiles/boxes/boxes.style | 8 +- Telegram/SourceFiles/boxes/confirmbox.cpp | 107 ++-- Telegram/SourceFiles/boxes/confirmbox.h | 29 +- Telegram/SourceFiles/boxes/connectionbox.cpp | 207 +++---- Telegram/SourceFiles/boxes/connectionbox.h | 37 +- Telegram/SourceFiles/boxes/contactsbox.cpp | 103 ++-- Telegram/SourceFiles/boxes/contactsbox.h | 16 +- .../SourceFiles/boxes/downloadpathbox.cpp | 68 +-- Telegram/SourceFiles/boxes/downloadpathbox.h | 14 +- Telegram/SourceFiles/boxes/languagebox.cpp | 13 +- Telegram/SourceFiles/boxes/languagebox.h | 6 +- Telegram/SourceFiles/boxes/photosendbox.cpp | 94 +-- Telegram/SourceFiles/boxes/photosendbox.h | 17 +- Telegram/SourceFiles/boxes/report_box.cpp | 1 + Telegram/SourceFiles/boxes/report_box.h | 12 +- .../SourceFiles/codegen/style/generator.cpp | 15 +- .../SourceFiles/codegen/style/options.cpp | 8 - Telegram/SourceFiles/codegen/style/options.h | 2 - .../SourceFiles/codegen/style/parsed_file.cpp | 81 +-- .../SourceFiles/codegen/style/parsed_file.h | 2 - .../SourceFiles/codegen/style/processor.cpp | 47 +- .../codegen/style/sprite_generator.cpp | 180 ------ .../codegen/style/sprite_generator.h | 57 -- .../codegen/style/structure_types.cpp | 15 - .../codegen/style/structure_types.h | 8 - Telegram/SourceFiles/dialogs/dialogs.style | 2 +- Telegram/SourceFiles/history/history.style | 4 +- .../SourceFiles/media/view/mediaview.style | 8 +- Telegram/SourceFiles/overview/overview.style | 10 +- .../profile/profile_settings_widget.cpp | 4 +- .../profile/profile_settings_widget.h | 5 +- .../settings/settings_background_widget.cpp | 1 + .../settings/settings_background_widget.h | 7 +- .../settings/settings_block_widget.cpp | 10 +- .../settings/settings_block_widget.h | 11 +- .../settings_chat_settings_widget.cpp | 1 + .../settings/settings_chat_settings_widget.h | 8 +- .../settings/settings_general_widget.cpp | 2 +- .../settings/settings_general_widget.h | 14 +- .../settings_notifications_widget.cpp | 2 +- .../settings/settings_notifications_widget.h | 12 +- .../settings/settings_scale_widget.cpp | 1 + .../settings/settings_scale_widget.h | 5 +- Telegram/SourceFiles/stickers/emoji_pan.cpp | 9 +- Telegram/SourceFiles/stickers/stickers.style | 6 +- .../checkbox.cpp} | 180 +----- .../ui/{flatcheckbox.h => buttons/checkbox.h} | 63 +-- Telegram/SourceFiles/ui/flatbutton.cpp | 103 ---- Telegram/SourceFiles/ui/flatbutton.h | 31 - Telegram/SourceFiles/ui/style/style_core.cpp | 2 - Telegram/SourceFiles/ui/style/style_core.h | 4 - .../SourceFiles/ui/style/style_core_types.cpp | 42 -- .../SourceFiles/ui/style/style_core_types.h | 47 -- Telegram/SourceFiles/ui/twidget.h | 43 -- Telegram/SourceFiles/ui/widgets/widgets.style | 6 +- Telegram/gyp/Telegram.gyp | 4 +- Telegram/gyp/codegen.gyp | 2 - Telegram/gyp/codegen_rules.gypi | 21 +- 70 files changed, 876 insertions(+), 1726 deletions(-) delete mode 100644 Telegram/Resources/art/blank.gif delete mode 100644 Telegram/Resources/art/sprite.png delete mode 100644 Telegram/Resources/art/sprite_200x.png delete mode 100644 Telegram/SourceFiles/codegen/style/sprite_generator.cpp delete mode 100644 Telegram/SourceFiles/codegen/style/sprite_generator.h rename Telegram/SourceFiles/ui/{flatcheckbox.cpp => buttons/checkbox.cpp} (69%) rename Telegram/SourceFiles/ui/{flatcheckbox.h => buttons/checkbox.h} (72%) diff --git a/Telegram/Resources/art/blank.gif b/Telegram/Resources/art/blank.gif deleted file mode 100644 index 75b945d2553848b8b6f41fe5e24599c0687b8472..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49 zcmZ?wbhEHbWMp7unE0RJ|Ns9C3=9Vj8~~DvKUo+V7?>DzfNY>Fh|Ltj$Y2csQN9XW diff --git a/Telegram/Resources/art/sprite.png b/Telegram/Resources/art/sprite.png deleted file mode 100644 index 5c0c7a7ac15a78aadeb00b712a4e2f958c7c724c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 775 zcmeAS@N?(olHy`uVBq!ia0y~yVC(_ny&P;n5jJ^8Ck6(lbDl1aAr*7po-^cSFyLS? zkaJPWo0Y~XDR4{PKsEJLlA@$}>QwcwQN>FVdQ&MBb@ E08Dllvj6}9 diff --git a/Telegram/Resources/art/sprite_200x.png b/Telegram/Resources/art/sprite_200x.png deleted file mode 100644 index 231f501d70b304e783546cafadf907d9a9e24491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2825 zcmeAS@N?(olHy`uVBq!ia0y~yV3q*lDh@V~h~s-x1_rJRo-U3d6?5L6GZbV{;9=Mp zwX&Y|J)fuyb7#{TpsGart/newmsg.wav art/bg.jpg art/bg0.png - art/sprite.png - art/sprite_125x.png - art/sprite_150x.png - art/sprite_200x.png art/icon256.png art/iconbig256.png diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index c44efaa90..475d302a6 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2370,10 +2370,6 @@ namespace { return ::monofont; } - const QPixmap &sprite() { - return style::spritePixmap(); - } - const QPixmap &emoji() { return *::emoji; } diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index ec27125c1..0181a1660 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -212,7 +212,6 @@ namespace App { void clearMousedItems(); const style::font &monofont(); - const QPixmap &sprite(); const QPixmap &emoji(); const QPixmap &emojiLarge(); const QPixmap &emojiSingle(EmojiPtr emoji, int32 fontHeight); diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index df76cbf67..33389489a 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -27,6 +27,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "confirmbox.h" #include "photocropbox.h" #include "ui/filedialog.h" +#include "ui/buttons/checkbox.h" #include "mainwidget.h" #include "mainwindow.h" #include "apiwrap.h" @@ -43,7 +44,7 @@ AddContactBox::AddContactBox(QString fname, QString lname, QString phone) : Abst , _phone(this, st::defaultInputField, lang(lng_contact_phone), phone) , _invertOrder(langFirstNameGoesSecond()) { if (!phone.isEmpty()) { - _phone.setDisabled(true); + _phone->setDisabled(true); } initBox(); @@ -58,47 +59,47 @@ AddContactBox::AddContactBox(UserData *user) : AbstractBox(st::boxWidth) , _last(this, st::defaultInputField, lang(lng_signup_lastname), user->lastName) , _phone(this, st::defaultInputField, lang(lng_contact_phone), user->phone()) , _invertOrder(langFirstNameGoesSecond()) { - _phone.setDisabled(true); + _phone->setDisabled(true); initBox(); } void AddContactBox::initBox() { if (_invertOrder) { - setTabOrder(&_last, &_first); + setTabOrder(_last, _first); } if (_user) { _boxTitle = lang(lng_edit_contact_title); } else { - bool readyToAdd = !_phone.getLastText().isEmpty() && (!_first.getLastText().isEmpty() || !_last.getLastText().isEmpty()); + bool readyToAdd = !_phone->getLastText().isEmpty() && (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty()); _boxTitle = lang(readyToAdd ? lng_confirm_contact_data : lng_enter_contact_data); } - setMaxHeight(st::boxTitleHeight + 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(); + setMaxHeight(st::boxTitleHeight + 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(); - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_retry, SIGNAL(clicked()), this, SLOT(onRetry())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_retry, SIGNAL(clicked()), this, SLOT(onRetry())); - connect(&_first, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_last, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_phone, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_first, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_last, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_phone, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); prepare(); } void AddContactBox::showAll() { - _first.show(); - _last.show(); - _phone.show(); - _save.show(); - _cancel.show(); + _first->show(); + _last->show(); + _phone->show(); + _save->show(); + _cancel->show(); } void AddContactBox::doSetInnerFocus() { - if ((_first.getLastText().isEmpty() && _last.getLastText().isEmpty()) || !_phone.isEnabled()) { - (_invertOrder ? _last : _first).setFocus(); + if ((_first->getLastText().isEmpty() && _last->getLastText().isEmpty()) || !_phone->isEnabled()) { + (_invertOrder ? _last : _first)->setFocus(); } else { - _phone.setFocus(); + _phone->setFocus(); } } @@ -108,47 +109,47 @@ void AddContactBox::paintEvent(QPaintEvent *e) { 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()); + 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()); } else { p.setPen(st::black->p); p.setFont(st::boxTextFont->f); - int32 h = height() - st::boxTitleHeight - st::contactPadding.top() - st::contactPadding.bottom() - st::boxPadding.bottom() - st::boxButtonPadding.top() - _retry.height() - st::boxButtonPadding.bottom(); + int32 h = height() - st::boxTitleHeight - st::contactPadding.top() - st::contactPadding.bottom() - st::boxPadding.bottom() - st::boxButtonPadding.top() - _retry->height() - st::boxButtonPadding.bottom(); p.drawText(QRect(st::boxPadding.left(), st::boxTitleHeight + st::contactPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), h), lng_contact_not_joined(lt_name, _sentName), style::al_topleft); } } void AddContactBox::resizeEvent(QResizeEvent *e) { - _first.resize(width() - st::boxPadding.left() - st::contactPadding.left() - st::boxPadding.right(), _first.height()); - _last.resize(_first.width(), _last.height()); - _phone.resize(_first.width(), _last.height()); + _first->resize(width() - st::boxPadding.left() - st::contactPadding.left() - st::boxPadding.right(), _first->height()); + _last->resize(_first->width(), _last->height()); + _phone->resize(_first->width(), _last->height()); if (_invertOrder) { - _last.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top()); - _first.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last.y() + _last.height() + st::contactSkip); - _phone.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first.y() + _first.height() + st::contactPhoneSkip); + _last->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top()); + _first->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last->y() + _last->height() + st::contactSkip); + _phone->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first->y() + _first->height() + st::contactPhoneSkip); } else { - _first.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top()); - _last.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first.y() + _first.height() + st::contactSkip); - _phone.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last.y() + _last.height() + st::contactPhoneSkip); + _first->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top()); + _last->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first->y() + _first->height() + st::contactSkip); + _phone->moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last->y() + _last->height() + st::contactPhoneSkip); } - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _retry.moveToRight(st::boxButtonPadding.right(), _save.y()); - _cancel.moveToRight(st::boxButtonPadding.right() + (_retry.isHidden() ? _save.width() : _retry.width()) + st::boxButtonPadding.left(), _save.y()); + _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height()); + _retry->moveToRight(st::boxButtonPadding.right(), _save->y()); + _cancel->moveToRight(st::boxButtonPadding.right() + (_retry->isHidden() ? _save->width() : _retry->width()) + st::boxButtonPadding.left(), _save->y()); AbstractBox::resizeEvent(e); } void AddContactBox::onSubmit() { - if (_first.hasFocus()) { - _last.setFocus(); - } else if (_last.hasFocus()) { - if (_phone.isEnabled()) { - _phone.setFocus(); + if (_first->hasFocus()) { + _last->setFocus(); + } else if (_last->hasFocus()) { + if (_phone->isEnabled()) { + _phone->setFocus(); } else { onSave(); } - } else if (_phone.hasFocus()) { + } else if (_phone->hasFocus()) { onSave(); } } @@ -156,21 +157,21 @@ void AddContactBox::onSubmit() { void AddContactBox::onSave() { if (_addRequest) return; - QString firstName = prepareText(_first.getLastText()); - QString lastName = prepareText(_last.getLastText()); - QString phone = _phone.getLastText().trimmed(); + QString firstName = prepareText(_first->getLastText()); + QString lastName = prepareText(_last->getLastText()); + QString phone = _phone->getLastText().trimmed(); if (firstName.isEmpty() && lastName.isEmpty()) { if (_invertOrder) { - _last.setFocus(); - _last.showError(); + _last->setFocus(); + _last->showError(); } else { - _first.setFocus(); - _first.showError(); + _first->setFocus(); + _first->showError(); } return; } else if (!_user && !App::isValidPhone(phone)) { - _phone.setFocus(); - _phone.showError(); + _phone->setFocus(); + _phone->showError(); return; } if (firstName.isEmpty()) { @@ -194,17 +195,17 @@ bool AddContactBox::onSaveUserFail(const RPCError &error) { _addRequest = 0; QString err(error.type()); - QString firstName = _first.getLastText().trimmed(), lastName = _last.getLastText().trimmed(); + QString firstName = _first->getLastText().trimmed(), lastName = _last->getLastText().trimmed(); if (err == "CHAT_TITLE_NOT_MODIFIED") { _user->setName(firstName, lastName, _user->nameOrPhone, _user->username); onClose(); return true; } else if (err == "NO_CHAT_TITLE") { - _first.setFocus(); - _first.showError(); + _first->setFocus(); + _first->showError(); return true; } - _first.setFocus(); + _first->setFocus(); return true; } @@ -226,11 +227,11 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) { Notify::userIsContactChanged(user, true); Ui::hideLayer(); } else { - _save.hide(); - _first.hide(); - _last.hide(); - _phone.hide(); - _retry.show(); + _save->hide(); + _first->hide(); + _last->hide(); + _phone->hide(); + _retry->show(); resizeEvent(0); update(); } @@ -245,17 +246,17 @@ void AddContactBox::onSaveUserDone(const MTPcontacts_ImportedContacts &res) { void AddContactBox::onRetry() { _addRequest = 0; _contactId = 0; - _save.show(); - _retry.hide(); + _save->show(); + _retry->hide(); resizeEvent(0); showAll(); - _first.setText(QString()); - _first.updatePlaceholder(); - _last.setText(QString()); - _last.updatePlaceholder(); - _phone.clearText(); - _phone.setDisabled(false); - _first.setFocus(); + _first->setText(QString()); + _first->updatePlaceholder(); + _last->setText(QString()); + _last->updatePlaceholder(); + _phone->clearText(); + _phone->setDisabled(false); + _first->setFocus(); update(); } @@ -268,19 +269,19 @@ _aboutChannel(st::normalFont, lang(lng_create_channel_about), _defaultOptions, _ _next(this, lang(lng_create_group_next), st::defaultBoxButton), _cancel(this, lang(lng_cancel), st::cancelBoxButton) { _aboutGroupHeight = _aboutGroup.countHeight(_aboutGroupWidth); - setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _group.height() + _aboutGroupHeight + st::newGroupSkip + _channel.height() + _aboutChannel.countHeight(_aboutGroupWidth) + st::newGroupPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _next.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _group->height() + _aboutGroupHeight + st::newGroupSkip + _channel->height() + _aboutChannel.countHeight(_aboutGroupWidth) + st::newGroupPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom()); - connect(&_next, SIGNAL(clicked()), this, SLOT(onNext())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_next, SIGNAL(clicked()), this, SLOT(onNext())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); prepare(); } void NewGroupBox::showAll() { - _group.show(); - _channel.show(); - _cancel.show(); - _next.show(); + _group->show(); + _channel->show(); + _cancel->show(); + _next->show(); } void NewGroupBox::keyPressEvent(QKeyEvent *e) { @@ -297,24 +298,24 @@ void NewGroupBox::paintEvent(QPaintEvent *e) { p.setPen(st::newGroupAboutFg->p); - QRect aboutGroup(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _group.y() + _group.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight); + QRect aboutGroup(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _group->y() + _group->height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight); _aboutGroup.drawLeft(p, aboutGroup.x(), aboutGroup.y(), aboutGroup.width(), width()); - QRect aboutChannel(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _channel.y() + _channel.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight); + QRect aboutChannel(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _channel->y() + _channel->height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight); _aboutChannel.drawLeft(p, aboutChannel.x(), aboutChannel.y(), aboutChannel.width(), width()); } void NewGroupBox::resizeEvent(QResizeEvent *e) { - _group.moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), st::boxPadding.top() + st::newGroupPadding.top()); - _channel.moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), _group.y() + _group.height() + _aboutGroupHeight + st::newGroupSkip); + _group->moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), st::boxPadding.top() + st::newGroupPadding.top()); + _channel->moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), _group->y() + _group->height() + _aboutGroupHeight + st::newGroupSkip); - _next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y()); + _next->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _next->width() + st::boxButtonPadding.left(), _next->y()); AbstractBox::resizeEvent(e); } void NewGroupBox::onNext() { - Ui::showLayer(new GroupInfoBox(_group.checked() ? CreatingGroupGroup : CreatingGroupChannel, true), KeepOtherLayers); + Ui::showLayer(new GroupInfoBox(_group->checked() ? CreatingGroupGroup : CreatingGroupChannel, true), KeepOtherLayers); } GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : AbstractBox(), @@ -330,20 +331,20 @@ _creationRequestId(0), _createdChannel(0) { setMouseTracking(true); - _title.setMaxLength(MaxGroupChannelTitle); + _title->setMaxLength(MaxGroupChannelTitle); - _description.setMaxLength(MaxChannelDescription); - _description.resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _description.height()); + _description->setMaxLength(MaxChannelDescription); + _description->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _description->height()); updateMaxHeight(); - connect(&_description, SIGNAL(resized()), this, SLOT(onDescriptionResized())); - connect(&_description, SIGNAL(submitted(bool)), this, SLOT(onNext())); - connect(&_description, SIGNAL(cancelled()), this, SLOT(onClose())); + connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized())); + connect(_description, SIGNAL(submitted(bool)), this, SLOT(onNext())); + connect(_description, SIGNAL(cancelled()), this, SLOT(onClose())); - connect(&_title, SIGNAL(submitted(bool)), this, SLOT(onNameSubmit())); + connect(_title, SIGNAL(submitted(bool)), this, SLOT(onNameSubmit())); - connect(&_next, SIGNAL(clicked()), this, SLOT(onNext())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_next, SIGNAL(clicked()), this, SLOT(onNext())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); @@ -353,18 +354,18 @@ _creationRequestId(0), _createdChannel(0) { } void GroupInfoBox::showAll() { - _title.show(); + _title->show(); if (_creating == CreatingGroupChannel) { - _description.show(); + _description->show(); } else { - _description.hide(); + _description->hide(); } - _cancel.show(); - _next.show(); + _cancel->show(); + _next->show(); } void GroupInfoBox::doSetInnerFocus() { - _title.setFocus(); + _title->setFocus(); } void GroupInfoBox::paintEvent(QPaintEvent *e) { @@ -400,13 +401,13 @@ void GroupInfoBox::paintEvent(QPaintEvent *e) { void GroupInfoBox::resizeEvent(QResizeEvent *e) { 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()); + _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()); - _description.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxPadding.top() + st::newGroupInfoPadding.top() + st::newGroupPhotoSize + st::newGroupDescriptionPadding.top()); + _description->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxPadding.top() + st::newGroupInfoPadding.top() + st::newGroupPhotoSize + st::newGroupDescriptionPadding.top()); - _next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y()); + _next->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _next->width() + st::boxButtonPadding.left(), _next->y()); AbstractBox::resizeEvent(e); } @@ -452,23 +453,23 @@ void GroupInfoBox::step_photoOver(float64 ms, bool timer) { } void GroupInfoBox::onNameSubmit() { - if (_title.getLastText().trimmed().isEmpty()) { - _title.setFocus(); - _title.showError(); - } else if (_description.isHidden()) { + if (_title->getLastText().trimmed().isEmpty()) { + _title->setFocus(); + _title->showError(); + } else if (_description->isHidden()) { onNext(); } else { - _description.setFocus(); + _description->setFocus(); } } void GroupInfoBox::onNext() { if (_creationRequestId) return; - QString title = prepareText(_title.getLastText()), description = prepareText(_description.getLastText(), true); + QString title = prepareText(_title->getLastText()), description = prepareText(_description->getLastText(), true); if (title.isEmpty()) { - _title.setFocus(); - _title.showError(); + _title->setFocus(); + _title->showError(); return; } if (_creating == CreatingGroupGroup) { @@ -513,8 +514,8 @@ bool GroupInfoBox::creationFail(const RPCError &error) { _creationRequestId = 0; if (error.type() == "NO_CHAT_TITLE") { - _title.setFocus(); - _title.showError(); + _title->setFocus(); + _title->showError(); return true; } else if (error.type() == qstr("USER_RESTRICTED")) { Ui::showLayer(new InformBox(lang(lng_cant_do_this))); @@ -541,9 +542,9 @@ QRect GroupInfoBox::photoRect() const { } 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(); + 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) { - h += st::newGroupDescriptionPadding.top() + _description.height() + st::newGroupDescriptionPadding.bottom(); + h += st::newGroupDescriptionPadding.top() + _description->height() + st::newGroupDescriptionPadding.bottom(); } setMaxHeight(h); } @@ -601,54 +602,54 @@ SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : Abstract _aboutPublicHeight = _aboutPublic.countHeight(_aboutPublicWidth); updateMaxHeight(); - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_skip, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_skip, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_link, SIGNAL(changed()), this, SLOT(onChange())); + connect(_link, SIGNAL(changed()), this, SLOT(onChange())); _checkTimer.setSingleShot(true); connect(&_checkTimer, SIGNAL(timeout()), this, SLOT(onCheck())); - connect(&_public, SIGNAL(changed()), this, SLOT(onPrivacyChange())); - connect(&_private, SIGNAL(changed()), this, SLOT(onPrivacyChange())); + connect(_public, SIGNAL(changed()), this, SLOT(onPrivacyChange())); + connect(_private, SIGNAL(changed()), this, SLOT(onPrivacyChange())); prepare(); } void SetupChannelBox::showAll() { - _public.show(); - _private.show(); - if (_public.checked()) { - _link.show(); + _public->show(); + _private->show(); + if (_public->checked()) { + _link->show(); } else { - _link.hide(); + _link->hide(); } - _save.show(); - _skip.show(); + _save->show(); + _skip->show(); } void SetupChannelBox::doSetInnerFocus() { - if (_link.isHidden()) { + if (_link->isHidden()) { setFocus(); } else { - _link.setFocus(); + _link->setFocus(); } } void SetupChannelBox::updateMaxHeight() { - if (!_channel->isMegagroup() || _public.checked()) { - setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top() + _link.height() + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom()); + if (!_channel->isMegagroup() || _public->checked()) { + setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public->height() + _aboutPublicHeight + st::newGroupSkip + _private->height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top() + _link->height() + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom()); } else { - setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPadding.top() + st::newGroupPadding.top() + _public->height() + _aboutPublicHeight + st::newGroupSkip + _private->height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom()); } } void SetupChannelBox::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { - if (_link.hasFocus()) { - if (_link.text().trimmed().isEmpty()) { - _link.setFocus(); - _link.showError(); + if (_link->hasFocus()) { + if (_link->text().trimmed().isEmpty()) { + _link->setFocus(); + _link->showError(); } else { onSave(); } @@ -664,19 +665,19 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) { p.setPen(st::newGroupAboutFg); - QRect aboutPublic(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _public.y() + _public.height(), _aboutPublicWidth, _aboutPublicHeight); + QRect aboutPublic(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _public->y() + _public->height(), _aboutPublicWidth, _aboutPublicHeight); _aboutPublic.drawLeft(p, aboutPublic.x(), aboutPublic.y(), aboutPublic.width(), width()); - QRect aboutPrivate(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _private.y() + _private.height(), _aboutPublicWidth, _aboutPublicHeight); + QRect aboutPrivate(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _private->y() + _private->height(), _aboutPublicWidth, _aboutPublicHeight); _aboutPrivate.drawLeft(p, aboutPrivate.x(), aboutPrivate.y(), aboutPrivate.width(), width()); - if (!_channel->isMegagroup() || !_link.isHidden()) { + if (!_channel->isMegagroup() || !_link->isHidden()) { p.setPen(st::black); p.setFont(st::newGroupLinkFont); - p.drawTextLeft(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, width(), lang(_link.isHidden() ? lng_create_group_invite_link : lng_create_group_link)); + p.drawTextLeft(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultInputField.textMargins.left(), _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop, width(), lang(_link->isHidden() ? lng_create_group_invite_link : lng_create_group_link)); } - if (_link.isHidden()) { + if (_link->isHidden()) { if (!_channel->isMegagroup()) { QTextOption option(style::al_left); option.setWrapMode(QTextOption::WrapAnywhere); @@ -687,7 +688,7 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) { p.setOpacity(a_goodOpacity.current()); p.setPen(st::setGoodColor); p.setFont(st::boxTextFont); - p.drawTextRight(st::boxPadding.right(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodTextLink); + p.drawTextRight(st::boxPadding.right(), _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodTextLink); p.setOpacity(1); } } @@ -695,25 +696,25 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) { if (!_errorText.isEmpty()) { p.setPen(st::setErrColor); p.setFont(st::boxTextFont); - p.drawTextRight(st::boxPadding.right(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _errorText); + p.drawTextRight(st::boxPadding.right(), _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _errorText); } else if (!_goodText.isEmpty()) { p.setPen(st::setGoodColor); p.setFont(st::boxTextFont); - p.drawTextRight(st::boxPadding.right(), _link.y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodText); + p.drawTextRight(st::boxPadding.right(), _link->y() - st::newGroupLinkPadding.top() + st::newGroupLinkTop + st::newGroupLinkFont->ascent - st::boxTextFont->ascent, width(), _goodText); } } } void SetupChannelBox::resizeEvent(QResizeEvent *e) { - _public.moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), st::boxPadding.top() + st::newGroupPadding.top()); - _private.moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), _public.y() + _public.height() + _aboutPublicHeight + st::newGroupSkip); + _public->moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), st::boxPadding.top() + st::newGroupPadding.top()); + _private->moveToLeft(st::boxPadding.left() + st::newGroupPadding.left(), _public->y() + _public->height() + _aboutPublicHeight + st::newGroupSkip); - _link.resize(width() - st::boxPadding.left() - st::newGroupLinkPadding.left() - st::boxPadding.right(), _link.height()); - _link.moveToLeft(st::boxPadding.left() + st::newGroupLinkPadding.left(), _private.y() + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top()); - _invitationLink = QRect(_link.x(), _link.y() + (_link.height() / 2) - st::boxTextFont->height, _link.width(), 2 * st::boxTextFont->height); + _link->resize(width() - st::boxPadding.left() - st::newGroupLinkPadding.left() - st::boxPadding.right(), _link->height()); + _link->moveToLeft(st::boxPadding.left() + st::newGroupLinkPadding.left(), _private->y() + _private->height() + _aboutPrivate.countHeight(_aboutPublicWidth) + st::newGroupSkip + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top()); + _invitationLink = QRect(_link->x(), _link->y() + (_link->height() / 2) - st::boxTextFont->height, _link->width(), 2 * st::boxTextFont->height); - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _skip.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height()); + _skip->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y()); AbstractBox::resizeEvent(e); } @@ -763,7 +764,7 @@ void SetupChannelBox::closePressed() { } void SetupChannelBox::onSave() { - if (!_public.checked()) { + if (!_public->checked()) { if (_existing) { _sentUsername = QString(); _saveRequestId = MTP::send(MTPchannels_UpdateUsername(_channel->inputChannel, MTP_string(_sentUsername)), rpcDone(&SetupChannelBox::onUpdateDone), rpcFail(&SetupChannelBox::onUpdateFail)); @@ -774,10 +775,10 @@ void SetupChannelBox::onSave() { if (_saveRequestId) return; - QString link = _link.text().trimmed(); + QString link = _link->text().trimmed(); if (link.isEmpty()) { - _link.setFocus(); - _link.showError(); + _link->setFocus(); + _link->showError(); return; } @@ -786,7 +787,7 @@ void SetupChannelBox::onSave() { } void SetupChannelBox::onChange() { - QString name = _link.text().trimmed(); + QString name = _link->text().trimmed(); if (name.isEmpty()) { if (!_errorText.isEmpty() || !_goodText.isEmpty()) { _errorText = _goodText = QString(); @@ -826,7 +827,7 @@ void SetupChannelBox::onCheck() { if (_checkRequestId) { MTP::cancel(_checkRequestId); } - QString link = _link.text().trimmed(); + QString link = _link->text().trimmed(); if (link.size() >= MinUsernameLength) { _checkUsername = link; _checkRequestId = MTP::send(MTPchannels_CheckUsername(_channel->inputChannel, MTP_string(link)), rpcDone(&SetupChannelBox::onCheckDone), rpcFail(&SetupChannelBox::onCheckFail)); @@ -834,21 +835,21 @@ void SetupChannelBox::onCheck() { } void SetupChannelBox::onPrivacyChange() { - if (_public.checked()) { + if (_public->checked()) { if (_tooMuchUsernames) { - _private.setChecked(true); + _private->setChecked(true); Ui::showLayer(new RevokePublicLinkBox([this, weak_this = weakThis()]() { if (!weak_this) return; _tooMuchUsernames = false; - _public.setChecked(true); + _public->setChecked(true); onCheck(); }), KeepOtherLayers); return; } - _link.show(); - _link.setFocus(); + _link->show(); + _link->setFocus(); } else { - _link.hide(); + _link->hide(); setFocus(); } if (_channel->isMegagroup()) { @@ -872,19 +873,19 @@ bool SetupChannelBox::onUpdateFail(const RPCError &error) { onClose(); return true; } else if (err == "USERNAME_INVALID") { - _link.setFocus(); - _link.showError(); + _link->setFocus(); + _link->showError(); _errorText = lang(lng_create_channel_link_invalid); update(); return true; } else if (err == "USERNAME_OCCUPIED" || err == "USERNAMES_UNAVAILABLE") { - _link.setFocus(); - _link.showError(); + _link->setFocus(); + _link->showError(); _errorText = lang(lng_create_channel_link_occupied); update(); return true; } - _link.setFocus(); + _link->setFocus(); return true; } @@ -912,7 +913,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) { showRevokePublicLinkBoxForEdit(); } else { _tooMuchUsernames = true; - _private.setChecked(true); + _private->setChecked(true); onPrivacyChange(); } return true; @@ -926,7 +927,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) { return true; } _goodText = QString(); - _link.setFocus(); + _link->setFocus(); return true; } @@ -950,13 +951,13 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) { showRevokePublicLinkBoxForEdit(); } else { _tooMuchUsernames = true; - _private.setChecked(true); + _private->setChecked(true); onPrivacyChange(); } return true; } _goodText = QString(); - _link.setFocus(); + _link->setFocus(); return true; } @@ -969,64 +970,64 @@ _last(this, st::defaultInputField, lang(lng_signup_lastname), peer->isUser() ? p _invertOrder(!peer->isChat() && langFirstNameGoesSecond()), _requestId(0) { if (_invertOrder) { - setTabOrder(&_last, &_first); + setTabOrder(_last, _first); } - _first.setMaxLength(MaxGroupChannelTitle); - _last.setMaxLength(MaxGroupChannelTitle); + _first->setMaxLength(MaxGroupChannelTitle); + _last->setMaxLength(MaxGroupChannelTitle); - int32 h = st::boxTitleHeight + st::contactPadding.top() + _first.height(); + int32 h = st::boxTitleHeight + st::contactPadding.top() + _first->height(); if (_peer->isUser()) { _boxTitle = lang(_peer == App::self() ? lng_edit_self_title : lng_edit_contact_title); - h += st::contactSkip + _last.height(); + h += st::contactSkip + _last->height(); } else if (_peer->isChat()) { _boxTitle = lang(lng_edit_group_title); } - h += st::boxPadding.bottom() + st::contactPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); + h += st::boxPadding.bottom() + st::contactPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); setMaxHeight(h); - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_first, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_last, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_first, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_last, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); prepare(); } void EditNameTitleBox::showAll() { - _first.show(); + _first->show(); if (_peer->isChat()) { - _last.hide(); + _last->hide(); } else { - _last.show(); + _last->show(); } - _save.show(); - _cancel.show(); + _save->show(); + _cancel->show(); } void EditNameTitleBox::doSetInnerFocus() { - (_invertOrder ? _last : _first).setFocus(); + (_invertOrder ? _last : _first)->setFocus(); } void EditNameTitleBox::onSubmit() { - if (_first.hasFocus()) { + if (_first->hasFocus()) { if (_peer->isChat()) { - if (_first.getLastText().trimmed().isEmpty()) { - _first.setFocus(); - _first.showError(); + if (_first->getLastText().trimmed().isEmpty()) { + _first->setFocus(); + _first->showError(); } else { onSave(); } } else { - _last.setFocus(); + _last->setFocus(); } - } else if (_last.hasFocus()) { - if (_first.getLastText().trimmed().isEmpty()) { - _first.setFocus(); - _first.showError(); - } else if (_last.getLastText().trimmed().isEmpty()) { - _last.setFocus(); - _last.showError(); + } else if (_last->hasFocus()) { + if (_first->getLastText().trimmed().isEmpty()) { + _first->setFocus(); + _first->showError(); + } else if (_last->getLastText().trimmed().isEmpty()) { + _last->setFocus(); + _last->showError(); } else { onSave(); } @@ -1041,32 +1042,32 @@ void EditNameTitleBox::paintEvent(QPaintEvent *e) { } void EditNameTitleBox::resizeEvent(QResizeEvent *e) { - _first.resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _first.height()); - _last.resize(_first.size()); + _first->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _first->height()); + _last->resize(_first->size()); if (_invertOrder) { - _last.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::contactPadding.top()); - _first.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _last.y() + _last.height() + st::contactSkip); + _last->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::contactPadding.top()); + _first->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _last->y() + _last->height() + st::contactSkip); } else { - _first.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::contactPadding.top()); - _last.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _first.y() + _first.height() + st::contactSkip); + _first->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::contactPadding.top()); + _last->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _first->y() + _first->height() + st::contactSkip); } - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _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 EditNameTitleBox::onSave() { if (_requestId) return; - QString first = prepareText(_first.getLastText()), last = prepareText(_last.getLastText()); + QString first = prepareText(_first->getLastText()), last = prepareText(_last->getLastText()); if (first.isEmpty() && last.isEmpty()) { if (_invertOrder) { - _last.setFocus(); - _last.showError(); + _last->setFocus(); + _last->showError(); } else { - _first.setFocus(); - _first.showError(); + _first->setFocus(); + _first->showError(); } return; } @@ -1092,21 +1093,21 @@ bool EditNameTitleBox::onSaveSelfFail(const RPCError &error) { if (MTP::isDefaultHandledError(error)) return false; QString err(error.type()); - QString first = textOneLine(_first.getLastText().trimmed()), last = textOneLine(_last.getLastText().trimmed()); + QString first = textOneLine(_first->getLastText().trimmed()), last = textOneLine(_last->getLastText().trimmed()); if (err == "NAME_NOT_MODIFIED") { App::self()->setName(first, last, QString(), textOneLine(App::self()->username)); onClose(); return true; } else if (err == "FIRSTNAME_INVALID") { - _first.setFocus(); - _first.showError(); + _first->setFocus(); + _first->showError(); return true; } else if (err == "LASTNAME_INVALID") { - _last.setFocus(); - _last.showError(); + _last->setFocus(); + _last->showError(); return true; } - _first.setFocus(); + _first->setFocus(); return true; } @@ -1122,11 +1123,11 @@ bool EditNameTitleBox::onSaveChatFail(const RPCError &error) { onClose(); return true; } else if (err == qstr("NO_CHAT_TITLE")) { - _first.setFocus(); - _first.showError(); + _first->setFocus(); + _first->showError(); return true; } - _first.setFocus(); + _first->setFocus(); return true; } @@ -1150,48 +1151,48 @@ EditChannelBox::EditChannelBox(ChannelData *channel) : AbstractBox() setMouseTracking(true); - _title.setMaxLength(MaxGroupChannelTitle); - _description.setMaxLength(MaxChannelDescription); - _description.resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _description.height()); - myEnsureResized(&_description); + _title->setMaxLength(MaxGroupChannelTitle); + _description->setMaxLength(MaxChannelDescription); + _description->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _description->height()); + myEnsureResized(_description); updateMaxHeight(); - connect(&_description, SIGNAL(resized()), this, SLOT(onDescriptionResized())); - connect(&_description, SIGNAL(submitted(bool)), this, SLOT(onSave())); - connect(&_description, SIGNAL(cancelled()), this, SLOT(onClose())); + connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized())); + connect(_description, SIGNAL(submitted(bool)), this, SLOT(onSave())); + connect(_description, SIGNAL(cancelled()), this, SLOT(onClose())); - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_publicLink, SIGNAL(clicked()), this, SLOT(onPublicLink())); + connect(_publicLink, SIGNAL(clicked()), this, SLOT(onPublicLink())); prepare(); } void EditChannelBox::showAll() { - _title.show(); - _description.show(); - _save.show(); - _cancel.show(); + _title->show(); + _description->show(); + _save->show(); + _cancel->show(); if (_channel->canEditUsername()) { - _publicLink.show(); + _publicLink->show(); } else { - _publicLink.hide(); + _publicLink->hide(); } if (_channel->isMegagroup()) { - _sign.hide(); + _sign->hide(); } else { - _sign.show(); + _sign->show(); } } void EditChannelBox::doSetInnerFocus() { - _title.setFocus(); + _title->setFocus(); } void EditChannelBox::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { - if (_title.hasFocus()) { + if (_title->hasFocus()) { onSave(); } } else { @@ -1208,8 +1209,8 @@ void EditChannelBox::paintEvent(QPaintEvent *e) { void EditChannelBox::peerUpdated(PeerData *peer) { if (peer == _channel) { - _publicLink.setText(lang(_channel->isPublic() ? lng_profile_edit_public_link : lng_profile_create_public_link)); - _sign.setChecked(_channel->addsSignature()); + _publicLink->setText(lang(_channel->isPublic() ? lng_profile_edit_public_link : lng_profile_create_public_link)); + _sign->setChecked(_channel->addsSignature()); } } @@ -1219,44 +1220,44 @@ void EditChannelBox::onDescriptionResized() { } void EditChannelBox::updateMaxHeight() { - int32 h = st::boxTitleHeight + st::newGroupInfoPadding.top() + _title.height(); - h += st::newGroupDescriptionPadding.top() + _description.height() + st::newGroupDescriptionPadding.bottom(); + int32 h = st::boxTitleHeight + st::newGroupInfoPadding.top() + _title->height(); + h += st::newGroupDescriptionPadding.top() + _description->height() + st::newGroupDescriptionPadding.bottom(); if (!_channel->isMegagroup()) { - h += st::newGroupPublicLinkPadding.top() + _sign.height() + st::newGroupPublicLinkPadding.bottom(); + h += st::newGroupPublicLinkPadding.top() + _sign->height() + st::newGroupPublicLinkPadding.bottom(); } if (_channel->canEditUsername()) { - h += st::newGroupPublicLinkPadding.top() + _publicLink.height() + st::newGroupPublicLinkPadding.bottom(); + h += st::newGroupPublicLinkPadding.top() + _publicLink->height() + st::newGroupPublicLinkPadding.bottom(); } - h += st::boxPadding.bottom() + st::newGroupInfoPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); + h += st::boxPadding.bottom() + st::newGroupInfoPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); setMaxHeight(h); } void EditChannelBox::resizeEvent(QResizeEvent *e) { - _title.resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _title.height()); - _title.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::newGroupInfoPadding.top() + st::newGroupNamePosition.y()); + _title->resize(width() - st::boxPadding.left() - st::newGroupInfoPadding.left() - st::boxPadding.right(), _title->height()); + _title->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), st::boxTitleHeight + st::newGroupInfoPadding.top() + st::newGroupNamePosition.y()); - _description.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _title.y() + _title.height() + st::newGroupDescriptionPadding.top()); + _description->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _title->y() + _title->height() + st::newGroupDescriptionPadding.top()); - _sign.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description.y() + _description.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); + _sign->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description->y() + _description->height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); if (_channel->isMegagroup()) { - _publicLink.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description.y() + _description.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); + _publicLink->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _description->y() + _description->height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); } else { - _publicLink.moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _sign.y() + _sign.height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); + _publicLink->moveToLeft(st::boxPadding.left() + st::newGroupInfoPadding.left(), _sign->y() + _sign->height() + st::newGroupDescriptionPadding.bottom() + st::newGroupPublicLinkPadding.top()); } - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _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 EditChannelBox::onSave() { if (_saveTitleRequestId || _saveDescriptionRequestId || _saveSignRequestId) return; - QString title = prepareText(_title.getLastText()), description = prepareText(_description.getLastText(), true); + QString title = prepareText(_title->getLastText()), description = prepareText(_description->getLastText(), true); if (title.isEmpty()) { - _title.setFocus(); - _title.showError(); + _title->setFocus(); + _title->showError(); return; } _sentTitle = title; @@ -1281,10 +1282,10 @@ void EditChannelBox::saveDescription() { } void EditChannelBox::saveSign() { - if (_channel->isMegagroup() || _channel->addsSignature() == _sign.checked()) { + if (_channel->isMegagroup() || _channel->addsSignature() == _sign->checked()) { onClose(); } else { - _saveSignRequestId = MTP::send(MTPchannels_ToggleSignatures(_channel->inputChannel, MTP_bool(_sign.checked())), rpcDone(&EditChannelBox::onSaveSignDone), rpcFail(&EditChannelBox::onSaveFail)); + _saveSignRequestId = MTP::send(MTPchannels_ToggleSignatures(_channel->inputChannel, MTP_bool(_sign->checked())), rpcDone(&EditChannelBox::onSaveSignDone), rpcFail(&EditChannelBox::onSaveFail)); } } @@ -1299,11 +1300,11 @@ bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) { saveDescription(); return true; } else if (err == qstr("NO_CHAT_TITLE")) { - _title.setFocus(); - _title.showError(); + _title->setFocus(); + _title->showError(); return true; } else { - _title.setFocus(); + _title->setFocus(); } } else if (req == _saveDescriptionRequestId) { _saveDescriptionRequestId = 0; @@ -1316,7 +1317,7 @@ bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) { saveSign(); return true; } else { - _description.setFocus(); + _description->setFocus(); } } else if (req == _saveSignRequestId) { _saveSignRequestId = 0; diff --git a/Telegram/SourceFiles/boxes/addcontactbox.h b/Telegram/SourceFiles/boxes/addcontactbox.h index 09a28dc5b..8ae48c95f 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.h +++ b/Telegram/SourceFiles/boxes/addcontactbox.h @@ -27,6 +27,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org class FlatLabel; class ConfirmBox; +namespace Ui { +class Checkbox; +class Radiobutton; +} // namespace Ui + class AddContactBox : public AbstractBox, public RPCSender { Q_OBJECT @@ -57,9 +62,13 @@ private: UserData *_user = nullptr; QString _boxTitle; - BoxButton _save, _cancel, _retry; - InputField _first, _last; - PhoneInput _phone; + ChildWidget _first; + ChildWidget _last; + ChildWidget _phone; + + ChildWidget _save; + ChildWidget _cancel; + ChildWidget _retry; bool _invertOrder; @@ -86,10 +95,14 @@ protected: void showAll() override; private: - Radiobutton _group, _channel; + ChildWidget _group; + ChildWidget _channel; + int32 _aboutGroupWidth, _aboutGroupHeight; Text _aboutGroup, _aboutChannel; - BoxButton _next, _cancel; + + ChildWidget _next; + ChildWidget _cancel; }; @@ -132,12 +145,14 @@ private: Animation _a_photoOver; bool _photoOver; - InputField _title; - InputArea _description; + ChildWidget _title; + ChildWidget _description; QImage _photoBig; QPixmap _photoSmall; - BoxButton _next, _cancel; + + ChildWidget _next; + ChildWidget _cancel; // channel creation int32 _creationRequestId; @@ -194,13 +209,17 @@ private: ChannelData *_channel; bool _existing; - Radiobutton _public, _private; + ChildWidget _public, _private; int32 _aboutPublicWidth, _aboutPublicHeight; Text _aboutPublic, _aboutPrivate; - UsernameInput _link; + + ChildWidget _link; + QRect _invitationLink; bool _linkOver; - BoxButton _save, _skip; + + ChildWidget _save; + ChildWidget _skip; bool _tooMuchUsernames = false; @@ -243,8 +262,11 @@ private: PeerData *_peer; QString _boxTitle; - BoxButton _save, _cancel; - InputField _first, _last; + ChildWidget _first; + ChildWidget _last; + + ChildWidget _save; + ChildWidget _cancel; bool _invertOrder; @@ -287,14 +309,19 @@ private: ChannelData *_channel; - BoxButton _save, _cancel; - InputField _title; - InputArea _description; - Checkbox _sign; + ChildWidget _title; + ChildWidget _description; + ChildWidget _sign; - LinkButton _publicLink; + ChildWidget _publicLink; + + ChildWidget _save; + ChildWidget _cancel; + + mtpRequestId _saveTitleRequestId; + mtpRequestId _saveDescriptionRequestId; + mtpRequestId _saveSignRequestId; - mtpRequestId _saveTitleRequestId, _saveDescriptionRequestId, _saveSignRequestId; QString _sentTitle, _sentDescription; }; diff --git a/Telegram/SourceFiles/boxes/autolockbox.cpp b/Telegram/SourceFiles/boxes/autolockbox.cpp index 238941a3a..b0fa448ce 100644 --- a/Telegram/SourceFiles/boxes/autolockbox.cpp +++ b/Telegram/SourceFiles/boxes/autolockbox.cpp @@ -27,6 +27,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "confirmbox.h" #include "mainwidget.h" #include "mainwindow.h" +#include "ui/buttons/checkbox.h" AutoLockBox::AutoLockBox() : _close(this, lang(lng_box_ok), st::defaultBoxButton) { @@ -41,7 +42,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) { _options.reserve(cnt); for (int32 i = 0; i < cnt; ++i) { int32 v = opts[i]; - _options.push_back(new Radiobutton(this, qsl("autolock"), v, (v % 3600) ? lng_passcode_autolock_minutes(lt_count, v / 60) : lng_passcode_autolock_hours(lt_count, v / 3600), (Global::AutoLock() == v), st::langsButton)); + _options.push_back(new Ui::Radiobutton(this, qsl("autolock"), v, (v % 3600) ? lng_passcode_autolock_minutes(lt_count, v / 60) : lng_passcode_autolock_hours(lt_count, v / 3600), (Global::AutoLock() == v), st::langsButton)); _options.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); y += _options.back()->height() + st::boxOptionListPadding.top(); connect(_options.back(), SIGNAL(changed()), this, SLOT(onChange())); diff --git a/Telegram/SourceFiles/boxes/autolockbox.h b/Telegram/SourceFiles/boxes/autolockbox.h index 075576ad0..b542042e4 100644 --- a/Telegram/SourceFiles/boxes/autolockbox.h +++ b/Telegram/SourceFiles/boxes/autolockbox.h @@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" +namespace Ui { +class Radiobutton; +} // namespace Ui + class AutoLockBox : public AbstractBox { Q_OBJECT @@ -37,7 +41,7 @@ protected: void showAll() override; private: - QVector _options; + QVector _options; BoxButton _close; }; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index c04b07c32..c055abfbf 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -120,8 +120,8 @@ contactsMultiSelect: MultiSelect { textBg: transparent; textMargins: margins(2px, 7px, 2px, 0px); - placeholderFg: #999; - placeholderFgActive: #aaa; + placeholderFg: #999999; + placeholderFgActive: #aaaaaa; placeholderMargins: margins(2px, 0px, 2px, 0px); border: 0px; @@ -203,7 +203,7 @@ notificationSampleTextFg: #d7d7d7; notificationSampleNameFg: #939393; membersAboutPadding: margins(0px, 12px, 0px, 12px); -membersAboutFg: #777; +membersAboutFg: #777777; sessionsScroll: flatScroll(boxScroll) { round: 2px; @@ -217,7 +217,7 @@ sessionCurrentHeight: 118px; sessionPadding: margins(21px, 10px, 21px, 0px); sessionNameFont: msgNameFont; sessionActiveFont: msgDateFont; -sessionActiveColor: #aaa; +sessionActiveColor: #aaaaaa; sessionInfoFont: msgFont; sessionInfoColor: #888888; sessionTerminateTop: 30px; diff --git a/Telegram/SourceFiles/boxes/confirmbox.cpp b/Telegram/SourceFiles/boxes/confirmbox.cpp index 25265a48a..47d17bf6b 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.cpp +++ b/Telegram/SourceFiles/boxes/confirmbox.cpp @@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwindow.h" #include "apiwrap.h" #include "application.h" +#include "ui/buttons/checkbox.h" #include "core/click_handler_types.h" #include "styles/style_boxes.h" #include "localstorage.h" @@ -56,10 +57,10 @@ ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const style void ConfirmBox::init(const QString &text) { _text.setText(st::boxTextFont, text, _informative ? _confirmBoxTextOptions : _textPlainOptions); - connect(&_confirm, SIGNAL(clicked()), this, SLOT(onConfirmPressed())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onCancel())); + connect(_confirm, SIGNAL(clicked()), this, SLOT(onConfirmPressed())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onCancel())); if (_informative) { - _cancel.hide(); + _cancel->hide(); connect(this, SIGNAL(confirmed()), this, SLOT(onCancel())); } onTextUpdated(); @@ -78,7 +79,7 @@ void ConfirmBox::onTextUpdated() { textstyleSet(&st::boxTextStyle); _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()); + setMaxHeight(st::boxPadding.top() + _textHeight + st::boxPadding.bottom() + st::boxButtonPadding.top() + _confirm->height() + st::boxButtonPadding.bottom()); textstyleRestore(); setMouseTracking(_text.hasLinks()); @@ -144,10 +145,10 @@ void ConfirmBox::closePressed() { void ConfirmBox::showAll() { if (_informative) { - _confirm.show(); + _confirm->show(); } else { - _confirm.show(); - _cancel.show(); + _confirm->show(); + _cancel->show(); } } @@ -171,8 +172,8 @@ void ConfirmBox::paintEvent(QPaintEvent *e) { } void ConfirmBox::resizeEvent(QResizeEvent *e) { - _confirm.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _confirm.width() + st::boxButtonPadding.left(), _confirm.y()); + _confirm->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _confirm->width() + st::boxButtonPadding.left(), _confirm->y()); AbstractBox::resizeEvent(e); } @@ -219,9 +220,9 @@ MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth) _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() + st::boxButtonPadding.top() + _close.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _close->height() + st::boxButtonPadding.bottom()); - connect(&_close, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_close, SIGNAL(clicked()), this, SLOT(onClose())); prepare(); } @@ -267,7 +268,7 @@ void MaxInviteBox::step_good(float64 ms, bool timer) { } void MaxInviteBox::showAll() { - _close.show(); + _close->show(); } void MaxInviteBox::paintEvent(QPaintEvent *e) { @@ -287,13 +288,13 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) { p.setOpacity(a_goodOpacity.current()); p.setPen(st::setGoodColor); p.setFont(st::boxTextFont); - p.drawTextLeft(st::boxPadding.left(), height() - st::boxButtonPadding.bottom() - _close.height() + st::defaultBoxButton.textTop + st::defaultBoxButton.font->ascent - st::boxTextFont->ascent, width(), _goodTextLink); + p.drawTextLeft(st::boxPadding.left(), height() - st::boxButtonPadding.bottom() - _close->height() + st::defaultBoxButton.textTop + st::defaultBoxButton.font->ascent - st::boxTextFont->ascent, width(), _goodTextLink); p.setOpacity(1); } } void MaxInviteBox::resizeEvent(QResizeEvent *e) { - _close.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close.height()); + _close->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close->height()); _invitationLink = myrtlrect(st::boxPadding.left(), st::boxPadding.top() + _textHeight + st::boxTextFont->height, width() - st::boxPadding.left() - st::boxPadding.right(), 2 * st::boxTextFont->height); AbstractBox::resizeEvent(e); } @@ -315,11 +316,11 @@ ConvertToSupergroupBox::ConvertToSupergroupBox(ChatData *chat) : AbstractBox(st: _note.setText(st::boxTextFont, lng_profile_convert_warning(lt_bold_start, textcmdStartSemibold(), lt_bold_end, textcmdStopSemibold()), _confirmBoxTextOptions); _textWidth = st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right(); _textHeight = _text.countHeight(_textWidth); - setMaxHeight(st::boxTitleHeight + _textHeight + st::boxPadding.bottom() + _note.countHeight(_textWidth) + st::boxButtonPadding.top() + _convert.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxTitleHeight + _textHeight + st::boxPadding.bottom() + _note.countHeight(_textWidth) + st::boxButtonPadding.top() + _convert->height() + st::boxButtonPadding.bottom()); textstyleRestore(); - connect(&_convert, SIGNAL(clicked()), this, SLOT(onConvert())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_convert, SIGNAL(clicked()), this, SLOT(onConvert())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); prepare(); } @@ -360,8 +361,8 @@ bool ConvertToSupergroupBox::convertFail(const RPCError &error) { } void ConvertToSupergroupBox::showAll() { - _convert.show(); - _cancel.show(); + _convert->show(); + _cancel->show(); } void ConvertToSupergroupBox::keyPressEvent(QKeyEvent *e) { @@ -387,8 +388,8 @@ void ConvertToSupergroupBox::paintEvent(QPaintEvent *e) { } void ConvertToSupergroupBox::resizeEvent(QResizeEvent *e) { - _convert.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _convert.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _convert.width() + st::boxButtonPadding.left(), _convert.y()); + _convert->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _convert->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _convert->width() + st::boxButtonPadding.left(), _convert->y()); AbstractBox::resizeEvent(e); } @@ -399,18 +400,18 @@ PinMessageBox::PinMessageBox(ChannelData *channel, MsgId msgId) : AbstractBox(st , _notify(this, lang(lng_pinned_notify), true, st::defaultBoxCheckbox) , _pin(this, lang(lng_pinned_pin), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { - _text.resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); - setMaxHeight(st::boxPadding.top() + _text.height() + st::boxMediumSkip + _notify.height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _pin.height() + st::boxButtonPadding.bottom()); + _text->resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); + setMaxHeight(st::boxPadding.top() + _text->height() + st::boxMediumSkip + _notify->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _pin->height() + st::boxButtonPadding.bottom()); - connect(&_pin, SIGNAL(clicked()), this, SLOT(onPin())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_pin, SIGNAL(clicked()), this, SLOT(onPin())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); } void PinMessageBox::resizeEvent(QResizeEvent *e) { - _text.moveToLeft(st::boxPadding.left(), st::boxPadding.top()); - _notify.moveToLeft(st::boxPadding.left(), _text.y() + _text.height() + st::boxMediumSkip); - _pin.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _pin.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _pin.width() + st::boxButtonPadding.left(), _pin.y()); + _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top()); + _notify->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); + _pin->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _pin->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _pin->width() + st::boxButtonPadding.left(), _pin->y()); AbstractBox::resizeEvent(e); } @@ -418,17 +419,17 @@ void PinMessageBox::onPin() { if (_requestId) return; MTPchannels_UpdatePinnedMessage::Flags flags = 0; - if (!_notify.checked()) { + if (!_notify->checked()) { flags |= MTPchannels_UpdatePinnedMessage::Flag::f_silent; } _requestId = MTP::send(MTPchannels_UpdatePinnedMessage(MTP_flags(flags), _channel->inputChannel, MTP_int(_msgId)), rpcDone(&PinMessageBox::pinDone), rpcFail(&PinMessageBox::pinFail)); } void PinMessageBox::showAll() { - _text.show(); - _notify.show(); - _pin.show(); - _cancel.show(); + _text->show(); + _notify->show(); + _pin->show(); + _cancel->show(); } void PinMessageBox::pinDone(const MTPUpdates &updates) { @@ -456,31 +457,31 @@ RichDeleteMessageBox::RichDeleteMessageBox(ChannelData *channel, UserData *from, , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { t_assert(_channel != nullptr); - _text.resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); - setMaxHeight(st::boxPadding.top() + _text.height() + st::boxMediumSkip + _banUser.height() + st::boxLittleSkip + _reportSpam.height() + st::boxLittleSkip + _deleteAll.height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _delete.height() + st::boxButtonPadding.bottom()); + _text->resizeToWidth(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()); + setMaxHeight(st::boxPadding.top() + _text->height() + st::boxMediumSkip + _banUser->height() + st::boxLittleSkip + _reportSpam->height() + st::boxLittleSkip + _deleteAll->height() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _delete->height() + st::boxButtonPadding.bottom()); - connect(&_delete, SIGNAL(clicked()), this, SLOT(onDelete())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_delete, SIGNAL(clicked()), this, SLOT(onDelete())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); } void RichDeleteMessageBox::resizeEvent(QResizeEvent *e) { - _text.moveToLeft(st::boxPadding.left(), st::boxPadding.top()); - _banUser.moveToLeft(st::boxPadding.left(), _text.y() + _text.height() + st::boxMediumSkip); - _reportSpam.moveToLeft(st::boxPadding.left(), _banUser.y() + _banUser.height() + st::boxLittleSkip); - _deleteAll.moveToLeft(st::boxPadding.left(), _reportSpam.y() + _reportSpam.height() + st::boxLittleSkip); - _delete.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _delete.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _delete.width() + st::boxButtonPadding.left(), _delete.y()); + _text->moveToLeft(st::boxPadding.left(), st::boxPadding.top()); + _banUser->moveToLeft(st::boxPadding.left(), _text->y() + _text->height() + st::boxMediumSkip); + _reportSpam->moveToLeft(st::boxPadding.left(), _banUser->y() + _banUser->height() + st::boxLittleSkip); + _deleteAll->moveToLeft(st::boxPadding.left(), _reportSpam->y() + _reportSpam->height() + st::boxLittleSkip); + _delete->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _delete->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _delete->width() + st::boxButtonPadding.left(), _delete->y()); AbstractBox::resizeEvent(e); } void RichDeleteMessageBox::onDelete() { - if (_banUser.checked()) { + if (_banUser->checked()) { MTP::send(MTPchannels_KickFromChannel(_channel->inputChannel, _from->inputUser, MTP_boolTrue()), App::main()->rpcDone(&MainWidget::sentUpdatesReceived)); } - if (_reportSpam.checked()) { + if (_reportSpam->checked()) { MTP::send(MTPchannels_ReportSpam(_channel->inputChannel, _from->inputUser, MTP_vector(1, MTP_int(_msgId)))); } - if (_deleteAll.checked()) { + if (_deleteAll->checked()) { App::main()->deleteAllFromUser(_channel, _from); } if (HistoryItem *item = App::histItemById(_channel ? peerToChannel(_channel->id) : 0, _msgId)) { @@ -497,12 +498,12 @@ void RichDeleteMessageBox::onDelete() { } void RichDeleteMessageBox::showAll() { - _text.show(); - _banUser.show(); - _reportSpam.show(); - _deleteAll.show(); - _delete.show(); - _cancel.show(); + _text->show(); + _banUser->show(); + _reportSpam->show(); + _deleteAll->show(); + _delete->show(); + _cancel->show(); } KickMemberBox::KickMemberBox(PeerData *chat, UserData *member) diff --git a/Telegram/SourceFiles/boxes/confirmbox.h b/Telegram/SourceFiles/boxes/confirmbox.h index ecd8525d3..38b545cdd 100644 --- a/Telegram/SourceFiles/boxes/confirmbox.h +++ b/Telegram/SourceFiles/boxes/confirmbox.h @@ -24,6 +24,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/flatlabel.h" #include "core/lambda_wrap.h" +namespace Ui { +class Checkbox; +} // namespace Ui + class InformBox; class ConfirmBox : public AbstractBox, public ClickHandlerHost { Q_OBJECT @@ -81,7 +85,8 @@ private: QPoint _lastMousePos; - BoxButton _confirm, _cancel; + ChildWidget _confirm; + ChildWidget _cancel; base::lambda_unique _confirmedCallback; @@ -159,7 +164,8 @@ private: void updateSelected(const QPoint &cursorGlobalPosition); void step_good(float64 ms, bool timer); - BoxButton _close; + ChildWidget _close; + Text _text; int32 _textWidth, _textHeight; @@ -199,7 +205,8 @@ private: Text _text, _note; int32 _textWidth, _textHeight; - BoxButton _convert, _cancel; + ChildWidget _convert; + ChildWidget _cancel; }; @@ -224,10 +231,11 @@ private: ChannelData *_channel; MsgId _msgId; - FlatLabel _text; - Checkbox _notify; + ChildWidget _text; + ChildWidget _notify; - BoxButton _pin, _cancel; + ChildWidget _pin; + ChildWidget _cancel; mtpRequestId _requestId = 0; @@ -252,10 +260,13 @@ private: UserData *_from; MsgId _msgId; - FlatLabel _text; - Checkbox _banUser, _reportSpam, _deleteAll; + ChildWidget _text; + ChildWidget _banUser; + ChildWidget _reportSpam; + ChildWidget _deleteAll; - BoxButton _delete, _cancel; + ChildWidget _delete; + ChildWidget _cancel; }; diff --git a/Telegram/SourceFiles/boxes/connectionbox.cpp b/Telegram/SourceFiles/boxes/connectionbox.cpp index cc9e59743..dfaf522b5 100644 --- a/Telegram/SourceFiles/boxes/connectionbox.cpp +++ b/Telegram/SourceFiles/boxes/connectionbox.cpp @@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "connectionbox.h" #include "mainwidget.h" #include "mainwindow.h" +#include "ui/buttons/checkbox.h" #include "history/history_location_manager.h" ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth) @@ -40,51 +41,51 @@ ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth) , _save(this, lang(lng_connection_save), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_autoRadio, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); + connect(_autoRadio, SIGNAL(changed()), this, SLOT(onChange())); + connect(_httpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); + connect(_tcpProxyRadio, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_hostInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_portInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); - connect(&_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_hostInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_portInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_userInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); + connect(_passwordInput, SIGNAL(submitted(bool)), this, SLOT(onSubmit())); prepare(); } void ConnectionBox::showAll() { - _autoRadio.show(); - _httpProxyRadio.show(); - _tcpProxyRadio.show(); - _tryIPv6.show(); + _autoRadio->show(); + _httpProxyRadio->show(); + _tcpProxyRadio->show(); + _tryIPv6->show(); - int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _autoRadio.height() + st::boxOptionListPadding.top() + _httpProxyRadio.height() + st::boxOptionListPadding.top() + _tcpProxyRadio.height() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6.height() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); - if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { - h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput.height(); - _hostInput.show(); - _portInput.show(); - _userInput.show(); - _passwordInput.show(); + int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _autoRadio->height() + st::boxOptionListPadding.top() + _httpProxyRadio->height() + st::boxOptionListPadding.top() + _tcpProxyRadio->height() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6->height() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); + if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) { + h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput->height(); + _hostInput->show(); + _portInput->show(); + _userInput->show(); + _passwordInput->show(); } else { - _hostInput.hide(); - _portInput.hide(); - _userInput.hide(); - _passwordInput.hide(); + _hostInput->hide(); + _portInput->hide(); + _userInput->hide(); + _passwordInput->hide(); } - _save.show(); - _cancel.show(); + _save->show(); + _cancel->show(); setMaxHeight(h); resizeEvent(0); } void ConnectionBox::doSetInnerFocus() { - if (!_hostInput.isHidden()) { - _hostInput.setFocus(); + if (!_hostInput->isHidden()) { + _hostInput->setFocus(); } } @@ -96,70 +97,70 @@ void ConnectionBox::paintEvent(QPaintEvent *e) { } void ConnectionBox::resizeEvent(QResizeEvent *e) { - _autoRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); - _httpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio.y() + _autoRadio.height() + st::boxOptionListPadding.top()); + _autoRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); + _httpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _autoRadio->y() + _autoRadio->height() + st::boxOptionListPadding.top()); int32 inputy = 0; - if (_httpProxyRadio.checked()) { - inputy = _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top(); - _tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput.height() + st::boxOptionListPadding.top()); + if (_httpProxyRadio->checked()) { + inputy = _httpProxyRadio->y() + _httpProxyRadio->height() + st::boxOptionListPadding.top(); + _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput->height() + st::boxOptionListPadding.top()); } else { - _tcpProxyRadio.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio.y() + _httpProxyRadio.height() + st::boxOptionListPadding.top()); - if (_tcpProxyRadio.checked()) { - inputy = _tcpProxyRadio.y() + _tcpProxyRadio.height() + st::boxOptionListPadding.top(); + _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio->y() + _httpProxyRadio->height() + st::boxOptionListPadding.top()); + if (_tcpProxyRadio->checked()) { + inputy = _tcpProxyRadio->y() + _tcpProxyRadio->height() + st::boxOptionListPadding.top(); } } if (inputy) { - _hostInput.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), 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::boxPadding.right(), _userInput.y()); + _hostInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x() - st::defaultInputField.textMargins.left(), 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::boxPadding.right(), _userInput->y()); } - int32 tryipv6y = (_tcpProxyRadio.checked() ? (_userInput.y() + _userInput.height()) : (_tcpProxyRadio.y() + _tcpProxyRadio.height())) + st::boxOptionListPadding.top() + st::connectionIPv6Skip; - _tryIPv6.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y); + int32 tryipv6y = (_tcpProxyRadio->checked() ? (_userInput->y() + _userInput->height()) : (_tcpProxyRadio->y() + _tcpProxyRadio->height())) + st::boxOptionListPadding.top() + st::connectionIPv6Skip; + _tryIPv6->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), tryipv6y); - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _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 ConnectionBox::onChange() { showAll(); - if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { - _hostInput.setFocus(); - if (_httpProxyRadio.checked() && !_portInput.getLastText().toInt()) { - _portInput.setText(qsl("80")); - _portInput.updatePlaceholder(); + if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) { + _hostInput->setFocus(); + if (_httpProxyRadio->checked() && !_portInput->getLastText().toInt()) { + _portInput->setText(qsl("80")); + _portInput->updatePlaceholder(); } } update(); } void ConnectionBox::onSubmit() { - if (_hostInput.hasFocus()) { - if (!_hostInput.getLastText().trimmed().isEmpty()) { - _portInput.setFocus(); + if (_hostInput->hasFocus()) { + if (!_hostInput->getLastText().trimmed().isEmpty()) { + _portInput->setFocus(); } else { - _hostInput.showError(); + _hostInput->showError(); } - } else if (_portInput.hasFocus()) { - if (_portInput.getLastText().trimmed().toInt() > 0) { - _userInput.setFocus(); + } else if (_portInput->hasFocus()) { + if (_portInput->getLastText().trimmed().toInt() > 0) { + _userInput->setFocus(); } else { - _portInput.showError(); + _portInput->showError(); } - } else if (_userInput.hasFocus()) { - _passwordInput.setFocus(); - } else if (_passwordInput.hasFocus()) { - if (_hostInput.getLastText().trimmed().isEmpty()) { - _hostInput.setFocus(); - _hostInput.showError(); - } else if (_portInput.getLastText().trimmed().toInt() <= 0) { - _portInput.setFocus(); - _portInput.showError(); + } else if (_userInput->hasFocus()) { + _passwordInput->setFocus(); + } else if (_passwordInput->hasFocus()) { + if (_hostInput->getLastText().trimmed().isEmpty()) { + _hostInput->setFocus(); + _hostInput->showError(); + } else if (_portInput->getLastText().trimmed().toInt() <= 0) { + _portInput->setFocus(); + _portInput->showError(); } else { onSave(); } @@ -167,20 +168,20 @@ void ConnectionBox::onSubmit() { } void ConnectionBox::onSave() { - if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) { + if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) { ProxyData p; - p.host = _hostInput.getLastText().trimmed(); - p.user = _userInput.getLastText().trimmed(); - p.password = _passwordInput.getLastText().trimmed(); - p.port = _portInput.getLastText().toInt(); + p.host = _hostInput->getLastText().trimmed(); + p.user = _userInput->getLastText().trimmed(); + p.password = _passwordInput->getLastText().trimmed(); + p.port = _portInput->getLastText().toInt(); if (p.host.isEmpty()) { - _hostInput.setFocus(); + _hostInput->setFocus(); return; } else if (!p.port) { - _portInput.setFocus(); + _portInput->setFocus(); return; } - if (_httpProxyRadio.checked()) { + if (_httpProxyRadio->checked()) { Global::SetConnectionType(dbictHttpProxy); } else { Global::SetConnectionType(dbictTcpProxy); @@ -194,8 +195,8 @@ void ConnectionBox::onSave() { QNetworkProxyFactory::setUseSystemConfiguration(true); #endif // !TDESKTOP_DISABLE_NETWORK_PROXY } - if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6.checked()) { - Global::SetTryIPv6(_tryIPv6.checked()); + if (cPlatform() == dbipWindows && Global::TryIPv6() != _tryIPv6->checked()) { + Global::SetTryIPv6(_tryIPv6->checked()); Local::writeSettings(); Global::RefConnectionTypeChanged().notify(); @@ -203,7 +204,7 @@ void ConnectionBox::onSave() { cSetRestartingToSettings(true); App::quit(); } else { - Global::SetTryIPv6(_tryIPv6.checked()); + Global::SetTryIPv6(_tryIPv6->checked()); Local::writeSettings(); Global::RefConnectionTypeChanged().notify(); @@ -226,25 +227,25 @@ AutoDownloadBox::AutoDownloadBox() : AbstractBox(st::boxWidth) , _save(this, lang(lng_connection_save), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { - setMaxHeight(3 * _sectionHeight + st::setLittleSkip + _gifPlay.height() + st::setLittleSkip + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom()); + setMaxHeight(3 * _sectionHeight + st::setLittleSkip + _gifPlay->height() + st::setLittleSkip + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom()); - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); prepare(); } void AutoDownloadBox::showAll() { - _photoPrivate.show(); - _photoGroups.show(); - _audioPrivate.show(); - _audioGroups.show(); - _gifPrivate.show(); - _gifGroups.show(); - _gifPlay.show(); + _photoPrivate->show(); + _photoGroups->show(); + _audioPrivate->show(); + _audioGroups->show(); + _gifPrivate->show(); + _gifGroups->show(); + _gifPlay->show(); - _save.show(); - _cancel.show(); + _save->show(); + _cancel->show(); } void AutoDownloadBox::paintEvent(QPaintEvent *e) { @@ -259,25 +260,25 @@ void AutoDownloadBox::paintEvent(QPaintEvent *e) { } void AutoDownloadBox::resizeEvent(QResizeEvent *e) { - _photoPrivate.moveToLeft(st::boxTitlePosition.x(), st::boxTitleHeight + st::setLittleSkip); - _photoGroups.moveToLeft(st::boxTitlePosition.x(), _photoPrivate.y() + _photoPrivate.height() + st::setLittleSkip); + _photoPrivate->moveToLeft(st::boxTitlePosition.x(), st::boxTitleHeight + st::setLittleSkip); + _photoGroups->moveToLeft(st::boxTitlePosition.x(), _photoPrivate->y() + _photoPrivate->height() + st::setLittleSkip); - _audioPrivate.moveToLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitleHeight + st::setLittleSkip); - _audioGroups.moveToLeft(st::boxTitlePosition.x(), _audioPrivate.y() + _audioPrivate.height() + st::setLittleSkip); + _audioPrivate->moveToLeft(st::boxTitlePosition.x(), _sectionHeight + st::boxTitleHeight + st::setLittleSkip); + _audioGroups->moveToLeft(st::boxTitlePosition.x(), _audioPrivate->y() + _audioPrivate->height() + st::setLittleSkip); - _gifPrivate.moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitleHeight + st::setLittleSkip); - _gifGroups.moveToLeft(st::boxTitlePosition.x(), _gifPrivate.y() + _gifPrivate.height() + st::setLittleSkip); - _gifPlay.moveToLeft(st::boxTitlePosition.x(), _gifGroups.y() + _gifGroups.height() + st::setLittleSkip); + _gifPrivate->moveToLeft(st::boxTitlePosition.x(), 2 * _sectionHeight + st::boxTitleHeight + st::setLittleSkip); + _gifGroups->moveToLeft(st::boxTitlePosition.x(), _gifPrivate->y() + _gifPrivate->height() + st::setLittleSkip); + _gifPlay->moveToLeft(st::boxTitlePosition.x(), _gifGroups->y() + _gifGroups->height() + st::setLittleSkip); - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _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 AutoDownloadBox::onSave() { bool changed = false; - int32 autoDownloadPhoto = (_photoPrivate.checked() ? 0 : dbiadNoPrivate) | (_photoGroups.checked() ? 0 : dbiadNoGroups); + int32 autoDownloadPhoto = (_photoPrivate->checked() ? 0 : dbiadNoPrivate) | (_photoGroups->checked() ? 0 : dbiadNoGroups); if (cAutoDownloadPhoto() != autoDownloadPhoto) { bool enabledPrivate = ((cAutoDownloadPhoto() & dbiadNoPrivate) && !(autoDownloadPhoto & dbiadNoPrivate)); bool enabledGroups = ((cAutoDownloadPhoto() & dbiadNoGroups) && !(autoDownloadPhoto & dbiadNoGroups)); @@ -290,7 +291,7 @@ void AutoDownloadBox::onSave() { } changed = true; } - int32 autoDownloadAudio = (_audioPrivate.checked() ? 0 : dbiadNoPrivate) | (_audioGroups.checked() ? 0 : dbiadNoGroups); + int32 autoDownloadAudio = (_audioPrivate->checked() ? 0 : dbiadNoPrivate) | (_audioGroups->checked() ? 0 : dbiadNoGroups); if (cAutoDownloadAudio() != autoDownloadAudio) { bool enabledPrivate = ((cAutoDownloadAudio() & dbiadNoPrivate) && !(autoDownloadAudio & dbiadNoPrivate)); bool enabledGroups = ((cAutoDownloadAudio() & dbiadNoGroups) && !(autoDownloadAudio & dbiadNoGroups)); @@ -305,7 +306,7 @@ void AutoDownloadBox::onSave() { } changed = true; } - int32 autoDownloadGif = (_gifPrivate.checked() ? 0 : dbiadNoPrivate) | (_gifGroups.checked() ? 0 : dbiadNoGroups); + int32 autoDownloadGif = (_gifPrivate->checked() ? 0 : dbiadNoPrivate) | (_gifGroups->checked() ? 0 : dbiadNoGroups); if (cAutoDownloadGif() != autoDownloadGif) { bool enabledPrivate = ((cAutoDownloadGif() & dbiadNoPrivate) && !(autoDownloadGif & dbiadNoPrivate)); bool enabledGroups = ((cAutoDownloadGif() & dbiadNoGroups) && !(autoDownloadGif & dbiadNoGroups)); @@ -320,8 +321,8 @@ void AutoDownloadBox::onSave() { } changed = true; } - if (cAutoPlayGif() != _gifPlay.checked()) { - cSetAutoPlayGif(_gifPlay.checked()); + if (cAutoPlayGif() != _gifPlay->checked()) { + cSetAutoPlayGif(_gifPlay->checked()); if (!cAutoPlayGif()) { App::stopGifItems(); } diff --git a/Telegram/SourceFiles/boxes/connectionbox.h b/Telegram/SourceFiles/boxes/connectionbox.h index 98f69e5b1..6d66477e6 100644 --- a/Telegram/SourceFiles/boxes/connectionbox.h +++ b/Telegram/SourceFiles/boxes/connectionbox.h @@ -22,6 +22,11 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" +namespace Ui { +class Checkbox; +class Radiobutton; +} // namespace Ui + class ConnectionBox : public AbstractBox { Q_OBJECT @@ -41,14 +46,17 @@ protected: void doSetInnerFocus() override; private: - InputField _hostInput; - PortInput _portInput; - InputField _userInput; - PasswordField _passwordInput; - Radiobutton _autoRadio, _httpProxyRadio, _tcpProxyRadio; - Checkbox _tryIPv6; + ChildWidget _hostInput; + ChildWidget _portInput; + ChildWidget _userInput; + ChildWidget _passwordInput; + ChildWidget _autoRadio; + ChildWidget _httpProxyRadio; + ChildWidget _tcpProxyRadio; + ChildWidget _tryIPv6; - BoxButton _save, _cancel; + ChildWidget _save; + ChildWidget _cancel; }; @@ -68,12 +76,17 @@ protected: void showAll() override; private: - Checkbox _photoPrivate, _photoGroups; - Checkbox _audioPrivate, _audioGroups; - Checkbox _gifPrivate, _gifGroups, _gifPlay; + ChildWidget _photoPrivate; + ChildWidget _photoGroups; + ChildWidget _audioPrivate; + ChildWidget _audioGroups; + ChildWidget _gifPrivate; + ChildWidget _gifGroups; + ChildWidget _gifPlay; - int32 _sectionHeight; + int _sectionHeight; - BoxButton _save, _cancel; + ChildWidget _save; + ChildWidget _cancel; }; diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 879935f68..e50d15116 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -30,6 +30,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwidget.h" #include "mainwindow.h" #include "application.h" +#include "ui/buttons/checkbox.h" #include "ui/filedialog.h" #include "ui/widgets/multi_select.h" #include "ui/effects/widget_slide_wrap.h" @@ -104,7 +105,7 @@ void ContactsBox::init() { auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat(); auto topSkip = getTopScrollSkip(); - auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next.height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; + auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; ItemListBox::init(_inner, bottomSkip, topSkip); connect(_inner, SIGNAL(addRequested()), App::wnd(), SLOT(onShowAddContact())); @@ -127,22 +128,22 @@ void ContactsBox::init() { }); if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) { - _next.hide(); - _cancel.hide(); + _next->hide(); + _cancel->hide(); } else if (_inner->chat() && _inner->membersFilter() == MembersFilter::Admins) { - connect(&_next, SIGNAL(clicked()), this, SLOT(onSaveAdmins())); - _bottomShadow = new ScrollableBoxShadow(this); + connect(_next, SIGNAL(clicked()), this, SLOT(onSaveAdmins())); + _bottomShadow.create(this); } else if (_inner->chat() || _inner->channel()) { - connect(&_next, SIGNAL(clicked()), this, SLOT(onInvite())); - _bottomShadow = new ScrollableBoxShadow(this); + connect(_next, SIGNAL(clicked()), this, SLOT(onInvite())); + _bottomShadow.create(this); } else if (_inner->creating() != CreatingGroupNone) { - connect(&_next, SIGNAL(clicked()), this, SLOT(onCreate())); - _bottomShadow = new ScrollableBoxShadow(this); + connect(_next, SIGNAL(clicked()), this, SLOT(onCreate())); + _bottomShadow.create(this); } else { - _next.hide(); - _cancel.hide(); + _next->hide(); + _cancel->hide(); } - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(scrollArea(), SIGNAL(scrolled()), this, SLOT(onScroll())); _select->entity()->setQueryChangedCallback([this](const QString &query) { onFilterUpdate(query); }); _select->entity()->setItemRemovedCallback([this](uint64 itemId) { @@ -237,19 +238,19 @@ void ContactsBox::showAll() { _select->showFast(); } if (_inner->channel() && _inner->membersFilter() == MembersFilter::Admins) { - _next.hide(); - _cancel.hide(); + _next->hide(); + _cancel->hide(); } else if (_inner->chat() || _inner->channel()) { - _next.show(); - _cancel.show(); + _next->show(); + _cancel->show(); } else if (_inner->creating() != CreatingGroupNone) { - _next.show(); - _cancel.show(); + _next->show(); + _cancel->show(); } else { - _next.hide(); - _cancel.hide(); + _next->hide(); + _cancel->hide(); } - _topShadow.show(); + _topShadow->show(); if (_bottomShadow) _bottomShadow->show(); ItemListBox::showAll(); } @@ -317,14 +318,14 @@ void ContactsBox::updateScrollSkips() { auto oldScrollHeight = scrollArea()->height(); auto inviting = (_inner->creating() == CreatingGroupGroup) || (_inner->channel() && _inner->membersFilter() == MembersFilter::Recent) || _inner->chat(); auto topSkip = getTopScrollSkip(); - auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next.height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; + auto bottomSkip = inviting ? (st::boxButtonPadding.top() + _next->height() + st::boxButtonPadding.bottom()) : st::boxScrollSkip; setScrollSkips(bottomSkip, topSkip); auto scrollHeightDelta = scrollArea()->height() - oldScrollHeight; if (scrollHeightDelta) { scrollArea()->scrollToY(scrollArea()->scrollTop() - scrollHeightDelta); } - _topShadow.setGeometry(0, topSkip, width(), st::lineWidth); + _topShadow->setGeometry(0, topSkip, width(), st::lineWidth); } void ContactsBox::resizeEvent(QResizeEvent *e) { @@ -336,9 +337,9 @@ void ContactsBox::resizeEvent(QResizeEvent *e) { updateScrollSkips(); _inner->resize(width(), _inner->height()); - _next.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _next.width() + st::boxButtonPadding.left(), _next.y()); - if (_bottomShadow) _bottomShadow->setGeometry(0, height() - st::boxButtonPadding.bottom() - _next.height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth); + _next->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _next->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _next->width() + st::boxButtonPadding.left(), _next->y()); + if (_bottomShadow) _bottomShadow->setGeometry(0, height() - st::boxButtonPadding.bottom() - _next->height() - st::boxButtonPadding.top() - st::lineWidth, width(), st::lineWidth); } void ContactsBox::closePressed() { @@ -647,8 +648,8 @@ ContactsBox::Inner::Inner(QWidget *parent, UserData *bot) : TWidget(parent) void ContactsBox::Inner::init() { subscribe(FileDownload::ImageLoaded(), [this] { update(); }); - connect(&_addContactLnk, SIGNAL(clicked()), App::wnd(), SLOT(onShowAddContact())); - connect(&_allAdmins, SIGNAL(changed()), this, SLOT(onAllAdminsChanged())); + connect(_addContactLnk, SIGNAL(clicked()), App::wnd(), SLOT(onShowAddContact())); + connect(_allAdmins, SIGNAL(changed()), this, SLOT(onAllAdminsChanged())); setAttribute(Qt::WA_OpaquePaintEvent); @@ -676,7 +677,7 @@ void ContactsBox::Inner::initList() { for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { if (i.key()->id == peerFromUser(_chat->creator)) continue; - if (!_allAdmins.checked() && _chat->admins.contains(i.key())) { + if (!_allAdmins->checked() && _chat->admins.contains(i.key())) { admins.push_back(i.key()); if (!_checkedContacts.contains(i.key())) { _checkedContacts.insert(i.key()); @@ -743,8 +744,8 @@ void ContactsBox::Inner::onNoAddAdminBox(QObject *obj) { } void ContactsBox::Inner::onAllAdminsChanged() { - if (_saving && _allAdmins.checked() != _allAdminsChecked) { - _allAdmins.setChecked(_allAdminsChecked); + if (_saving && _allAdmins->checked() != _allAdminsChecked) { + _allAdmins->setChecked(_allAdminsChecked); } else if (_allAdminsChangedCallback) { _allAdminsChangedCallback(); } @@ -797,7 +798,7 @@ bool ContactsBox::Inner::addAdminFail(const RPCError &error, mtpRequestId req) { void ContactsBox::Inner::saving(bool flag) { _saving = flag; - _allAdminsChecked = _allAdmins.checked(); + _allAdminsChecked = _allAdmins->checked(); update(); } @@ -933,7 +934,7 @@ void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, Cont UserData *user = peer->asUser(); if (_chat && _membersFilter == MembersFilter::Admins) { - if (_allAdmins.checked() || peer->id == peerFromUser(_chat->creator) || _saving) { + if (_allAdmins->checked() || peer->id == peerFromUser(_chat->creator) || _saving) { sel = false; } } else { @@ -944,7 +945,7 @@ void ContactsBox::Inner::paintDialog(Painter &p, uint64 ms, PeerData *peer, Cont auto paintDisabledCheck = data->disabledChecked; if (_chat && _membersFilter == MembersFilter::Admins) { - if (peer->id == peerFromUser(_chat->creator) || _allAdmins.checked()) { + if (peer->id == peerFromUser(_chat->creator) || _allAdmins->checked()) { paintDisabledCheck = true; } } @@ -1059,7 +1060,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { p.setPen(st::black); p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins)); int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right(); - (_allAdmins.checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); + (_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); } else { p.fillRect(0, 0, width(), st::contactsNewItemHeight, (_newItemSel ? st::contactsBgOver : st::white)->b); p.setFont(st::contactsNameFont); @@ -1114,7 +1115,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { p.setPen(st::black); p.drawTextLeft(st::contactsPadding.left(), st::contactsNewItemTop, width(), lang(lng_chat_all_members_admins)); int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right(); - (_allAdmins.checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); + (_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsNewItemHeight + st::contactsAboutTop, aboutw); p.translate(0, _newItemHeight); } else if (cContactsReceived() && !_searching) { text = lang(lng_no_contacts); @@ -1383,7 +1384,7 @@ void ContactsBox::Inner::changeCheckState(Dialogs::Row *row) { void ContactsBox::Inner::changeCheckState(ContactData *data, PeerData *peer) { t_assert(usingMultiSelect()); - if (_chat && _membersFilter == MembersFilter::Admins && _allAdmins.checked()) { + if (_chat && _membersFilter == MembersFilter::Admins && _allAdmins->checked()) { } else if (data->checkbox->checked()) { changePeerCheckState(data, peer, false); } else if (selectedCount() < ((_channel && _channel->isMegagroup()) ? Global::MegagroupSizeMax() : Global::ChatSizeMax())) { @@ -1499,8 +1500,8 @@ void ContactsBox::Inner::updateFilter(QString filter) { _sel = 0; refresh(); } else { - if (!_addContactLnk.isHidden()) _addContactLnk.hide(); - if (!_allAdmins.isHidden()) _allAdmins.hide(); + if (!_addContactLnk->isHidden()) _addContactLnk->hide(); + if (!_allAdmins->isHidden()) _allAdmins->hide(); QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi; _filtered.clear(); @@ -1678,28 +1679,28 @@ void ContactsBox::Inner::peopleReceived(const QString &query, const QVectorisHidden()) _allAdmins->show(); } else { - if (!_allAdmins.isHidden()) _allAdmins.hide(); + if (!_allAdmins->isHidden()) _allAdmins->hide(); } if (!_contacts->isEmpty() || !_byUsername.isEmpty()) { - if (!_addContactLnk.isHidden()) _addContactLnk.hide(); + if (!_addContactLnk->isHidden()) _addContactLnk->hide(); resize(width(), _newItemHeight + (_contacts->size() * _rowHeight) + (_byUsername.isEmpty() ? 0 : (st::searchedBarHeight + _byUsername.size() * _rowHeight))); } else if (_chat && _membersFilter == MembersFilter::Admins) { - if (!_addContactLnk.isHidden()) _addContactLnk.hide(); + if (!_addContactLnk->isHidden()) _addContactLnk->hide(); resize(width(), _newItemHeight + st::noContactsHeight); } else { if (cContactsReceived() && !bot()) { - if (_addContactLnk.isHidden()) _addContactLnk.show(); + if (_addContactLnk->isHidden()) _addContactLnk->show(); } else { - if (!_addContactLnk.isHidden()) _addContactLnk.hide(); + if (!_addContactLnk->isHidden()) _addContactLnk->hide(); } resize(width(), st::noContactsHeight); } } else { - if (!_allAdmins.isHidden()) _allAdmins.hide(); + if (!_allAdmins->isHidden()) _allAdmins->hide(); if (_filtered.isEmpty() && _byUsernameFiltered.isEmpty()) { - if (!_addContactLnk.isHidden()) _addContactLnk.hide(); + if (!_addContactLnk->isHidden()) _addContactLnk->hide(); resize(width(), st::noContactsHeight); } else { resize(width(), (_filtered.size() * _rowHeight) + (_byUsernameFiltered.isEmpty() ? 0 : (st::searchedBarHeight + _byUsernameFiltered.size() * _rowHeight))); @@ -1745,8 +1746,8 @@ ContactsBox::Inner::~Inner() { } void ContactsBox::Inner::resizeEvent(QResizeEvent *e) { - _addContactLnk.move((width() - _addContactLnk.width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2); - _allAdmins.moveToLeft(st::contactsPadding.left(), st::contactsNewItemTop); + _addContactLnk->move((width() - _addContactLnk->width()) / 2, (st::noContactsHeight + st::noContactsFont->height) / 2); + _allAdmins->moveToLeft(st::contactsPadding.left(), st::contactsNewItemTop); } void ContactsBox::Inner::selectSkip(int32 dir) { @@ -1940,3 +1941,7 @@ QVector ContactsBox::Inner::selectedInputs() { } return result; } + +bool ContactsBox::Inner::allAdmins() const { + return _allAdmins->checked(); +} diff --git a/Telegram/SourceFiles/boxes/contactsbox.h b/Telegram/SourceFiles/boxes/contactsbox.h index c56f97b50..d0020347b 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.h +++ b/Telegram/SourceFiles/boxes/contactsbox.h @@ -31,6 +31,7 @@ class IndexedList; } // namespace Dialogs namespace Ui { +class Checkbox; class MultiSelect; template class WidgetSlideWrap; @@ -91,11 +92,12 @@ private: ChildWidget _inner; ChildWidget> _select; - BoxButton _next, _cancel; + ChildWidget _next; + ChildWidget _cancel; MembersFilter _membersFilter; - ScrollableBoxShadow _topShadow; - ScrollableBoxShadow *_bottomShadow = nullptr; + ChildWidget _topShadow; + ChildWidget _bottomShadow = { nullptr }; void peopleReceived(const MTPcontacts_Found &result, mtpRequestId req); bool peopleFailed(const RPCError &error, mtpRequestId req); @@ -152,9 +154,7 @@ public: QVector selected(); QVector selectedInputs(); - bool allAdmins() const { - return _allAdmins.checked(); - } + bool allAdmins() const; void setAllAdminsChangedCallback(base::lambda_unique allAdminsChangedCallback) { _allAdminsChangedCallback = std_::move(allAdminsChangedCallback); } @@ -263,7 +263,7 @@ private: CreatingGroupType _creating = CreatingGroupNone; MembersAlreadyIn _already; - Checkbox _allAdmins; + ChildWidget _allAdmins; int32 _aboutWidth; Text _aboutAllAdmins, _aboutAdmins; base::lambda_unique _allAdminsChangedCallback; @@ -301,7 +301,7 @@ private: int _byUsernameSel = -1; QPoint _lastMousePos; - LinkButton _addContactLnk; + ChildWidget _addContactLnk; bool _saving = false; bool _allAdminsChecked = false; diff --git a/Telegram/SourceFiles/boxes/downloadpathbox.cpp b/Telegram/SourceFiles/boxes/downloadpathbox.cpp index 980263537..b680a07b5 100644 --- a/Telegram/SourceFiles/boxes/downloadpathbox.cpp +++ b/Telegram/SourceFiles/boxes/downloadpathbox.cpp @@ -19,12 +19,12 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" +#include "boxes/downloadpathbox.h" + #include "lang.h" - #include "localstorage.h" - -#include "downloadpathbox.h" #include "ui/filedialog.h" +#include "ui/buttons/checkbox.h" #include "pspecific.h" DownloadPathBox::DownloadPathBox() : AbstractBox() @@ -37,14 +37,14 @@ DownloadPathBox::DownloadPathBox() : AbstractBox() , _save(this, lang(lng_connection_save), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - connect(&_default, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_temp, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_dir, SIGNAL(changed()), this, SLOT(onChange())); + connect(_default, SIGNAL(changed()), this, SLOT(onChange())); + connect(_temp, SIGNAL(changed()), this, SLOT(onChange())); + connect(_dir, SIGNAL(changed()), this, SLOT(onChange())); - connect(&_pathLink, SIGNAL(clicked()), this, SLOT(onEditPath())); + connect(_pathLink, SIGNAL(clicked()), this, SLOT(onEditPath())); if (!_path.isEmpty() && _path != qsl("tmp")) { setPathText(QDir::toNativeSeparators(_path)); } @@ -52,22 +52,22 @@ DownloadPathBox::DownloadPathBox() : AbstractBox() } void DownloadPathBox::showAll() { - _default.show(); - _temp.show(); - _dir.show(); + _default->show(); + _temp->show(); + _dir->show(); - if (_dir.checked()) { - _pathLink.show(); + if (_dir->checked()) { + _pathLink->show(); } else { - _pathLink.hide(); + _pathLink->hide(); } - _save.show(); - _cancel.show(); + _save->show(); + _cancel->show(); - int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _default.height() + st::boxOptionListPadding.top() + _temp.height() + st::boxOptionListPadding.top() + _dir.height(); - if (_dir.checked()) h += st::downloadPathSkip + _pathLink.height(); - h += st::boxOptionListPadding.bottom() + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); + int32 h = st::boxTitleHeight + st::boxOptionListPadding.top() + _default->height() + st::boxOptionListPadding.top() + _temp->height() + st::boxOptionListPadding.top() + _dir->height(); + if (_dir->checked()) h += st::downloadPathSkip + _pathLink->height(); + h += st::boxOptionListPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); setMaxHeight(h); } @@ -80,31 +80,31 @@ void DownloadPathBox::paintEvent(QPaintEvent *e) { } void DownloadPathBox::resizeEvent(QResizeEvent *e) { - _default.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); - _temp.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _default.y() + _default.height() + st::boxOptionListPadding.top()); - _dir.moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _temp.y() + _temp.height() + st::boxOptionListPadding.top()); + _default->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), st::boxTitleHeight + st::boxOptionListPadding.top()); + _temp->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _default->y() + _default->height() + st::boxOptionListPadding.top()); + _dir->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _temp->y() + _temp->height() + st::boxOptionListPadding.top()); int32 inputx = st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultRadiobutton.textPosition.x(); - int32 inputy = _dir.y() + _dir.height() + st::downloadPathSkip; + int32 inputy = _dir->y() + _dir->height() + st::downloadPathSkip; - _pathLink.moveToLeft(inputx, inputy); + _pathLink->moveToLeft(inputx, inputy); - _save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height()); - _cancel.moveToRight(st::boxButtonPadding.right() + _save.width() + st::boxButtonPadding.left(), _save.y()); + _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 DownloadPathBox::onChange() { - if (_dir.checked()) { + if (_dir->checked()) { if (_path.isEmpty() || _path == qsl("tmp")) { - (_path.isEmpty() ? _default : _temp).setChecked(true); + (_path.isEmpty() ? _default : _temp)->setChecked(true); onEditPath(); if (!_path.isEmpty() && _path != qsl("tmp")) { - _dir.setChecked(true); + _dir->setChecked(true); } } else { setPathText(QDir::toNativeSeparators(_path)); } - } else if (_temp.checked()) { + } else if (_temp->checked()) { _path = qsl("tmp"); } else { _path = QString(); @@ -130,8 +130,8 @@ void DownloadPathBox::onEditPath() { } void DownloadPathBox::onSave() { - Global::SetDownloadPath(_default.checked() ? QString() : (_temp.checked() ? qsl("tmp") : _path)); - Global::SetDownloadPathBookmark((_default.checked() || _temp.checked()) ? QByteArray() : _pathBookmark); + Global::SetDownloadPath(_default->checked() ? QString() : (_temp->checked() ? qsl("tmp") : _path)); + Global::SetDownloadPathBookmark((_default->checked() || _temp->checked()) ? QByteArray() : _pathBookmark); Local::writeUserSettings(); Global::RefDownloadPathChanged().notify(); onClose(); @@ -139,5 +139,5 @@ void DownloadPathBox::onSave() { void DownloadPathBox::setPathText(const QString &text) { int32 availw = st::boxWideWidth - st::boxPadding.left() - st::defaultRadiobutton.textPosition.x() - st::boxPadding.right(); - _pathLink.setText(st::boxTextFont->elided(text, availw)); + _pathLink->setText(st::boxTextFont->elided(text, availw)); } diff --git a/Telegram/SourceFiles/boxes/downloadpathbox.h b/Telegram/SourceFiles/boxes/downloadpathbox.h index 7c4f26a3b..a0fdfe5fd 100644 --- a/Telegram/SourceFiles/boxes/downloadpathbox.h +++ b/Telegram/SourceFiles/boxes/downloadpathbox.h @@ -23,6 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" #include "core/observer.h" +namespace Ui { +class Radiobutton; +} // namespace Ui + class DownloadPathBox : public AbstractBox { Q_OBJECT @@ -46,8 +50,12 @@ private: QString _path; QByteArray _pathBookmark; - Radiobutton _default, _temp, _dir; - LinkButton _pathLink; - BoxButton _save, _cancel; + ChildWidget _default; + ChildWidget _temp; + ChildWidget _dir; + ChildWidget _pathLink; + + ChildWidget _save; + ChildWidget _cancel; }; diff --git a/Telegram/SourceFiles/boxes/languagebox.cpp b/Telegram/SourceFiles/boxes/languagebox.cpp index f79bdaed6..15fafe9ba 100644 --- a/Telegram/SourceFiles/boxes/languagebox.cpp +++ b/Telegram/SourceFiles/boxes/languagebox.cpp @@ -19,15 +19,14 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" +#include "boxes/languagebox.h" + #include "lang.h" - +#include "ui/buttons/checkbox.h" #include "localstorage.h" - -#include "languagebox.h" -#include "confirmbox.h" +#include "boxes/confirmbox.h" #include "mainwidget.h" #include "mainwindow.h" - #include "langloaderplain.h" LanguageBox::LanguageBox() : @@ -38,7 +37,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) { int32 y = st::boxTitleHeight + st::boxOptionListPadding.top(); _langs.reserve(languageCount + (haveTestLang ? 1 : 0)); if (haveTestLang) { - _langs.push_back(new Radiobutton(this, qsl("lang"), languageTest, qsl("Custom Lang"), (cLang() == languageTest), st::langsButton)); + _langs.push_back(new Ui::Radiobutton(this, qsl("lang"), languageTest, qsl("Custom Lang"), (cLang() == languageTest), st::langsButton)); _langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); y += _langs.back()->height() + st::boxOptionListPadding.top(); connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange())); @@ -51,7 +50,7 @@ _close(this, lang(lng_box_ok), st::defaultBoxButton) { } else { result.insert(lng_language_name, langOriginal(lng_language_name)); } - _langs.push_back(new Radiobutton(this, qsl("lang"), i, result.value(lng_language_name, LanguageCodes[i].c_str() + qsl(" language")), (cLang() == i), st::langsButton)); + _langs.push_back(new Ui::Radiobutton(this, qsl("lang"), i, result.value(lng_language_name, LanguageCodes[i].c_str() + qsl(" language")), (cLang() == i), st::langsButton)); _langs.back()->move(st::boxPadding.left() + st::boxOptionListPadding.left(), y); y += _langs.back()->height() + st::boxOptionListPadding.top(); connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange())); diff --git a/Telegram/SourceFiles/boxes/languagebox.h b/Telegram/SourceFiles/boxes/languagebox.h index 8b0332e39..9714fcde7 100644 --- a/Telegram/SourceFiles/boxes/languagebox.h +++ b/Telegram/SourceFiles/boxes/languagebox.h @@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" +namespace Ui { +class Radiobutton; +} // namespace Ui + class LanguageBox : public AbstractBox { Q_OBJECT @@ -40,7 +44,7 @@ protected: void showAll() override; private: - QVector _langs; + QVector _langs; BoxButton _close; }; diff --git a/Telegram/SourceFiles/boxes/photosendbox.cpp b/Telegram/SourceFiles/boxes/photosendbox.cpp index 98aac9648..988e5b439 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.cpp +++ b/Telegram/SourceFiles/boxes/photosendbox.cpp @@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwidget.h" #include "photosendbox.h" #include "history/history_media_types.h" +#include "ui/buttons/checkbox.h" #include "styles/style_history.h" PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxWideWidth) @@ -44,8 +45,8 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW , _isImage(false) , _replyTo(_file->to.replyTo) , _confirmed(false) { - connect(&_send, SIGNAL(clicked()), this, SLOT(onSend())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_send, SIGNAL(clicked()), this, SLOT(onSend())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); _animated = false; QSize dimensions; @@ -134,16 +135,16 @@ PhotoSendBox::PhotoSendBox(const FileLoadResultPtr &file) : AbstractBox(st::boxW _isImage = fileIsImage(_file->filename, _file->filemime); } if (_file->type != PreparePhoto) { - _compressed.hide(); + _compressed->hide(); } updateBoxSize(); - _caption.setMaxLength(MaxPhotoCaption); - _caption.setCtrlEnterSubmit(CtrlEnterSubmitBoth); - 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())); + _caption->setMaxLength(MaxPhotoCaption); + _caption->setCtrlEnterSubmit(CtrlEnterSubmitBoth); + 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(); } @@ -164,10 +165,10 @@ PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QSt , _lname(lname) , _replyTo(replyTo) , _confirmed(false) { - connect(&_send, SIGNAL(clicked()), this, SLOT(onSend())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_send, SIGNAL(clicked()), this, SLOT(onSend())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); - _compressed.hide(); + _compressed->hide(); _name.setText(st::semiboldFont, lng_full_name(lt_first_name, _fname, lt_last_name, _lname), _textNameOptions); _status = _phone; @@ -179,10 +180,10 @@ PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QSt void PhotoSendBox::onCompressedChange() { showAll(); - if (_caption.isHidden()) { + if (_caption->isHidden()) { setFocus(); } else { - _caption.setFocus(); + _caption->setFocus(); } updateBoxSize(); resizeEvent(0); @@ -197,11 +198,11 @@ void PhotoSendBox::onCaptionResized() { void PhotoSendBox::updateBoxSize() { if (_file && (_file->type == PreparePhoto || _animated)) { - setMaxHeight(st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + (_animated ? 0 : (st::boxPhotoCompressedPadding.top() + _compressed.height())) + st::boxPhotoCompressedPadding.bottom() + _caption.height() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPhotoPadding.top() + _thumbh + st::boxPhotoPadding.bottom() + (_animated ? 0 : (st::boxPhotoCompressedPadding.top() + _compressed->height())) + st::boxPhotoCompressedPadding.bottom() + _caption->height() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom()); } else if (_thumbw) { - setMaxHeight(st::boxPhotoPadding.top() + st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption.height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPhotoPadding.top() + st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption->height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom()); } else { - setMaxHeight(st::boxPhotoPadding.top() + st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption.height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom()); + setMaxHeight(st::boxPhotoPadding.top() + st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() + (_file ? (st::boxPhotoCompressedPadding.bottom() + _caption->height()) : 0) + st::boxPhotoPadding.bottom() + st::boxButtonPadding.top() + _send->height() + st::boxButtonPadding.bottom()); } } @@ -291,11 +292,11 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) { } void PhotoSendBox::resizeEvent(QResizeEvent *e) { - _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()); + _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()); AbstractBox::resizeEvent(e); } @@ -310,47 +311,47 @@ void PhotoSendBox::closePressed() { } void PhotoSendBox::showAll() { - _send.show(); - _cancel.show(); + _send->show(); + _cancel->show(); if (_file) { if (_file->type == PreparePhoto) { - _compressed.show(); + _compressed->show(); } - _caption.show(); + _caption->show(); } else { - _caption.hide(); - _compressed.hide(); + _caption->hide(); + _compressed->hide(); } } void PhotoSendBox::doSetInnerFocus() { - if (_caption.isHidden()) { + if (_caption->isHidden()) { setFocus(); } else { - _caption.setFocus(); + _caption->setFocus(); } } void PhotoSendBox::onSend(bool ctrlShiftEnter) { if (App::main()) { if (_file) { - if (_compressed.isHidden()) { + if (_compressed->isHidden()) { if (_file->type == PrepareAuto) { _file->type = PrepareDocument; } } else { - if (_compressedFromSettings && _compressed.checked() != cCompressPastedImage()) { - cSetCompressPastedImage(_compressed.checked()); + if (_compressedFromSettings && _compressed->checked() != cCompressPastedImage()) { + cSetCompressPastedImage(_compressed->checked()); Local::writeUserSettings(); } - if (_compressed.checked()) { + if (_compressed->checked()) { _file->type = PreparePhoto; } else { _file->type = PrepareDocument; } } - if (!_caption.isHidden()) { - _file->caption = prepareText(_caption.getLastText(), true); + if (!_caption->isHidden()) { + _file->caption = prepareText(_caption->getLastText(), true); } App::main()->onSendFileConfirm(_file, ctrlShiftEnter); } else { @@ -366,7 +367,6 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth) , _animated(false) , _photo(false) , _doc(false) -, _field(0) , _save(this, lang(lng_settings_save), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) , _thumbx(0) @@ -377,8 +377,8 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth) , _isImage(false) , _previewCancelled(false) , _saveRequestId(0) { - connect(&_save, SIGNAL(clicked()), this, SLOT(onSave())); - connect(&_cancel, SIGNAL(clicked()), this, SLOT(onClose())); + connect(_save, SIGNAL(clicked()), this, SLOT(onSave())); + connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); QSize dimensions; ImagePtr image; @@ -490,13 +490,13 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth) } if (_animated || _photo || _doc) { - _field = new InputArea(this, st::confirmCaptionArea, lang(lng_photo_caption), caption); + _field.create(this, st::confirmCaptionArea, lang(lng_photo_caption), caption); _field->setMaxLength(MaxPhotoCaption); _field->setCtrlEnterSubmit(CtrlEnterSubmitBoth); } else { auto original = msg->originalText(); QString text = textApplyEntities(original.text, original.entities); - _field = new InputArea(this, st::editTextArea, lang(lng_photo_caption), text); + _field.create(this, st::editTextArea, lang(lng_photo_caption), text); // _field->setMaxLength(MaxMessageSize); // entities can make text in input field larger but still valid _field->setCtrlEnterSubmit(cCtrlEnter() ? CtrlEnterSubmitCtrlEnter : CtrlEnterSubmitEnter); } @@ -523,7 +523,7 @@ void EditCaptionBox::onCaptionResized() { } void EditCaptionBox::updateBoxSize() { - int32 bottomh = st::boxPhotoCompressedPadding.bottom() + _field->height() + st::normalFont->height + st::boxButtonPadding.top() + _save.height() + st::boxButtonPadding.bottom(); + int32 bottomh = st::boxPhotoCompressedPadding.bottom() + _field->height() + st::normalFont->height + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); if (_photo || _animated) { setMaxHeight(st::boxPhotoPadding.top() + _thumbh + bottomh); } else if (_thumbw) { @@ -620,16 +620,16 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { } void EditCaptionBox::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()); + _save->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save->height()); + _cancel->moveToRight(st::boxButtonPadding.right() + _save->width() + st::boxButtonPadding.left(), _save->y()); _field->resize(st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right(), _field->height()); - _field->moveToLeft(st::boxPhotoPadding.left(), _save.y() - st::boxButtonPadding.top() - st::normalFont->height - _field->height()); + _field->moveToLeft(st::boxPhotoPadding.left(), _save->y() - st::boxButtonPadding.top() - st::normalFont->height - _field->height()); AbstractBox::resizeEvent(e); } void EditCaptionBox::showAll() { - _save.show(); - _cancel.show(); + _save->show(); + _cancel->show(); _field->show(); } diff --git a/Telegram/SourceFiles/boxes/photosendbox.h b/Telegram/SourceFiles/boxes/photosendbox.h index 4856131d3..8c41c31f1 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.h +++ b/Telegram/SourceFiles/boxes/photosendbox.h @@ -23,6 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" #include "localimageloader.h" +namespace Ui { +class Checkbox; +} // namespace Ui + class PhotoSendBox : public AbstractBox { Q_OBJECT @@ -52,10 +56,12 @@ private: QPixmap _thumb; - InputArea _caption; + ChildWidget _caption; bool _compressedFromSettings; - Checkbox _compressed; - BoxButton _send, _cancel; + ChildWidget _compressed; + + ChildWidget _send; + ChildWidget _cancel; int32 _thumbx, _thumby, _thumbw, _thumbh; Text _name; @@ -101,8 +107,9 @@ private: QPixmap _thumb; - InputArea *_field; - BoxButton _save, _cancel; + ChildWidget _field = { nullptr }; + ChildWidget _save; + ChildWidget _cancel; int32 _thumbx, _thumby, _thumbw, _thumbh; Text _name; diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 42cb287ff..8c93392f5 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "lang.h" #include "styles/style_profile.h" #include "boxes/confirmbox.h" +#include "ui/buttons/checkbox.h" #include "mainwindow.h" ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth) diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index 39954c348..c4f81d358 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -22,6 +22,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" +namespace Ui { +class Radiobutton; +} // namespace Ui + class ReportBox : public AbstractBox, public RPCSender { Q_OBJECT @@ -50,10 +54,10 @@ private: ChannelData *_channel; - ChildWidget _reasonSpam; - ChildWidget _reasonViolence; - ChildWidget _reasonPornography; - ChildWidget _reasonOther; + ChildWidget _reasonSpam; + ChildWidget _reasonViolence; + ChildWidget _reasonPornography; + ChildWidget _reasonOther; ChildWidget _reasonOtherText = { nullptr }; ChildWidget _report, _cancel; diff --git a/Telegram/SourceFiles/codegen/style/generator.cpp b/Telegram/SourceFiles/codegen/style/generator.cpp index 4dbd47fc1..62db76caf 100644 --- a/Telegram/SourceFiles/codegen/style/generator.cpp +++ b/Telegram/SourceFiles/codegen/style/generator.cpp @@ -194,7 +194,6 @@ QString Generator::typeToString(structure::Type type) const { case Tag::String: return "QString"; case Tag::Color: return "style::color"; case Tag::Point: return "style::point"; - case Tag::Sprite: return "style::sprite"; case Tag::Size: return "style::size"; case Tag::Transition: return "style::transition"; case Tag::Cursor: return "style::cursor"; @@ -217,7 +216,6 @@ QString Generator::typeToDefaultValue(structure::Type type) const { case Tag::String: return "QString()"; case Tag::Color: return "{ Qt::Uninitialized }"; case Tag::Point: return "{ 0, 0 }"; - case Tag::Sprite: return "{ 0, 0, 0, 0 }"; case Tag::Size: return "{ 0, 0 }"; case Tag::Transition: return "anim::linear"; case Tag::Cursor: return "style::cur_default"; @@ -260,10 +258,6 @@ QString Generator::valueAssignmentCode(structure::Value value) const { auto v(value.Point()); return QString("{ %1, %2 }").arg(pxValueName(v.x)).arg(pxValueName(v.y)); } break; - case Tag::Sprite: { - auto v(value.Sprite()); - return QString("{ %1, %2, %3, %4 }").arg(pxValueName(v.left)).arg(pxValueName(v.top)).arg(pxValueName(v.width)).arg(pxValueName(v.height)); - } break; case Tag::Size: { auto v(value.Size()); return QString("{ %1, %2 }").arg(pxValueName(v.width)).arg(pxValueName(v.height)); @@ -694,13 +688,6 @@ bool Generator::collectUniqueValues() { pxValues_.insert(v.x, true); pxValues_.insert(v.y, true); } break; - case Tag::Sprite: { - auto v(value.Sprite()); - pxValues_.insert(v.left, true); - pxValues_.insert(v.top, true); - pxValues_.insert(v.width, true); - pxValues_.insert(v.height, true); - } break; case Tag::Size: { auto v(value.Size()); pxValues_.insert(v.width, true); @@ -722,7 +709,7 @@ bool Generator::collectUniqueValues() { } break; case Tag::Icon: { auto v(value.Icon()); - for (const auto &part : v.parts) { + for (auto &part : v.parts) { pxValues_.insert(part.offset.Point().x, true); pxValues_.insert(part.offset.Point().y, true); if (!iconMasks_.contains(part.filename)) { diff --git a/Telegram/SourceFiles/codegen/style/options.cpp b/Telegram/SourceFiles/codegen/style/options.cpp index 2793e3cf7..1b4d08a2c 100644 --- a/Telegram/SourceFiles/codegen/style/options.cpp +++ b/Telegram/SourceFiles/codegen/style/options.cpp @@ -49,14 +49,6 @@ Options parseOptions() { if (arg == "--rebuild") { result.rebuildDependencies = true; - // Skip generating style modules - } else if (arg == "--skip-styles") { - result.skipStyles = true; - - // Skip generating sprite_125x.png and sprite_150x.png - } else if (arg == "--skip-sprites") { - result.skipSprites = true; - // Include paths } else if (arg == "-I") { if (++i == count) { diff --git a/Telegram/SourceFiles/codegen/style/options.h b/Telegram/SourceFiles/codegen/style/options.h index f1f591b7c..34746ee2d 100644 --- a/Telegram/SourceFiles/codegen/style/options.h +++ b/Telegram/SourceFiles/codegen/style/options.h @@ -31,8 +31,6 @@ struct Options { QString outputPath = "."; QString inputPath; bool rebuildDependencies = false; - bool skipStyles = false; - bool skipSprites = false; }; // Parsing failed if inputPath is empty in the result. diff --git a/Telegram/SourceFiles/codegen/style/parsed_file.cpp b/Telegram/SourceFiles/codegen/style/parsed_file.cpp index 1f5ab35f9..7f9cc0cc3 100644 --- a/Telegram/SourceFiles/codegen/style/parsed_file.cpp +++ b/Telegram/SourceFiles/codegen/style/parsed_file.cpp @@ -64,7 +64,7 @@ QString tokenValue(const BasicToken &token) { bool isValidColor(const QString &str) { auto len = str.size(); - if (len != 3 && len != 4 && len != 6 && len != 8) { + if (len != 6 && len != 8) { return false; } @@ -89,17 +89,11 @@ uchar readHexUchar(QChar char1, QChar char2) { structure::data::color convertWebColor(const QString &str) { uchar r = 0, g = 0, b = 0, a = 255; if (isValidColor(str)) { - auto len = str.size(); - if (len == 3 || len == 4) { - r = readHexUchar(str.at(0), str.at(0)); - g = readHexUchar(str.at(1), str.at(1)); - b = readHexUchar(str.at(2), str.at(2)); - if (len == 4) a = readHexUchar(str.at(3), str.at(3)); - } else { - r = readHexUchar(str.at(0), str.at(1)); - g = readHexUchar(str.at(2), str.at(3)); - b = readHexUchar(str.at(4), str.at(5)); - if (len == 8) a = readHexUchar(str.at(6), str.at(7)); + r = readHexUchar(str.at(0), str.at(1)); + g = readHexUchar(str.at(2), str.at(3)); + b = readHexUchar(str.at(4), str.at(5)); + if (str.size() == 8) { + a = readHexUchar(str.at(6), str.at(7)); } } return { r, g, b, a }; @@ -120,7 +114,6 @@ std::string logType(const structure::Type &type) { { structure::TypeTag::String , "string" }, { structure::TypeTag::Color , "color" }, { structure::TypeTag::Point , "point" }, - { structure::TypeTag::Sprite , "sprite" }, { structure::TypeTag::Size , "size" }, { structure::TypeTag::Transition, "transition" }, { structure::TypeTag::Cursor , "cursor" }, @@ -285,8 +278,6 @@ structure::Value ParsedFile::readValue() { return colorValue; } else if (auto pointValue = readPointValue()) { return pointValue; - } else if (auto spriteValue = readSpriteValue()) { - return spriteValue; } else if (auto sizeValue = readSizeValue()) { return sizeValue; } else if (auto transitionValue = readTransitionValue()) { @@ -509,41 +500,6 @@ structure::Value ParsedFile::readColorValue() { } else { logErrorUnexpectedToken() << "color value in #ccc, #ccca, #cccccc or #ccccccaa format"; } - } else if (auto rgbaToken = file_.getToken(BasicType::Name)) { - if (tokenValue(rgbaToken) == "rgba") { - assertNextToken(BasicType::LeftParenthesis); - - auto r = readNumericValue(); assertNextToken(BasicType::Comma); - auto g = readNumericValue(); assertNextToken(BasicType::Comma); - auto b = readNumericValue(); assertNextToken(BasicType::Comma); - auto a = readNumericValue(); - if (r.type().tag != structure::TypeTag::Int || r.Int() < 0 || r.Int() > 255 || - g.type().tag != structure::TypeTag::Int || g.Int() < 0 || g.Int() > 255 || - b.type().tag != structure::TypeTag::Int || b.Int() < 0 || b.Int() > 255 || - a.type().tag != structure::TypeTag::Int || a.Int() < 0 || a.Int() > 255) { - logErrorTypeMismatch() << "expected four 0-255 values for the rgba color"; - } - - assertNextToken(BasicType::RightParenthesis); - - return { convertIntColor(r.Int(), g.Int(), b.Int(), a.Int()) }; - } else if (tokenValue(rgbaToken) == "rgb") { - assertNextToken(BasicType::LeftParenthesis); - - auto r = readNumericValue(); assertNextToken(BasicType::Comma); - auto g = readNumericValue(); assertNextToken(BasicType::Comma); - auto b = readNumericValue(); - if (r.type().tag != structure::TypeTag::Int || r.Int() < 0 || r.Int() > 255 || - g.type().tag != structure::TypeTag::Int || g.Int() < 0 || g.Int() > 255 || - b.type().tag != structure::TypeTag::Int || b.Int() < 0 || b.Int() > 255) { - logErrorTypeMismatch() << "expected three int values for the rgb color"; - } - - assertNextToken(BasicType::RightParenthesis); - - return { convertIntColor(r.Int(), g.Int(), b.Int(), 255) }; - } - file_.putBack(); } return {}; } @@ -569,31 +525,6 @@ structure::Value ParsedFile::readPointValue() { return {}; } -structure::Value ParsedFile::readSpriteValue() { - if (auto font = file_.getToken(BasicType::Name)) { - if (tokenValue(font) == "sprite") { - assertNextToken(BasicType::LeftParenthesis); - - auto x = readNumericValue(); assertNextToken(BasicType::Comma); - auto y = readNumericValue(); assertNextToken(BasicType::Comma); - auto w = readNumericValue(); assertNextToken(BasicType::Comma); - auto h = readNumericValue(); - if (x.type().tag != structure::TypeTag::Pixels || - y.type().tag != structure::TypeTag::Pixels || - w.type().tag != structure::TypeTag::Pixels || - h.type().tag != structure::TypeTag::Pixels) { - logErrorTypeMismatch() << "expected four px values for the sprite"; - } - - assertNextToken(BasicType::RightParenthesis); - - return { structure::data::sprite { x.Int(), y.Int(), w.Int(), h.Int() } }; - } - file_.putBack(); - } - return {}; -} - structure::Value ParsedFile::readSizeValue() { if (auto font = file_.getToken(BasicType::Name)) { if (tokenValue(font) == "size") { diff --git a/Telegram/SourceFiles/codegen/style/parsed_file.h b/Telegram/SourceFiles/codegen/style/parsed_file.h index 8eea16483..520e0aad2 100644 --- a/Telegram/SourceFiles/codegen/style/parsed_file.h +++ b/Telegram/SourceFiles/codegen/style/parsed_file.h @@ -88,7 +88,6 @@ private: structure::Value readStringValue(); structure::Value readColorValue(); structure::Value readPointValue(); - structure::Value readSpriteValue(); structure::Value readSizeValue(); structure::Value readTransitionValue(); structure::Value readCursorValue(); @@ -127,7 +126,6 @@ private: { "string" , { structure::TypeTag::String } }, { "color" , { structure::TypeTag::Color } }, { "point" , { structure::TypeTag::Point } }, - { "sprite" , { structure::TypeTag::Sprite } }, { "size" , { structure::TypeTag::Size } }, { "transition", { structure::TypeTag::Transition } }, { "cursor" , { structure::TypeTag::Cursor } }, diff --git a/Telegram/SourceFiles/codegen/style/processor.cpp b/Telegram/SourceFiles/codegen/style/processor.cpp index 4b534e7c2..b73bc503f 100644 --- a/Telegram/SourceFiles/codegen/style/processor.cpp +++ b/Telegram/SourceFiles/codegen/style/processor.cpp @@ -25,7 +25,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "codegen/common/cpp_file.h" #include "codegen/style/parsed_file.h" #include "codegen/style/generator.h" -#include "codegen/style/sprite_generator.h" namespace codegen { namespace style { @@ -66,38 +65,28 @@ int Processor::launch() { bool Processor::write(const structure::Module &module) const { bool forceReGenerate = false; - bool onlyStyles = options_.skipSprites; - bool onlySprites = options_.skipStyles; - if (!onlyStyles) { - SpriteGenerator spriteGenerator(module, forceReGenerate); - if (!spriteGenerator.writeSprites()) { - return false; - } + QDir dir(options_.outputPath); + if (!dir.mkpath(".")) { + common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString(); + return false; } - if (!onlySprites) { - QDir dir(options_.outputPath); - if (!dir.mkpath(".")) { - common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString(); - return false; - } - QFileInfo srcFile(module.filepath()); - QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module); + QFileInfo srcFile(module.filepath()); + QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module); - common::ProjectInfo project = { - "codegen_style", - srcFile.fileName(), - "stdafx.h", - forceReGenerate - }; + common::ProjectInfo project = { + "codegen_style", + srcFile.fileName(), + "stdafx.h", + forceReGenerate + }; - Generator generator(module, dstFilePath, project); - if (!generator.writeHeader()) { - return false; - } - if (!generator.writeSource()) { - return false; - } + Generator generator(module, dstFilePath, project); + if (!generator.writeHeader()) { + return false; + } + if (!generator.writeSource()) { + return false; } return true; } diff --git a/Telegram/SourceFiles/codegen/style/sprite_generator.cpp b/Telegram/SourceFiles/codegen/style/sprite_generator.cpp deleted file mode 100644 index c7d07be97..000000000 --- a/Telegram/SourceFiles/codegen/style/sprite_generator.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -In addition, as a special exception, the copyright holders give permission -to link the code of portions of this program with the OpenSSL library. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org -*/ -#include "codegen/style/sprite_generator.h" - -#include -#include -#include -#include -#include -#include -#include "codegen/style/parsed_file.h" - -using Module = codegen::style::structure::Module; -using Struct = codegen::style::structure::Struct; -using Variable = codegen::style::structure::Variable; -using Tag = codegen::style::structure::TypeTag; - -namespace codegen { -namespace style { - -using structure::logFullName; - -namespace { - -constexpr int kErrorSpritesIntersect = 841; -constexpr int kErrorCouldNotGenerate = 842; -constexpr int kErrorCouldNotSerialize = 843; -constexpr int kErrorCouldNotOpen = 844; -constexpr int kErrorCouldNotWrite = 845; - -} // namespace - -SpriteGenerator::SpriteGenerator(const structure::Module &module, bool forceReGenerate) -: module_(module) -, forceReGenerate_(forceReGenerate) -, basePath_(QFileInfo(module.filepath()).dir().absolutePath()) { -} - -bool SpriteGenerator::writeSprites() { - if (!collectSprites()) { - return false; - } - if (sprites_.isEmpty()) { - return true; - } - - sprite2x_ = QImage(basePath_ + "/art/sprite_200x.png"); - if (sprite2x_.isNull()) { - common::logError(common::kErrorFileNotFound, "/art/sprite_200x.png") << "sprite file was not found"; - return false; - } - std::vector sizes = { 5, 6 }; - std::vector postfixes = { "125", "150" }; - for (int i = 0, l = sizes.size(); i < l; ++i) { - auto sprite = generateSprite(sizes[i]); - QString filepath = basePath_ + "/art/sprite_" + postfixes[i] + "x.png"; - if (sprite.isNull()) { - common::logError(kErrorCouldNotGenerate, filepath) << "could not generate sprite file"; - return false; - } - QByteArray spriteData; - { - QBuffer spriteBuffer(&spriteData); - if (!sprite.save(&spriteBuffer, "PNG")) { - common::logError(kErrorCouldNotSerialize, filepath) << "could not serialize sprite file"; - return false; - } - } - QFile file(filepath); - if (!forceReGenerate_ && file.open(QIODevice::ReadOnly)) { - if (file.readAll() == spriteData) { - continue; - } - file.close(); - } - if (!file.open(QIODevice::WriteOnly)) { - common::logError(kErrorCouldNotOpen, filepath) << "could not open sprite file for write"; - return false; - } - if (file.write(spriteData) != spriteData.size()) { - common::logError(kErrorCouldNotWrite, filepath) << "could not write sprite file"; - return false; - } - - // Touch resource file. - filepath = basePath_ + "/telegram.qrc"; - QFile qrc(filepath); - if (qrc.open(QIODevice::ReadOnly)) { - auto qrcContent = qrc.readAll(); - qrc.close(); - if (!qrc.open(QIODevice::WriteOnly)) { - common::logError(kErrorCouldNotOpen, filepath) << "could not open .qrc file for write"; - return false; - } - if (qrc.write(qrcContent) != qrcContent.size()) { - common::logError(kErrorCouldNotWrite, filepath) << "could not write .qrc file"; - return false; - } - } - } - - return true; -} - -bool SpriteGenerator::collectSprites() { - std::function collector = [this, &collector](const Variable &variable) { - auto value = variable.value; - if (value.type().tag == Tag::Sprite) { - auto v(value.Sprite()); - if (!v.width || !v.height) return true; - - QRect vRect(v.left, v.top, v.width, v.height); - bool found = false; - for (auto var : sprites_) { - auto sprite = var.value.Sprite(); - QRect spriteRect(sprite.left, sprite.top, sprite.width, sprite.height); - if (spriteRect == vRect) { - found = true; - } else if (spriteRect.intersects(vRect)) { - common::logError(kErrorSpritesIntersect, module_.filepath()) << "sprite '" << logFullName(variable.name) << "' intersects with '" << logFullName(var.name) << "'"; - return false; - } - } - if (!found) { - sprites_.push_back(variable); - } - } else if (value.type().tag == Tag::Struct) { - auto fields = variable.value.Fields(); - if (!fields) { - return false; - } - - for (auto field : *fields) { - if (!collector(field.variable)) { - return false; - } - } - } - return true; - }; - return module_.enumVariables(collector); -} - -QImage SpriteGenerator::generateSprite(int scale) { - auto convert = [scale](int value) -> int { return structure::data::pxAdjust(value, scale); }; - QImage result(convert(sprite2x_.width() / 2), convert(sprite2x_.height() / 2), sprite2x_.format()); - { - QPainter p(&result); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(0, 0, result.width(), result.height(), QColor(0, 0, 0, 0)); - for (auto variable : sprites_) { - auto sprite = variable.value.Sprite(); - auto copy = sprite2x_.copy(sprite.left * 2, sprite.top * 2, sprite.width * 2, sprite.height * 2); - copy = copy.scaled(convert(sprite.width), convert(sprite.height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - p.drawImage(convert(sprite.left), convert(sprite.top), copy); - } - } - return result; -} - -} // namespace style -} // namespace codegen diff --git a/Telegram/SourceFiles/codegen/style/sprite_generator.h b/Telegram/SourceFiles/codegen/style/sprite_generator.h deleted file mode 100644 index fc1458db3..000000000 --- a/Telegram/SourceFiles/codegen/style/sprite_generator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop version of Telegram messaging app, see https://telegram.org - -Telegram Desktop is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -It is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -In addition, as a special exception, the copyright holders give permission -to link the code of portions of this program with the OpenSSL library. - -Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE -Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org -*/ -#pragma once - -#include -#include -#include -#include -#include "codegen/style/structure_types.h" - -namespace codegen { -namespace style { -namespace structure { -class Module; -} // namespace structure - -class SpriteGenerator { -public: - SpriteGenerator(const structure::Module &module, bool forceReGenerate); - SpriteGenerator(const SpriteGenerator &other) = delete; - SpriteGenerator &operator=(const SpriteGenerator &other) = delete; - - bool writeSprites(); - -private: - - bool collectSprites(); - QImage generateSprite(int scale); // scale = 5 for 125% and 6 for 150%. - - const structure::Module &module_; - bool forceReGenerate_; - QString basePath_; - QImage sprite2x_; - QList sprites_; - -}; - -} // namespace style -} // namespace codegen diff --git a/Telegram/SourceFiles/codegen/style/structure_types.cpp b/Telegram/SourceFiles/codegen/style/structure_types.cpp index cec0f0c48..e11042a34 100644 --- a/Telegram/SourceFiles/codegen/style/structure_types.cpp +++ b/Telegram/SourceFiles/codegen/style/structure_types.cpp @@ -69,17 +69,6 @@ struct Value::DataTypes { }; - class TSprite : public DataBase { - public: - TSprite(data::sprite value) : value_(value) { - } - data::sprite Sprite() const override { return value_; } - - private: - data::sprite value_; - - }; - class TSize : public DataBase { public: TSize(data::size value) : value_(value) { @@ -154,9 +143,6 @@ Value::Value() : Value(TypeTag::Invalid, std::make_shared()) { Value::Value(data::point value) : Value(TypeTag::Point, std::make_shared(value)) { } -Value::Value(data::sprite value) : Value(TypeTag::Sprite, std::make_shared(value)) { -} - Value::Value(data::size value) : Value(TypeTag::Size, std::make_shared(value)) { } @@ -210,7 +196,6 @@ Value::Value(Type type, Qt::Initialization) : type_(type) { case TypeTag::String: data_ = std::make_shared(""); break; case TypeTag::Color: data_ = std::make_shared(data::color { 0, 0, 0, 255 }); break; case TypeTag::Point: data_ = std::make_shared(data::point { 0, 0 }); break; - case TypeTag::Sprite: data_ = std::make_shared(data::sprite { 0, 0, 0, 0 }); break; case TypeTag::Size: data_ = std::make_shared(data::size { 0, 0 }); break; case TypeTag::Transition: data_ = std::make_shared("linear"); break; case TypeTag::Cursor: data_ = std::make_shared("default"); break; diff --git a/Telegram/SourceFiles/codegen/style/structure_types.h b/Telegram/SourceFiles/codegen/style/structure_types.h index 848acb32a..b2c785809 100644 --- a/Telegram/SourceFiles/codegen/style/structure_types.h +++ b/Telegram/SourceFiles/codegen/style/structure_types.h @@ -47,7 +47,6 @@ enum class TypeTag { String, Color, Point, - Sprite, Size, Transition, Cursor, @@ -86,10 +85,6 @@ struct point { int x, y; }; -struct sprite { - int left, top, width, height; -}; - struct size { int width, height; }; @@ -127,7 +122,6 @@ class Value { public: Value(); Value(data::point value); - Value(data::sprite value); Value(data::size value); Value(data::color value); Value(data::margins value); @@ -152,7 +146,6 @@ public: double Double() const { return data_->Double(); } std::string String() const { return data_->String(); } data::point Point() const { return data_->Point(); } - data::sprite Sprite() const { return data_->Sprite(); }; data::size Size() const { return data_->Size(); }; data::color Color() const { return data_->Color(); }; data::margins Margins() const { return data_->Margins(); }; @@ -182,7 +175,6 @@ private: virtual double Double() const { return 0.; } virtual std::string String() const { return std::string(); } virtual data::point Point() const { return {}; }; - virtual data::sprite Sprite() const { return {}; }; virtual data::size Size() const { return {}; }; virtual data::color Color() const { return {}; }; virtual data::margins Margins() const { return {}; }; diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index ec82cc590..ee44cb5a7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -44,7 +44,7 @@ dialogsDateFont: font(13px); dialogsDateFgActive: #ffffff; dialogsDateFg: #a8a8a8; dialogsDateSkip: 5px; -dialogsNameFg: #000; +dialogsNameFg: #000000; dialogsNameTop: 2px; dialogsRowHeight: 62px; diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index eb07e0fe1..1e6904521 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -26,7 +26,7 @@ historyPaddingBottom: 10px; historyToDown: icon { { "history_down_shadow", #00000040 }, - { "history_down_circle", #fff, point(2px, 1px) }, + { "history_down_circle", #ffffff, point(2px, 1px) }, }; historyToDownPosition: point(12px, 10px); historyToDownArrow: icon { @@ -189,7 +189,7 @@ historyRecordVoiceActive: icon {{ "send_control_record", #58b2ed }}; historyRecordSignalColor: #f17077; historyRecordSignalMin: 5px; historyRecordSignalMax: 12px; -historyRecordCancel: #aaa; +historyRecordCancel: #aaaaaa; historyRecordCancelActive: #ec6466; historyRecordFont: font(13px); historyRecordTextTop: 14px; diff --git a/Telegram/SourceFiles/media/view/mediaview.style b/Telegram/SourceFiles/media/view/mediaview.style index 7171d2b12..d25f147d2 100644 --- a/Telegram/SourceFiles/media/view/mediaview.style +++ b/Telegram/SourceFiles/media/view/mediaview.style @@ -116,10 +116,10 @@ mediaviewMenu: Menu(defaultMenu) { itemBgOver: #505050; itemFg: white; itemFgOver: white; - itemFgDisabled: #999; - itemFgShortcut: #eee; - itemFgShortcutOver: #fff; - itemFgShortcutDisabled: #999; + itemFgDisabled: #999999; + itemFgShortcut: #eeeeee; + itemFgShortcutOver: #ffffff; + itemFgShortcutDisabled: #999999; separatorFg: #484848; } diff --git a/Telegram/SourceFiles/overview/overview.style b/Telegram/SourceFiles/overview/overview.style index 7250e6d15..bbf292fc6 100644 --- a/Telegram/SourceFiles/overview/overview.style +++ b/Telegram/SourceFiles/overview/overview.style @@ -42,7 +42,7 @@ OverviewFileLayout { fileDateTop: pixels; } -overviewCheckBg: #0006; +overviewCheckBg: #00000066; overviewCheckedBg: #2fa9e2; overviewPhotoSkip: 10px; @@ -50,11 +50,11 @@ overviewPhotoBg: #F1F1F1; overviewPhotoMinSize: minPhotoSize; overviewPhotoCheck: icon { { size(32px, 32px), overviewCheckBg }, - { "overview_photo_check", #fff, point(8px, 10px) }, + { "overview_photo_check", #ffffff, point(8px, 10px) }, }; overviewPhotoChecked: icon { { size(32px, 32px), overviewCheckedBg }, - { "overview_photo_check", #fff, point(8px, 10px) }, + { "overview_photo_check", #ffffff, point(8px, 10px) }, }; overviewPhotoSelectOverlay: #0a7bb03f; @@ -104,9 +104,9 @@ linksPhotoSize: 46px; linksPhotoPadding: 12px; overviewLinksCheck: icon { { "overview_links_check_bg", overviewCheckBg }, - { "overview_links_check", #fff, point(4px, 5px) }, + { "overview_links_check", #ffffff, point(4px, 5px) }, }; overviewLinksChecked: icon { { "overview_links_check_bg", overviewCheckedBg }, - { "overview_links_check", #fff, point(4px, 5px) }, + { "overview_links_check", #ffffff, point(4px, 5px) }, }; diff --git a/Telegram/SourceFiles/profile/profile_settings_widget.cpp b/Telegram/SourceFiles/profile/profile_settings_widget.cpp index 4c6d254c8..c93ee264c 100644 --- a/Telegram/SourceFiles/profile/profile_settings_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_settings_widget.cpp @@ -23,7 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "styles/style_profile.h" #include "ui/buttons/left_outline_button.h" -#include "ui/flatcheckbox.h" +#include "ui/buttons/checkbox.h" #include "boxes/confirmbox.h" #include "boxes/contactsbox.h" #include "observer_peer.h" @@ -114,7 +114,7 @@ void SettingsWidget::refreshEnableNotifications() { } else { auto ¬ifySettings = peer()->notify; bool enabled = (notifySettings == EmptyNotifySettings || notifySettings->mute < unixtime()); - _enableNotifications->setChecked(enabled, Checkbox::NotifyAboutChange::DontNotify); + _enableNotifications->setChecked(enabled, Ui::Checkbox::NotifyAboutChange::DontNotify); } } diff --git a/Telegram/SourceFiles/profile/profile_settings_widget.h b/Telegram/SourceFiles/profile/profile_settings_widget.h index 4b02ee17c..ba727cb57 100644 --- a/Telegram/SourceFiles/profile/profile_settings_widget.h +++ b/Telegram/SourceFiles/profile/profile_settings_widget.h @@ -22,9 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "profile/profile_block_widget.h" -class Checkbox; - namespace Ui { +class Checkbox; class LeftOutlineButton; } // namespace Ui @@ -59,7 +58,7 @@ private: void refreshManageAdminsButton(); void refreshInviteLinkButton(); - ChildWidget _enableNotifications; + ChildWidget _enableNotifications; // In groups: creator of non-deactivated groups can see this link. // In channels: creator of supergroup can see this link. diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index 27a53b28b..35e910c24 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "mainwidget.h" #include "boxes/backgroundbox.h" #include "ui/effects/widget_slide_wrap.h" +#include "ui/buttons/checkbox.h" #include "localstorage.h" #include "mainwindow.h" #include "window/chat_background.h" diff --git a/Telegram/SourceFiles/settings/settings_background_widget.h b/Telegram/SourceFiles/settings/settings_background_widget.h index 4a61b69b1..6b7d458f2 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.h +++ b/Telegram/SourceFiles/settings/settings_background_widget.h @@ -25,8 +25,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/filedialog.h" class LinkButton; -class Checkbox; + namespace Ui { +class Checkbox; template class WidgetSlideWrap; } // namespace Ui; @@ -84,8 +85,8 @@ private: void notifyFileQueryUpdated(const FileDialog::QueryUpdate &update); ChildWidget _background = { nullptr }; - ChildWidget _tile = { nullptr }; - ChildWidget> _adaptive = { nullptr }; + ChildWidget _tile = { nullptr }; + ChildWidget> _adaptive = { nullptr }; FileDialog::QueryId _chooseFromFileQueryId = 0; diff --git a/Telegram/SourceFiles/settings/settings_block_widget.cpp b/Telegram/SourceFiles/settings/settings_block_widget.cpp index 8a188de02..edfe760a4 100644 --- a/Telegram/SourceFiles/settings/settings_block_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_block_widget.cpp @@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "settings/settings_block_widget.h" #include "styles/style_settings.h" -#include "ui/flatcheckbox.h" +#include "ui/buttons/checkbox.h" namespace Settings { @@ -84,13 +84,13 @@ void BlockWidget::rowHeightUpdated() { } } -void BlockWidget::createChildRow(ChildWidget &child, style::margins &margin, const QString &text, const char *slot, bool checked) { - child = new Checkbox(this, text, checked, st::defaultBoxCheckbox); +void BlockWidget::createChildRow(ChildWidget &child, style::margins &margin, const QString &text, const char *slot, bool checked) { + child = new Ui::Checkbox(this, text, checked, st::defaultBoxCheckbox); connect(child, SIGNAL(changed()), this, slot); } -void BlockWidget::createChildRow(ChildWidget &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked) { - child = new Radiobutton(this, group, value, text, checked, st::defaultRadiobutton); +void BlockWidget::createChildRow(ChildWidget &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked) { + child = new Ui::Radiobutton(this, group, value, text, checked, st::defaultRadiobutton); connect(child, SIGNAL(changed()), this, slot); } diff --git a/Telegram/SourceFiles/settings/settings_block_widget.h b/Telegram/SourceFiles/settings/settings_block_widget.h index 059973d04..92e28a5ab 100644 --- a/Telegram/SourceFiles/settings/settings_block_widget.h +++ b/Telegram/SourceFiles/settings/settings_block_widget.h @@ -22,10 +22,9 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/observer.h" +namespace Ui { class Checkbox; class Radiobutton; - -namespace Ui { template class WidgetSlideWrap; } // namespace Ui @@ -87,8 +86,8 @@ private: margin.setRight(margin.right() - padding.right()); margin.setBottom(margin.bottom() - padding.bottom()); } - void createChildRow(ChildWidget &child, style::margins &margin, const QString &text, const char *slot, bool checked); - void createChildRow(ChildWidget &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked); + void createChildRow(ChildWidget &child, style::margins &margin, const QString &text, const char *slot, bool checked); + void createChildRow(ChildWidget &child, style::margins &margin, const QString &group, int value, const QString &text, const char *slot, bool checked); void createChildRow(ChildWidget &child, style::margins &margin, const QString &text, const char *slot, const style::linkButton &st = st::defaultBoxLinkButton); void addCreatedRow(TWidget *child, const style::margins &margin); @@ -106,8 +105,8 @@ private: template using NotImplementedYet = std_::enable_if_t< !IsWidgetSlideWrap::value && - !std_::is_same::value && - !std_::is_same::value && + !std_::is_same::value && + !std_::is_same::value && !std_::is_same::value>; template > diff --git a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp index 00167763e..c9527e6c8 100644 --- a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp @@ -24,6 +24,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "styles/style_settings.h" #include "lang.h" #include "ui/effects/widget_slide_wrap.h" +#include "ui/buttons/checkbox.h" #include "ui/flatlabel.h" #include "localstorage.h" #include "mainwidget.h" diff --git a/Telegram/SourceFiles/settings/settings_chat_settings_widget.h b/Telegram/SourceFiles/settings/settings_chat_settings_widget.h index f04ac7f53..2c1da6c74 100644 --- a/Telegram/SourceFiles/settings/settings_chat_settings_widget.h +++ b/Telegram/SourceFiles/settings/settings_chat_settings_widget.h @@ -105,12 +105,12 @@ private slots: private: void createControls(); - ChildWidget _replaceEmoji = { nullptr }; + ChildWidget _replaceEmoji = { nullptr }; ChildWidget> _viewList = { nullptr }; - ChildWidget _dontAskDownloadPath = { nullptr }; + ChildWidget _dontAskDownloadPath = { nullptr }; ChildWidget> _downloadPath = { nullptr }; - ChildWidget _sendByEnter = { nullptr }; - ChildWidget _sendByCtrlEnter = { nullptr }; + ChildWidget _sendByEnter = { nullptr }; + ChildWidget _sendByCtrlEnter = { nullptr }; ChildWidget _automaticMediaDownloadSettings = { nullptr }; ChildWidget _manageStickerSets = { nullptr }; diff --git a/Telegram/SourceFiles/settings/settings_general_widget.cpp b/Telegram/SourceFiles/settings/settings_general_widget.cpp index 06790fe07..454a25232 100644 --- a/Telegram/SourceFiles/settings/settings_general_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_general_widget.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "lang.h" #include "ui/effects/widget_slide_wrap.h" #include "ui/flatbutton.h" -#include "ui/flatcheckbox.h" +#include "ui/buttons/checkbox.h" #include "localstorage.h" #include "pspecific.h" #include "mainwindow.h" diff --git a/Telegram/SourceFiles/settings/settings_general_widget.h b/Telegram/SourceFiles/settings/settings_general_widget.h index 018dba991..228cf182a 100644 --- a/Telegram/SourceFiles/settings/settings_general_widget.h +++ b/Telegram/SourceFiles/settings/settings_general_widget.h @@ -23,10 +23,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "settings/settings_block_widget.h" #include "ui/filedialog.h" -class Checkbox; class LinkButton; namespace Ui { +class Checkbox; template class WidgetSlideWrap; } // namespace Ui @@ -116,14 +116,14 @@ private: ChildWidget _changeLanguage; #ifndef TDESKTOP_DISABLE_AUTOUPDATE - ChildWidget _updateAutomatically = { nullptr }; + ChildWidget _updateAutomatically = { nullptr }; ChildWidget> _updateRow = { nullptr }; #endif // !TDESKTOP_DISABLE_AUTOUPDATE - ChildWidget _enableTrayIcon = { nullptr }; - ChildWidget _enableTaskbarIcon = { nullptr }; - ChildWidget _autoStart = { nullptr }; - ChildWidget> _startMinimized = { nullptr }; - ChildWidget _addInSendTo = { nullptr }; + ChildWidget _enableTrayIcon = { nullptr }; + ChildWidget _enableTaskbarIcon = { nullptr }; + ChildWidget _autoStart = { nullptr }; + ChildWidget> _startMinimized = { nullptr }; + ChildWidget _addInSendTo = { nullptr }; FileDialog::QueryId _chooseLangFileQueryId = 0; QString _testLanguage; diff --git a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp index 6068f7787..2bd3b7ce8 100644 --- a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp @@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "lang.h" #include "localstorage.h" #include "ui/effects/widget_slide_wrap.h" -#include "ui/flatcheckbox.h" +#include "ui/buttons/checkbox.h" #include "mainwindow.h" #include "window/notifications_manager.h" #include "boxes/notifications_box.h" diff --git a/Telegram/SourceFiles/settings/settings_notifications_widget.h b/Telegram/SourceFiles/settings/settings_notifications_widget.h index 5bc3c28d9..404457c5c 100644 --- a/Telegram/SourceFiles/settings/settings_notifications_widget.h +++ b/Telegram/SourceFiles/settings/settings_notifications_widget.h @@ -45,12 +45,12 @@ private: void desktopEnabledUpdated(); void viewParamUpdated(); - ChildWidget _desktopNotifications = { nullptr }; - ChildWidget> _showSenderName = { nullptr }; - ChildWidget> _showMessagePreview = { nullptr }; - ChildWidget _nativeNotifications = { nullptr }; - ChildWidget _playSound = { nullptr }; - ChildWidget _includeMuted = { nullptr }; + ChildWidget _desktopNotifications = { nullptr }; + ChildWidget> _showSenderName = { nullptr }; + ChildWidget> _showMessagePreview = { nullptr }; + ChildWidget _nativeNotifications = { nullptr }; + ChildWidget _playSound = { nullptr }; + ChildWidget _includeMuted = { nullptr }; ChildWidget> _advanced = { nullptr }; }; diff --git a/Telegram/SourceFiles/settings/settings_scale_widget.cpp b/Telegram/SourceFiles/settings/settings_scale_widget.cpp index a621e832d..c4ab37279 100644 --- a/Telegram/SourceFiles/settings/settings_scale_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_scale_widget.cpp @@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "settings/settings_scale_widget.h" #include "styles/style_settings.h" +#include "ui/buttons/checkbox.h" #include "lang.h" #include "localstorage.h" #include "mainwindow.h" diff --git a/Telegram/SourceFiles/settings/settings_scale_widget.h b/Telegram/SourceFiles/settings/settings_scale_widget.h index 39684d754..1f975a726 100644 --- a/Telegram/SourceFiles/settings/settings_scale_widget.h +++ b/Telegram/SourceFiles/settings/settings_scale_widget.h @@ -22,9 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "settings/settings_block_widget.h" -class Checkbox; - namespace Ui { +class Checkbox; class DiscreteSlider; } // namespace Ui @@ -45,7 +44,7 @@ private: void createControls(); void setScale(DBIScale newScale); - ChildWidget _auto = { nullptr }; + ChildWidget _auto = { nullptr }; ChildWidget _scale = { nullptr }; }; diff --git a/Telegram/SourceFiles/stickers/emoji_pan.cpp b/Telegram/SourceFiles/stickers/emoji_pan.cpp index e1252378c..fb97c37c9 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.cpp +++ b/Telegram/SourceFiles/stickers/emoji_pan.cpp @@ -2784,14 +2784,7 @@ void EmojiPan::paintEvent(QPaintEvent *e) { p.drawPixmapLeft(x + (st::emojiCategory.width - s.pixw) / 2, _iconsTop + (st::emojiCategory.height - s.pixh) / 2, width(), pix); x += st::emojiCategory.width; } else { - if (true || selxrel != x) { - getSpecialSetIcon(s.setId, false)->paint(p, x + st::emojiCategory.iconPosition.x(), _iconsTop + st::emojiCategory.iconPosition.y(), width()); - } - //if (selxrel < x + st::emojiCategory.width && selxrel > x - st::emojiCategory.width) { - // p.setOpacity(1 - (qAbs(selxrel - x) / float64(st::emojiCategory.width))); - // p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), getSpecialSetIcon(s.setId, true)); - // p.setOpacity(1); - //} + getSpecialSetIcon(s.setId, false)->paint(p, x + st::emojiCategory.iconPosition.x(), _iconsTop + st::emojiCategory.iconPosition.y(), width()); if (s.setId == Stickers::FeaturedSetId) { paintFeaturedStickerSetsBadge(p, x); } diff --git a/Telegram/SourceFiles/stickers/stickers.style b/Telegram/SourceFiles/stickers/stickers.style index 2d2c67324..4e28e6f4d 100644 --- a/Telegram/SourceFiles/stickers/stickers.style +++ b/Telegram/SourceFiles/stickers/stickers.style @@ -30,7 +30,7 @@ stickersTrendingHeaderFont: semiboldFont; stickersTrendingHeaderFg: windowTextFg; stickersTrendingHeaderTop: 0px; stickersTrendingSubheaderFont: normalFont; -stickersTrendingSubheaderFg: #777; +stickersTrendingSubheaderFg: #777777; stickersTrendingSubheaderTop: 20px; stickersTrendingAddTop: 3px; @@ -68,7 +68,7 @@ stickersScroll: flatScroll(boxScroll) { deltab: 9px; } stickersReorderPadding: margins(0px, 12px, 0px, 12px); -stickersReorderFg: #777; +stickersReorderFg: #777777; stickersRowDisabledOpacity: 0.4; stickersRowDuration: 200; @@ -131,7 +131,7 @@ emojiPanHover: #f0f4f7; emojiPanHeader: 42px; emojiPanHeaderFont: semiboldFont; -emojiPanHeaderColor: #999; +emojiPanHeaderColor: #999999; emojiPanHeaderLeft: 22px; emojiPanHeaderTop: 12px; emojiPanHeaderBg: #fffffff2; diff --git a/Telegram/SourceFiles/ui/flatcheckbox.cpp b/Telegram/SourceFiles/ui/buttons/checkbox.cpp similarity index 69% rename from Telegram/SourceFiles/ui/flatcheckbox.cpp rename to Telegram/SourceFiles/ui/buttons/checkbox.cpp index ba03450a7..36aeedbb4 100644 --- a/Telegram/SourceFiles/ui/flatcheckbox.cpp +++ b/Telegram/SourceFiles/ui/buttons/checkbox.cpp @@ -19,126 +19,21 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "stdafx.h" -#include "ui/flatcheckbox.h" +#include "ui/buttons/checkbox.h" #include "lang.h" -FlatCheckbox::FlatCheckbox(QWidget *parent, const QString &text, bool checked, const style::flatCheckbox &st) : Button(parent) -, _st(st) -, a_over(0, 0) -, _a_appearance(animation(this, &FlatCheckbox::step_appearance)) -, _text(text) -, _opacity(1) -, _checked(checked) { - connect(this, SIGNAL(clicked()), this, SLOT(onClicked())); - connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource))); - setCursor(_st.cursor); - int32 w = _st.width, h = _st.height; - if (w <= 0) w = _st.textLeft + _st.font->width(_text) + 2; - if (h <= 0) h = qMax(_st.font->height, _st.imageRect.pxHeight()); - resize(QSize(w, h)); -} +namespace Ui { +namespace { -bool FlatCheckbox::checked() const { - return _checked; -} - -void FlatCheckbox::setChecked(bool checked) { - if (_checked != checked) { - _checked = checked; - emit changed(); - update(); - } -} - -void FlatCheckbox::setOpacity(float64 o) { - _opacity = o; - update(); -} - -void FlatCheckbox::onClicked() { - if (_state & StateDisabled) return; - setChecked(!checked()); -} - -void FlatCheckbox::onStateChange(int oldState, ButtonStateChangeSource source) { - if ((_state & StateOver) && !(oldState & StateOver)) { - a_over.start(1); - _a_appearance.start(); - } else if (!(_state & StateOver) && (oldState & StateOver)) { - a_over.start(0); - _a_appearance.start(); - } - if ((_state & StateDisabled) && !(oldState & StateDisabled)) { - setCursor(_st.disabledCursor); - _a_appearance.start(); - } else if (!(_state & StateDisabled) && (oldState & StateDisabled)) { - setCursor(_st.cursor); - _a_appearance.start(); - } -} - -void FlatCheckbox::paintEvent(QPaintEvent *e) { - Painter p(this); - - p.setOpacity(_opacity); - if (_st.bgColor != st::transparent) { - p.fillRect(rect(), _st.bgColor->b); - } - - if (!_text.isEmpty()) { - p.setFont(_st.font->f); - p.setRenderHint(QPainter::TextAntialiasing); - p.setPen((_state & StateDisabled ? _st.disColor : _st.textColor)->p); - - QRect tRect(rect()); - tRect.setTop(_st.textTop); - tRect.setLeft(_st.textLeft); -// p.drawText(_st.textLeft, _st.textTop + _st.font->ascent, _text); - p.drawText(tRect, _text, QTextOption(style::al_topleft)); - } - - if (_state & StateDisabled) { - const style::sprite &sRect(_checked ? _st.chkDisImageRect : _st.disImageRect); - p.drawSprite(_st.imagePos, sRect); - } else if ((_checked && _st.chkImageRect == _st.chkOverImageRect) || (!_checked && _st.imageRect == _st.overImageRect)) { - p.setOpacity(_opacity); - const style::sprite &sRect(_checked ? _st.chkImageRect : _st.imageRect); - p.drawSprite(_st.imagePos, sRect); - } else { - if (a_over.current() < 1) { - const style::sprite &sRect(_checked ? _st.chkImageRect : _st.imageRect); - p.drawSprite(_st.imagePos, sRect); - } - if (a_over.current() > 0) { - p.setOpacity(_opacity * a_over.current()); - const style::sprite &sRect(_checked ? _st.chkOverImageRect : _st.overImageRect); - p.drawSprite(_st.imagePos, sRect); - } - } -} - -void FlatCheckbox::step_appearance(float64 ms, bool timer) { - float64 dt = ms / _st.duration; - if (dt >= 1) { - _a_appearance.stop(); - a_over.finish(); - } else { - a_over.update(dt, _st.bgFunc); - } - if (timer) update(); -} - -template -class TemplateRadiobuttonsGroup : public QMap { - typedef QMap Parent; +class RadiobuttonGroup : public QMap { + using Parent = QMap; public: - TemplateRadiobuttonsGroup(const QString &name) : _name(name), _val(0) { + RadiobuttonGroup(const QString &name) : _name(name) { } - void remove(Type * const &radio) { - } + void remove(Radiobutton * const &radio); int32 val() const { return _val; } @@ -148,23 +43,18 @@ public: private: QString _name; - int32 _val; + int _val = 0; }; -typedef TemplateRadiobuttonsGroup FlatRadiobuttonGroup; -typedef TemplateRadiobuttonsGroup RadiobuttonGroup; - -template -class Radiobuttons : public QMap *> { - typedef QMap *> Parent; +class Radiobuttons : public QMap { + using Parent = QMap; public: - - TemplateRadiobuttonsGroup *reg(const QString &group) { + RadiobuttonGroup *reg(const QString &group) { typename Parent::const_iterator i = Parent::constFind(group); if (i == Parent::cend()) { - i = Parent::insert(group, new TemplateRadiobuttonsGroup(group)); + i = Parent::insert(group, new RadiobuttonGroup(group)); } return i.value(); } @@ -186,55 +76,17 @@ public: } }; -namespace { - Radiobuttons flatRadiobuttons; - Radiobuttons radiobuttons; -} +Radiobuttons radiobuttons; -template <> -void TemplateRadiobuttonsGroup::remove(FlatRadiobutton * const &radio) { - Parent::remove(radio); - if (isEmpty()) { - flatRadiobuttons.remove(_name); - } -} +} // namespace -template <> -void TemplateRadiobuttonsGroup::remove(Radiobutton * const &radio) { +void RadiobuttonGroup::remove(Radiobutton * const &radio) { Parent::remove(radio); if (isEmpty()) { radiobuttons.remove(_name); } } -FlatRadiobutton::FlatRadiobutton(QWidget *parent, const QString &group, int32 value, const QString &text, bool checked, const style::flatCheckbox &st) : - FlatCheckbox(parent, text, checked, st), _group(flatRadiobuttons.reg(group)), _value(value) { - reinterpret_cast(_group)->insert(this, true); - connect(this, SIGNAL(changed()), this, SLOT(onChanged())); - if (this->checked()) onChanged(); -} - -void FlatRadiobutton::onChanged() { - FlatRadiobuttonGroup *group = reinterpret_cast(_group); - if (checked()) { - int32 uncheck = group->val(); - if (uncheck != _value) { - group->setVal(_value); - for (FlatRadiobuttonGroup::const_iterator i = group->cbegin(), e = group->cend(); i != e; ++i) { - if (i.key()->val() == uncheck) { - i.key()->setChecked(false); - } - } - } - } else if (group->val() == _value) { - setChecked(true); - } -} - -FlatRadiobutton::~FlatRadiobutton() { - reinterpret_cast(_group)->remove(this); -} - Checkbox::Checkbox(QWidget *parent, const QString &text, bool checked, const style::Checkbox &st) : Button(parent) , _st(st) , a_over(0) @@ -564,3 +416,5 @@ void Radiobutton::onChanged() { Radiobutton::~Radiobutton() { reinterpret_cast(_group)->remove(this); } + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/flatcheckbox.h b/Telegram/SourceFiles/ui/buttons/checkbox.h similarity index 72% rename from Telegram/SourceFiles/ui/flatcheckbox.h rename to Telegram/SourceFiles/ui/buttons/checkbox.h index ea43ce09d..8b7ccf367 100644 --- a/Telegram/SourceFiles/ui/flatcheckbox.h +++ b/Telegram/SourceFiles/ui/buttons/checkbox.h @@ -22,62 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/button.h" -class FlatCheckbox : public Button { - Q_OBJECT - -public: - FlatCheckbox(QWidget *parent, const QString &text, bool checked, const style::flatCheckbox &st); - - bool checked() const; - void setChecked(bool checked); - - void step_appearance(float64 ms, bool timer); - void paintEvent(QPaintEvent *e); - - void setOpacity(float64 o); - -public slots: - void onClicked(); - void onStateChange(int oldState, ButtonStateChangeSource source); - -signals: - void changed(); - -private: - style::flatCheckbox _st; - anim::fvalue a_over; - Animation _a_appearance; - - QString _text; - style::font _font; - - float64 _opacity; - - bool _checked; - -}; - -class FlatRadiobutton : public FlatCheckbox { - Q_OBJECT - -public: - - FlatRadiobutton(QWidget *parent, const QString &group, int32 value, const QString &text, bool checked, const style::flatCheckbox &st); - int32 val() const { - return _value; - } - ~FlatRadiobutton(); - -public slots: - - void onChanged(); - -private: - - void *_group; - int32 _value; - -}; +namespace Ui { class Checkbox : public Button { Q_OBJECT @@ -99,7 +44,7 @@ public: protected: void paintEvent(QPaintEvent *e) override; -public slots: + public slots: void onClicked(); void onStateChange(int oldState, ButtonStateChangeSource source); @@ -142,7 +87,7 @@ public: ~Radiobutton(); -public slots: + public slots: void onClicked(); void onStateChange(int oldState, ButtonStateChangeSource source); @@ -166,3 +111,5 @@ private: int32 _value; }; + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/flatbutton.cpp b/Telegram/SourceFiles/ui/flatbutton.cpp index 7fcc8d8b3..15573f26a 100644 --- a/Telegram/SourceFiles/ui/flatbutton.cpp +++ b/Telegram/SourceFiles/ui/flatbutton.cpp @@ -163,109 +163,6 @@ void LinkButton::onStateChange(int oldState, ButtonStateChangeSource source) { LinkButton::~LinkButton() { } -IconedButton::IconedButton(QWidget *parent, const style::iconedButton &st, const QString &text) : Button(parent) -, _text(text) -, _st(st) -, _width(_st.width) -, a_opacity(_st.opacity) -, a_bg(_st.bgColor->c) -, _a_appearance(animation(this, &IconedButton::step_appearance)) -, _opacity(1) { - - if (_width < 0) { - _width = _st.font->width(text) - _width; - } else if (!_width) { - _width = _st.font->width(text) + _st.height - _st.font->height; - } - connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource))); - resize(_width, _st.height); - setCursor(_st.cursor); -} - -void IconedButton::setOpacity(float64 opacity) { - _opacity = opacity; - update(); -} - -void IconedButton::setText(const QString &text) { - if (_text != text) { - _text = text; - if (_st.width < 0) { - _width = _st.font->width(text) - _st.width; - } else if (!_st.width) { - _width = _st.font->width(text) + _st.height - _st.font->height; - } - resize(_width, _st.height); - update(); - } -} - -QString IconedButton::getText() const { - return _text; -} - -void IconedButton::step_appearance(float64 ms, bool timer) { - if (_st.duration <= 1) { - _a_appearance.stop(); - a_opacity.finish(); - a_bg.finish(); - } else { - float64 dt = ms / _st.duration; - if (dt >= 1) { - _a_appearance.stop(); - a_opacity.finish(); - a_bg.finish(); - } else { - a_opacity.update(dt, anim::linear); - a_bg.update(dt, anim::linear); - } - } - if (timer) update(); -} - -void IconedButton::onStateChange(int oldState, ButtonStateChangeSource source) { - a_opacity.start((_state & (StateOver | StateDown)) ? _st.overOpacity : _st.opacity); - a_bg.start(((_state & (StateOver | StateDown)) ? _st.overBgColor : _st.bgColor)->c); - - if (source == ButtonByUser || source == ButtonByPress) { - _a_appearance.stop(); - a_opacity.finish(); - a_bg.finish(); - update(); - } else { - _a_appearance.start(); - } -} - -void IconedButton::paintEvent(QPaintEvent *e) { - Painter p(this); - - p.setOpacity(_opacity); - - p.fillRect(e->rect(), a_bg.current()); - - p.setOpacity(a_opacity.current() * _opacity); - - if (!_text.isEmpty()) { - p.setFont(_st.font->f); - p.setRenderHint(QPainter::TextAntialiasing); - p.setPen(_st.color->p); - const QPoint &t((_state & StateDown) ? _st.downTextPos : _st.textPos); - p.drawText(t.x(), t.y() + _st.font->ascent, _text); - } - const style::sprite &i((_state & StateDown) ? _st.downIcon : _st.icon); - if (i.pxWidth()) { - QPoint t((_state & StateDown) ? _st.downIconPos : _st.iconPos); - if (t.x() < 0) { - t.setX((width() - i.pxWidth()) / 2); - } - if (t.y() < 0) { - t.setY((height() - i.pxHeight()) / 2); - } - p.drawSprite(t, i); - } -} - BoxButton::BoxButton(QWidget *parent, const QString &text, const style::RoundButton &st) : Button(parent) , _text(text.toUpper()) , _fullText(text.toUpper()) diff --git a/Telegram/SourceFiles/ui/flatbutton.h b/Telegram/SourceFiles/ui/flatbutton.h index 643836c66..6b1c2576f 100644 --- a/Telegram/SourceFiles/ui/flatbutton.h +++ b/Telegram/SourceFiles/ui/flatbutton.h @@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #pragma once #include "ui/button.h" -#include "ui/flatcheckbox.h" #include "ui/animation.h" class FlatButton : public Button { @@ -84,36 +83,6 @@ private: }; -class IconedButton : public Button { - Q_OBJECT - -public: - IconedButton(QWidget *parent, const style::iconedButton &st, const QString &text = QString()); - - void step_appearance(float64 ms, bool timer); - void paintEvent(QPaintEvent *e); - - void setOpacity(float64 o); - - void setText(const QString &text); - QString getText() const; - -public slots: - void onStateChange(int oldState, ButtonStateChangeSource source); - -protected: - QString _text; - - style::iconedButton _st; - int32 _width; - - anim::fvalue a_opacity; - anim::cvalue a_bg; - Animation _a_appearance; - - float64 _opacity; -}; - class BoxButton : public Button { Q_OBJECT diff --git a/Telegram/SourceFiles/ui/style/style_core.cpp b/Telegram/SourceFiles/ui/style/style_core.cpp index 846394ef8..736c1fe67 100644 --- a/Telegram/SourceFiles/ui/style/style_core.cpp +++ b/Telegram/SourceFiles/ui/style/style_core.cpp @@ -65,7 +65,6 @@ void startManager() { } internal::registerFontFamily(qsl("Open Sans")); - internal::loadSprite(); internal::startModules(); } @@ -74,7 +73,6 @@ void stopManager() { internal::destroyFonts(); internal::destroyColors(); internal::destroyIcons(); - internal::destroySprite(); } QImage colorizeImage(const QImage &src, const color &c, const QRect &r) { diff --git a/Telegram/SourceFiles/ui/style/style_core.h b/Telegram/SourceFiles/ui/style/style_core.h index f3848978a..ea61f8ce7 100644 --- a/Telegram/SourceFiles/ui/style/style_core.h +++ b/Telegram/SourceFiles/ui/style/style_core.h @@ -77,7 +77,3 @@ inline QImage createInvertedCircleMask(int size) { } } // namespace style - -inline QRect centersprite(const QRect &inRect, const style::sprite &sprite) { - return centerrect(inRect, QRect(QPoint(0, 0), sprite.pxSize())); -} diff --git a/Telegram/SourceFiles/ui/style/style_core_types.cpp b/Telegram/SourceFiles/ui/style/style_core_types.cpp index 2f0444307..d26a173da 100644 --- a/Telegram/SourceFiles/ui/style/style_core_types.cpp +++ b/Telegram/SourceFiles/ui/style/style_core_types.cpp @@ -22,46 +22,4 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/style/style_core_types.h" namespace style { -namespace internal { -namespace { - -int spriteWidthValue = 0; -QPixmap *spriteData = nullptr; - -} // namespace - -void loadSprite() { - QString spriteFilePostfix; - if (cRetina() || cScale() == dbisTwo) { - spriteFilePostfix = qsl("_200x"); - } else if (cScale() == dbisOneAndQuarter) { - spriteFilePostfix = qsl("_125x"); - } else if (cScale() == dbisOneAndHalf) { - spriteFilePostfix = qsl("_150x"); - } - QString spriteFile = qsl(":/gui/art/sprite") + spriteFilePostfix + qsl(".png"); - if (rtl()) { - spriteData = new QPixmap(App::pixmapFromImageInPlace(QImage(spriteFile).mirrored(true, false))); - } else { - spriteData = new QPixmap(spriteFile); - } - if (cRetina()) spriteData->setDevicePixelRatio(cRetinaFactor()); - spriteWidthValue = spriteData->width(); -} - -int spriteWidth() { - return spriteWidthValue; -} - -void destroySprite() { - delete spriteData; - spriteData = nullptr; -} - -} // namespace internal - -const QPixmap &spritePixmap() { - return *internal::spriteData; -} - } // namespace style diff --git a/Telegram/SourceFiles/ui/style/style_core_types.h b/Telegram/SourceFiles/ui/style/style_core_types.h index aa2fa782c..89194a264 100644 --- a/Telegram/SourceFiles/ui/style/style_core_types.h +++ b/Telegram/SourceFiles/ui/style/style_core_types.h @@ -33,50 +33,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/style/style_core_icon.h" namespace style { -namespace internal { - -void loadSprite(); -int spriteWidth(); -void destroySprite(); - -class Sprite { -public: - Sprite() { - } - Sprite(int left, int top, int width, int height) - : _rect(rtl() ? (spriteWidth() - left * cIntRetinaFactor() - width * cIntRetinaFactor()) : left * cIntRetinaFactor(), - top * cIntRetinaFactor(), - width * cIntRetinaFactor(), - height * cIntRetinaFactor()) { - } - int pxWidth() const { - return _rect.width() / cIntRetinaFactor(); - } - int pxHeight() const { - return _rect.height() / cIntRetinaFactor(); - } - QSize pxSize() const { - return _rect.size() / cIntRetinaFactor(); - } - QRect rect() const { - return _rect; - } - bool isEmpty() const { - return _rect.isEmpty(); - } - -private: - QRect _rect; - -}; -inline bool operator==(const Sprite &a, const Sprite &b) { - return a.rect() == b.rect(); -} -inline bool operator!=(const Sprite &a, const Sprite &b) { - return !(a == b); -} - -} // namespace internal using string = QString; using rect = QRect; @@ -88,7 +44,6 @@ using align = Qt::Alignment; using margins = QMargins; using font = internal::Font; using color = internal::Color; -using sprite = internal::Sprite; using icon = internal::Icon; static constexpr cursor cur_default = Qt::ArrowCursor; @@ -111,6 +66,4 @@ static const align al_bottomleft = (Qt::AlignBottom | Qt::AlignLeft); static const align al_left = (Qt::AlignVCenter | Qt::AlignLeft); static const align al_center = (Qt::AlignVCenter | Qt::AlignHCenter); -const QPixmap &spritePixmap(); - } // namespace style diff --git a/Telegram/SourceFiles/ui/twidget.h b/Telegram/SourceFiles/ui/twidget.h index 8c9c6f964..b8bb58a7c 100644 --- a/Telegram/SourceFiles/ui/twidget.h +++ b/Telegram/SourceFiles/ui/twidget.h @@ -20,10 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #pragma once -namespace App { - const QPixmap &sprite(); -} - namespace Fonts { void start(); } @@ -79,45 +75,6 @@ public: void drawPixmapRight(const QPoint &p, int outerw, const QPixmap &pix) { return drawPixmapRight(p.x(), p.y(), outerw, pix); } - void drawSprite(int x, int y, const style::sprite &sprite) { - return drawPixmap(QPoint(x, y), App::sprite(), sprite.rect()); - } - void drawSprite(const QPoint &p, const style::sprite &sprite) { - return drawPixmap(p, App::sprite(), sprite.rect()); - } - void drawSpriteLeft(int x, int y, int outerw, const style::sprite &sprite) { - return drawPixmapLeft(x, y, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteLeft(const QPoint &p, int outerw, const style::sprite &sprite) { - return drawPixmapLeft(p, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteLeft(int x, int y, int w, int h, int outerw, const style::sprite &sprite) { - return drawPixmapLeft(x, y, w, h, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteLeft(const QRect &r, int outerw, const style::sprite &sprite) { - return drawPixmapLeft(r, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteRight(int x, int y, int outerw, const style::sprite &sprite) { - return drawPixmapRight(x, y, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteRight(const QPoint &p, int outerw, const style::sprite &sprite) { - return drawPixmapRight(p, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteRight(int x, int y, int w, int h, int outerw, const style::sprite &sprite) { - return drawPixmapRight(x, y, w, h, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteRight(const QRect &r, int outerw, const style::sprite &sprite) { - return drawPixmapRight(r, outerw, App::sprite(), sprite.rect()); - } - void drawSpriteCenter(const QRect &in, const style::sprite &sprite) { - return drawPixmap(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), App::sprite(), sprite.rect()); - } - void drawSpriteCenterLeft(const QRect &in, int outerw, const style::sprite &sprite) { - return drawPixmapLeft(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), outerw, App::sprite(), sprite.rect()); - } - void drawSpriteCenterRight(const QRect &in, int outerw, const style::sprite &sprite) { - return drawPixmapRight(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), outerw, App::sprite(), sprite.rect()); - } }; #define T_WIDGET \ diff --git a/Telegram/SourceFiles/ui/widgets/widgets.style b/Telegram/SourceFiles/ui/widgets/widgets.style index 48c61dd98..2f6f99509 100644 --- a/Telegram/SourceFiles/ui/widgets/widgets.style +++ b/Telegram/SourceFiles/ui/widgets/widgets.style @@ -195,10 +195,10 @@ defaultMenu: Menu { itemBgOver: overBg; itemFg: black; itemFgOver: black; - itemFgDisabled: #ccc; - itemFgShortcut: #999; + itemFgDisabled: #cccccc; + itemFgShortcut: #999999; itemFgShortcutOver: #7c99b2; - itemFgShortcutDisabled: #ccc; + itemFgShortcutDisabled: #cccccc; itemIconPosition: point(0px, 0px); itemIconOpacity: 1.; itemIconOverOpacity: 1.; diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index 9ffc4d0f8..e7a05c460 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -444,6 +444,8 @@ '<(src_loc)/stickers/emoji_pan.h', '<(src_loc)/stickers/stickers.cpp', '<(src_loc)/stickers/stickers.h', + '<(src_loc)/ui/buttons/checkbox.cpp', + '<(src_loc)/ui/buttons/checkbox.h', '<(src_loc)/ui/buttons/history_down_button.cpp', '<(src_loc)/ui/buttons/history_down_button.h', '<(src_loc)/ui/buttons/icon_button.cpp', @@ -522,8 +524,6 @@ '<(src_loc)/ui/filedialog.h', '<(src_loc)/ui/flatbutton.cpp', '<(src_loc)/ui/flatbutton.h', - '<(src_loc)/ui/flatcheckbox.cpp', - '<(src_loc)/ui/flatcheckbox.h', '<(src_loc)/ui/flatinput.cpp', '<(src_loc)/ui/flatinput.h', '<(src_loc)/ui/flatlabel.cpp', diff --git a/Telegram/gyp/codegen.gyp b/Telegram/gyp/codegen.gyp index b48dcb970..04f62494a 100644 --- a/Telegram/gyp/codegen.gyp +++ b/Telegram/gyp/codegen.gyp @@ -83,8 +83,6 @@ '<(src_loc)/codegen/style/parsed_file.h', '<(src_loc)/codegen/style/processor.cpp', '<(src_loc)/codegen/style/processor.h', - '<(src_loc)/codegen/style/sprite_generator.cpp', - '<(src_loc)/codegen/style/sprite_generator.h', '<(src_loc)/codegen/style/structure_types.cpp', '<(src_loc)/codegen/style/structure_types.h', ], diff --git a/Telegram/gyp/codegen_rules.gypi b/Telegram/gyp/codegen_rules.gypi index 058098b9d..825a09f4e 100644 --- a/Telegram/gyp/codegen_rules.gypi +++ b/Telegram/gyp/codegen_rules.gypi @@ -19,25 +19,6 @@ { 'actions': [{ - 'action_name': 'update_sprites', - 'inputs': [ - '<(PRODUCT_DIR)/codegen_style<(exe_ext)', - '<(res_loc)/basic.style', - '<(res_loc)/art/sprite.png', - '<(res_loc)/art/sprite_200x.png', - ], - 'outputs': [ - '<(res_loc)/art/sprite_125x.png', - '<(res_loc)/art/sprite_150x.png', - ], - 'action': [ - '<(PRODUCT_DIR)/codegen_style<(exe_ext)', - '-I<(res_loc)', '-I<(src_loc)', - '-w<(PRODUCT_DIR)/../..', - '--skip-styles', '<(res_loc)/basic.style', - ], - 'message': 'Updating sprites..', - }, { 'action_name': 'update_dependent_styles', 'inputs': [ '<(DEPTH)/update_dependent.py', @@ -116,7 +97,7 @@ ], 'action': [ '<(PRODUCT_DIR)/codegen_style<(exe_ext)', - '-I<(res_loc)', '-I<(src_loc)', '--skip-sprites', + '-I<(res_loc)', '-I<(src_loc)', '-o<(SHARED_INTERMEDIATE_DIR)/styles', '-w<(PRODUCT_DIR)/../..',