Skip to content

Commit da01f7b

Browse files
Kakueeendeepin-mozart
authored andcommitted
feat: [project] Add project infomations to macro variables
as title Log: Add project infomations to macro variables
1 parent 25082e6 commit da01f7b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/plugins/project/projectcore.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "mainframe/projecttree.h"
1010
#include "mainframe/recent/recentopenwidget.h"
1111
#include "common/common.h"
12+
#include "common/util/macroexpander.h"
1213
#include "base/abstractmenu.h"
1314
#include "base/abstractaction.h"
1415
#include "base/abstractwidget.h"
@@ -81,6 +82,7 @@ bool ProjectCore::start()
8182

8283
initProject(ctx);
8384
initLocator(ctx);
85+
registerVariables();
8486

8587
return true;
8688
}
@@ -219,6 +221,16 @@ void ProjectCore::initProject(dpf::PluginServiceContext &ctx)
219221
}
220222
}
221223

224+
void ProjectCore::registerVariables()
225+
{
226+
globalMacroExpander()->registerFileVariables("CurrentProject",
227+
tr("Current project"),
228+
[] {
229+
auto info = ProjectKeeper::instance()->treeView()->getActiveProjectInfo();
230+
return QFileInfo(info.workspaceFolder());
231+
});
232+
}
233+
222234
dpf::Plugin::ShutdownFlag ProjectCore::stop()
223235
{
224236
qInfo() << __FUNCTION__;

src/plugins/project/projectcore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ProjectCore : public dpf::Plugin
2828

2929
void initLocator(dpf::PluginServiceContext& ctx);
3030
void initProject(dpf::PluginServiceContext& ctx);
31+
void registerVariables();
3132

3233
private slots:
3334
void pluginsStartedMain();

0 commit comments

Comments
 (0)