Remove QPropertyAnimation from modals to work around a regression on Qt 5.10.1 (#87)

pull/1/head
Konstantinos Sideris 7 years ago
parent 59e4148a7c
commit fdd5051dcf
  1. 15
      include/ui/OverlayModal.h
  2. 8
      src/ChatPage.cc
  3. 10
      src/MainWindow.cc
  4. 2
      src/RoomList.cc
  5. 10
      src/SideBarActions.cc
  6. 5
      src/TopRoomBar.cc
  7. 5
      src/UserInfoWidget.cc
  8. 35
      src/ui/OverlayModal.cc

@ -17,11 +17,9 @@
#pragma once
#include <QGraphicsOpacityEffect>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QPropertyAnimation>
#include "OverlayWidget.h"
@ -30,14 +28,6 @@ class OverlayModal : public OverlayWidget
public:
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 setDismissible(bool state) { isDismissible_ = state; }
@ -48,13 +38,8 @@ protected:
private:
QWidget *content_;
int duration_;
QColor color_;
//! Decides whether or not the modal can be removed by clicking into it.
bool isDismissible_ = true;
QGraphicsOpacityEffect *opacity_;
QPropertyAnimation *animation_;
};

@ -680,7 +680,7 @@ ChatPage::showQuickSwitcher()
connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() {
if (!this->quickSwitcherModal_.isNull())
this->quickSwitcherModal_->fadeOut();
this->quickSwitcherModal_->hide();
this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason);
});
}
@ -689,7 +689,6 @@ ChatPage::showQuickSwitcher()
quickSwitcherModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), quickSwitcher_.data()),
[=](OverlayModal *modal) { modal->deleteLater(); });
quickSwitcherModal_->setDuration(0);
quickSwitcherModal_->setColor(QColor(30, 30, 30, 170));
}
@ -704,7 +703,7 @@ ChatPage::showQuickSwitcher()
}
quickSwitcher_->setRoomList(rooms);
quickSwitcherModal_->fadeIn();
quickSwitcherModal_->show();
}
void
@ -922,12 +921,11 @@ ChatPage::showReadReceipts(const QString &event_id)
receiptsModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), receiptsDialog_.data()),
[=](OverlayModal *modal) { modal->deleteLater(); });
receiptsModal_->setDuration(0);
receiptsModal_->setColor(QColor(30, 30, 30, 170));
}
receiptsDialog_->addUsers(cache_->readReceipts(event_id, current_room_));
receiptsModal_->fadeIn();
receiptsModal_->show();
}
void

@ -162,7 +162,7 @@ MainWindow::removeOverlayProgressBar()
timer->deleteLater();
if (!progressModal_.isNull())
progressModal_->fadeOut();
progressModal_->hide();
if (!spinner_.isNull())
spinner_->stop();
@ -215,8 +215,7 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token)
QSharedPointer<OverlayModal>(new OverlayModal(this, spinner_.data()),
[=](OverlayModal *modal) { modal->deleteLater(); });
progressModal_->setDismissible(false);
progressModal_->fadeIn();
progressModal_->setDuration(modalOpacityDuration);
progressModal_->show();
}
login_page_->reset();
@ -271,7 +270,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
leaveRoomDialog_ = QSharedPointer<dialogs::LeaveRoom>(new dialogs::LeaveRoom(this));
connect(leaveRoomDialog_.data(), &dialogs::LeaveRoom::closing, this, [=](bool leaving) {
leaveRoomModal_->fadeOut();
leaveRoomModal_->hide();
if (leaving)
client_->leaveRoom(roomToLeave);
@ -279,8 +278,7 @@ MainWindow::openLeaveRoomDialog(const QString &room_id)
leaveRoomModal_ =
QSharedPointer<OverlayModal>(new OverlayModal(this, leaveRoomDialog_.data()));
leaveRoomModal_->setDuration(0);
leaveRoomModal_->setColor(QColor(30, 30, 30, 170));
leaveRoomModal_->fadeIn();
leaveRoomModal_->show();
}

@ -321,7 +321,7 @@ RoomList::leaveEvent(QEvent *event)
void
RoomList::closeJoinRoomDialog(bool isJoining, QString roomAlias)
{
joinRoomModal_->fadeOut();
joinRoomModal_->hide();
if (isJoining)
client_->joinRoom(roomAlias);

@ -43,7 +43,7 @@ SideBarActions::SideBarActions(QWidget *parent)
&dialogs::JoinRoom::closing,
this,
[=](bool isJoining, const QString &room) {
joinRoomModal_->fadeOut();
joinRoomModal_->hide();
if (isJoining && !room.isEmpty())
emit joinRoom(room);
@ -53,11 +53,10 @@ SideBarActions::SideBarActions(QWidget *parent)
if (joinRoomModal_.isNull()) {
joinRoomModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), joinRoomDialog_.data()));
joinRoomModal_->setDuration(0);
joinRoomModal_->setColor(QColor(30, 30, 30, 170));
}
joinRoomModal_->fadeIn();
joinRoomModal_->show();
});
connect(createRoomAction_, &QAction::triggered, this, [=]() {
@ -69,7 +68,7 @@ SideBarActions::SideBarActions(QWidget *parent)
&dialogs::CreateRoom::closing,
this,
[=](bool isCreating, const mtx::requests::CreateRoom &request) {
createRoomModal_->fadeOut();
createRoomModal_->hide();
if (isCreating)
emit createRoom(request);
@ -79,11 +78,10 @@ SideBarActions::SideBarActions(QWidget *parent)
if (createRoomModal_.isNull()) {
createRoomModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), createRoomDialog_.data()));
createRoomModal_->setDuration(0);
createRoomModal_->setColor(QColor(30, 30, 30, 170));
}
createRoomModal_->fadeIn();
createRoomModal_->show();
});
addMenu_->addAction(createRoomAction_);

@ -100,7 +100,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
&dialogs::InviteUsers::closing,
this,
[=](bool isSending, QStringList invitees) {
inviteUsersModal_->fadeOut();
inviteUsersModal_->hide();
if (isSending && !invitees.isEmpty())
emit inviteUsers(invitees);
@ -110,11 +110,10 @@ TopRoomBar::TopRoomBar(QWidget *parent)
if (inviteUsersModal_.isNull()) {
inviteUsersModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), inviteUsersDialog_.data()));
inviteUsersModal_->setDuration(0);
inviteUsersModal_->setColor(QColor(30, 30, 30, 170));
}
inviteUsersModal_->fadeIn();
inviteUsersModal_->show();
});
leaveRoom_ = new QAction(tr("Leave room"), this);

@ -102,18 +102,17 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
if (logoutModal_.isNull()) {
logoutModal_ = QSharedPointer<OverlayModal>(
new OverlayModal(MainWindow::instance(), logoutDialog_.data()));
logoutModal_->setDuration(0);
logoutModal_->setColor(QColor(30, 30, 30, 170));
}
logoutModal_->fadeIn();
logoutModal_->show();
});
}
void
UserInfoWidget::closeLogoutDialog(bool isLoggingOut)
{
logoutModal_->fadeOut();
logoutModal_->hide();
if (isLoggingOut)
emit logout();

@ -23,7 +23,6 @@
OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
: OverlayWidget(parent)
, content_{content}
, duration_{500}
, color_{QColor(55, 55, 55)}
{
auto layout = new QVBoxLayout();
@ -32,21 +31,6 @@ OverlayModal::OverlayModal(QWidget *parent, QWidget *content)
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();
}
@ -63,22 +47,7 @@ void
OverlayModal::mousePressEvent(QMouseEvent *e)
{
if (isDismissible_ && content_ && !content_->geometry().contains(e->pos()))
fadeOut();
}
void
OverlayModal::fadeIn()
{
animation_->setDirection(QAbstractAnimation::Backward);
animation_->start();
show();
}
void
OverlayModal::fadeOut()
{
animation_->setDirection(QAbstractAnimation::Forward);
animation_->start();
hide();
}
void
@ -86,6 +55,6 @@ OverlayModal::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
event->accept();
fadeOut();
hide();
}
}

Loading…
Cancel
Save