Core: Expose DocumentManager data to MacroExpander

Expose the last visited directory as well as the project directory
stored by the DocumentManager to the MacroExpander.

Change-Id: I7cdbe5e5471b5c96954c74f21187786de7bb9aa3
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-06-09 13:56:08 +02:00
parent 14ec0a63b9
commit f733f1805a

View File

@@ -39,6 +39,7 @@
#include "iwizardfactory.h" #include "iwizardfactory.h"
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/findplugin.h> #include <coreplugin/find/findplugin.h>
#include <coreplugin/locator/locator.h> #include <coreplugin/locator/locator.h>
@@ -206,6 +207,10 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
[]() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); }); []() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); });
expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."), expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."),
[]() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); }); []() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); });
expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."),
[]() { return DocumentManager::projectsDirectory(); });
expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."),
[]() { return DocumentManager::fileDialogLastVisitedDirectory(); });
expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."), expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."),
[](const QString &fmt) { return QDate::currentDate().toString(fmt); }); [](const QString &fmt) { return QDate::currentDate().toString(fmt); });
expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."), expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."),