From 6f4f66b9d04c8a4ffb846ee55dda168ce428eeb5 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 13 Aug 2020 17:17:53 +0200 Subject: [PATCH] use different window frame for user popup based on the setting --- src/controllers/commands/CommandController.cpp | 2 +- src/widgets/dialogs/UserInfoPopup.cpp | 12 ++++++++++-- src/widgets/dialogs/UserInfoPopup.hpp | 2 +- src/widgets/helper/ChannelView.cpp | 6 +----- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index a6f4746f5..1e1d1466a 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -451,7 +451,7 @@ QString CommandController::execCommand(const QString &textNoEmoji, makeSystemMessage("Usage /usercard [user]")); return ""; } - auto *userPopup = new UserInfoPopup; + auto *userPopup = new UserInfoPopup(false); userPopup->setData(words[1], channel); userPopup->move(QCursor::pos()); userPopup->show(); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index fd31b1b9e..cc1665aac 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -87,13 +87,21 @@ namespace { }; } // namespace -UserInfoPopup::UserInfoPopup() - : BaseWindow(BaseWindow::EnableCustomFrame) +UserInfoPopup::UserInfoPopup(bool closeAutomatically) + : BaseWindow( + closeAutomatically + ? FlagsEnum{BaseWindow::EnableCustomFrame, + BaseWindow::Frameless, + BaseWindow::FramelessDraggable} + : BaseWindow::EnableCustomFrame) , hack_(new bool) { this->setWindowTitle("Usercard"); this->setStayInScreenRect(true); + if (closeAutomatically) + this->setActionOnFocusLoss(BaseWindow::Delete); + // Close the popup when Escape is pressed createWindowShortcut(this, "Escape", [this] { this->deleteLater(); }); diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index daa3cb69d..2523c2521 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -18,7 +18,7 @@ class UserInfoPopup final : public BaseWindow Q_OBJECT public: - UserInfoPopup(); + UserInfoPopup(bool closeAutomatically); void setData(const QString &name, const ChannelPtr &channel); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index abcce8038..2253547b2 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1820,11 +1820,7 @@ void ChannelView::hideEvent(QHideEvent *) void ChannelView::showUserInfoPopup(const QString &userName) { - auto *userPopup = new UserInfoPopup; - if (getSettings()->autoCloseUserPopup) - { - userPopup->setActionOnFocusLoss(BaseWindow::Delete); - } + auto *userPopup = new UserInfoPopup(getSettings()->autoCloseUserPopup); userPopup->setData(userName, this->hasSourceChannel() ? this->sourceChannel_ : this->channel_); QPoint offset(int(150 * this->scale()), int(70 * this->scale()));