From 88a4a27d8e5d02b83b5487d5f156bf45e7ae14ee Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 13 Jul 2020 07:22:38 +0400 Subject: [PATCH 1/3] Add a file with missing QTextItemInt symbols --- CMakeLists.txt | 1 + ui/text/qtextitemint.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 ui/text/qtextitemint.cpp 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/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 From 34eb5a8eb802dbbf9e5c9516e55a04af6b87aeb2 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 15 Jul 2020 17:29:42 +0300 Subject: [PATCH 2/3] Reduced font size for drag area by 1px. --- ui/basic.style | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 697f2851b0625ae784e405e7fc596d1629e8668a Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 18 Jul 2020 19:15:05 +0300 Subject: [PATCH 3/3] Added ability to pass rpl::producer to Checkbox constructors. --- ui/widgets/checkbox.cpp | 51 +++++++++++++++++++++++++++++++++++++++-- ui/widgets/checkbox.h | 17 ++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) 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);