forked from qt-creator/qt-creator
Utils: Add commonly used paths to AppInfo
Change-Id: Icfd7e549a1589aff13bfacfe6abd85e7e780b3c0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -522,6 +522,38 @@ private:
|
|||||||
|
|
||||||
ShowInGuiHandler *ShowInGuiHandler::instance = nullptr;
|
ShowInGuiHandler *ShowInGuiHandler::instance = nullptr;
|
||||||
|
|
||||||
|
FilePath userPluginsRoot()
|
||||||
|
{
|
||||||
|
FilePath rootPath = FilePath::fromUserInput(
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
||||||
|
|
||||||
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
||||||
|
rootPath /= "data";
|
||||||
|
|
||||||
|
rootPath /= Core::Constants::IDE_SETTINGSVARIANT_STR;
|
||||||
|
|
||||||
|
rootPath /= QLatin1StringView(
|
||||||
|
HostOsInfo::isMacHost() ? Core::Constants::IDE_DISPLAY_NAME : Core::Constants::IDE_ID);
|
||||||
|
rootPath /= "plugins";
|
||||||
|
|
||||||
|
rootPath /= Core::Constants::IDE_VERSION_LONG;
|
||||||
|
|
||||||
|
return rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath userResourcePath(const QString &settingsPath, const QString &appId)
|
||||||
|
{
|
||||||
|
const FilePath configDir = FilePath::fromUserInput(settingsPath).parentDir();
|
||||||
|
const FilePath urp = configDir / appId;
|
||||||
|
|
||||||
|
if (!urp.exists()) {
|
||||||
|
if (!urp.createDir())
|
||||||
|
qWarning() << "could not create" << urp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return urp;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Restarter restarter(argc, argv);
|
Restarter restarter(argc, argv);
|
||||||
@@ -723,6 +755,14 @@ int main(int argc, char **argv)
|
|||||||
info.revision = Constants::IDE_REVISION_STR;
|
info.revision = Constants::IDE_REVISION_STR;
|
||||||
info.revisionUrl = Constants::IDE_REVISION_URL;
|
info.revisionUrl = Constants::IDE_REVISION_URL;
|
||||||
info.userFileExtension = Constants::IDE_PROJECT_USER_FILE_EXTENSION;
|
info.userFileExtension = Constants::IDE_PROJECT_USER_FILE_EXTENSION;
|
||||||
|
|
||||||
|
const FilePath appDirPath = FilePath::fromUserInput(QApplication::applicationDirPath());
|
||||||
|
|
||||||
|
info.plugins = (appDirPath / RELATIVE_PLUGIN_PATH).cleanPath();
|
||||||
|
info.userPluginsRoot = userPluginsRoot();
|
||||||
|
info.resources = (appDirPath / RELATIVE_DATA_PATH).cleanPath();
|
||||||
|
info.userResources = userResourcePath(settings->fileName(), Constants::IDE_ID);
|
||||||
|
|
||||||
Utils::Internal::setAppInfo(info);
|
Utils::Internal::setAppInfo(info);
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
|
@@ -7,7 +7,7 @@ Q_GLOBAL_STATIC(Utils::AppInfo, sAppInfo)
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
Utils::AppInfo appInfo()
|
const Utils::AppInfo &appInfo()
|
||||||
{
|
{
|
||||||
return *sAppInfo;
|
return *sAppInfo;
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "utils_global.h"
|
#include "utils_global.h"
|
||||||
|
|
||||||
|
#include "filepath.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@@ -19,9 +21,22 @@ public:
|
|||||||
QString revision;
|
QString revision;
|
||||||
QString revisionUrl;
|
QString revisionUrl;
|
||||||
QString userFileExtension;
|
QString userFileExtension;
|
||||||
|
|
||||||
|
FilePath plugins;
|
||||||
|
|
||||||
|
/*! Local plugin path: <localappdata>/plugins
|
||||||
|
where <localappdata> is e.g.
|
||||||
|
"%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later
|
||||||
|
"$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux
|
||||||
|
"~/Library/Application Support/QtProject/Qt Creator" on Mac
|
||||||
|
*/
|
||||||
|
FilePath userPluginsRoot;
|
||||||
|
|
||||||
|
FilePath resources;
|
||||||
|
FilePath userResources;
|
||||||
};
|
};
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT AppInfo appInfo();
|
QTCREATOR_UTILS_EXPORT const AppInfo &appInfo();
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
QTCREATOR_UTILS_EXPORT void setAppInfo(const AppInfo &info);
|
QTCREATOR_UTILS_EXPORT void setAppInfo(const AppInfo &info);
|
||||||
|
Reference in New Issue
Block a user