2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Add media search to all info modes.

This commit is contained in:
John Preston
2017-11-03 16:03:00 +04:00
parent 86ad15612a
commit 09d1e3629a
20 changed files with 408 additions and 133 deletions

View File

@@ -227,6 +227,9 @@ public:
}
void toggleFast(bool visible) {
toggleAnimated(visible);
finishAnimations();
}
void finishAnimations() {
_a_show.finish();
}

View File

@@ -2499,9 +2499,14 @@ void InputArea::setErrorShown(bool error) {
}
}
InputField::InputField(QWidget *parent, const style::InputField &st, base::lambda<QString()> placeholderFactory, const QString &val) : TWidget(parent)
InputField::InputField(
QWidget *parent,
const style::InputField &st,
base::lambda<QString()> placeholderFactory,
const QString &val)
: RpWidget(parent)
, _st(st)
, _inner(this)
, _inner(std::make_unique<Inner>(this))
, _oldtext(val)
, _placeholderFactory(std::move(placeholderFactory)) {
_inner->setAcceptRichText(false);
@@ -2542,9 +2547,9 @@ InputField::InputField(QWidget *parent, const style::InputField &st, base::lambd
connect(_inner->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onDocumentContentsChange(int,int,int)));
connect(_inner->document(), SIGNAL(contentsChanged()), this, SLOT(onDocumentContentsChanged()));
connect(_inner, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
connect(_inner, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
if (App::wnd()) connect(_inner, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
connect(_inner.get(), SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
connect(_inner.get(), SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
if (App::wnd()) connect(_inner.get(), SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
setCursor(style::cur_text);
if (!val.isEmpty()) {
@@ -2744,7 +2749,9 @@ void InputField::setFocused(bool focused) {
}
void InputField::startPlaceholderAnimation() {
auto placeholderShifted = _forcePlaceholderHidden || (_focused && _st.placeholderScale > 0.) || !getLastText().isEmpty();
auto placeholderShifted = _forcePlaceholderHidden
|| (_focused && _st.placeholderScale > 0.)
|| !getLastText().isEmpty();
if (_placeholderShifted != placeholderShifted) {
_placeholderShifted = placeholderShifted;
_a_placeholderShifted.start([this] { update(); }, _placeholderShifted ? 0. : 1., _placeholderShifted ? 1. : 0., _st.duration);

View File

@@ -20,6 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "ui/rp_widget.h"
#include "styles/style_widgets.h"
class UserData;
@@ -499,7 +500,7 @@ private:
};
class InputField : public TWidget, private base::Subscriber {
class InputField : public RpWidget, private base::Subscriber {
Q_OBJECT
public:
@@ -645,11 +646,11 @@ private:
const style::InputField &_st;
std::unique_ptr<Inner> _inner;
int _maxLength = -1;
bool _forcePlaceholderHidden = false;
object_ptr<Inner> _inner;
QString _oldtext;
bool _undoAvailable = false;

View File

@@ -1111,6 +1111,16 @@ defaultPeerList: PeerList {
item: defaultPeerListItem;
}
SearchFieldRow {
height: pixels;
padding: margins;
field: InputField;
fieldIcon: icon;
fieldIconSkip: pixels;
fieldCancel: CrossButton;
fieldCancelSkip: pixels;
}
InfoTopBar {
height: pixels;
back: IconButton;
@@ -1121,13 +1131,6 @@ InfoTopBar {
mediaActionsSkip: pixels;
mediaForward: IconButton;
mediaDelete: IconButton;
}
SearchFieldRow {
height: pixels;
padding: margins;
field: InputField;
fieldIcon: icon;
fieldIconSkip: pixels;
fieldCancel: CrossButton;
fieldCancelSkip: pixels;
search: IconButton;
searchRow: SearchFieldRow;
}