mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Moved some constants for peer editing to separated file.
This commit is contained in:
parent
2d37920a4c
commit
b776308fd7
8 changed files with 41 additions and 37 deletions
|
@ -160,6 +160,7 @@ PRIVATE
|
|||
boxes/peers/edit_participant_box.h
|
||||
boxes/peers/edit_participants_box.cpp
|
||||
boxes/peers/edit_participants_box.h
|
||||
boxes/peers/edit_peer_common.h
|
||||
boxes/peers/edit_peer_info_box.cpp
|
||||
boxes/peers/edit_peer_info_box.h
|
||||
boxes/peers/edit_peer_invite_link.cpp
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/peers/add_participants_box.h"
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
#include "boxes/peers/edit_participant_box.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "core/application.h"
|
||||
|
@ -47,11 +48,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxGroupChannelTitle = 128; // See also edit_peer_info_box.
|
||||
constexpr auto kMaxUserFirstLastName = 64; // See also edit_contact_box.
|
||||
constexpr auto kMaxChannelDescription = 255; // See also edit_peer_info_box.
|
||||
constexpr auto kMinUsernameLength = 5;
|
||||
|
||||
bool IsValidPhone(QString phone) {
|
||||
phone = phone.replace(QRegularExpression(qsl("[^\\d]")), QString());
|
||||
return (phone.length() >= 8)
|
||||
|
@ -504,7 +500,7 @@ void GroupInfoBox::prepare() {
|
|||
? tr::lng_dlg_new_channel_name
|
||||
: tr::lng_dlg_new_group_name)(),
|
||||
_initialTitle);
|
||||
_title->setMaxLength(kMaxGroupChannelTitle);
|
||||
_title->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
|
||||
_title->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
_title->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
|
@ -520,7 +516,7 @@ void GroupInfoBox::prepare() {
|
|||
Ui::InputField::Mode::MultiLine,
|
||||
tr::lng_create_group_description());
|
||||
_description->show();
|
||||
_description->setMaxLength(kMaxChannelDescription);
|
||||
_description->setMaxLength(Ui::EditPeer::kMaxChannelDescription);
|
||||
_description->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
_description->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
|
@ -1157,7 +1153,7 @@ void SetupChannelBox::handleChange() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (name.size() < kMinUsernameLength) {
|
||||
if (name.size() < Ui::EditPeer::kMinUsernameLength) {
|
||||
const auto tooShort =
|
||||
tr::lng_create_channel_link_too_short(tr::now);
|
||||
if (_errorText != tooShort) {
|
||||
|
@ -1170,7 +1166,7 @@ void SetupChannelBox::handleChange() {
|
|||
_errorText = _goodText = QString();
|
||||
update();
|
||||
}
|
||||
_checkTimer.callOnce(UsernameCheckTimeout);
|
||||
_checkTimer.callOnce(Ui::EditPeer::kUsernameCheckTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1180,7 +1176,7 @@ void SetupChannelBox::check() {
|
|||
_channel->session().api().request(_checkRequestId).cancel();
|
||||
}
|
||||
const auto link = _link->text().trimmed();
|
||||
if (link.size() >= kMinUsernameLength) {
|
||||
if (link.size() >= Ui::EditPeer::kMinUsernameLength) {
|
||||
_checkUsername = link;
|
||||
_checkRequestId = _api.request(MTPchannels_CheckUsername(
|
||||
_channel->inputChannel,
|
||||
|
@ -1340,8 +1336,8 @@ void EditNameBox::prepare() {
|
|||
if (_invertOrder) {
|
||||
setTabOrder(_last, _first);
|
||||
}
|
||||
_first->setMaxLength(kMaxUserFirstLastName);
|
||||
_last->setMaxLength(kMaxUserFirstLastName);
|
||||
_first->setMaxLength(Ui::EditPeer::kMaxUserFirstLastName);
|
||||
_last->setMaxLength(Ui::EditPeer::kMaxUserFirstLastName);
|
||||
|
||||
connect(_first, &Ui::InputField::submitted, [=] { submit(); });
|
||||
connect(_last, &Ui::InputField::submitted, [=] { submit(); });
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
|
@ -26,8 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxUserFirstLastName = 64; // See also add_contact_box.
|
||||
|
||||
QString UserPhone(not_null<UserData*> user) {
|
||||
const auto phone = user->phone();
|
||||
return phone.isEmpty()
|
||||
|
@ -222,8 +221,8 @@ void Controller::initNameFields(
|
|||
};
|
||||
QObject::connect(first, &Ui::InputField::submitted, submit);
|
||||
QObject::connect(last, &Ui::InputField::submitted, submit);
|
||||
first->setMaxLength(kMaxUserFirstLastName);
|
||||
first->setMaxLength(kMaxUserFirstLastName);
|
||||
first->setMaxLength(Ui::EditPeer::kMaxUserFirstLastName);
|
||||
first->setMaxLength(Ui::EditPeer::kMaxUserFirstLastName);
|
||||
}
|
||||
|
||||
void Controller::setupWarning() {
|
||||
|
|
18
Telegram/SourceFiles/boxes/peers/edit_peer_common.h
Normal file
18
Telegram/SourceFiles/boxes/peers/edit_peer_common.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Ui::EditPeer {
|
||||
|
||||
constexpr auto kMaxGroupChannelTitle = 128;
|
||||
constexpr auto kMaxUserFirstLastName = 64;
|
||||
constexpr auto kMaxChannelDescription = 255;
|
||||
constexpr auto kMinUsernameLength = 5;
|
||||
constexpr auto kUsernameCheckTimeout = crl::time(200);
|
||||
|
||||
} // namespace Ui::EditPeer
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
#include "boxes/peers/edit_peer_type_box.h"
|
||||
#include "boxes/peers/edit_peer_history_visibility_box.h"
|
||||
#include "boxes/peers/edit_peer_permissions_box.h"
|
||||
|
@ -249,9 +250,6 @@ void ShowEditPermissions(
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxGroupChannelTitle = 128; // See also add_contact_box.
|
||||
constexpr auto kMaxChannelDescription = 255; // See also add_contact_box.
|
||||
|
||||
class Controller : public base::has_weak_ptr {
|
||||
public:
|
||||
Controller(
|
||||
|
@ -475,7 +473,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
|
|||
: tr::lng_dlg_new_channel_name)(),
|
||||
_peer->name),
|
||||
st::editPeerTitleMargins);
|
||||
result->entity()->setMaxLength(kMaxGroupChannelTitle);
|
||||
result->entity()->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
|
||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
result->entity()->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
|
@ -509,7 +507,7 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
|
|||
tr::lng_create_group_description(),
|
||||
_peer->about()),
|
||||
st::editPeerDescriptionMargins);
|
||||
result->entity()->setMaxLength(kMaxChannelDescription);
|
||||
result->entity()->setMaxLength(Ui::EditPeer::kMaxChannelDescription);
|
||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
result->entity()->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
#include "boxes/peers/edit_peer_info_box.h" // CreateButton.
|
||||
#include "boxes/peers/edit_peer_invite_link.h"
|
||||
#include "boxes/peers/edit_peer_invite_links.h"
|
||||
|
@ -55,9 +56,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
constexpr auto kUsernameCheckTimeout = crl::time(200);
|
||||
constexpr auto kMinUsernameLength = 5;
|
||||
|
||||
class Controller : public base::has_weak_ptr {
|
||||
public:
|
||||
Controller(
|
||||
|
@ -419,7 +417,7 @@ void Controller::checkUsernameAvailability() {
|
|||
const auto checking = initial
|
||||
? qsl(".bad.")
|
||||
: getUsernameInput();
|
||||
if (checking.size() < kMinUsernameLength) {
|
||||
if (checking.size() < Ui::EditPeer::kMinUsernameLength) {
|
||||
return;
|
||||
}
|
||||
if (_checkUsernameRequestId) {
|
||||
|
@ -496,11 +494,11 @@ void Controller::usernameChanged() {
|
|||
});
|
||||
if (bad) {
|
||||
showUsernameError(tr::lng_create_channel_link_bad_symbols());
|
||||
} else if (username.size() < kMinUsernameLength) {
|
||||
} else if (username.size() < Ui::EditPeer::kMinUsernameLength) {
|
||||
showUsernameError(tr::lng_create_channel_link_too_short());
|
||||
} else {
|
||||
_controls.usernameResult = nullptr;
|
||||
_checkUsernameTimer.callOnce(kUsernameCheckTimeout);
|
||||
_checkUsernameTimer.callOnce(Ui::EditPeer::kUsernameCheckTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "boxes/username_box.h"
|
||||
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/special_fields.h"
|
||||
|
@ -20,12 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMinUsernameLength = 5;
|
||||
|
||||
} // namespace
|
||||
|
||||
UsernameBox::UsernameBox(QWidget*, not_null<Main::Session*> session)
|
||||
: _session(session)
|
||||
, _textStyle(st::usernameTextStyle)
|
||||
|
@ -190,7 +185,7 @@ void UsernameBox::check() {
|
|||
_api.request(base::take(_checkRequestId)).cancel();
|
||||
|
||||
const auto name = getName();
|
||||
if (name.size() < kMinUsernameLength) {
|
||||
if (name.size() < Ui::EditPeer::kMinUsernameLength) {
|
||||
return;
|
||||
}
|
||||
_checkUsername = name;
|
||||
|
@ -240,7 +235,7 @@ void UsernameBox::changed() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (name.size() < kMinUsernameLength) {
|
||||
if (name.size() < Ui::EditPeer::kMinUsernameLength) {
|
||||
if (_errorText != tr::lng_username_too_short(tr::now)) {
|
||||
_errorText = tr::lng_username_too_short(tr::now);
|
||||
update();
|
||||
|
@ -251,7 +246,7 @@ void UsernameBox::changed() {
|
|||
_errorText = _goodText = QString();
|
||||
update();
|
||||
}
|
||||
_checkTimer.callOnce(UsernameCheckTimeout);
|
||||
_checkTimer.callOnce(Ui::EditPeer::kUsernameCheckTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ enum {
|
|||
PreloadHeightsCount = 3, // when 3 screens to scroll left make a preload request
|
||||
|
||||
SearchPeopleLimit = 5,
|
||||
UsernameCheckTimeout = 200,
|
||||
|
||||
MaxMessageSize = 4096,
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue