mirror of https://github.com/procxx/kepka.git
Move QtConnectionOwner to base/qt_connection.
This commit is contained in:
parent
c057f28425
commit
dda587a2fc
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
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 "base/algorithm.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
class qt_connection final {
|
||||||
|
public:
|
||||||
|
qt_connection(QMetaObject::Connection data = {}) : _data(data) {
|
||||||
|
}
|
||||||
|
qt_connection(qt_connection &&other) : _data(base::take(other._data)) {
|
||||||
|
}
|
||||||
|
qt_connection &operator=(qt_connection &&other) {
|
||||||
|
reset(base::take(other._data));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~qt_connection() {
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void release() {
|
||||||
|
_data = QMetaObject::Connection();
|
||||||
|
}
|
||||||
|
void reset(QMetaObject::Connection data = {}) {
|
||||||
|
disconnect();
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void disconnect() {
|
||||||
|
if (_data) {
|
||||||
|
QObject::disconnect(base::take(_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMetaObject::Connection _data;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
|
@ -552,28 +552,6 @@ AutocompleteQuery ParseMentionHashtagBotCommandQuery(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QtConnectionOwner::QtConnectionOwner(QMetaObject::Connection connection)
|
|
||||||
: _data(connection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
QtConnectionOwner::QtConnectionOwner(QtConnectionOwner &&other)
|
|
||||||
: _data(base::take(other._data)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
QtConnectionOwner &QtConnectionOwner::operator=(QtConnectionOwner &&other) {
|
|
||||||
disconnect();
|
|
||||||
_data = base::take(other._data);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtConnectionOwner::disconnect() {
|
|
||||||
QObject::disconnect(base::take(_data));
|
|
||||||
}
|
|
||||||
|
|
||||||
QtConnectionOwner::~QtConnectionOwner() {
|
|
||||||
disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageLinksParser::MessageLinksParser(not_null<Ui::InputField*> field)
|
MessageLinksParser::MessageLinksParser(not_null<Ui::InputField*> field)
|
||||||
: _field(field)
|
: _field(field)
|
||||||
, _timer([=] { parse(); }) {
|
, _timer([=] { parse(); }) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "base/qt_connection.h"
|
||||||
|
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
|
||||||
|
@ -59,20 +60,6 @@ struct AutocompleteQuery {
|
||||||
AutocompleteQuery ParseMentionHashtagBotCommandQuery(
|
AutocompleteQuery ParseMentionHashtagBotCommandQuery(
|
||||||
not_null<const Ui::InputField*> field);
|
not_null<const Ui::InputField*> field);
|
||||||
|
|
||||||
class QtConnectionOwner final {
|
|
||||||
public:
|
|
||||||
QtConnectionOwner(QMetaObject::Connection connection = {});
|
|
||||||
QtConnectionOwner(QtConnectionOwner &&other);
|
|
||||||
QtConnectionOwner &operator=(QtConnectionOwner &&other);
|
|
||||||
~QtConnectionOwner();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void disconnect();
|
|
||||||
|
|
||||||
QMetaObject::Connection _data;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class MessageLinksParser : private QObject {
|
class MessageLinksParser : private QObject {
|
||||||
public:
|
public:
|
||||||
MessageLinksParser(not_null<Ui::InputField*> field);
|
MessageLinksParser(not_null<Ui::InputField*> field);
|
||||||
|
@ -104,7 +91,7 @@ private:
|
||||||
rpl::variable<QStringList> _list;
|
rpl::variable<QStringList> _list;
|
||||||
int _lastLength = 0;
|
int _lastLength = 0;
|
||||||
base::Timer _timer;
|
base::Timer _timer;
|
||||||
QtConnectionOwner _connection;
|
base::qt_connection _connection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
'<(src_loc)/base/qthelp_regex.h',
|
'<(src_loc)/base/qthelp_regex.h',
|
||||||
'<(src_loc)/base/qthelp_url.cpp',
|
'<(src_loc)/base/qthelp_url.cpp',
|
||||||
'<(src_loc)/base/qthelp_url.h',
|
'<(src_loc)/base/qthelp_url.h',
|
||||||
|
'<(src_loc)/base/qt_connection.h',
|
||||||
'<(src_loc)/base/qt_signal_producer.h',
|
'<(src_loc)/base/qt_signal_producer.h',
|
||||||
'<(src_loc)/base/runtime_composer.cpp',
|
'<(src_loc)/base/runtime_composer.cpp',
|
||||||
'<(src_loc)/base/runtime_composer.h',
|
'<(src_loc)/base/runtime_composer.h',
|
||||||
|
|
Loading…
Reference in New Issue