MCPcopy Create free account
hub / github.com/KDE/kdevelop / ProjectManagerView

Method ProjectManagerView

plugins/projectmanagerview/projectmanagerview.cpp:66–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64static const int projectBuildSetStrechFactor = 25; // %
65
66ProjectManagerView::ProjectManagerView( ProjectManagerViewPlugin* plugin, QWidget *parent )
67 : QWidget( parent ), m_ui(new Ui::ProjectManagerView), m_plugin(plugin)
68{
69 m_ui->setupUi( this );
70 setFocusProxy(m_ui->projectTreeView);
71
72 m_ui->projectTreeView->installEventFilter(this);
73
74 setWindowIcon( QIcon::fromTheme( QStringLiteral("project-development"), windowIcon() ) );
75 setWindowTitle(i18nc("@title:window", "Projects"));
76
77 KConfigGroup pmviewConfig(ICore::self()->activeSession()->config(), sessionConfigGroup());
78 if (pmviewConfig.hasKey(splitterStateConfigKey)) {
79 QByteArray geometry = pmviewConfig.readEntry<QByteArray>(splitterStateConfigKey, QByteArray());
80 m_ui->splitter->restoreState(geometry);
81 } else {
82 m_ui->splitter->setStretchFactor(0, projectTreeViewStrechFactor);
83 m_ui->splitter->setStretchFactor(1, projectBuildSetStrechFactor);
84 }
85
86 // keep the project tree view from collapsing (would confuse users)
87 m_ui->splitter->setCollapsible(0, false);
88
89 auto* const syncActionMenu = new KActionMenu(this);
90 auto* const syncSubAction = plugin->actionCollection()->action(QStringLiteral("locate_document"));
91 Q_ASSERT(syncSubAction);
92 for (QAction* action : {static_cast<QAction*>(syncActionMenu), syncSubAction}) {
93 action->setText(i18nc("@action", "Locate Current Document"));
94 action->setToolTip(i18nc("@info:tooltip", "Locates the current document in the project tree and selects it."));
95 action->setIcon(QIcon::fromTheme(QStringLiteral("dirsync")));
96 connect(action, &QAction::triggered, this, &ProjectManagerView::raiseAndLocateCurrentDocument);
97 }
98 syncActionMenu->addAction(syncSubAction);
99
100 auto* const autoSyncSubAction = new QAction(i18nc("@action", "Auto-Select Current Document"), this);
101 autoSyncSubAction->setToolTip(i18nc("@info:tooltip", "Automatically select the current document in the project tree."));
102 autoSyncSubAction->setCheckable(true);
103 autoSyncSubAction->setChecked(pmviewConfig.readEntry<bool>(syncCurrentDocumentKey, true));
104 connect(autoSyncSubAction, &QAction::triggered, this, &ProjectManagerView::toggleSyncCurrentDocument);
105 connect(ICore::self()->documentController(), &KDevelop::IDocumentController::documentActivated, this, [autoSyncSubAction, this] {
106 if (autoSyncSubAction->isChecked()) {
107 locateCurrentDocument();
108 }
109 });
110 // TODO: the above lambda should be connected to IDocumentController::documentUrlChanged as well. However, this
111 // works incorrectly, because a renamed file is included into its project with a delay. This issue also affects
112 // other slots connected to documentUrlChanged (see a similar TODO in CompileAnalyzer::CompileAnalyzer()).
113 syncActionMenu->addAction(autoSyncSubAction);
114
115 const auto updateSyncAction = [syncActionMenu, syncSubAction, autoSyncSubAction] {
116 const bool enable = KDevelop::ICore::self()->documentController()->activeDocument();
117 syncActionMenu->setEnabled(enable);
118 syncSubAction->setEnabled(enable);
119 autoSyncSubAction->setEnabled(enable);
120 };
121 addAction(syncActionMenu);
122
123 m_toggleTargetsAction = new QAction(i18nc("@action", "Show Build Targets"), this);

Callers

nothing calls this directly

Calls 15

sessionConfigGroupFunction · 0.85
setupUiMethod · 0.80
restoreStateMethod · 0.80
setToolTipMethod · 0.80
setIconMethod · 0.80
documentControllerMethod · 0.80
activeDocumentMethod · 0.80
setProjectViewMethod · 0.80
showTargetsMethod · 0.80
setSourceModelMethod · 0.80
projectControllerMethod · 0.80
uiControllerMethod · 0.80

Tested by

no test coverage detected