diff --git a/addons/kate-ctags/kate_ctags_view.h b/addons/kate-ctags/kate_ctags_view.h --- a/addons/kate-ctags/kate_ctags_view.h +++ b/addons/kate-ctags/kate_ctags_view.h @@ -1,7 +1,7 @@ #ifndef KATE_CTAGS_VIEW_H #define KATE_CTAGS_VIEW_H /* Description : Kate CTags plugin - * + * * Copyright (C) 2008-2011 by Kare Sars * * This program is free software; you can redistribute it and/or @@ -21,7 +21,6 @@ * License along with this program. If not, see . */ - #include #include @@ -34,7 +33,6 @@ #include #include -#include #include #include "tags.h" @@ -49,7 +47,6 @@ KTextEditor::Cursor cursor; } TagJump; -/******************************************************************/ class KateCTagsView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface { Q_OBJECT @@ -69,13 +66,12 @@ void lookupTag(); void stepBack(); void editLookUp(); - void aboutToShow(); void tagHitClicked(QTreeWidgetItem *); void startEditTmr(); - + void addTagTarget(); void delTagTarget(); - + void updateSessionDB(); void updateDone(int exitCode, QProcess::ExitStatus status); @@ -90,30 +86,23 @@ bool listContains(const QString &target); QString currentWord(); - + void setNewLookupText(const QString &newText); void displayHits(const Tags::TagList &list); - + void gotoTagForTypes(const QString &tag, QStringList const &types); void jumpToTag(const QString &file, const QString &pattern, const QString &word); - KTextEditor::MainWindow *m_mWin; QWidget *m_toolView; Ui::kateCtags m_ctagsUi; - QPointer m_menu; - QAction *m_gotoDef; - QAction *m_gotoDec; - QAction *m_lookup; - QProcess m_proc; QString m_commonDB; QTimer m_editTimer; QStack m_jumpStack; }; - #endif diff --git a/addons/kate-ctags/kate_ctags_view.cpp b/addons/kate-ctags/kate_ctags_view.cpp --- a/addons/kate-ctags/kate_ctags_view.cpp +++ b/addons/kate-ctags/kate_ctags_view.cpp @@ -63,18 +63,19 @@ connect(defin, &QAction::triggered, this, &KateCTagsView::gotoDefinition); QAction *lookup = actionCollection()->addAction(QLatin1String("ctags_lookup_current")); - lookup->setText(i18n("Lookup Current Text")); + lookup->setText(i18n("Lookup Selected Text")); connect(lookup, &QAction::triggered, this, &KateCTagsView::lookupTag); - // popup menu - m_menu = new KActionMenu(i18n("CTags"), this); - actionCollection()->addAction(QLatin1String("popup_ctags"), m_menu); - - m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration())); - m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition())); - m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag())); - - connect(m_menu->menu(), &QMenu::aboutToShow, this, &KateCTagsView::aboutToShow); + // context menu (same actions as above but with prefix in item title) + decl = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_declaration_popup")); + decl->setText(i18n("CTags: Go to Declaration")); + connect(decl, &QAction::triggered, this, &KateCTagsView::gotoDeclaration); + defin = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_definition_popup")); + defin->setText(i18n("CTags: Go to Definition")); + connect(defin, &QAction::triggered, this, &KateCTagsView::gotoDefinition); + lookup = actionCollection()->addAction(QLatin1String("ctags_lookup_current_popup")); + lookup->setText(i18n("CTags: Lookup Selected Text")); + connect(lookup, &QAction::triggered, this, &KateCTagsView::lookupTag); QWidget *ctagsWidget = new QWidget(m_toolView); m_ctagsUi.setupUi(ctagsWidget); @@ -130,24 +131,6 @@ delete m_toolView; } -/******************************************************************/ -void KateCTagsView::aboutToShow() -{ - QString currWord = currentWord(); - if (currWord.isEmpty()) { - return; - } - - if (Tags::hasTag(m_commonDB, currWord) || Tags::hasTag(m_ctagsUi.tagsFile->text(), currWord)) { - QString squeezed = KStringHandler::csqueeze(currWord, 30); - - m_gotoDec->setText(i18n("Go to Declaration: %1",squeezed)); - m_gotoDef->setText(i18n("Go to Definition: %1",squeezed)); - m_lookup->setText(i18n("Lookup: %1",squeezed)); - } -} - - /******************************************************************/ void KateCTagsView::readSessionConfig (const KConfigGroup& cg) { diff --git a/addons/kate-ctags/ui.rc b/addons/kate-ctags/ui.rc --- a/addons/kate-ctags/ui.rc +++ b/addons/kate-ctags/ui.rc @@ -8,11 +8,12 @@ - - + + + diff --git a/addons/project/kateprojectpluginview.h b/addons/project/kateprojectpluginview.h --- a/addons/project/kateprojectpluginview.h +++ b/addons/project/kateprojectpluginview.h @@ -178,11 +178,6 @@ */ void slotDocumentUrlChanged(KTextEditor::Document *document); - /** - * Show context menu - */ - void slotContextMenuAboutToShow(); - private: /** * find current selected or under cursor word @@ -245,11 +240,6 @@ * remember for which text views we might need to cleanup stuff */ QSet m_textViews; - - /** - * lookup action - */ - QAction *m_lookupAction; }; #endif diff --git a/addons/project/kateprojectpluginview.cpp b/addons/project/kateprojectpluginview.cpp --- a/addons/project/kateprojectpluginview.cpp +++ b/addons/project/kateprojectpluginview.cpp @@ -50,7 +50,6 @@ , m_mainWindow(mainWin) , m_toolView(nullptr) , m_toolInfoView(nullptr) - , m_lookupAction(nullptr) { KXMLGUIClient::setComponentName(QStringLiteral("kateproject"), i18n("Kate Project Manager")); setXMLFile(QStringLiteral("ui.rc")); @@ -90,13 +89,10 @@ a = actionCollection()->addAction(KStandardAction::Goto, QStringLiteral("projects_goto_index"), this, SLOT(slotProjectIndex())); actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::ALT | Qt::Key_1)); - // popup menu - auto popup = new KActionMenu(i18n("Project"), this); - actionCollection()->addAction(QLatin1String("popup_project"), popup); - - m_lookupAction = popup->menu()->addAction(i18n("Lookup: %1", QString()), this, SLOT(slotProjectIndex())); - - connect(popup->menu(), &QMenu::aboutToShow, this, &KateProjectPluginView::slotContextMenuAboutToShow); + // context menu actions + QAction* lookupAction = actionCollection()->addAction(QLatin1String("projects_lookup_in_code_index")); + lookupAction->setText(i18n("Lookup in Project Code Index")); + connect(lookupAction, &QAction::triggered, this, &KateProjectPluginView::slotProjectIndex); /** * add us to gui @@ -509,15 +505,4 @@ } } -void KateProjectPluginView::slotContextMenuAboutToShow() -{ - const QString word = currentWord(); - if (word.isEmpty()) { - return; - } - - const QString squeezed = KStringHandler::csqueeze(word, 30); - m_lookupAction->setText(i18n("Lookup: %1", squeezed)); -} - #include "kateprojectpluginview.moc" diff --git a/addons/project/ui.rc b/addons/project/ui.rc --- a/addons/project/ui.rc +++ b/addons/project/ui.rc @@ -10,7 +10,7 @@ - +