mirror of https://github.com/procxx/kepka.git
parent
76c06923d5
commit
57f2ae098f
|
@ -955,7 +955,7 @@ void HistoryInner::touchScrollUpdated(const QPoint &screenPos) {
|
||||||
touchUpdateSpeed();
|
touchUpdateSpeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint HistoryInner::mapPointToItem(QPoint p, const Element *view) {
|
QPoint HistoryInner::mapPointToItem(QPoint p, const Element *view) const {
|
||||||
if (view) {
|
if (view) {
|
||||||
const auto top = itemTop(view);
|
const auto top = itemTop(view);
|
||||||
p.setY(p.y() - top);
|
p.setY(p.y() - top);
|
||||||
|
@ -964,7 +964,9 @@ QPoint HistoryInner::mapPointToItem(QPoint p, const Element *view) {
|
||||||
return QPoint();
|
return QPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint HistoryInner::mapPointToItem(QPoint p, const HistoryItem *item) {
|
QPoint HistoryInner::mapPointToItem(
|
||||||
|
QPoint p,
|
||||||
|
const HistoryItem *item) const {
|
||||||
return item ? mapPointToItem(p, item->mainView()) : QPoint();
|
return item ? mapPointToItem(p, item->mainView()) : QPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2524,7 +2526,8 @@ void HistoryInner::mouseActionUpdate() {
|
||||||
}
|
}
|
||||||
if (dragState.link
|
if (dragState.link
|
||||||
|| dragState.cursor == CursorState::Date
|
|| dragState.cursor == CursorState::Date
|
||||||
|| dragState.cursor == CursorState::Forwarded) {
|
|| dragState.cursor == CursorState::Forwarded
|
||||||
|
|| dragState.customTooltip) {
|
||||||
Ui::Tooltip::Show(1000, this);
|
Ui::Tooltip::Show(1000, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3037,8 +3040,17 @@ QString HistoryInner::tooltipText() const {
|
||||||
return forwarded->text.originalText(AllTextSelection, ExpandLinksNone);
|
return forwarded->text.originalText(AllTextSelection, ExpandLinksNone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (auto lnk = ClickHandler::getActive()) {
|
} else if (const auto lnk = ClickHandler::getActive()) {
|
||||||
return lnk->tooltip();
|
return lnk->tooltip();
|
||||||
|
} else if (const auto view = App::mousedItem()) {
|
||||||
|
StateRequest request;
|
||||||
|
const auto local = mapFromGlobal(_mousePosition);
|
||||||
|
const auto point = _widget->clampMousePosition(local);
|
||||||
|
request.flags |= Text::StateRequest::Flag::LookupCustomTooltip;
|
||||||
|
const auto state = view->textState(
|
||||||
|
mapPointToItem(point, view),
|
||||||
|
request);
|
||||||
|
return state.customTooltipText;
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,8 @@ private:
|
||||||
std::unique_ptr<QMimeData> prepareDrag();
|
std::unique_ptr<QMimeData> prepareDrag();
|
||||||
void performDrag();
|
void performDrag();
|
||||||
|
|
||||||
QPoint mapPointToItem(QPoint p, const Element *view);
|
QPoint mapPointToItem(QPoint p, const Element *view) const;
|
||||||
QPoint mapPointToItem(QPoint p, const HistoryItem *item);
|
QPoint mapPointToItem(QPoint p, const HistoryItem *item) const;
|
||||||
|
|
||||||
void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
|
void showContextMenu(QContextMenuEvent *e, bool showFromTouch = false);
|
||||||
void cancelContextDownload(not_null<DocumentData*> document);
|
void cancelContextDownload(not_null<DocumentData*> document);
|
||||||
|
|
|
@ -730,10 +730,11 @@ void HistoryPoll::startAnswersAnimation() const {
|
||||||
|
|
||||||
TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
|
TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
|
||||||
auto result = TextState(_parent);
|
auto result = TextState(_parent);
|
||||||
if (!canVote() || !_poll->sendingVote.isEmpty()) {
|
if (!_poll->sendingVote.isEmpty()) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto can = canVote();
|
||||||
const auto padding = st::msgPadding;
|
const auto padding = st::msgPadding;
|
||||||
auto paintw = width();
|
auto paintw = width();
|
||||||
auto tshift = st::historyPollQuestionTop;
|
auto tshift = st::historyPollQuestionTop;
|
||||||
|
@ -750,8 +751,18 @@ TextState HistoryPoll::textState(QPoint point, StateRequest request) const {
|
||||||
for (const auto &answer : _answers) {
|
for (const auto &answer : _answers) {
|
||||||
const auto height = countAnswerHeight(answer, paintw);
|
const auto height = countAnswerHeight(answer, paintw);
|
||||||
if (point.y() >= tshift && point.y() < tshift + height) {
|
if (point.y() >= tshift && point.y() < tshift + height) {
|
||||||
|
if (can) {
|
||||||
_lastLinkPoint = point;
|
_lastLinkPoint = point;
|
||||||
result.link = answer.handler;
|
result.link = answer.handler;
|
||||||
|
} else {
|
||||||
|
result.customTooltip = true;
|
||||||
|
using Flag = Text::StateRequest::Flag;
|
||||||
|
if (request.flags & Flag::LookupCustomTooltip) {
|
||||||
|
result.customTooltipText = answer.votes
|
||||||
|
? lng_polls_votes_count(lt_count, answer.votes)
|
||||||
|
: lang(lng_polls_votes_none);
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
tshift += height;
|
tshift += height;
|
||||||
|
|
|
@ -50,7 +50,9 @@ struct TextState {
|
||||||
CursorState cursor = CursorState::None;
|
CursorState cursor = CursorState::None;
|
||||||
ClickHandlerPtr link;
|
ClickHandlerPtr link;
|
||||||
bool afterSymbol = false;
|
bool afterSymbol = false;
|
||||||
|
bool customTooltip = false;
|
||||||
uint16 symbol = 0;
|
uint16 symbol = 0;
|
||||||
|
QString customTooltipText;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
BreakEverywhere = (1 << 0),
|
BreakEverywhere = (1 << 0),
|
||||||
LookupSymbol = (1 << 1),
|
LookupSymbol = (1 << 1),
|
||||||
LookupLink = (1 << 2),
|
LookupLink = (1 << 2),
|
||||||
|
LookupCustomTooltip = (1 << 3),
|
||||||
};
|
};
|
||||||
using Flags = base::flags<Flag>;
|
using Flags = base::flags<Flag>;
|
||||||
friend inline constexpr auto is_flag_type(Flag) { return true; };
|
friend inline constexpr auto is_flag_type(Flag) { return true; };
|
||||||
|
|
Loading…
Reference in New Issue