mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: Change lifetime of context menus (#4924)
This commit is contained in:
parent
7ecbfa0cdb
commit
c811e2d991
|
@ -44,6 +44,7 @@
|
|||
- Dev: Improve performance by reducing repaints caused by selections. (#4889)
|
||||
- Dev: Removed direct dependency on Qt 5 compatibility module. (#4906)
|
||||
- Dev: Refactor `DebugCount` and add copy button to debug popup. (#4921)
|
||||
- Dev: Changed lifetime of context menus. (#4924)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -278,15 +278,8 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent,
|
|||
return;
|
||||
}
|
||||
|
||||
static QMenu *previousMenu = nullptr;
|
||||
if (previousMenu != nullptr)
|
||||
{
|
||||
previousMenu->deleteLater();
|
||||
previousMenu = nullptr;
|
||||
}
|
||||
|
||||
auto menu = new QMenu;
|
||||
previousMenu = menu;
|
||||
auto *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
auto avatarUrl = this->avatarUrl_;
|
||||
|
||||
|
|
|
@ -73,19 +73,13 @@ namespace {
|
|||
MessageElementFlags creatorFlags, QMenu &menu)
|
||||
{
|
||||
auto *openAction = menu.addAction("&Open");
|
||||
auto openMenu = new QMenu;
|
||||
auto *openMenu = new QMenu(&menu);
|
||||
openAction->setMenu(openMenu);
|
||||
|
||||
auto *copyAction = menu.addAction("&Copy");
|
||||
auto copyMenu = new QMenu;
|
||||
auto *copyMenu = new QMenu(&menu);
|
||||
copyAction->setMenu(copyMenu);
|
||||
|
||||
// see if the QMenu actually gets destroyed
|
||||
QObject::connect(openMenu, &QMenu::destroyed, [] {
|
||||
QMessageBox(QMessageBox::Information, "xD", "the menu got deleted")
|
||||
.exec();
|
||||
});
|
||||
|
||||
// Add copy and open links for 1x, 2x, 3x
|
||||
auto addImageLink = [&](const ImagePtr &image, char scale) {
|
||||
if (!image->isEmpty())
|
||||
|
@ -2099,15 +2093,8 @@ void ChannelView::addContextMenuItems(
|
|||
const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout,
|
||||
QMouseEvent *event)
|
||||
{
|
||||
static QMenu *previousMenu = nullptr;
|
||||
if (previousMenu != nullptr)
|
||||
{
|
||||
previousMenu->deleteLater();
|
||||
previousMenu = nullptr;
|
||||
}
|
||||
|
||||
auto menu = new QMenu;
|
||||
previousMenu = menu;
|
||||
auto *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
// Add image options if the element clicked contains an image (e.g. a badge or an emote)
|
||||
this->addImageContextMenuItems(hoveredElement, layout, event, *menu);
|
||||
|
@ -2416,7 +2403,7 @@ void ChannelView::addCommandExecutionContextMenuItems(
|
|||
|
||||
menu.addSeparator();
|
||||
auto *executeAction = menu.addAction("&Execute command");
|
||||
auto cmdMenu = new QMenu;
|
||||
auto *cmdMenu = new QMenu(&menu);
|
||||
executeAction->setMenu(cmdMenu);
|
||||
|
||||
for (auto &cmd : cmds)
|
||||
|
|
Loading…
Reference in a new issue