forked from qt-creator/qt-creator
QmlDesigner: Use font folder for fonts
We should use the fonts folder as default if it exists. Change-Id: If18714ffa195856f14d7960b46b20992b48faa6f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -65,6 +65,7 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
#include <projectexplorer/projecttree.h>
|
||||||
|
#include "projectexplorer/session.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -949,9 +950,25 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::FilePath projectFilePath()
|
||||||
|
{
|
||||||
|
if (auto *doc = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()) {
|
||||||
|
if (auto *proj = ProjectExplorer::SessionManager::projectForFile(doc->fileName()))
|
||||||
|
return proj->projectDirectory();
|
||||||
|
}
|
||||||
|
return Utils::FilePath();
|
||||||
|
}
|
||||||
|
|
||||||
bool addFontToProject(const QStringList &fileNames, const QString &defaultDirectory)
|
bool addFontToProject(const QStringList &fileNames, const QString &defaultDirectory)
|
||||||
{
|
{
|
||||||
QString directory = AddImagesDialog::getDirectory(fileNames, defaultDirectory);
|
|
||||||
|
QString adjustedDefaultDirectory = defaultDirectory;
|
||||||
|
Utils::FilePath fonts = projectFilePath().pathAppended("fonts");
|
||||||
|
|
||||||
|
if (fonts.exists())
|
||||||
|
adjustedDefaultDirectory = fonts.toString();
|
||||||
|
|
||||||
|
QString directory = AddImagesDialog::getDirectory(fileNames, adjustedDefaultDirectory);
|
||||||
|
|
||||||
if (directory.isEmpty())
|
if (directory.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user