Updated lib_ui sources to TDesktop version 2.4.7
This commit is contained in:
commit
5f5339aa7e
13 changed files with 97 additions and 101 deletions
|
|
@ -1,57 +0,0 @@
|
|||
<?xml version='1.0'?>
|
||||
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
||||
<fontconfig>
|
||||
<dir>/usr/share/fonts</dir>
|
||||
<dir>/usr/local/share/fonts</dir>
|
||||
<dir>~/.fonts</dir>
|
||||
<dir>~/.local/share/fonts</dir>
|
||||
<dir>/usr/X11R6/lib/X11/fonts</dir>
|
||||
<dir prefix="xdg">fonts</dir>
|
||||
<match target="pattern">
|
||||
<test qual="any" name="family">
|
||||
<string>mono</string>
|
||||
</test>
|
||||
<edit name="family" mode="assign" binding="same">
|
||||
<string>monospace</string>
|
||||
</edit>
|
||||
</match>
|
||||
<match target="pattern">
|
||||
<test qual="any" name="family">
|
||||
<string>sans serif</string>
|
||||
</test>
|
||||
<edit name="family" mode="assign" binding="same">
|
||||
<string>sans-serif</string>
|
||||
</edit>
|
||||
</match>
|
||||
<match target="pattern">
|
||||
<test qual="any" name="family">
|
||||
<string>sans</string>
|
||||
</test>
|
||||
<edit name="family" mode="assign" binding="same">
|
||||
<string>sans-serif</string>
|
||||
</edit>
|
||||
</match>
|
||||
<cachedir>/var/cache/fontconfig_11</cachedir>
|
||||
<cachedir prefix="xdg">fontconfig_11</cachedir>
|
||||
<cachedir>~/.fontconfig_11</cachedir>
|
||||
<match target="font">
|
||||
<edit mode="assign" name="antialias">
|
||||
<bool>true</bool>
|
||||
</edit>
|
||||
<edit mode="assign" name="embeddedbitmap">
|
||||
<bool>false</bool>
|
||||
</edit>
|
||||
<edit mode="assign" name="hinting">
|
||||
<bool>true</bool>
|
||||
</edit>
|
||||
<edit mode="assign" name="hintstyle">
|
||||
<const>hintslight</const>
|
||||
</edit>
|
||||
<edit mode="assign" name="lcdfilter">
|
||||
<const>lcddefault</const>
|
||||
</edit>
|
||||
<edit mode="assign" name="rgba">
|
||||
<const>rgb</const>
|
||||
</edit>
|
||||
</match>
|
||||
</fontconfig>
|
||||
|
|
@ -10,7 +10,4 @@
|
|||
<file>DAVazirMediumAsBold.ttf</file>
|
||||
<file>DAVazirMedium.ttf</file>
|
||||
</qresource>
|
||||
<qresource prefix="/fc">
|
||||
<file>fc-custom.conf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -41,13 +41,16 @@ QString UrlClickHandler::copyToClipboardContextItemText() const {
|
|||
: Ui::Integration::Instance().phraseContextCopyLink();
|
||||
}
|
||||
|
||||
QString UrlClickHandler::url() const {
|
||||
if (isEmail()) {
|
||||
return _originalUrl;
|
||||
QString UrlClickHandler::EncodeForOpening(const QString &originalUrl) {
|
||||
if (IsEmail(originalUrl)) {
|
||||
return originalUrl;
|
||||
}
|
||||
|
||||
QUrl u(_originalUrl), good(u.isValid() ? u.toEncoded() : QString());
|
||||
QString result(good.isValid() ? QString::fromUtf8(good.toEncoded()) : _originalUrl);
|
||||
const auto u = QUrl(originalUrl);
|
||||
const auto good = QUrl(u.isValid() ? u.toEncoded() : QString());
|
||||
const auto result = good.isValid()
|
||||
? QString::fromUtf8(good.toEncoded())
|
||||
: originalUrl;
|
||||
|
||||
if (!result.isEmpty()
|
||||
&& !QRegularExpression(
|
||||
|
|
|
|||
|
|
@ -59,11 +59,17 @@ public:
|
|||
const auto at = url.indexOf('@'), slash = url.indexOf('/');
|
||||
return ((at > 0) && (slash < 0 || slash > at));
|
||||
}
|
||||
[[nodiscard]] static QString EncodeForOpening(const QString &originalUrl);
|
||||
[[nodiscard]] static bool IsSuspicious(const QString &url);
|
||||
[[nodiscard]] static QString ShowEncoded(const QString &url);
|
||||
|
||||
protected:
|
||||
QString url() const override;
|
||||
[[nodiscard]] QString originalUrl() const {
|
||||
return _originalUrl;
|
||||
}
|
||||
QString url() const override {
|
||||
return EncodeForOpening(_originalUrl);
|
||||
}
|
||||
QString readable() const override {
|
||||
return _readable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,20 @@ std::array<QImage, 4> PrepareCorners(
|
|||
return result;
|
||||
}
|
||||
|
||||
std::array<QImage, 4> CornersMask(int radius) {
|
||||
return PrepareCornersMask(radius);
|
||||
}
|
||||
|
||||
std::array<QImage, 4> PrepareCorners(
|
||||
int radius,
|
||||
const style::color &color) {
|
||||
auto result = CornersMask(radius);
|
||||
for (auto &image : result) {
|
||||
style::colorizeImage(image, color->c, &image);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QImage prepareBlur(QImage img) {
|
||||
if (img.isNull()) {
|
||||
return img;
|
||||
|
|
|
|||
|
|
@ -27,12 +27,18 @@ namespace Images {
|
|||
|
||||
[[nodiscard]] QPixmap PixmapFast(QImage &&image);
|
||||
[[nodiscard]] QImage BlurLargeImage(QImage image, int radius);
|
||||
|
||||
[[nodiscard]] const std::array<QImage, 4> &CornersMask(
|
||||
ImageRoundRadius radius);
|
||||
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
||||
ImageRoundRadius radius,
|
||||
const style::color &color);
|
||||
|
||||
[[nodiscard]] std::array<QImage, 4> CornersMask(int radius);
|
||||
[[nodiscard]] std::array<QImage, 4> PrepareCorners(
|
||||
int radius,
|
||||
const style::color &color);
|
||||
|
||||
QImage prepareBlur(QImage image);
|
||||
void prepareRound(
|
||||
QImage &image,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void IgnoreAllActivation(not_null<QWidget*> widget) {
|
|||
|
||||
ShowWindow(handle, SW_HIDE);
|
||||
const auto style = GetWindowLongPtr(handle, GWL_EXSTYLE);
|
||||
SetWindowLong(
|
||||
SetWindowLongPtr(
|
||||
handle,
|
||||
GWL_EXSTYLE,
|
||||
style | WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ void WindowShadow::init(QColor color) {
|
|||
return;
|
||||
}
|
||||
ShadowByHandle.emplace(_handles[i], this);
|
||||
SetWindowLongPtr(_handles[i], GWLP_HWNDPARENT, (LONG)_handle);
|
||||
SetWindowLongPtr(_handles[i], GWLP_HWNDPARENT, (LONG_PTR)_handle);
|
||||
|
||||
_contexts[i] = CreateCompatibleDC(_screenContext);
|
||||
if (!_contexts[i]) {
|
||||
|
|
|
|||
|
|
@ -74,6 +74,17 @@ RoundRect::RoundRect(
|
|||
}, _lifetime);
|
||||
}
|
||||
|
||||
RoundRect::RoundRect(
|
||||
int radius,
|
||||
const style::color &color)
|
||||
: _color(color)
|
||||
, _corners(Images::PrepareCorners(radius, color)) {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_corners = Images::PrepareCorners(radius, _color);
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
const style::color &RoundRect::color() const {
|
||||
return _color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ void DrawRoundedRect(
|
|||
class RoundRect final {
|
||||
public:
|
||||
RoundRect(ImageRoundRadius radius, const style::color &color);
|
||||
RoundRect(int radius, const style::color &color);
|
||||
|
||||
[[nodiscard]] const style::color &color() const;
|
||||
void paint(
|
||||
|
|
|
|||
|
|
@ -535,6 +535,20 @@ bool Parser::checkEntities() {
|
|||
const auto entityLength = _waitingEntity->length();
|
||||
const auto entityBegin = _start + _waitingEntity->offset();
|
||||
const auto entityEnd = entityBegin + entityLength;
|
||||
const auto pushSimpleUrl = [&](EntityType type) {
|
||||
link.type = type;
|
||||
link.data = QString(entityBegin, entityLength);
|
||||
if (type == EntityType::Url) {
|
||||
computeLinkText(link.data, &link.text, &link.shown);
|
||||
} else {
|
||||
link.text = link.data;
|
||||
}
|
||||
};
|
||||
const auto pushComplexUrl = [&] {
|
||||
link.type = entityType;
|
||||
link.data = _waitingEntity->data();
|
||||
link.text = QString(entityBegin, entityLength);
|
||||
};
|
||||
if (entityType == EntityType::Bold) {
|
||||
flags = TextBlockFBold;
|
||||
} else if (entityType == EntityType::Semibold) {
|
||||
|
|
@ -559,18 +573,17 @@ bool Parser::checkEntities() {
|
|||
|| entityType == EntityType::Hashtag
|
||||
|| entityType == EntityType::Cashtag
|
||||
|| entityType == EntityType::BotCommand) {
|
||||
link.type = entityType;
|
||||
link.data = QString(entityBegin, entityLength);
|
||||
if (link.type == EntityType::Url) {
|
||||
computeLinkText(link.data, &link.text, &link.shown);
|
||||
pushSimpleUrl(entityType);
|
||||
} else if (entityType == EntityType::CustomUrl) {
|
||||
const auto url = _waitingEntity->data();
|
||||
const auto text = QString(entityBegin, entityLength);
|
||||
if (url == text) {
|
||||
pushSimpleUrl(EntityType::Url);
|
||||
} else {
|
||||
link.text = link.data;
|
||||
pushComplexUrl();
|
||||
}
|
||||
} else if (entityType == EntityType::CustomUrl
|
||||
|| entityType == EntityType::MentionName) {
|
||||
link.type = entityType;
|
||||
link.data = _waitingEntity->data();
|
||||
link.text = QString(_start + _waitingEntity->offset(), _waitingEntity->length());
|
||||
} else if (entityType == EntityType::MentionName) {
|
||||
pushComplexUrl();
|
||||
}
|
||||
|
||||
if (link.type != EntityType::Invalid) {
|
||||
|
|
@ -3271,16 +3284,20 @@ TextForMimeData String::toText(
|
|||
if (!composeExpanded && !composeEntities) {
|
||||
return;
|
||||
}
|
||||
const auto skipLink = (entity.type == EntityType::CustomUrl)
|
||||
&& (entity.data.startsWith(qstr("internal:")));
|
||||
const auto customTextLink = (entity.type == EntityType::CustomUrl);
|
||||
const auto internalLink = customTextLink
|
||||
&& entity.data.startsWith(qstr("internal:"));
|
||||
if (composeExpanded) {
|
||||
result.expanded.append(full);
|
||||
if (entity.type == EntityType::CustomUrl && !skipLink) {
|
||||
const auto sameAsTextLink = customTextLink
|
||||
&& (entity.data
|
||||
== UrlClickHandler::EncodeForOpening(full.toString()));
|
||||
if (customTextLink && !internalLink && !sameAsTextLink) {
|
||||
const auto &url = entity.data;
|
||||
result.expanded.append(qstr(" (")).append(url).append(')');
|
||||
}
|
||||
}
|
||||
if (composeEntities && !skipLink) {
|
||||
if (composeEntities && !internalLink) {
|
||||
insertEntity({
|
||||
entity.type,
|
||||
linkStart,
|
||||
|
|
|
|||
|
|
@ -1587,7 +1587,8 @@ void ParseEntities(TextWithEntities &result, int32 flags, bool rich) {
|
|||
|
||||
int32 len = result.text.size(), commandOffset = rich ? 0 : len;
|
||||
bool inLink = false, commandIsLink = false;
|
||||
const QChar *start = result.text.constData(), *end = start + result.text.size();
|
||||
const auto start = result.text.constData();
|
||||
const auto end = start + result.text.size();
|
||||
for (int32 offset = 0, matchOffset = offset, mentionSkip = 0; offset < len;) {
|
||||
if (commandOffset <= offset) {
|
||||
for (commandOffset = offset; commandOffset < len; ++commandOffset) {
|
||||
|
|
@ -1642,6 +1643,10 @@ void ParseEntities(TextWithEntities &result, int32 flags, bool rich) {
|
|||
}
|
||||
if (!(start + mentionStart + 1)->isLetter() || !(start + mentionEnd - 1)->isLetterOrNumber()) {
|
||||
mentionSkip = mentionEnd;
|
||||
if (mentionSkip < len
|
||||
&& (start + mentionSkip)->isLowSurrogate()) {
|
||||
++mentionSkip;
|
||||
}
|
||||
mMention = RegExpMention().match(result.text, qMax(mentionSkip, matchOffset));
|
||||
if (mMention.hasMatch()) {
|
||||
mentionStart = mMention.capturedStart();
|
||||
|
|
|
|||
|
|
@ -24,23 +24,11 @@ class object_ptr;
|
|||
namespace Ui {
|
||||
namespace details {
|
||||
|
||||
struct ForwardTag {
|
||||
};
|
||||
|
||||
struct InPlaceTag {
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
class AttachmentOwner : public QObject {
|
||||
public:
|
||||
template <typename OtherValue>
|
||||
AttachmentOwner(QObject *parent, const ForwardTag&, OtherValue &&value)
|
||||
: QObject(parent)
|
||||
, _value(std::forward<OtherValue>(value)) {
|
||||
}
|
||||
|
||||
template <typename ...Args>
|
||||
AttachmentOwner(QObject *parent, const InPlaceTag&, Args &&...args)
|
||||
AttachmentOwner(QObject *parent, Args &&...args)
|
||||
: QObject(parent)
|
||||
, _value(std::forward<Args>(args)...) {
|
||||
}
|
||||
|
|
@ -74,11 +62,19 @@ inline Value *CreateChild(
|
|||
} else {
|
||||
return CreateChild<details::AttachmentOwner<Value>>(
|
||||
parent,
|
||||
details::InPlaceTag{},
|
||||
std::forward<Args>(args)...)->value();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
inline not_null<details::AttachmentOwner<std::decay_t<Value>>*> WrapAsQObject(
|
||||
not_null<QObject*> parent,
|
||||
Value &&value) {
|
||||
return CreateChild<details::AttachmentOwner<std::decay_t<Value>>>(
|
||||
parent.get(),
|
||||
std::forward<Value>(value));
|
||||
}
|
||||
|
||||
inline void DestroyChild(QWidget *child) {
|
||||
delete child;
|
||||
}
|
||||
|
|
@ -92,10 +88,7 @@ template <typename Value>
|
|||
inline not_null<std::decay_t<Value>*> AttachAsChild(
|
||||
not_null<QObject*> parent,
|
||||
Value &&value) {
|
||||
return CreateChild<details::AttachmentOwner<std::decay_t<Value>>>(
|
||||
parent.get(),
|
||||
details::ForwardTag{},
|
||||
std::forward<Value>(value))->value();
|
||||
return WrapAsQObject(parent, std::forward<Value>(value))->value();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool AppInFocus();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue