Commit acc47c7d authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

set parent for QMenu

Takes care of most of the QMenu occurunces. A couple remain in
SearchPlugin

BUG: 460983
parent f2e53e28
......@@ -389,7 +389,7 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event)
bool isWidgetDir = m_proxyModel->isWidgetDir(m_indexContextMenu);
bool isWidget = m_indexContextMenu.data(KateFileTreeModel::WidgetRole).value<QWidget *>() != nullptr;
QMenu menu;
QMenu menu(this);
if (doc) {
if (doc->url().isValid()) {
QMenu *openWithMenu = menu.addMenu(i18nc("@action:inmenu", "Open With"));
......
......@@ -21,7 +21,7 @@ void DataOutputView::slotCustomContextMenuRequested(const QPoint &pos)
{
Q_UNUSED(pos);
QMenu menu;
QMenu menu(this);
menu.addActions(actions());
......
......@@ -260,7 +260,7 @@ void SchemaWidget::slotItemExpanded(QTreeWidgetItem *item)
void SchemaWidget::slotCustomContextMenuRequested(const QPoint &pos)
{
QMenu menu;
QMenu menu(this);
QTreeWidgetItem *item = itemAt(pos);
if (item) {
......
......@@ -293,7 +293,7 @@ void LSPClientConfigPage::updateHighlighters()
void LSPClientConfigPage::showContextMenuAllowedBlocked(const QPoint &pos)
{
// allow deletion of stuff
QMenu myMenu;
QMenu myMenu(this);
auto currentDelete = myMenu.addAction(i18n("Delete selected entries"), this, [this]() {
qDeleteAll(ui->allowedAndBlockedServers->selectedItems());
......
......@@ -1057,7 +1057,7 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
auto treeItem = idx.data(GitStatusModel::TreeItemType);
if (treeItem == GitStatusModel::NodeChanges || treeItem == GitStatusModel::NodeUntrack) {
QMenu menu;
QMenu menu(this);
bool untracked = treeItem == GitStatusModel::NodeUntrack;
auto stageAct = menu.addAction(i18n("Stage All"));
......@@ -1115,7 +1115,7 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
showDiff(QString(), false);
}
} else if (treeItem == GitStatusModel::NodeFile) {
QMenu menu;
QMenu menu(this);
const auto statusItemType = idx.data(GitStatusModel::GitItemType).value<GitStatusModel::ItemType>();
const bool staged = statusItemType == GitStatusModel::NodeStage;
const bool untracked = statusItemType == GitStatusModel::NodeUntrack;
......@@ -1169,7 +1169,7 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
m_mainWin->openUrl(QUrl::fromLocalFile(file));
}
} else if (treeItem == GitStatusModel::NodeStage) {
QMenu menu;
QMenu menu(this);
auto stage = menu.addAction(i18n("Unstage All"));
auto diff = menu.addAction(i18n("Show Diff"));
auto model = m_treeView->model();
......@@ -1236,7 +1236,7 @@ void GitWidget::selectedContextMenu(QContextMenuEvent *e)
return;
}
QMenu menu;
QMenu menu(this);
auto stageAct = selectionHasStagedItems ? menu.addAction(i18n("Unstage Selected Files")) : menu.addAction(i18n("Stage Selected Files"));
auto discardAct = selectionHasChangedItems && !selectionHasUntrackedItems ? menu.addAction(i18n("Discard Selected Files")) : nullptr;
if (discardAct) {
......
......@@ -63,7 +63,7 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
/**
* Create context menu
*/
QMenu menu;
QMenu menu(parent);
/**
* Copy Path, always available, put that to the top
......
......@@ -8,23 +8,20 @@
#ifndef KATE_PROJECT_TREE_VIEW_CONTEXT_MENU_H
#define KATE_PROJECT_TREE_VIEW_CONTEXT_MENU_H
#include <QObject>
#include <QPoint>
#include <QString>
class QWidget;
class QModelIndex;
class KateProjectViewTree;
class KateProjectTreeViewContextMenu : public QObject
class KateProjectTreeViewContextMenu
{
Q_OBJECT
public:
/**
* our project.
* @return project
*/
void exec(const QString &filename, const QModelIndex &index, const QPoint &pos, KateProjectViewTree *parent);
static void exec(const QString &filename, const QModelIndex &index, const QPoint &pos, KateProjectViewTree *parent);
};
#endif
......@@ -23,7 +23,7 @@ MatchExportDialog::MatchExportDialog(QWidget *parent, QAbstractItemModel *matchM
exportPatternText->addAction(QIcon::fromTheme(QStringLiteral("code-context")), QLineEdit::TrailingPosition);
connect(exportPatternTextActionForInsertRegexButton, &QAction::triggered, this, [this]() {
QMenu menu;
QMenu menu(this);
QSet<QAction *> actionList;
KatePluginSearchView::addRegexHelperActionsForReplace(&actionList, &menu);
auto &&action = menu.exec(QCursor::pos());
......
......@@ -113,7 +113,7 @@ public:
// provide simple context menu, e.g. for copy&paste
void contextMenuEvent(QContextMenuEvent *event) override
{
QMenu menu;
QMenu menu(this);
menu.addAction(m_copyAction);
menu.exec(viewport()->mapToGlobal(event->pos()));
event->accept();
......
......@@ -232,7 +232,7 @@ void WelcomeView::onRecentItemsContextMenuRequested(const QPoint &pos)
const QUrl url = m_recentItemsModel->url(index);
Q_ASSERT(url.isValid());
QMenu contextMenu;
QMenu contextMenu(listViewRecentItems);
QAction *action = new QAction(i18n("Copy &Location"));
action->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy-path")));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment