2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
#include "boxes/abstractbox.h"
|
2016-11-24 19:28:23 +00:00
|
|
|
#include "styles/style_widgets.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QString findValidCode(QString fullCode);
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
namespace Ui {
|
2016-10-22 13:03:20 +00:00
|
|
|
class MultiSelect;
|
2016-10-20 16:32:15 +00:00
|
|
|
} // namespace Ui
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
class CountryInput : public TWidget {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-11-24 19:28:23 +00:00
|
|
|
CountryInput(QWidget *parent, const style::InputField &st);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onChooseCode(const QString &code);
|
|
|
|
bool onChooseCountry(const QString &country);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void codeChanged(const QString &code);
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void enterEvent(QEvent *e) override;
|
|
|
|
void leaveEvent(QEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
private:
|
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;
|
2016-12-09 18:56:01 +00:00
|
|
|
QPainterPath _placeholderPath;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class CountrySelectBox : public BoxContent {
|
2016-10-20 16:32:15 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
CountrySelectBox(QWidget*);
|
2016-10-20 16:32:15 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void countryChosen(const QString &iso);
|
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
private slots:
|
|
|
|
void onSubmit();
|
2016-10-20 16:32:15 +00:00
|
|
|
|
|
|
|
private:
|
2016-10-22 13:03:20 +00:00
|
|
|
void onFilterUpdate(const QString &query);
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::MultiSelect> _select;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class Inner;
|
|
|
|
QPointer<Inner> _inner;
|
2016-10-20 16:32:15 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// This class is hold in header because it requires Qt preprocessing.
|
2016-10-26 16:43:13 +00:00
|
|
|
class CountrySelectBox::Inner : public TWidget {
|
2015-10-11 08:37:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-10-20 16:32:15 +00:00
|
|
|
Inner(QWidget *parent);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
void updateFilter(QString filter = QString());
|
|
|
|
|
|
|
|
void selectSkip(int32 dir);
|
|
|
|
void selectSkipPage(int32 h, int32 dir);
|
|
|
|
|
|
|
|
void chooseCountry();
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
void refresh();
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
~Inner();
|
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
signals:
|
|
|
|
void countryChosen(const QString &iso);
|
|
|
|
void mustScrollTo(int ymin, int ymax);
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void enterEvent(QEvent *e) override;
|
|
|
|
void leaveEvent(QEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
2016-12-05 11:01:08 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
private:
|
2016-12-05 11:01:08 +00:00
|
|
|
void updateSelected() {
|
|
|
|
updateSelected(mapFromGlobal(QCursor::pos()));
|
|
|
|
}
|
|
|
|
void updateSelected(QPoint localPos);
|
2015-10-11 08:37:24 +00:00
|
|
|
void updateSelectedRow();
|
2016-12-05 11:01:08 +00:00
|
|
|
void updateRow(int index);
|
|
|
|
void setPressed(int pressed);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
int _rowHeight;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
int _selected = -1;
|
|
|
|
int _pressed = -1;
|
2015-10-11 08:37:24 +00:00
|
|
|
QString _filter;
|
2016-12-05 11:01:08 +00:00
|
|
|
bool _mouseSelection = false;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
std_::vector_of_moveable<std_::unique_ptr<Ui::RippleAnimation>> _ripples;
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
};
|