Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Eric Kotato 2020-03-30 22:04:35 +03:00
commit d443119c7c
8 changed files with 94 additions and 15 deletions

View file

@ -7,4 +7,7 @@
<file>DAOpenSansSemibold.ttf</file>
<file>DAOpenSansSemiboldItalic.ttf</file>
</qresource>
<qresource prefix="/fc">
<file>fc-custom.conf</file>
</qresource>
</RCC>

View file

@ -2,7 +2,4 @@
<qresource prefix="/qt/etc">
<file alias="qt.conf">qt_linux.conf</file>
</qresource>
<qresource prefix="/fc">
<file>fc-custom.conf</file>
</qresource>
</RCC>

View file

@ -36,6 +36,12 @@ void Integration::textActionsUpdated() {
void Integration::activationFromTopPanel() {
}
void Integration::startFontsBegin() {
}
void Integration::startFontsEnd() {
}
std::shared_ptr<ClickHandler> Integration::createLinkHandler(
EntityType type,
const QString &text,

View file

@ -39,6 +39,9 @@ public:
virtual void textActionsUpdated();
virtual void activationFromTopPanel();
virtual void startFontsBegin();
virtual void startFontsEnd();
[[nodiscard]] virtual std::shared_ptr<ClickHandler> createLinkHandler(
EntityType type,
const QString &text,

View file

@ -6,8 +6,9 @@
//
#include "ui/style/style_core_font.h"
#include "base/algorithm.h"
#include "ui/ui_log.h"
#include "base/algorithm.h"
#include "ui/integration.h"
#include <QtCore/QMap>
#include <QtCore/QVector>
@ -183,6 +184,11 @@ void StartFonts() {
style_InitFontsResource();
const auto integrationExists = Ui::Integration::Exists();
if (integrationExists) {
Ui::Integration::Instance().startFontsBegin();
}
if (!UseSystemFont) {
#ifndef DESKTOP_APP_USE_PACKAGED_FONTS
bool areGood[FontTypesCount] = { false };
@ -232,6 +238,10 @@ void StartFonts() {
Overrides[FontTypeSemibold] = CustomSemiboldFont;
Overrides[FontTypeSemiboldItalic] = CustomSemiboldFont;
}
if (integrationExists) {
Ui::Integration::Instance().startFontsEnd();
}
}
QString GetPossibleEmptyOverride(const QString &familyName, int32 flags) {

View file

@ -14,9 +14,18 @@
namespace Ui {
namespace {
constexpr auto kScrollFactor = 0.05;
} // namespace
VerticalLayoutReorder::VerticalLayoutReorder(
not_null<VerticalLayout*> layout)
: _layout(layout) {
not_null<VerticalLayout*> layout,
not_null<ScrollArea*> scroll)
: _layout(layout)
, _scroll(scroll)
, _scrollAnimation([=] { updateScrollCallback(); }) {
}
void VerticalLayoutReorder::cancel() {
@ -52,9 +61,7 @@ void VerticalLayoutReorder::start() {
static_cast<QMouseEvent*>(e.get())->globalPos());
break;
case QEvent::MouseButtonRelease:
mouseRelease(
widget,
static_cast<QMouseEvent*>(e.get())->button());
mouseRelease(static_cast<QMouseEvent*>(e.get())->button());
break;
}
}, [=] {
@ -100,6 +107,8 @@ void VerticalLayoutReorder::updateOrder(int index, QPoint position) {
current.shift = current.finalShift = shift;
_layout->setVerticalShift(index, shift);
checkForScrollAnimation();
const auto count = _entries.size();
const auto currentHeight = current.widget->height();
const auto currentMiddle = current.widget->y() + currentHeight / 2;
@ -147,13 +156,11 @@ void VerticalLayoutReorder::mousePress(
_currentStart = position.y();
}
void VerticalLayoutReorder::mouseRelease(
not_null<RpWidget*> widget,
Qt::MouseButton button) {
void VerticalLayoutReorder::mouseRelease(Qt::MouseButton button) {
if (button != Qt::LeftButton) {
return;
}
finishCurrent();
finishReordering();
}
void VerticalLayoutReorder::cancelCurrent() {
@ -175,6 +182,11 @@ void VerticalLayoutReorder::cancelCurrent(int index) {
}
}
void VerticalLayoutReorder::finishReordering() {
_scrollAnimation.stop();
finishCurrent();
}
void VerticalLayoutReorder::finishCurrent() {
if (!_currentWidget) {
return;
@ -267,4 +279,41 @@ auto VerticalLayoutReorder::updates() const -> rpl::producer<Single> {
return _updates.events();
}
void VerticalLayoutReorder::updateScrollCallback() {
const auto delta = deltaFromEdge();
const auto oldTop = _scroll->scrollTop();
_scroll->scrollToY(oldTop + delta);
const auto newTop = _scroll->scrollTop();
_currentStart += oldTop - newTop;
if (newTop == 0 || newTop == _scroll->scrollTopMax()) {
_scrollAnimation.stop();
}
}
void VerticalLayoutReorder::checkForScrollAnimation() {
if (!deltaFromEdge() || _scrollAnimation.animating()) {
return;
}
_scrollAnimation.start();
}
int VerticalLayoutReorder::deltaFromEdge() {
Expects(_currentWidget != nullptr);
const auto globalPosition = _currentWidget->mapToGlobal(QPoint(0, 0));
const auto localTop = _scroll->mapFromGlobal(globalPosition).y();
const auto localBottom = localTop
+ _currentWidget->height()
- _scroll->height();
const auto isTopEdge = (localTop < 0);
const auto isBottomEdge = (localBottom > 0);
if (!isTopEdge && !isBottomEdge) {
_scrollAnimation.stop();
return 0;
}
return int((isBottomEdge ? localBottom : localTop) * kScrollFactor);
}
} // namespace Ui

View file

@ -7,6 +7,7 @@
#pragma once
#include "ui/effects/animations.h"
#include "ui/widgets/scroll_area.h"
namespace Ui {
@ -27,10 +28,13 @@ public:
State state = State::Started;
};
VerticalLayoutReorder(not_null<VerticalLayout*> layout);
VerticalLayoutReorder(
not_null<VerticalLayout*> layout,
not_null<ScrollArea*> scroll);
void start();
void cancel();
void finishReordering();
[[nodiscard]] rpl::producer<Single> updates() const;
private:
@ -47,7 +51,7 @@ private:
not_null<RpWidget*> widget,
Qt::MouseButton button,
QPoint position);
void mouseRelease(not_null<RpWidget*> widget, Qt::MouseButton button);
void mouseRelease(Qt::MouseButton button);
void checkForStart(QPoint position);
void updateOrder(int index, QPoint position);
@ -59,7 +63,14 @@ private:
void moveToShift(int index, int shift);
void updateShift(not_null<RpWidget*> widget, int indexHint);
void updateScrollCallback();
void checkForScrollAnimation();
int deltaFromEdge();
const not_null<Ui::VerticalLayout*> _layout;
const not_null<Ui::ScrollArea*> _scroll;
Ui::Animations::Basic _scrollAnimation;
RpWidget *_currentWidget = nullptr;
int _currentStart = 0;