2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-03-23 16:06:59 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2016-11-24 19:28:23 +00:00
|
|
|
#include "styles/style_widgets.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-06-22 12:01:54 +00:00
|
|
|
namespace Data {
|
2021-08-26 14:53:59 +00:00
|
|
|
struct Info;
|
2019-06-22 12:01:54 +00:00
|
|
|
} // namespace Data
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-09-02 18:41:31 +00:00
|
|
|
namespace Countries {
|
|
|
|
struct Info;
|
|
|
|
} // namespace Countries
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
namespace Ui {
|
2016-10-22 13:03:20 +00:00
|
|
|
class MultiSelect;
|
2018-01-11 19:33:26 +00:00
|
|
|
class RippleAnimation;
|
2016-10-20 16:32:15 +00:00
|
|
|
} // namespace Ui
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-03-23 16:06:59 +00:00
|
|
|
class CountryInput : public Ui::RpWidget {
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-24 19:28:23 +00:00
|
|
|
CountryInput(QWidget *parent, const style::InputField &st);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-03-23 16:06:59 +00:00
|
|
|
[[nodiscard]] QString iso() const {
|
2018-05-30 15:08:12 +00:00
|
|
|
return _chosenIso;
|
|
|
|
}
|
2021-03-23 16:06:59 +00:00
|
|
|
bool chooseCountry(const QString &country);
|
2018-05-30 15:08:12 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void onChooseCode(const QString &code);
|
|
|
|
|
2021-09-02 18:55:36 +00:00
|
|
|
rpl::producer<QString> codeChanged() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
2021-10-19 13:00:21 +00:00
|
|
|
void enterEventHook(QEnterEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
private:
|
2021-09-02 18:41:31 +00:00
|
|
|
void chooseCountry(not_null<const Countries::Info*> info, int codeIndex);
|
2014-05-30 08:53:19 +00:00
|
|
|
void setText(const QString &newText);
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
const style::InputField &_st;
|
|
|
|
bool _active = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _text;
|
2018-05-30 15:08:12 +00:00
|
|
|
QString _chosenIso;
|
2016-12-09 18:56:01 +00:00
|
|
|
QPainterPath _placeholderPath;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-09-02 18:55:36 +00:00
|
|
|
rpl::event_stream<QString> _codeChanged;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|