tdesktop/Telegram/SourceFiles/ui/countryinput.h

61 lines
1.3 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/rp_widget.h"
namespace style {
struct InputField;
} // namespace style
namespace Countries {
struct Info;
} // namespace Countries
namespace Ui {
2022-06-09 01:50:00 +00:00
class Show;
} // namespace Ui
2022-06-09 01:50:00 +00:00
class CountryInput : public Ui::RpWidget {
public:
2022-06-09 01:50:00 +00:00
CountryInput(
QWidget *parent,
std::shared_ptr<Ui::Show> show,
2022-06-09 01:50:00 +00:00
const style::InputField &st);
[[nodiscard]] QString iso() const {
2018-05-30 15:08:12 +00:00
return _chosenIso;
}
bool chooseCountry(const QString &country);
2018-05-30 15:08:12 +00:00
void onChooseCode(const QString &code);
2021-09-02 18:55:36 +00:00
rpl::producer<QString> codeChanged() const;
protected:
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void enterEventHook(QEnterEvent *e) override;
void leaveEventHook(QEvent *e) override;
private:
void chooseCountry(not_null<const Countries::Info*> info, int codeIndex);
void setText(const QString &newText);
const std::shared_ptr<Ui::Show> _show;
2016-11-24 19:28:23 +00:00
const style::InputField &_st;
bool _active = false;
QString _text;
2018-05-30 15:08:12 +00:00
QString _chosenIso;
QPainterPath _placeholderPath;
2021-09-02 18:55:36 +00:00
rpl::event_stream<QString> _codeChanged;
};