diff --git a/CMakeLists.txt b/CMakeLists.txt index 87d41a8..562ba9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ PRIVATE ui/style/style_core_scale.h ui/style/style_core_types.cpp ui/style/style_core_types.h + ui/text/qtextitemint.cpp ui/text/text.cpp ui/text/text.h ui/text/text_block.cpp diff --git a/ui/basic.style b/ui/basic.style index 6c49f39..3f0832e 100644 --- a/ui/basic.style +++ b/ui/basic.style @@ -233,8 +233,8 @@ emojiReplaceHeight: 56px; emojiReplaceInnerHeight: 42px; emojiReplacePadding: 14px; -dragFont: font(28px semibold); -dragSubfont: font(20px semibold); +dragFont: font(27px semibold); +dragSubfont: font(19px semibold); dragColor: windowSubTextFg; dragDropColor: windowActiveTextFg; diff --git a/ui/text/qtextitemint.cpp b/ui/text/qtextitemint.cpp new file mode 100644 index 0000000..20c33a9 --- /dev/null +++ b/ui/text/qtextitemint.cpp @@ -0,0 +1,54 @@ +// This file is part of Desktop App Toolkit, +// a set of libraries for developing nice desktop applications. +// +// For license and copyright information please follow this link: +// https://github.com/desktop-app/legal/blob/master/LEGAL +// +#ifdef DESKTOP_APP_USE_PACKAGED +#include + +QTextItemInt::QTextItemInt( + const QGlyphLayout &g, + QFont *font, + const QChar *chars_, + int numChars, + QFontEngine *fe, + const QTextCharFormat &format) +: flags(0) +, justified(false) +, underlineStyle(QTextCharFormat::NoUnderline) +, charFormat(format) +, num_chars(numChars) +, chars(chars_) +, logClusters(0) +, f(font) +, glyphs(g) +, fontEngine(fe) { +} + +void QTextItemInt::initWithScriptItem(const QScriptItem &si) { + // explicitly initialize flags so that initFontAttributes can be called + // multiple times on the same TextItem + flags = 0; + if (si.analysis.bidiLevel %2) + flags |= QTextItem::RightToLeft; + ascent = si.ascent; + descent = si.descent; + + if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) { + underlineStyle = charFormat.underlineStyle(); + } else if (charFormat.boolProperty(QTextFormat::FontUnderline) + || f->d->underline) { + underlineStyle = QTextCharFormat::SingleUnderline; + } + + // compat + if (underlineStyle == QTextCharFormat::SingleUnderline) + flags |= QTextItem::Underline; + + if (f->d->overline || charFormat.fontOverline()) + flags |= QTextItem::Overline; + if (f->d->strikeOut || charFormat.fontStrikeOut()) + flags |= QTextItem::StrikeOut; +} +#endif // !DESKTOP_APP_USE_PACKAGED diff --git a/ui/widgets/checkbox.cpp b/ui/widgets/checkbox.cpp index d921e51..3822d50 100644 --- a/ui/widgets/checkbox.cpp +++ b/ui/widgets/checkbox.cpp @@ -394,7 +394,37 @@ Checkbox::Checkbox( const style::Toggle &toggleSt) : Checkbox( parent, - text, + rpl::single(text), + st, + std::make_unique( + toggleSt, + checked)) { +} + +Checkbox::Checkbox( + QWidget *parent, + rpl::producer &&text, + bool checked, + const style::Checkbox &st, + const style::Check &checkSt) +: Checkbox( + parent, + std::move(text), + st, + std::make_unique( + checkSt, + checked)) { +} + +Checkbox::Checkbox( + QWidget *parent, + rpl::producer &&text, + bool checked, + const style::Checkbox &st, + const style::Toggle &toggleSt) +: Checkbox( + parent, + std::move(text), st, std::make_unique( toggleSt, @@ -406,17 +436,34 @@ Checkbox::Checkbox( const QString &text, const style::Checkbox &st, std::unique_ptr check) +: Checkbox( + parent, + rpl::single(text), + st, + std::move(check)) { +} + +Checkbox::Checkbox( + QWidget *parent, + rpl::producer &&text, + const style::Checkbox &st, + std::unique_ptr check) : RippleButton(parent, st.ripple) , _st(st) , _check(std::move(check)) , _text( _st.style, - text, + QString(), _checkboxOptions, countTextMinWidth()) { _check->setUpdateCallback([=] { update(); }); resizeToText(); setCursor(style::cur_pointer); + std::move( + text + ) | rpl::start_with_next([=](QString &&value) { + setText(std::move(value)); + }, lifetime()); } int Checkbox::countTextMinWidth() const { diff --git a/ui/widgets/checkbox.h b/ui/widgets/checkbox.h index d12121e..7c0d7de 100644 --- a/ui/widgets/checkbox.h +++ b/ui/widgets/checkbox.h @@ -146,11 +146,28 @@ public: bool checked, const style::Checkbox &st, const style::Toggle &toggleSt); + Checkbox( + QWidget *parent, + rpl::producer &&text, + bool checked = false, + const style::Checkbox &st = st::defaultCheckbox, + const style::Check &checkSt = st::defaultCheck); + Checkbox( + QWidget *parent, + rpl::producer &&text, + bool checked, + const style::Checkbox &st, + const style::Toggle &toggleSt); Checkbox( QWidget *parent, const QString &text, const style::Checkbox &st, std::unique_ptr check); + Checkbox( + QWidget *parent, + rpl::producer &&text, + const style::Checkbox &st, + std::unique_ptr check); void setText(const QString &text, bool rich = false); void setCheckAlignment(style::align alignment);