ui: style search view
Added stylesheet for search view. Added utility function that loads all font files inside a folder. Added icons and font files.
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
#include "utilityQt.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
|
||||
#include "utility/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
namespace utility
|
||||
{
|
||||
void setWidgetBackgroundColor(QWidget* widget, const Colori& color)
|
||||
@@ -9,4 +17,34 @@ namespace utility
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
namespace utility
|
||||
{
|
||||
void setWidgetBackgroundColor(QWidget* widget, const Colori& color);
|
||||
void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf");
|
||||
}
|
||||
|
||||
# endif // UTILITY_QT_H
|
||||
|
||||
Reference in New Issue
Block a user