Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d443119c7c
8 changed files with 94 additions and 15 deletions
|
|
@ -7,4 +7,7 @@
|
||||||
<file>DAOpenSansSemibold.ttf</file>
|
<file>DAOpenSansSemibold.ttf</file>
|
||||||
<file>DAOpenSansSemiboldItalic.ttf</file>
|
<file>DAOpenSansSemiboldItalic.ttf</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
<qresource prefix="/fc">
|
||||||
|
<file>fc-custom.conf</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,4 @@
|
||||||
<qresource prefix="/qt/etc">
|
<qresource prefix="/qt/etc">
|
||||||
<file alias="qt.conf">qt_linux.conf</file>
|
<file alias="qt.conf">qt_linux.conf</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/fc">
|
|
||||||
<file>fc-custom.conf</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,12 @@ void Integration::textActionsUpdated() {
|
||||||
void Integration::activationFromTopPanel() {
|
void Integration::activationFromTopPanel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Integration::startFontsBegin() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Integration::startFontsEnd() {
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<ClickHandler> Integration::createLinkHandler(
|
std::shared_ptr<ClickHandler> Integration::createLinkHandler(
|
||||||
EntityType type,
|
EntityType type,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ public:
|
||||||
virtual void textActionsUpdated();
|
virtual void textActionsUpdated();
|
||||||
virtual void activationFromTopPanel();
|
virtual void activationFromTopPanel();
|
||||||
|
|
||||||
|
virtual void startFontsBegin();
|
||||||
|
virtual void startFontsEnd();
|
||||||
|
|
||||||
[[nodiscard]] virtual std::shared_ptr<ClickHandler> createLinkHandler(
|
[[nodiscard]] virtual std::shared_ptr<ClickHandler> createLinkHandler(
|
||||||
EntityType type,
|
EntityType type,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@
|
||||||
//
|
//
|
||||||
#include "ui/style/style_core_font.h"
|
#include "ui/style/style_core_font.h"
|
||||||
|
|
||||||
#include "base/algorithm.h"
|
|
||||||
#include "ui/ui_log.h"
|
#include "ui/ui_log.h"
|
||||||
|
#include "base/algorithm.h"
|
||||||
|
#include "ui/integration.h"
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
|
|
@ -183,6 +184,11 @@ void StartFonts() {
|
||||||
|
|
||||||
style_InitFontsResource();
|
style_InitFontsResource();
|
||||||
|
|
||||||
|
const auto integrationExists = Ui::Integration::Exists();
|
||||||
|
if (integrationExists) {
|
||||||
|
Ui::Integration::Instance().startFontsBegin();
|
||||||
|
}
|
||||||
|
|
||||||
if (!UseSystemFont) {
|
if (!UseSystemFont) {
|
||||||
#ifndef DESKTOP_APP_USE_PACKAGED_FONTS
|
#ifndef DESKTOP_APP_USE_PACKAGED_FONTS
|
||||||
bool areGood[FontTypesCount] = { false };
|
bool areGood[FontTypesCount] = { false };
|
||||||
|
|
@ -232,6 +238,10 @@ void StartFonts() {
|
||||||
Overrides[FontTypeSemibold] = CustomSemiboldFont;
|
Overrides[FontTypeSemibold] = CustomSemiboldFont;
|
||||||
Overrides[FontTypeSemiboldItalic] = CustomSemiboldFont;
|
Overrides[FontTypeSemiboldItalic] = CustomSemiboldFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (integrationExists) {
|
||||||
|
Ui::Integration::Instance().startFontsEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GetPossibleEmptyOverride(const QString &familyName, int32 flags) {
|
QString GetPossibleEmptyOverride(const QString &familyName, int32 flags) {
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,18 @@
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kScrollFactor = 0.05;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
VerticalLayoutReorder::VerticalLayoutReorder(
|
VerticalLayoutReorder::VerticalLayoutReorder(
|
||||||
not_null<VerticalLayout*> layout)
|
not_null<VerticalLayout*> layout,
|
||||||
: _layout(layout) {
|
not_null<ScrollArea*> scroll)
|
||||||
|
: _layout(layout)
|
||||||
|
, _scroll(scroll)
|
||||||
|
, _scrollAnimation([=] { updateScrollCallback(); }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerticalLayoutReorder::cancel() {
|
void VerticalLayoutReorder::cancel() {
|
||||||
|
|
@ -52,9 +61,7 @@ void VerticalLayoutReorder::start() {
|
||||||
static_cast<QMouseEvent*>(e.get())->globalPos());
|
static_cast<QMouseEvent*>(e.get())->globalPos());
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
mouseRelease(
|
mouseRelease(static_cast<QMouseEvent*>(e.get())->button());
|
||||||
widget,
|
|
||||||
static_cast<QMouseEvent*>(e.get())->button());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, [=] {
|
}, [=] {
|
||||||
|
|
@ -100,6 +107,8 @@ void VerticalLayoutReorder::updateOrder(int index, QPoint position) {
|
||||||
current.shift = current.finalShift = shift;
|
current.shift = current.finalShift = shift;
|
||||||
_layout->setVerticalShift(index, shift);
|
_layout->setVerticalShift(index, shift);
|
||||||
|
|
||||||
|
checkForScrollAnimation();
|
||||||
|
|
||||||
const auto count = _entries.size();
|
const auto count = _entries.size();
|
||||||
const auto currentHeight = current.widget->height();
|
const auto currentHeight = current.widget->height();
|
||||||
const auto currentMiddle = current.widget->y() + currentHeight / 2;
|
const auto currentMiddle = current.widget->y() + currentHeight / 2;
|
||||||
|
|
@ -147,13 +156,11 @@ void VerticalLayoutReorder::mousePress(
|
||||||
_currentStart = position.y();
|
_currentStart = position.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerticalLayoutReorder::mouseRelease(
|
void VerticalLayoutReorder::mouseRelease(Qt::MouseButton button) {
|
||||||
not_null<RpWidget*> widget,
|
|
||||||
Qt::MouseButton button) {
|
|
||||||
if (button != Qt::LeftButton) {
|
if (button != Qt::LeftButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finishCurrent();
|
finishReordering();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerticalLayoutReorder::cancelCurrent() {
|
void VerticalLayoutReorder::cancelCurrent() {
|
||||||
|
|
@ -175,6 +182,11 @@ void VerticalLayoutReorder::cancelCurrent(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerticalLayoutReorder::finishReordering() {
|
||||||
|
_scrollAnimation.stop();
|
||||||
|
finishCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
void VerticalLayoutReorder::finishCurrent() {
|
void VerticalLayoutReorder::finishCurrent() {
|
||||||
if (!_currentWidget) {
|
if (!_currentWidget) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -267,4 +279,41 @@ auto VerticalLayoutReorder::updates() const -> rpl::producer<Single> {
|
||||||
return _updates.events();
|
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
|
} // namespace Ui
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
|
|
@ -27,10 +28,13 @@ public:
|
||||||
State state = State::Started;
|
State state = State::Started;
|
||||||
};
|
};
|
||||||
|
|
||||||
VerticalLayoutReorder(not_null<VerticalLayout*> layout);
|
VerticalLayoutReorder(
|
||||||
|
not_null<VerticalLayout*> layout,
|
||||||
|
not_null<ScrollArea*> scroll);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
void finishReordering();
|
||||||
[[nodiscard]] rpl::producer<Single> updates() const;
|
[[nodiscard]] rpl::producer<Single> updates() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -47,7 +51,7 @@ private:
|
||||||
not_null<RpWidget*> widget,
|
not_null<RpWidget*> widget,
|
||||||
Qt::MouseButton button,
|
Qt::MouseButton button,
|
||||||
QPoint position);
|
QPoint position);
|
||||||
void mouseRelease(not_null<RpWidget*> widget, Qt::MouseButton button);
|
void mouseRelease(Qt::MouseButton button);
|
||||||
|
|
||||||
void checkForStart(QPoint position);
|
void checkForStart(QPoint position);
|
||||||
void updateOrder(int index, QPoint position);
|
void updateOrder(int index, QPoint position);
|
||||||
|
|
@ -59,7 +63,14 @@ private:
|
||||||
void moveToShift(int index, int shift);
|
void moveToShift(int index, int shift);
|
||||||
void updateShift(not_null<RpWidget*> widget, int indexHint);
|
void updateShift(not_null<RpWidget*> widget, int indexHint);
|
||||||
|
|
||||||
|
void updateScrollCallback();
|
||||||
|
void checkForScrollAnimation();
|
||||||
|
int deltaFromEdge();
|
||||||
|
|
||||||
const not_null<Ui::VerticalLayout*> _layout;
|
const not_null<Ui::VerticalLayout*> _layout;
|
||||||
|
const not_null<Ui::ScrollArea*> _scroll;
|
||||||
|
|
||||||
|
Ui::Animations::Basic _scrollAnimation;
|
||||||
|
|
||||||
RpWidget *_currentWidget = nullptr;
|
RpWidget *_currentWidget = nullptr;
|
||||||
int _currentStart = 0;
|
int _currentStart = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue