Files
Sourcetrail/src/app/qt/utility/utilityQt.cpp
T
malte_langkabel 8bc11c9d9c logic: File Manager
* added FileManager that keeps track of the files analyzed by the project. It therefore checks if files get added, updated or deleted from the source- and include folders.
* refactored ASTVisitor::hasValidLocation() and implemented one version that search for the location in the currently parsed file and one that searches in all the project's source files.
* quickfix: switched order in FileManager so that header files are parsed first.
* created folder for helper classes used in tests.
* added test code for FileManager
* adjusted test code for Parser Tests.
2015-02-09 14:52:31 +01:00

51 lines
1.2 KiB
C++

#include "utilityQt.h"
#include <set>
#include <QFile>
#include <QFontDatabase>
#include "utility/file/FileSystem.h"
#include "utility/logging/logging.h"
namespace utility
{
void setWidgetBackgroundColor(QWidget* widget, const Colori& color)
{
QPalette palette = widget->palette();
palette.setColor(widget->backgroundRole(), QColor(color.r, color.g, color.b, color.a));
widget->setPalette(palette);
widget->setAutoFillBackground(true);
}
void loadFontsFromDirectory(const std::string& path, const std::string& extension)
{
std::vector<std::string> extensions;
extensions.push_back(extension);
std::vector<std::string> fontFileNames = FileSystem::getFileNamesFromDirectory(path, extensions);
std::set<int> loadedFontIds;
for (const std::string& fontFileName: fontFileNames)
{
QFile file(fontFileName.c_str());
if (file.open(QIODevice::ReadOnly))
{
int id = QFontDatabase::addApplicationFontFromData(file.readAll());
if (id != -1)
{
loadedFontIds.insert(id);
}
}
}
for (int loadedFontId: loadedFontIds)
{
for (QString family: QFontDatabase::applicationFontFamilies(loadedFontId))
{
LOG_INFO("Loaded FontFamily: " + family.toStdString());
}
}
}
}