Remove QPropertyAnimation from modals to work around a regression on Qt 5.10.1 (#87)
This commit is contained in:
parent
59e4148a7c
commit
fdd5051dcf
@ -17,11 +17,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QGraphicsOpacityEffect>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QPropertyAnimation>
|
|
||||||
|
|
||||||
#include "OverlayWidget.h"
|
#include "OverlayWidget.h"
|
||||||
|
|
||||||
@ -30,14 +28,6 @@ class OverlayModal : public OverlayWidget
|
|||||||
public:
|
public:
|
||||||
OverlayModal(QWidget *parent, QWidget *content);
|
OverlayModal(QWidget *parent, QWidget *content);
|
||||||
|
|
||||||
void fadeIn();
|
|
||||||
void fadeOut();
|
|
||||||
|
|
||||||
void setDuration(int duration)
|
|
||||||
{
|
|
||||||
duration_ = duration;
|
|
||||||
animation_->setDuration(duration_);
|
|
||||||
};
|
|
||||||
void setColor(QColor color) { color_ = color; }
|
void setColor(QColor color) { color_ = color; }
|
||||||
void setDismissible(bool state) { isDismissible_ = state; }
|
void setDismissible(bool state) { isDismissible_ = state; }
|
||||||
|
|
||||||
@ -48,13 +38,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *content_;
|
QWidget *content_;
|
||||||
|
|
||||||
int duration_;
|
|
||||||
QColor color_;
|
QColor color_;
|
||||||
|
|
||||||
//! Decides whether or not the modal can be removed by clicking into it.
|
//! Decides whether or not the modal can be removed by clicking into it.
|
||||||
bool isDismissible_ = true;
|
bool isDismissible_ = true;
|
||||||
|
|
||||||
QGraphicsOpacityEffect *opacity_;
|
|
||||||
QPropertyAnimation *animation_;
|
|
||||||
};
|
};
|
||||||
|
@ -680,7 +680,7 @@ ChatPage::showQuickSwitcher()
|
|||||||
|
|
||||||
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() {
|
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() {
|
||||||
if (!this->quickSwitcherModal_.isNull())
|
if (!this->quickSwitcherModal_.isNull())
|
||||||
this->quickSwitcherModal_->fadeOut();
|
this->quickSwitcherModal_->hide();
|
||||||
this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason);
|
this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -689,7 +689,6 @@ ChatPage::showQuickSwitcher()
|
|||||||
quickSwitcherModal_ = QSharedPointer<OverlayModal>(
|
quickSwitcherModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()),
|
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()),
|
||||||
[=](OverlayModal *modal) { modal->deleteLater(); });
|
[=](OverlayModal *modal) { modal->deleteLater(); });
|
||||||
quickSwitcherModal_->setDuration(0);
|
|
||||||
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170));
|
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +703,7 @@ ChatPage::showQuickSwitcher()
|
|||||||
}
|
}
|
||||||
|
|
||||||
quickSwitcher_->setRoomList(rooms);
|
quickSwitcher_->setRoomList(rooms);
|
||||||
quickSwitcherModal_->fadeIn();
|
quickSwitcherModal_->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -922,12 +921,11 @@ ChatPage::showReadReceipts(const QString &event_id)
|
|||||||
receiptsModal_ = QSharedPointer<OverlayModal>(
|
receiptsModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), receiptsDialog_.data()),
|
new OverlayModal(MainWindow::instance(), receiptsDialog_.data()),
|
||||||
[=](OverlayModal *modal) { modal->deleteLater(); });
|
[=](OverlayModal *modal) { modal->deleteLater(); });
|
||||||
receiptsModal_->setDuration(0);
|
|
||||||
receiptsModal_->setColor(QColor(30, 30, 30, 170));
|
receiptsModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
receiptsDialog_->addUsers(cache_->readReceipts(event_id, current_room_));
|
receiptsDialog_->addUsers(cache_->readReceipts(event_id, current_room_));
|
||||||
receiptsModal_->fadeIn();
|
receiptsModal_->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -162,7 +162,7 @@ MainWindow::removeOverlayProgressBar()
|
|||||||
timer->deleteLater();
|
timer->deleteLater();
|
||||||
|
|
||||||
if (!progressModal_.isNull())
|
if (!progressModal_.isNull())
|
||||||
progressModal_->fadeOut();
|
progressModal_->hide();
|
||||||
|
|
||||||
if (!spinner_.isNull())
|
if (!spinner_.isNull())
|
||||||
spinner_->stop();
|
spinner_->stop();
|
||||||
@ -215,8 +215,7 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token)
|
|||||||
QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
|
QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
|
||||||
[=](OverlayModal *modal) { modal->deleteLater(); });
|
[=](OverlayModal *modal) { modal->deleteLater(); });
|
||||||
progressModal_->setDismissible(false);
|
progressModal_->setDismissible(false);
|
||||||
progressModal_->fadeIn();
|
progressModal_->show();
|
||||||
progressModal_->setDuration(modalOpacityDuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
login_page_->reset();
|
login_page_->reset();
|
||||||
@ -271,7 +270,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
|
|||||||
leaveRoomDialog_ = QSharedPointer<dialogs::LeaveRoom>(new dialogs::LeaveRoom(this));
|
leaveRoomDialog_ = QSharedPointer<dialogs::LeaveRoom>(new dialogs::LeaveRoom(this));
|
||||||
|
|
||||||
connect(leaveRoomDialog_.data(), &dialogs::LeaveRoom::closing, this, [=](bool leaving) {
|
connect(leaveRoomDialog_.data(), &dialogs::LeaveRoom::closing, this, [=](bool leaving) {
|
||||||
leaveRoomModal_->fadeOut();
|
leaveRoomModal_->hide();
|
||||||
|
|
||||||
if (leaving)
|
if (leaving)
|
||||||
client_->leaveRoom(roomToLeave);
|
client_->leaveRoom(roomToLeave);
|
||||||
@ -279,8 +278,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
|
|||||||
|
|
||||||
leaveRoomModal_ =
|
leaveRoomModal_ =
|
||||||
QSharedPointer<OverlayModal>(new OverlayModal(this, leaveRoomDialog_.data()));
|
QSharedPointer<OverlayModal>(new OverlayModal(this, leaveRoomDialog_.data()));
|
||||||
leaveRoomModal_->setDuration(0);
|
|
||||||
leaveRoomModal_->setColor(QColor(30, 30, 30, 170));
|
leaveRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
|
|
||||||
leaveRoomModal_->fadeIn();
|
leaveRoomModal_->show();
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ RoomList::leaveEvent(QEvent *event)
|
|||||||
void
|
void
|
||||||
RoomList::closeJoinRoomDialog(bool isJoining, QString roomAlias)
|
RoomList::closeJoinRoomDialog(bool isJoining, QString roomAlias)
|
||||||
{
|
{
|
||||||
joinRoomModal_->fadeOut();
|
joinRoomModal_->hide();
|
||||||
|
|
||||||
if (isJoining)
|
if (isJoining)
|
||||||
client_->joinRoom(roomAlias);
|
client_->joinRoom(roomAlias);
|
||||||
|
@ -43,7 +43,7 @@ SideBarActions::SideBarActions(QWidget *parent)
|
|||||||
&dialogs::JoinRoom::closing,
|
&dialogs::JoinRoom::closing,
|
||||||
this,
|
this,
|
||||||
[=](bool isJoining, const QString &room) {
|
[=](bool isJoining, const QString &room) {
|
||||||
joinRoomModal_->fadeOut();
|
joinRoomModal_->hide();
|
||||||
|
|
||||||
if (isJoining && !room.isEmpty())
|
if (isJoining && !room.isEmpty())
|
||||||
emit joinRoom(room);
|
emit joinRoom(room);
|
||||||
@ -53,11 +53,10 @@ SideBarActions::SideBarActions(QWidget *parent)
|
|||||||
if (joinRoomModal_.isNull()) {
|
if (joinRoomModal_.isNull()) {
|
||||||
joinRoomModal_ = QSharedPointer<OverlayModal>(
|
joinRoomModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
|
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
|
||||||
joinRoomModal_->setDuration(0);
|
|
||||||
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
|
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
joinRoomModal_->fadeIn();
|
joinRoomModal_->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(createRoomAction_, &QAction::triggered, this, [=]() {
|
connect(createRoomAction_, &QAction::triggered, this, [=]() {
|
||||||
@ -69,7 +68,7 @@ SideBarActions::SideBarActions(QWidget *parent)
|
|||||||
&dialogs::CreateRoom::closing,
|
&dialogs::CreateRoom::closing,
|
||||||
this,
|
this,
|
||||||
[=](bool isCreating, const mtx::requests::CreateRoom &request) {
|
[=](bool isCreating, const mtx::requests::CreateRoom &request) {
|
||||||
createRoomModal_->fadeOut();
|
createRoomModal_->hide();
|
||||||
|
|
||||||
if (isCreating)
|
if (isCreating)
|
||||||
emit createRoom(request);
|
emit createRoom(request);
|
||||||
@ -79,11 +78,10 @@ SideBarActions::SideBarActions(QWidget *parent)
|
|||||||
if (createRoomModal_.isNull()) {
|
if (createRoomModal_.isNull()) {
|
||||||
createRoomModal_ = QSharedPointer<OverlayModal>(
|
createRoomModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), createRoomDialog_.data()));
|
new OverlayModal(MainWindow::instance(), createRoomDialog_.data()));
|
||||||
createRoomModal_->setDuration(0);
|
|
||||||
createRoomModal_->setColor(QColor(30, 30, 30, 170));
|
createRoomModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
createRoomModal_->fadeIn();
|
createRoomModal_->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
addMenu_->addAction(createRoomAction_);
|
addMenu_->addAction(createRoomAction_);
|
||||||
|
@ -100,7 +100,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
|||||||
&dialogs::InviteUsers::closing,
|
&dialogs::InviteUsers::closing,
|
||||||
this,
|
this,
|
||||||
[=](bool isSending, QStringList invitees) {
|
[=](bool isSending, QStringList invitees) {
|
||||||
inviteUsersModal_->fadeOut();
|
inviteUsersModal_->hide();
|
||||||
|
|
||||||
if (isSending && !invitees.isEmpty())
|
if (isSending && !invitees.isEmpty())
|
||||||
emit inviteUsers(invitees);
|
emit inviteUsers(invitees);
|
||||||
@ -110,11 +110,10 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
|||||||
if (inviteUsersModal_.isNull()) {
|
if (inviteUsersModal_.isNull()) {
|
||||||
inviteUsersModal_ = QSharedPointer<OverlayModal>(
|
inviteUsersModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), inviteUsersDialog_.data()));
|
new OverlayModal(MainWindow::instance(), inviteUsersDialog_.data()));
|
||||||
inviteUsersModal_->setDuration(0);
|
|
||||||
inviteUsersModal_->setColor(QColor(30, 30, 30, 170));
|
inviteUsersModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
inviteUsersModal_->fadeIn();
|
inviteUsersModal_->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
leaveRoom_ = new QAction(tr("Leave room"), this);
|
leaveRoom_ = new QAction(tr("Leave room"), this);
|
||||||
|
@ -102,18 +102,17 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
|||||||
if (logoutModal_.isNull()) {
|
if (logoutModal_.isNull()) {
|
||||||
logoutModal_ = QSharedPointer<OverlayModal>(
|
logoutModal_ = QSharedPointer<OverlayModal>(
|
||||||
new OverlayModal(MainWindow::instance(), logoutDialog_.data()));
|
new OverlayModal(MainWindow::instance(), logoutDialog_.data()));
|
||||||
logoutModal_->setDuration(0);
|
|
||||||
logoutModal_->setColor(QColor(30, 30, 30, 170));
|
logoutModal_->setColor(QColor(30, 30, 30, 170));
|
||||||
}
|
}
|
||||||
|
|
||||||
logoutModal_->fadeIn();
|
logoutModal_->show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UserInfoWidget::closeLogoutDialog(bool isLoggingOut)
|
UserInfoWidget::closeLogoutDialog(bool isLoggingOut)
|
||||||
{
|
{
|
||||||
logoutModal_->fadeOut();
|
logoutModal_->hide();
|
||||||
|
|
||||||
if (isLoggingOut)
|
if (isLoggingOut)
|
||||||
emit logout();
|
emit logout();
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
|
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
|
||||||
: OverlayWidget(parent)
|
: OverlayWidget(parent)
|
||||||
, content_{content}
|
, content_{content}
|
||||||
, duration_{500}
|
|
||||||
, color_{QColor(55, 55, 55)}
|
, color_{QColor(55, 55, 55)}
|
||||||
{
|
{
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
@ -32,21 +31,6 @@ OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
|
|||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
opacity_ = new QGraphicsOpacityEffect(this);
|
|
||||||
setGraphicsEffect(opacity_);
|
|
||||||
|
|
||||||
opacity_->setOpacity(1);
|
|
||||||
animation_ = new QPropertyAnimation(opacity_, "opacity", this);
|
|
||||||
animation_->setStartValue(1);
|
|
||||||
animation_->setEndValue(0);
|
|
||||||
animation_->setDuration(duration_);
|
|
||||||
animation_->setEasingCurve(QEasingCurve::Linear);
|
|
||||||
|
|
||||||
connect(animation_, &QPropertyAnimation::finished, [this]() {
|
|
||||||
if (animation_->direction() == QAbstractAnimation::Forward)
|
|
||||||
this->close();
|
|
||||||
});
|
|
||||||
|
|
||||||
content->setFocus();
|
content->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,22 +47,7 @@ void
|
|||||||
OverlayModal::mousePressEvent(QMouseEvent *e)
|
OverlayModal::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
if (isDismissible_ && content_ && !content_->geometry().contains(e->pos()))
|
if (isDismissible_ && content_ && !content_->geometry().contains(e->pos()))
|
||||||
fadeOut();
|
hide();
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
OverlayModal::fadeIn()
|
|
||||||
{
|
|
||||||
animation_->setDirection(QAbstractAnimation::Backward);
|
|
||||||
animation_->start();
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
OverlayModal::fadeOut()
|
|
||||||
{
|
|
||||||
animation_->setDirection(QAbstractAnimation::Forward);
|
|
||||||
animation_->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -86,6 +55,6 @@ OverlayModal::keyPressEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
if (event->key() == Qt::Key_Escape) {
|
if (event->key() == Qt::Key_Escape) {
|
||||||
event->accept();
|
event->accept();
|
||||||
fadeOut();
|
hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user