diff --git a/include/ui/OverlayModal.h b/include/ui/OverlayModal.h index 0fd96390..a761e3ed 100644 --- a/include/ui/OverlayModal.h +++ b/include/ui/OverlayModal.h @@ -17,11 +17,9 @@ #pragma once -#include #include #include #include -#include #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_; }; diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 42884567..a5e3a6f8 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -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( 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( 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 diff --git a/src/MainWindow.cc b/src/MainWindow.cc index 2ada704a..11df796c 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -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(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(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(new OverlayModal(this, leaveRoomDialog_.data())); - leaveRoomModal_->setDuration(0); leaveRoomModal_->setColor(QColor(30, 30, 30, 170)); - leaveRoomModal_->fadeIn(); + leaveRoomModal_->show(); } diff --git a/src/RoomList.cc b/src/RoomList.cc index bb4b7956..8a6d4151 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -321,7 +321,7 @@ RoomList::leaveEvent(QEvent *event) void RoomList::closeJoinRoomDialog(bool isJoining, QString roomAlias) { - joinRoomModal_->fadeOut(); + joinRoomModal_->hide(); if (isJoining) client_->joinRoom(roomAlias); diff --git a/src/SideBarActions.cc b/src/SideBarActions.cc index 904184f1..9c784011 100644 --- a/src/SideBarActions.cc +++ b/src/SideBarActions.cc @@ -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( 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( new OverlayModal(MainWindow::instance(), createRoomDialog_.data())); - createRoomModal_->setDuration(0); createRoomModal_->setColor(QColor(30, 30, 30, 170)); } - createRoomModal_->fadeIn(); + createRoomModal_->show(); }); addMenu_->addAction(createRoomAction_); diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index f676a4d8..5dae10fc 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -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( 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); diff --git a/src/UserInfoWidget.cc b/src/UserInfoWidget.cc index 77aed5d5..5125b861 100644 --- a/src/UserInfoWidget.cc +++ b/src/UserInfoWidget.cc @@ -102,18 +102,17 @@ UserInfoWidget::UserInfoWidget(QWidget *parent) if (logoutModal_.isNull()) { logoutModal_ = QSharedPointer( 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(); diff --git a/src/ui/OverlayModal.cc b/src/ui/OverlayModal.cc index e6fb0c7e..4b0747a1 100644 --- a/src/ui/OverlayModal.cc +++ b/src/ui/OverlayModal.cc @@ -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(); } }