Updated lib_ui sources to TDesktop version 2.7.1+df73bda

This commit is contained in:
Eric Kotato 2021-04-07 00:14:33 +03:00
commit 50415733c8
13 changed files with 141 additions and 8 deletions

View file

@ -140,6 +140,8 @@ boxTitleCloseFgOver: cancelIconFgOver; // settings close icon and box search can
//boxSearchCancelIconFg: cancelIconFg; // search cancel X button icon (like in contacts box) (not implemented yet) //boxSearchCancelIconFg: cancelIconFg; // search cancel X button icon (like in contacts box) (not implemented yet)
//boxSearchCancelIconFgOver: cancelIconFgOver; // search cancel X button icon with mouse over (not implemented yet) //boxSearchCancelIconFgOver: cancelIconFgOver; // search cancel X button icon with mouse over (not implemented yet)
paymentsTipActive: #01ad0f; // tip button text in payments checkout form
membersAboutLimitFg: windowSubTextFgOver; // text in channel members box about the limit (max 200 last members are shown) membersAboutLimitFg: windowSubTextFgOver; // text in channel members box about the limit (max 200 last members are shown)
contactsBg: windowBg; // contacts (and some other) box row background contactsBg: windowBg; // contacts (and some other) box row background

View file

@ -79,6 +79,10 @@ const Emoji::One *Integration::defaultEmojiVariant(const Emoji::One *emoji) {
return emoji; return emoji;
} }
QWidget *Integration::modalWindowParent() {
return nullptr;
}
rpl::producer<> Integration::forcePopupMenuHideRequests() { rpl::producer<> Integration::forcePopupMenuHideRequests() {
return rpl::never<rpl::empty_value>(); return rpl::never<rpl::empty_value>();
} }

View file

@ -56,6 +56,8 @@ public:
[[nodiscard]] virtual const Emoji::One *defaultEmojiVariant( [[nodiscard]] virtual const Emoji::One *defaultEmojiVariant(
const Emoji::One *emoji); const Emoji::One *emoji);
[[nodiscard]] virtual QWidget *modalWindowParent();
[[nodiscard]] virtual rpl::producer<> forcePopupMenuHideRequests(); [[nodiscard]] virtual rpl::producer<> forcePopupMenuHideRequests();
[[nodiscard]] virtual QString phraseContextCopyText(); [[nodiscard]] virtual QString phraseContextCopyText();

View file

@ -184,6 +184,17 @@ bool TranslucentWindowsSupported(QPoint globalPosition) {
void IgnoreAllActivation(not_null<QWidget*> widget) { void IgnoreAllActivation(not_null<QWidget*> widget) {
} }
void ClearTransientParent(not_null<QWidget*> widget) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (::Platform::IsX11()) {
xcb_delete_property(
base::Platform::XCB::GetConnectionFromQt(),
widget->windowHandle()->winId(),
XCB_ATOM_WM_TRANSIENT_FOR);
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
}
bool WindowExtentsSupported() { bool WindowExtentsSupported() {
#ifdef DESKTOP_APP_QT_PATCHED #ifdef DESKTOP_APP_QT_PATCHED
if (::Platform::IsWayland()) { if (::Platform::IsWayland()) {

View file

@ -20,6 +20,9 @@ inline bool TranslucentWindowsSupported(QPoint globalPosition) {
inline void UpdateOverlayed(not_null<QWidget*> widget) { inline void UpdateOverlayed(not_null<QWidget*> widget) {
} }
inline void ClearTransientParent(not_null<QWidget*> widget) {
}
inline constexpr bool UseMainQueueGeneric() { inline constexpr bool UseMainQueueGeneric() {
return ::Platform::IsMacStoreBuild(); return ::Platform::IsMacStoreBuild();
} }

View file

@ -28,6 +28,7 @@ void UpdateOverlayed(not_null<QWidget*> widget);
void ShowOverAll(not_null<QWidget*> widget, bool canFocus = true); void ShowOverAll(not_null<QWidget*> widget, bool canFocus = true);
void BringToBack(not_null<QWidget*> widget); void BringToBack(not_null<QWidget*> widget);
void IgnoreAllActivation(not_null<QWidget*> widget); void IgnoreAllActivation(not_null<QWidget*> widget);
void ClearTransientParent(not_null<QWidget*> widget);
[[nodiscard]] constexpr bool UseMainQueueGeneric(); [[nodiscard]] constexpr bool UseMainQueueGeneric();
void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false. void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false.

View file

@ -90,12 +90,16 @@ not_null<QWidget*> TitleControls::window() const {
void TitleControls::init(Fn<void(bool maximized)> maximize) { void TitleControls::init(Fn<void(bool maximized)> maximize) {
_minimize->setClickedCallback([=] { _minimize->setClickedCallback([=] {
const auto weak = MakeWeak(_minimize.data());
window()->setWindowState( window()->setWindowState(
window()->windowState() | Qt::WindowMinimized); window()->windowState() | Qt::WindowMinimized);
_minimize->clearState(); if (weak) {
_minimize->clearState();
}
}); });
_minimize->setPointerCursor(false); _minimize->setPointerCursor(false);
_maximizeRestore->setClickedCallback([=] { _maximizeRestore->setClickedCallback([=] {
const auto weak = MakeWeak(_maximizeRestore.data());
if (maximize) { if (maximize) {
maximize(!_maximizedState); maximize(!_maximizedState);
} else { } else {
@ -103,12 +107,17 @@ void TitleControls::init(Fn<void(bool maximized)> maximize) {
? Qt::WindowNoState ? Qt::WindowNoState
: Qt::WindowMaximized); : Qt::WindowMaximized);
} }
_maximizeRestore->clearState(); if (weak) {
_maximizeRestore->clearState();
}
}); });
_maximizeRestore->setPointerCursor(false); _maximizeRestore->setPointerCursor(false);
_close->setClickedCallback([=] { _close->setClickedCallback([=] {
const auto weak = MakeWeak(_close.data());
window()->close(); window()->close();
_close->clearState(); if (weak) {
_close->clearState();
}
}); });
_close->setPointerCursor(false); _close->setPointerCursor(false);

View file

@ -38,6 +38,9 @@ inline void ShowOverAll(not_null<QWidget*> widget, bool canFocus) {
inline void BringToBack(not_null<QWidget*> widget) { inline void BringToBack(not_null<QWidget*> widget) {
} }
inline void ClearTransientParent(not_null<QWidget*> widget) {
}
inline constexpr bool UseMainQueueGeneric() { inline constexpr bool UseMainQueueGeneric() {
return true; return true;
} }

View file

@ -12,11 +12,14 @@ namespace style {
namespace internal { namespace internal {
Color::Proxy Color::operator[](const style::palette &paletteOverride) const { Color::Proxy Color::operator[](const style::palette &paletteOverride) const {
auto index = main_palette::indexOfColor(*this); const auto index = main_palette::indexOfColor(*this);
return Proxy((index >= 0) ? paletteOverride.colorAtIndex(index) : (*this)); return { (index >= 0) ? paletteOverride.colorAtIndex(index) : (*this) };
} }
ColorData::ColorData(uchar r, uchar g, uchar b, uchar a) : c(int(r), int(g), int(b), int(a)), p(c), b(c) { ColorData::ColorData(uchar r, uchar g, uchar b, uchar a)
: c(int(r), int(g), int(b), int(a))
, p(c)
, b(c) {
} }
void ColorData::set(uchar r, uchar g, uchar b, uchar a) { void ColorData::set(uchar r, uchar g, uchar b, uchar a) {
@ -25,5 +28,12 @@ void ColorData::set(uchar r, uchar g, uchar b, uchar a) {
this->b = QBrush(c); this->b = QBrush(c);
} }
void ComplexColor::subscribeToPaletteChanges() {
style::PaletteChanged(
) | rpl::start_with_next([=] {
_owned.update(_generator());
}, _lifetime);
}
} // namespace internal } // namespace internal
} // namespace style } // namespace style

View file

@ -10,6 +10,8 @@
#include <QtGui/QPen> #include <QtGui/QPen>
#include <QtGui/QBrush> #include <QtGui/QBrush>
#include <rpl/lifetime.h>
namespace style { namespace style {
class palette; class palette;
@ -17,13 +19,15 @@ class palette;
namespace internal { namespace internal {
class Color; class Color;
class OwnedColor;
class ColorData { class ColorData {
public: public:
QColor c; QColor c;
QPen p; QPen p;
QBrush b; QBrush b;
QColor transparent() const { [[nodiscard]] QColor transparent() const {
return QColor(c.red(), c.green(), c.blue(), 0); return QColor(c.red(), c.green(), c.blue(), 0);
} }
@ -35,6 +39,7 @@ private:
void set(uchar r, uchar g, uchar b, uchar a); void set(uchar r, uchar g, uchar b, uchar a);
friend class Color; friend class Color;
friend class OwnedColor;
friend class style::palette; friend class style::palette;
}; };
@ -73,7 +78,9 @@ public:
Proxy operator[](const style::palette &paletteOverride) const; Proxy operator[](const style::palette &paletteOverride) const;
private: private:
friend class OwnedColor;
friend class style::palette; friend class style::palette;
Color(ColorData *data) : _data(data) { Color(ColorData *data) : _data(data) {
} }
@ -81,6 +88,70 @@ private:
}; };
class OwnedColor final {
public:
explicit OwnedColor(const QColor &color)
: _data(color.red(), color.green(), color.blue(), color.alpha())
, _color(&_data) {
}
OwnedColor(const OwnedColor &other)
: _data(other._data)
, _color(&_data) {
}
OwnedColor &operator=(const OwnedColor &other) {
_data = other._data;
return *this;
}
void update(const QColor &color) {
_data.set(color.red(), color.green(), color.blue(), color.alpha());
}
[[nodiscard]] const Color &color() const {
return _color;
}
private:
ColorData _data;
Color _color;
};
class ComplexColor final {
public:
explicit ComplexColor(Fn<QColor()> generator)
: _owned(generator())
, _generator(std::move(generator)) {
subscribeToPaletteChanges();
}
ComplexColor(const ComplexColor &other)
: _owned(other._owned)
, _generator(other._generator) {
subscribeToPaletteChanges();
}
ComplexColor &operator=(const ComplexColor &other) {
_owned = other._owned;
_generator = other._generator;
return *this;
}
[[nodiscard]] const Color &color() const {
return _owned.color();
}
private:
void subscribeToPaletteChanges();
OwnedColor _owned;
Fn<QColor()> _generator;
rpl::lifetime _lifetime;
};
class Color::Proxy { class Color::Proxy {
public: public:
Proxy(Color color) : _color(color) { Proxy(Color color) : _color(color) {

View file

@ -28,6 +28,8 @@ using align = Qt::Alignment;
using margins = QMargins; using margins = QMargins;
using font = internal::Font; using font = internal::Font;
using color = internal::Color; using color = internal::Color;
using owned_color = internal::OwnedColor;
using complex_color = internal::ComplexColor;
using icon = internal::Icon; using icon = internal::Icon;
static constexpr cursor cur_default = Qt::ArrowCursor; static constexpr cursor cur_default = Qt::ArrowCursor;

View file

@ -3598,6 +3598,10 @@ void InputField::showErrorNoFocus() {
setErrorShown(true); setErrorShown(true);
} }
void InputField::hideError() {
setErrorShown(false);
}
void InputField::setErrorShown(bool error) { void InputField::setErrorShown(bool error) {
if (_error != error) { if (_error != error) {
_error = error; _error = error;
@ -3915,12 +3919,20 @@ void MaskedInputField::inputMethodEvent(QInputMethodEvent *e) {
} }
void MaskedInputField::showError() { void MaskedInputField::showError() {
setErrorShown(true); showErrorNoFocus();
if (!hasFocus()) { if (!hasFocus()) {
setFocus(); setFocus();
} }
} }
void MaskedInputField::showErrorNoFocus() {
setErrorShown(true);
}
void MaskedInputField::hideError() {
setErrorShown(false);
}
void MaskedInputField::setErrorShown(bool error) { void MaskedInputField::setErrorShown(bool error) {
if (_error != error) { if (_error != error) {
_error = error; _error = error;

View file

@ -191,6 +191,7 @@ public:
void showError(); void showError();
void showErrorNoFocus(); void showErrorNoFocus();
void hideError();
void setMaxLength(int maxLength); void setMaxLength(int maxLength);
void setMinHeight(int minHeight); void setMinHeight(int minHeight);
@ -559,6 +560,8 @@ public:
const QString &val = QString()); const QString &val = QString());
void showError(); void showError();
void showErrorNoFocus();
void hideError();
QRect getTextRect() const; QRect getTextRect() const;