Display right action button not too high.

This commit is contained in:
John Preston 2017-12-06 18:15:41 +04:00
parent 1473c14668
commit c6d3fd883a
7 changed files with 42 additions and 26 deletions

View File

@ -460,4 +460,4 @@ historyFastShareBottom: 5px;
historyFastShareIcon: icon {{ "fast_share", msgServiceFg, point(4px, 3px)}};
historyGoToOriginalIcon: icon {{ "title_back-flip_horizontal", msgServiceFg, point(8px, 7px) }};
historySavedFont: font(semibold 15px);
historySavedFont: font(semibold 14px);

View File

@ -86,10 +86,10 @@ int BinarySearchBlocksOrItems(const T &list, int edge) {
// flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html
HistoryInner::HistoryInner(
HistoryWidget *historyWidget,
not_null<HistoryWidget*> historyWidget,
not_null<Window::Controller*> controller,
Ui::ScrollArea *scroll,
History *history)
not_null<History*> history)
: RpWidget(nullptr)
, _controller(controller)
, _peer(history->peer)
@ -1171,7 +1171,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
auto selectedState = getSelectionState();
auto canSendMessages = _widget->canSendMessages(_peer);
auto canSendMessages = _peer->canWrite();
// -2 - has full selected items, but not over, -1 - has selection, but no over, 0 - no selection, 1 - over text, 2 - over full selected items
auto isUponSelected = 0;

View File

@ -42,10 +42,10 @@ class HistoryInner
public:
HistoryInner(
HistoryWidget *historyWidget,
not_null<HistoryWidget*> historyWidget,
not_null<Window::Controller*> controller,
Ui::ScrollArea *scroll,
History *history);
not_null<History*> history);
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
void messagesReceivedDown(PeerData *peer, const QVector<MTPMessage> &messages);

View File

@ -1276,7 +1276,7 @@ QRect HistoryMessage::countGeometry() const {
maxwidth = qMax(_media->currentWidth(), qMin(maxwidth, plainMaxWidth()));
}
auto outLayout = hasOutLayout();
const auto outLayout = hasOutLayout();
auto contentLeft = (outLayout && !Adaptive::ChatWide())
? st::msgMargin.right()
: st::msgMargin.left();
@ -1297,8 +1297,12 @@ QRect HistoryMessage::countGeometry() const {
contentWidth = maxwidth;
}
auto contentTop = marginTop();
return QRect(contentLeft, contentTop, contentWidth, _height - contentTop - marginBottom());
const auto contentTop = marginTop();
return QRect(
contentLeft,
contentTop,
contentWidth,
_height - contentTop - marginBottom());
}
void HistoryMessage::fromNameUpdated(int32 width) const {
@ -1876,8 +1880,12 @@ void HistoryMessage::draw(Painter &p, QRect clip, TextSelection selection, TimeM
HistoryMessage::drawInfo(p, g.left() + g.width(), g.top() + g.height(), 2 * g.left() + g.width(), selected, InfoDisplayDefault);
}
if (displayRightAction()) {
auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
auto fastShareTop = g.top() + g.height() - st::historyFastShareBottom - st::historyFastShareSize;
const auto fastShareSkip = snap(
(g.height() - st::historyFastShareSize) / 2,
0,
st::historyFastShareBottom);
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
const auto fastShareTop = g.top() + g.height() - fastShareSkip - st::historyFastShareSize;
drawRightAction(p, fastShareLeft, fastShareTop, width());
}
} else if (_media) {
@ -2241,9 +2249,18 @@ HistoryTextState HistoryMessage::getState(QPoint point, HistoryStateRequest requ
}
}
if (displayRightAction()) {
auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
auto fastShareTop = g.top() + g.height() - st::historyFastShareBottom - st::historyFastShareSize;
if (QRect(fastShareLeft, fastShareTop, st::historyFastShareSize, st::historyFastShareSize).contains(point)) {
const auto fastShareSkip = snap(
(g.height() - st::historyFastShareSize) / 2,
0,
st::historyFastShareBottom);
const auto fastShareLeft = g.left() + g.width() + st::historyFastShareLeft;
const auto fastShareTop = g.top() + g.height() - fastShareSkip - st::historyFastShareSize;
if (QRect(
fastShareLeft,
fastShareTop,
st::historyFastShareSize,
st::historyFastShareSize
).contains(point)) {
result.link = rightActionLink();
}
}

View File

@ -1742,7 +1742,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
if (peerId) {
_peer = App::peer(peerId);
_channel = peerToChannel(_peer->id);
_canSendMessages = canSendMessages(_peer);
_canSendMessages = _peer->canWrite();
_tabbedSelector->setCurrentPeer(_peer);
}
_topBar->setHistoryPeer(_peer);
@ -3658,10 +3658,6 @@ void HistoryWidget::updateDragAreas() {
};
}
bool HistoryWidget::canSendMessages(PeerData *peer) const {
return peer && peer->canWrite();
}
bool HistoryWidget::readyToForward() const {
return _canSendMessages && !_toForward.empty();
}
@ -5345,7 +5341,9 @@ void HistoryWidget::onPhotoSend(PhotoData *photo) {
}
void HistoryWidget::onInlineResultSend(InlineBots::Result *result, UserData *bot) {
if (!_history || !result || !canSendMessages(_peer)) return;
if (!_peer || !_peer->canWrite() || !result) {
return;
}
auto errorText = result->getErrorOnSend(_history);
if (!errorText.isEmpty()) {
@ -5527,7 +5525,7 @@ void HistoryWidget::destroyPinnedBar() {
}
bool HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &caption) {
if (!_history || !doc || !canSendMessages(_peer)) {
if (!_peer || !_peer->canWrite() || !doc) {
return false;
}
@ -5592,7 +5590,9 @@ bool HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &capti
}
void HistoryWidget::sendExistingPhoto(PhotoData *photo, const QString &caption) {
if (!_history || !photo || !canSendMessages(_peer)) return;
if (!_peer || !_peer->canWrite() || !photo) {
return;
}
App::main()->readServerHistory(_history);
fastShowAtEnd(_history);
@ -6108,7 +6108,7 @@ void HistoryWidget::onCancel() {
void HistoryWidget::fullPeerUpdated(PeerData *peer) {
if (_list && peer == _peer) {
bool newCanSendMessages = canSendMessages(_peer);
auto newCanSendMessages = _peer->canWrite();
if (newCanSendMessages != _canSendMessages) {
_canSendMessages = newCanSendMessages;
if (!_canSendMessages) {
@ -6151,7 +6151,7 @@ void HistoryWidget::handlePeerUpdate() {
if (_unblock->isHidden() == isBlocked() || (!isBlocked() && _joinChannel->isHidden() == isJoinChannel())) {
resize = true;
}
bool newCanSendMessages = canSendMessages(_peer);
bool newCanSendMessages = _peer->canWrite();
if (newCanSendMessages != _canSendMessages) {
_canSendMessages = newCanSendMessages;
if (!_canSendMessages) {

View File

@ -318,7 +318,6 @@ public:
void updateFieldSubmitSettings();
void setInnerFocus();
bool canSendMessages(PeerData *peer) const;
void updateNotifySettings();

View File

@ -1464,7 +1464,7 @@ void MainWidget::sendMessage(const MessageToSend &message) {
readServerHistory(history);
_history->fastShowAtEnd(history);
if (!history || !_history->canSendMessages(history->peer)) {
if (!history || !history->peer->canWrite()) {
return;
}
saveRecentHashtags(textWithTags.text);