Changeset View
Changeset View
Standalone View
Standalone View
addons/project/kateprojectpluginview.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | K_PLUGIN_FACTORY_WITH_JSON(KateProjectPluginFactory, "kateprojectplugin.json", registerPlugin<KateProjectPlugin>();) | 45 | K_PLUGIN_FACTORY_WITH_JSON(KateProjectPluginFactory, "kateprojectplugin.json", registerPlugin<KateProjectPlugin>();) | ||
46 | 46 | | |||
47 | KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEditor::MainWindow *mainWin) | 47 | KateProjectPluginView::KateProjectPluginView(KateProjectPlugin *plugin, KTextEditor::MainWindow *mainWin) | ||
48 | : QObject(mainWin) | 48 | : QObject(mainWin) | ||
49 | , m_plugin(plugin) | 49 | , m_plugin(plugin) | ||
50 | , m_mainWindow(mainWin) | 50 | , m_mainWindow(mainWin) | ||
51 | , m_toolView(nullptr) | 51 | , m_toolView(nullptr) | ||
52 | , m_toolInfoView(nullptr) | 52 | , m_toolInfoView(nullptr) | ||
53 | , m_lookupAction(nullptr) | | |||
54 | { | 53 | { | ||
55 | KXMLGUIClient::setComponentName(QStringLiteral("kateproject"), i18n("Kate Project Manager")); | 54 | KXMLGUIClient::setComponentName(QStringLiteral("kateproject"), i18n("Kate Project Manager")); | ||
56 | setXMLFile(QStringLiteral("ui.rc")); | 55 | setXMLFile(QStringLiteral("ui.rc")); | ||
57 | 56 | | |||
58 | /** | 57 | /** | ||
59 | * create views for all already existing projects | 58 | * create views for all already existing projects | ||
60 | * will create toolviews on demand! | 59 | * will create toolviews on demand! | ||
61 | */ | 60 | */ | ||
Show All 23 Lines | |||||
85 | */ | 84 | */ | ||
86 | auto a = actionCollection()->addAction(KStandardAction::Back, QStringLiteral("projects_prev_project"), this, SLOT(slotProjectPrev())); | 85 | auto a = actionCollection()->addAction(KStandardAction::Back, QStringLiteral("projects_prev_project"), this, SLOT(slotProjectPrev())); | ||
87 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Left)); | 86 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Left)); | ||
88 | a = actionCollection()->addAction(KStandardAction::Forward, QStringLiteral("projects_next_project"), this, SLOT(slotProjectNext())); | 87 | a = actionCollection()->addAction(KStandardAction::Forward, QStringLiteral("projects_next_project"), this, SLOT(slotProjectNext())); | ||
89 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Right)); | 88 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Right)); | ||
90 | a = actionCollection()->addAction(KStandardAction::Goto, QStringLiteral("projects_goto_index"), this, SLOT(slotProjectIndex())); | 89 | a = actionCollection()->addAction(KStandardAction::Goto, QStringLiteral("projects_goto_index"), this, SLOT(slotProjectIndex())); | ||
91 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::ALT | Qt::Key_1)); | 90 | actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::ALT | Qt::Key_1)); | ||
92 | 91 | | |||
93 | // popup menu | 92 | // context menu actions | ||
94 | auto popup = new KActionMenu(i18n("Project"), this); | 93 | QAction* lookupAction = actionCollection()->addAction(QLatin1String("projects_lookup_in_code_index")); | ||
95 | actionCollection()->addAction(QLatin1String("popup_project"), popup); | 94 | lookupAction->setText(i18n("Lookup in Project Code Index")); | ||
96 | 95 | connect(lookupAction, &QAction::triggered, this, &KateProjectPluginView::slotProjectIndex); | |||
97 | m_lookupAction = popup->menu()->addAction(i18n("Lookup: %1", QString()), this, SLOT(slotProjectIndex())); | | |||
98 | | ||||
99 | connect(popup->menu(), &QMenu::aboutToShow, this, &KateProjectPluginView::slotContextMenuAboutToShow); | | |||
100 | 96 | | |||
101 | /** | 97 | /** | ||
102 | * add us to gui | 98 | * add us to gui | ||
103 | */ | 99 | */ | ||
104 | m_mainWindow->guiFactory()->addClient(this); | 100 | m_mainWindow->guiFactory()->addClient(this); | ||
105 | } | 101 | } | ||
106 | 102 | | |||
107 | KateProjectPluginView::~KateProjectPluginView() | 103 | KateProjectPluginView::~KateProjectPluginView() | ||
▲ Show 20 Lines • Show All 396 Lines • ▼ Show 20 Line(s) | 498 | if (!word.isEmpty()) { | |||
504 | if (tabView) { | 500 | if (tabView) { | ||
505 | tabView->setCurrentIndex(1); | 501 | tabView->setCurrentIndex(1); | ||
506 | } | 502 | } | ||
507 | m_mainWindow->showToolView(m_toolInfoView); | 503 | m_mainWindow->showToolView(m_toolInfoView); | ||
508 | emit projectLookupWord(word); | 504 | emit projectLookupWord(word); | ||
509 | } | 505 | } | ||
510 | } | 506 | } | ||
511 | 507 | | |||
512 | void KateProjectPluginView::slotContextMenuAboutToShow() | | |||
513 | { | | |||
514 | const QString word = currentWord(); | | |||
515 | if (word.isEmpty()) { | | |||
516 | return; | | |||
517 | } | | |||
518 | | ||||
519 | const QString squeezed = KStringHandler::csqueeze(word, 30); | | |||
520 | m_lookupAction->setText(i18n("Lookup: %1", squeezed)); | | |||
521 | } | | |||
522 | | ||||
523 | #include "kateprojectpluginview.moc" | 508 | #include "kateprojectpluginview.moc" |