Skip to content

Commit

Permalink
feat: [project] Add project infomations to macro variables
Browse files Browse the repository at this point in the history
as title

Log: Add project infomations to macro variables
  • Loading branch information
Kakueeen authored and deepin-mozart committed Nov 1, 2024
1 parent 25082e6 commit da01f7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/plugins/project/projectcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "mainframe/projecttree.h"
#include "mainframe/recent/recentopenwidget.h"
#include "common/common.h"
#include "common/util/macroexpander.h"
#include "base/abstractmenu.h"
#include "base/abstractaction.h"
#include "base/abstractwidget.h"
Expand Down Expand Up @@ -81,6 +82,7 @@ bool ProjectCore::start()

initProject(ctx);
initLocator(ctx);
registerVariables();

return true;
}
Expand Down Expand Up @@ -219,6 +221,16 @@ void ProjectCore::initProject(dpf::PluginServiceContext &ctx)
}
}

void ProjectCore::registerVariables()
{
globalMacroExpander()->registerFileVariables("CurrentProject",
tr("Current project"),
[] {
auto info = ProjectKeeper::instance()->treeView()->getActiveProjectInfo();
return QFileInfo(info.workspaceFolder());
});
}

dpf::Plugin::ShutdownFlag ProjectCore::stop()
{
qInfo() << __FUNCTION__;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/project/projectcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ProjectCore : public dpf::Plugin

void initLocator(dpf::PluginServiceContext& ctx);
void initProject(dpf::PluginServiceContext& ctx);
void registerVariables();

private slots:
void pluginsStartedMain();
Expand Down

0 comments on commit da01f7b

Please sign in to comment.