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:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,37 @@
|
|||||||
|
QLineEdit#search_box {
|
||||||
|
background: rgb(204, 204, 204);
|
||||||
|
border: 0px;
|
||||||
|
height: 26px;
|
||||||
|
padding: 0 4px;
|
||||||
|
selection-background-color: rgb(51, 51, 51);
|
||||||
|
font-family: "Source Code Pro";
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAbstractItemView#search_box_popup {
|
||||||
|
selection-background-color: rgb(51, 51, 51);
|
||||||
|
font-family: "Source Code Pro";
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#search_button {
|
||||||
|
border: 0px;
|
||||||
|
border-image: url(data/gui/search_view/images/button_search.png);
|
||||||
|
height: 26px;
|
||||||
|
height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#case_sensitive_button {
|
||||||
|
border-image: url(data/gui/search_view/images/button_case_sensitive_inactive.png);
|
||||||
|
border: 0px;
|
||||||
|
height: 26px;
|
||||||
|
height: 26px;
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#case_sensitive_button:checked {
|
||||||
|
border-image: url(data/gui/search_view/images/button_case_sensitive_active.png);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
QLineEdit#search_box {
|
||||||
|
background: rgb(204, 204, 204);
|
||||||
|
border: 0px;
|
||||||
|
height: 26px;
|
||||||
|
padding: 0 4px;
|
||||||
|
selection-background-color: rgb(51, 51, 51);
|
||||||
|
font-family: "Source Code Pro";
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAbstractItemView#search_box_popup {
|
||||||
|
selection-background-color: rgb(51, 51, 51);
|
||||||
|
font-family: "Source Code Pro";
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#search_button {
|
||||||
|
border: 0px;
|
||||||
|
border-image: url(data/gui/search_view/images/button_search.png);
|
||||||
|
height: 26px;
|
||||||
|
height: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#case_sensitive_button {
|
||||||
|
border-image: url(data/gui/search_view/images/button_case_sensitive_inactive.png);
|
||||||
|
border: 0px;
|
||||||
|
height: 26px;
|
||||||
|
height: 26px;
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton#case_sensitive_button:checked {
|
||||||
|
border-image: url(data/gui/search_view/images/button_case_sensitive_active.png);
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "qt/QtGuiFactory.h"
|
#include "qt/QtGuiFactory.h"
|
||||||
|
#include "qt/utility/utilityQt.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -14,5 +15,7 @@ int main(int argc, char *argv[])
|
|||||||
std::shared_ptr<Application> app = Application::create(&guiFactory);
|
std::shared_ptr<Application> app = Application::create(&guiFactory);
|
||||||
app->loadProject("data/ProjectSettings.xml");
|
app->loadProject("data/ProjectSettings.xml");
|
||||||
|
|
||||||
|
utility::loadFontsFromDirectory("data/fonts", ".otf");
|
||||||
|
|
||||||
return qtApp.exec();
|
return qtApp.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
#include "utilityQt.h"
|
#include "utilityQt.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFontDatabase>
|
||||||
|
|
||||||
|
#include "utility/FileSystem.h"
|
||||||
|
#include "utility/logging/logging.h"
|
||||||
|
|
||||||
namespace utility
|
namespace utility
|
||||||
{
|
{
|
||||||
void setWidgetBackgroundColor(QWidget* widget, const Colori& color)
|
void setWidgetBackgroundColor(QWidget* widget, const Colori& color)
|
||||||
@@ -9,4 +17,34 @@ namespace utility
|
|||||||
widget->setPalette(palette);
|
widget->setPalette(palette);
|
||||||
widget->setAutoFillBackground(true);
|
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
|
namespace utility
|
||||||
{
|
{
|
||||||
void setWidgetBackgroundColor(QWidget* widget, const Colori& color);
|
void setWidgetBackgroundColor(QWidget* widget, const Colori& color);
|
||||||
|
void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf");
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // UTILITY_QT_H
|
# endif // UTILITY_QT_H
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
#include "component/controller/SearchController.h"
|
||||||
#include "qt/element/QtButton.h"
|
#include "qt/element/QtButton.h"
|
||||||
#include "qt/element/QtEditBox.h"
|
#include "qt/element/QtEditBox.h"
|
||||||
#include "qt/QtWidgetWrapper.h"
|
#include "qt/QtWidgetWrapper.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
#include "component/controller/SearchController.h"
|
#include "utility/text/TextAccess.h"
|
||||||
|
|
||||||
QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
||||||
: SearchView(viewLayout)
|
: SearchView(viewLayout)
|
||||||
@@ -27,28 +28,30 @@ void QtSearchView::createWidgetWrapper()
|
|||||||
void QtSearchView::initGui()
|
void QtSearchView::initGui()
|
||||||
{
|
{
|
||||||
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
|
QWidget* widget = QtWidgetWrapper::getWidgetOfView(this);
|
||||||
utility::setWidgetBackgroundColor(widget, Colori(190, 190, 190, 255));
|
utility::setWidgetBackgroundColor(widget, Colori(255, 255, 255, 255));
|
||||||
|
widget->setStyleSheet(TextAccess::createFromFile("data/gui/search_view/search_view.css")->getText().c_str());
|
||||||
|
|
||||||
|
|
||||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
|
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
layout->setSpacing(3);
|
layout->setSpacing(0);
|
||||||
layout->setContentsMargins(3, 3, 3, 3);
|
//layout->setContentsMargins(3, 3, 3, 3);
|
||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
|
|
||||||
|
m_searchButton = new QtButton(widget);
|
||||||
|
m_searchButton->setCallbackOnClick(std::bind(&QtSearchView::onSearchButtonClick, this));
|
||||||
|
m_searchButton->setObjectName("search_button");
|
||||||
|
widget->layout()->addWidget(m_searchButton);
|
||||||
|
|
||||||
m_searchBox = new QtEditBox(widget);
|
m_searchBox = new QtEditBox(widget);
|
||||||
m_searchBox->setPlaceholderText("Please enter your search string.");
|
m_searchBox->setPlaceholderText("Please enter your search string.");
|
||||||
m_searchBox->setCallbackOnReturnPressed(std::bind(&QtSearchView::onSearchButtonClick, this));
|
m_searchBox->setCallbackOnReturnPressed(std::bind(&QtSearchView::onSearchButtonClick, this));
|
||||||
|
m_searchBox->setObjectName("search_box");
|
||||||
std::vector<std::string> autocompletionList;
|
|
||||||
autocompletionList.push_back("tralala");
|
|
||||||
autocompletionList.push_back("lalila");
|
|
||||||
setAutocompletionList(autocompletionList);
|
|
||||||
|
|
||||||
m_searchButton = new QtButton(widget);
|
|
||||||
m_searchButton->setText("Search");
|
|
||||||
m_searchButton->setCallbackOnClick(std::bind(&QtSearchView::onSearchButtonClick, this));
|
|
||||||
|
|
||||||
widget->layout()->addWidget(m_searchBox);
|
widget->layout()->addWidget(m_searchBox);
|
||||||
widget->layout()->addWidget(m_searchButton);
|
|
||||||
|
m_caseSensitiveButton = new QtButton(widget);
|
||||||
|
m_caseSensitiveButton->setObjectName("case_sensitive_button");
|
||||||
|
m_caseSensitiveButton->setCheckable(true);
|
||||||
|
widget->layout()->addWidget(m_caseSensitiveButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtSearchView::setText(const std::string& s)
|
void QtSearchView::setText(const std::string& s)
|
||||||
@@ -84,6 +87,8 @@ void QtSearchView::doSetAutocompletionList(const std::vector<std::string>& autoc
|
|||||||
for (const std::string& s: autocompletionList)
|
for (const std::string& s: autocompletionList)
|
||||||
wordList << s.c_str();
|
wordList << s.c_str();
|
||||||
QCompleter *completer = new QCompleter(wordList, m_searchBox);
|
QCompleter *completer = new QCompleter(wordList, m_searchBox);
|
||||||
|
completer->popup()->setObjectName("search_box_popup");
|
||||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_searchBox->setCompleter(completer);
|
m_searchBox->setCompleter(completer);
|
||||||
|
completer->popup()->setStyleSheet(TextAccess::createFromFile("data/gui/search_view/search_view.css")->getText().c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private:
|
|||||||
|
|
||||||
QtEditBox* m_searchBox;
|
QtEditBox* m_searchBox;
|
||||||
QtButton* m_searchButton;
|
QtButton* m_searchButton;
|
||||||
|
QtButton* m_caseSensitiveButton;
|
||||||
QtThreadedFunctor<const std::string&> m_setTextFunctor;
|
QtThreadedFunctor<const std::string&> m_setTextFunctor;
|
||||||
QtThreadedFunctor<const std::vector<std::string>&> m_setAutocompletionListFunctor;
|
QtThreadedFunctor<const std::vector<std::string>&> m_setAutocompletionListFunctor;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ std::vector<std::string> FileSystem::getSourceFilesFromDirectory(
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> FileSystem::getFileNamesFromDirectory(
|
||||||
|
const std::string& path, const std::vector<std::string>& extensions
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return getSourceFilesFromDirectory(path, extensions);
|
||||||
|
}
|
||||||
|
|
||||||
bool FileSystem::isValidExtension(const std::string& filepath, const std::vector<std::string>& extensions)
|
bool FileSystem::isValidExtension(const std::string& filepath, const std::vector<std::string>& extensions)
|
||||||
{
|
{
|
||||||
boost::filesystem::path path(filepath);
|
boost::filesystem::path path(filepath);
|
||||||
|
|||||||
@@ -7,9 +7,14 @@
|
|||||||
class FileSystem
|
class FileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::vector<std::string> getSourceFilesFromDirectory(
|
static std::vector<std::string> getSourceFilesFromDirectory( // TODO: Replace this with getFileNamesFromDirectory.
|
||||||
const std::string& path, const std::vector<std::string>& extensions
|
const std::string& path, const std::vector<std::string>& extensions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static std::vector<std::string> getFileNamesFromDirectory(
|
||||||
|
const std::string& path, const std::vector<std::string>& extensions
|
||||||
|
);
|
||||||
|
|
||||||
static bool exists(const std::string& path);
|
static bool exists(const std::string& path);
|
||||||
static std::string fileName(const std::string& path);
|
static std::string fileName(const std::string& path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user