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