mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-04 19:03:42 +00:00
max history width limited, custom tooltips replace QToolTip, keys with modifiers are not passed to MentionsDropdown
This commit is contained in:
@@ -886,6 +886,8 @@ namespace {
|
||||
|
||||
void TextLink::onClick(Qt::MouseButton button) const {
|
||||
if (button == Qt::LeftButton || button == Qt::MiddleButton) {
|
||||
PopupTooltip::Hide();
|
||||
|
||||
QString url = TextLink::encoded();
|
||||
QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)/?(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
QRegularExpressionMatch telegramMeGroup = QRegularExpression(qsl("^https?://telegram\\.me/joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url);
|
||||
@@ -912,6 +914,7 @@ void TextLink::onClick(Qt::MouseButton button) const {
|
||||
|
||||
void EmailLink::onClick(Qt::MouseButton button) const {
|
||||
if (button == Qt::LeftButton || button == Qt::MiddleButton) {
|
||||
PopupTooltip::Hide();
|
||||
QUrl url(qstr("mailto:") + _email);
|
||||
if (!QDesktopServices::openUrl(url)) {
|
||||
psOpenFile(url.toString(QUrl::FullyEncoded), true);
|
||||
@@ -2713,6 +2716,111 @@ void Text::removeSkipBlock() {
|
||||
}
|
||||
}
|
||||
|
||||
int32 Text::countWidth(int32 w) const {
|
||||
QFixed width = w;
|
||||
if (width < _minResizeWidth) width = _minResizeWidth;
|
||||
if (width >= _maxWidth) {
|
||||
return _maxWidth.ceil().toInt();
|
||||
}
|
||||
|
||||
QFixed minWidthLeft = width, widthLeft = width, last_rBearing = 0, last_rPadding = 0;
|
||||
bool longWordLine = true;
|
||||
for (TextBlocks::const_iterator i = _blocks.cbegin(), e = _blocks.cend(); i != e; ++i) {
|
||||
ITextBlock *b = *i;
|
||||
TextBlockType _btype = b->type();
|
||||
int32 blockHeight = _blockHeight(b, _font);
|
||||
QFixed _rb = _blockRBearing(b);
|
||||
|
||||
if (_btype == TextBlockTNewline) {
|
||||
last_rBearing = _rb;
|
||||
last_rPadding = b->f_rpadding();
|
||||
if (widthLeft < minWidthLeft) {
|
||||
minWidthLeft = widthLeft;
|
||||
}
|
||||
widthLeft = width - (b->f_width() - last_rBearing);
|
||||
|
||||
longWordLine = true;
|
||||
continue;
|
||||
}
|
||||
QFixed lpadding = b->f_lpadding();
|
||||
QFixed newWidthLeft = widthLeft - lpadding - last_rBearing - (last_rPadding + b->f_width() - _rb);
|
||||
if (newWidthLeft >= 0) {
|
||||
last_rBearing = _rb;
|
||||
last_rPadding = b->f_rpadding();
|
||||
widthLeft = newWidthLeft;
|
||||
|
||||
longWordLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_btype == TextBlockTText) {
|
||||
TextBlock *t = static_cast<TextBlock*>(b);
|
||||
if (t->_words.isEmpty()) { // no words in this block, spaces only => layout this block in the same line
|
||||
last_rPadding += lpadding;
|
||||
|
||||
longWordLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
QFixed f_wLeft = widthLeft;
|
||||
for (TextBlock::TextWords::const_iterator j = t->_words.cbegin(), e = t->_words.cend(), f = j; j != e; ++j) {
|
||||
bool wordEndsHere = (j->width >= 0);
|
||||
QFixed j_width = wordEndsHere ? j->width : -j->width;
|
||||
|
||||
QFixed newWidthLeft = widthLeft - lpadding - last_rBearing - (last_rPadding + j_width - j->f_rbearing());
|
||||
lpadding = 0;
|
||||
if (newWidthLeft >= 0) {
|
||||
last_rBearing = j->f_rbearing();
|
||||
last_rPadding = j->rpadding;
|
||||
widthLeft = newWidthLeft;
|
||||
|
||||
if (wordEndsHere) {
|
||||
longWordLine = false;
|
||||
}
|
||||
if (wordEndsHere || longWordLine) {
|
||||
f_wLeft = widthLeft;
|
||||
f = j + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f != j) {
|
||||
j = f;
|
||||
widthLeft = f_wLeft;
|
||||
j_width = (j->width >= 0) ? j->width : -j->width;
|
||||
}
|
||||
|
||||
last_rBearing = j->f_rbearing();
|
||||
last_rPadding = j->rpadding;
|
||||
if (widthLeft < minWidthLeft) {
|
||||
minWidthLeft = widthLeft;
|
||||
}
|
||||
widthLeft = width - (j_width - last_rBearing);
|
||||
|
||||
longWordLine = true;
|
||||
f = j + 1;
|
||||
f_wLeft = widthLeft;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
last_rBearing = _rb;
|
||||
last_rPadding = b->f_rpadding();
|
||||
if (widthLeft < minWidthLeft) {
|
||||
minWidthLeft = widthLeft;
|
||||
}
|
||||
widthLeft = width - (b->f_width() - last_rBearing);
|
||||
|
||||
longWordLine = true;
|
||||
continue;
|
||||
}
|
||||
if (widthLeft < minWidthLeft) {
|
||||
minWidthLeft = widthLeft;
|
||||
}
|
||||
|
||||
return (width - minWidthLeft).ceil().toInt();
|
||||
}
|
||||
|
||||
int32 Text::countHeight(int32 w) const {
|
||||
QFixed width = w;
|
||||
if (width < _minResizeWidth) width = _minResizeWidth;
|
||||
|
||||
Reference in New Issue
Block a user