2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Realtime UI translation in all fields and buttons.

This commit is contained in:
John Preston
2017-05-30 18:21:05 +03:00
parent 5fc4f4ed36
commit b94099e25b
80 changed files with 644 additions and 535 deletions

View File

@@ -47,13 +47,12 @@ public:
virtual Window::Controller *controller() const = 0;
virtual void setLayerType(bool layerType) = 0;
virtual void setTitle(const QString &title) = 0;
virtual void setTitle(const TextWithEntities &title) = 0;
virtual void setAdditionalTitle(const QString &additional) = 0;
virtual void setTitle(base::lambda<TextWithEntities()> titleFactory) = 0;
virtual void setAdditionalTitle(base::lambda<QString()> additionalFactory) = 0;
virtual void clearButtons() = 0;
virtual QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
virtual QPointer<Ui::RoundButton> addLeftButton(const QString &text, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
virtual QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
virtual QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) = 0;
virtual void updateButtonsPositions() = 0;
virtual void setDimensions(int newWidth, int maxHeight) = 0;
@@ -78,23 +77,27 @@ public:
getDelegate()->closeBox();
}
void setTitle(const QString &title) {
getDelegate()->setTitle(title);
void setTitle(base::lambda<QString()> titleFactory) {
if (titleFactory) {
getDelegate()->setTitle([titleFactory] { return TextWithEntities { titleFactory(), EntitiesInText() }; });
} else {
getDelegate()->setTitle(base::lambda<TextWithEntities()>());
}
}
void setTitle(const TextWithEntities &title) {
getDelegate()->setTitle(title);
void setTitle(base::lambda<TextWithEntities()> titleFactory) {
getDelegate()->setTitle(std::move(titleFactory));
}
void setAdditionalTitle(const QString &additional) {
getDelegate()->setAdditionalTitle(additional);
void setAdditionalTitle(base::lambda<QString()> additional) {
getDelegate()->setAdditionalTitle(std::move(additional));
}
void clearButtons() {
getDelegate()->clearButtons();
}
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> clickCallback);
QPointer<Ui::RoundButton> addLeftButton(const QString &text, base::lambda<void()> clickCallback);
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> clickCallback, const style::RoundButton &st) {
return getDelegate()->addButton(text, std::move(clickCallback), st);
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback);
QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback);
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) {
return getDelegate()->addButton(std::move(textFactory), std::move(clickCallback), st);
}
void updateButtonsGeometry() {
getDelegate()->updateButtonsPositions();
@@ -208,13 +211,12 @@ public:
void parentResized() override;
void setLayerType(bool layerType) override;
void setTitle(const QString &title) override;
void setTitle(const TextWithEntities &title) override;
void setAdditionalTitle(const QString &additional) override;
void setTitle(base::lambda<TextWithEntities()> titleFactory) override;
void setAdditionalTitle(base::lambda<QString()> additionalFactory) override;
void clearButtons() override;
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
QPointer<Ui::RoundButton> addLeftButton(const QString &text, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
QPointer<Ui::RoundButton> addButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
QPointer<Ui::RoundButton> addLeftButton(base::lambda<QString()> textFactory, base::lambda<void()> clickCallback, const style::RoundButton &st) override;
void updateButtonsPositions() override;
void setDimensions(int newWidth, int maxHeight) override;
@@ -248,6 +250,9 @@ protected:
private:
void paintAdditionalTitle(Painter &p);
void updateTitlePosition();
void refreshTitle();
void refreshAdditionalTitle();
void refreshLang();
bool hasTitle() const;
int titleHeight() const;
@@ -266,7 +271,9 @@ private:
object_ptr<BoxContent> _content;
object_ptr<Ui::FlatLabel> _title = { nullptr };
base::lambda<TextWithEntities()> _titleFactory;
QString _additionalTitle;
base::lambda<QString()> _additionalTitleFactory;
int _titleLeft = 0;
int _titleTop = 0;
bool _layerType = false;