use different window frame for user popup based on the setting

This commit is contained in:
fourtf 2020-08-13 17:17:53 +02:00
parent b2ae2e598f
commit 6f4f66b9d0
4 changed files with 13 additions and 9 deletions

View file

@ -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();

View file

@ -87,13 +87,21 @@ namespace {
};
} // namespace
UserInfoPopup::UserInfoPopup()
: BaseWindow(BaseWindow::EnableCustomFrame)
UserInfoPopup::UserInfoPopup(bool closeAutomatically)
: BaseWindow(
closeAutomatically
? FlagsEnum<BaseWindow::Flags>{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(); });

View file

@ -18,7 +18,7 @@ class UserInfoPopup final : public BaseWindow
Q_OBJECT
public:
UserInfoPopup();
UserInfoPopup(bool closeAutomatically);
void setData(const QString &name, const ChannelPtr &channel);

View file

@ -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()));