tdesktop/Telegram/SourceFiles/support/support_autocomplete.h

88 lines
1.9 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"
#include "boxes/abstract_box.h"
#include "history/admin_log/history_admin_log_item.h"
#include "history/view/history_view_element.h"
#include "history/history.h"
2019-07-24 11:45:24 +00:00
namespace Main {
class Session;
} // namespace Main
namespace Ui {
class ScrollArea;
class InputField;
} // namespace Ui
namespace Support {
struct Contact {
QString comment;
QString phone;
QString firstName;
QString lastName;
};
class Autocomplete : public Ui::RpWidget {
public:
2019-07-24 11:45:24 +00:00
Autocomplete(QWidget *parent, not_null<Main::Session*> session);
void activate(not_null<Ui::InputField*> field);
void deactivate();
void setBoundings(QRect rect);
rpl::producer<QString> insertRequests() const;
rpl::producer<Contact> shareContactRequests() const;
protected:
void keyPressEvent(QKeyEvent *e) override;
private:
void setupContent();
void submitValue(const QString &value);
2019-07-24 11:45:24 +00:00
not_null<Main::Session*> _session;
Fn<void()> _activate;
Fn<void()> _deactivate;
Fn<void(int delta)> _moveSelection;
rpl::event_stream<QString> _insertRequests;
rpl::event_stream<Contact> _shareContactRequests;
};
class ConfirmContactBox
2019-09-18 11:19:05 +00:00
: public Ui::BoxContent
2019-05-14 09:50:44 +00:00
, public HistoryView::SimpleElementDelegate {
public:
ConfirmContactBox(
QWidget*,
not_null<History*> history,
const Contact &data,
Fn<void(Qt::KeyboardModifiers)> submit);
using Element = HistoryView::Element;
HistoryView::Context elementContext() override;
protected:
void prepare() override;
void paintEvent(QPaintEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
private:
AdminLog::OwnedItem _comment;
AdminLog::OwnedItem _contact;
Fn<void(Qt::KeyboardModifiers)> _submit;
};
} //namespace Support