diff --git a/bin/app/data/fonts/SourceCodePro-Bold.otf b/bin/app/data/fonts/SourceCodePro-Bold.otf new file mode 100644 index 00000000..96b48775 Binary files /dev/null and b/bin/app/data/fonts/SourceCodePro-Bold.otf differ diff --git a/bin/app/data/fonts/SourceCodePro-Light.otf b/bin/app/data/fonts/SourceCodePro-Light.otf new file mode 100644 index 00000000..f624ee1c Binary files /dev/null and b/bin/app/data/fonts/SourceCodePro-Light.otf differ diff --git a/bin/app/data/fonts/SourceCodePro-Medium.otf b/bin/app/data/fonts/SourceCodePro-Medium.otf new file mode 100644 index 00000000..be70672f Binary files /dev/null and b/bin/app/data/fonts/SourceCodePro-Medium.otf differ diff --git a/bin/app/data/fonts/SourceCodePro-Regular.otf b/bin/app/data/fonts/SourceCodePro-Regular.otf new file mode 100644 index 00000000..8f031da9 Binary files /dev/null and b/bin/app/data/fonts/SourceCodePro-Regular.otf differ diff --git a/bin/app/data/gui/search_view/images/button_case_sensitive_active.png b/bin/app/data/gui/search_view/images/button_case_sensitive_active.png new file mode 100644 index 00000000..72212a67 Binary files /dev/null and b/bin/app/data/gui/search_view/images/button_case_sensitive_active.png differ diff --git a/bin/app/data/gui/search_view/images/button_case_sensitive_inactive.png b/bin/app/data/gui/search_view/images/button_case_sensitive_inactive.png new file mode 100644 index 00000000..02deccb4 Binary files /dev/null and b/bin/app/data/gui/search_view/images/button_case_sensitive_inactive.png differ diff --git a/bin/app/data/gui/search_view/images/button_search.png b/bin/app/data/gui/search_view/images/button_search.png new file mode 100644 index 00000000..21db3a21 Binary files /dev/null and b/bin/app/data/gui/search_view/images/button_search.png differ diff --git a/bin/app/data/gui/search_view/search_view.css b/bin/app/data/gui/search_view/search_view.css new file mode 100644 index 00000000..e6962948 --- /dev/null +++ b/bin/app/data/gui/search_view/search_view.css @@ -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); +} diff --git a/bin/app/data/gui/search_view/style_search_view.css b/bin/app/data/gui/search_view/style_search_view.css new file mode 100644 index 00000000..e6962948 --- /dev/null +++ b/bin/app/data/gui/search_view/style_search_view.css @@ -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); +} diff --git a/src/app/main.cpp b/src/app/main.cpp index 33f4855c..bbca8dc7 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -5,6 +5,7 @@ #include "Application.h" #include "includes.h" #include "qt/QtGuiFactory.h" +#include "qt/utility/utilityQt.h" int main(int argc, char *argv[]) { @@ -14,5 +15,7 @@ int main(int argc, char *argv[]) std::shared_ptr app = Application::create(&guiFactory); app->loadProject("data/ProjectSettings.xml"); + utility::loadFontsFromDirectory("data/fonts", ".otf"); + return qtApp.exec(); } diff --git a/src/app/qt/utility/utilityQt.cpp b/src/app/qt/utility/utilityQt.cpp index 17d1b78b..e043c96c 100644 --- a/src/app/qt/utility/utilityQt.cpp +++ b/src/app/qt/utility/utilityQt.cpp @@ -1,5 +1,13 @@ #include "utilityQt.h" +#include + +#include +#include + +#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 extensions; + extensions.push_back(extension); + std::vector fontFileNames = FileSystem::getFileNamesFromDirectory(path, extensions); + + std::set 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()); + } + } + } } diff --git a/src/app/qt/utility/utilityQt.h b/src/app/qt/utility/utilityQt.h index 8e915f25..bb2f93e4 100644 --- a/src/app/qt/utility/utilityQt.h +++ b/src/app/qt/utility/utilityQt.h @@ -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 diff --git a/src/app/qt/view/QtSearchView.cpp b/src/app/qt/view/QtSearchView.cpp index 51112048..1973f805 100644 --- a/src/app/qt/view/QtSearchView.cpp +++ b/src/app/qt/view/QtSearchView.cpp @@ -2,11 +2,12 @@ #include +#include "component/controller/SearchController.h" #include "qt/element/QtButton.h" #include "qt/element/QtEditBox.h" #include "qt/QtWidgetWrapper.h" #include "qt/utility/utilityQt.h" -#include "component/controller/SearchController.h" +#include "utility/text/TextAccess.h" QtSearchView::QtSearchView(ViewLayout* viewLayout) : SearchView(viewLayout) @@ -27,28 +28,30 @@ void QtSearchView::createWidgetWrapper() void QtSearchView::initGui() { 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); - layout->setSpacing(3); - layout->setContentsMargins(3, 3, 3, 3); + layout->setSpacing(0); + //layout->setContentsMargins(3, 3, 3, 3); 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->setPlaceholderText("Please enter your search string."); m_searchBox->setCallbackOnReturnPressed(std::bind(&QtSearchView::onSearchButtonClick, this)); - - std::vector 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)); - + m_searchBox->setObjectName("search_box"); 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) @@ -84,6 +87,8 @@ void QtSearchView::doSetAutocompletionList(const std::vector& autoc for (const std::string& s: autocompletionList) wordList << s.c_str(); QCompleter *completer = new QCompleter(wordList, m_searchBox); + completer->popup()->setObjectName("search_box_popup"); completer->setCaseSensitivity(Qt::CaseInsensitive); m_searchBox->setCompleter(completer); + completer->popup()->setStyleSheet(TextAccess::createFromFile("data/gui/search_view/search_view.css")->getText().c_str()); } diff --git a/src/app/qt/view/QtSearchView.h b/src/app/qt/view/QtSearchView.h index e14267fc..38b8a21a 100644 --- a/src/app/qt/view/QtSearchView.h +++ b/src/app/qt/view/QtSearchView.h @@ -31,6 +31,7 @@ private: QtEditBox* m_searchBox; QtButton* m_searchButton; + QtButton* m_caseSensitiveButton; QtThreadedFunctor m_setTextFunctor; QtThreadedFunctor&> m_setAutocompletionListFunctor; }; diff --git a/src/lib/utility/FileSystem.cpp b/src/lib/utility/FileSystem.cpp index 454991d4..f10ff449 100644 --- a/src/lib/utility/FileSystem.cpp +++ b/src/lib/utility/FileSystem.cpp @@ -25,6 +25,13 @@ std::vector FileSystem::getSourceFilesFromDirectory( return files; } +std::vector FileSystem::getFileNamesFromDirectory( + const std::string& path, const std::vector& extensions +) +{ + return getSourceFilesFromDirectory(path, extensions); +} + bool FileSystem::isValidExtension(const std::string& filepath, const std::vector& extensions) { boost::filesystem::path path(filepath); diff --git a/src/lib/utility/FileSystem.h b/src/lib/utility/FileSystem.h index 89b50d51..a96c6b0b 100644 --- a/src/lib/utility/FileSystem.h +++ b/src/lib/utility/FileSystem.h @@ -7,9 +7,14 @@ class FileSystem { public: - static std::vector getSourceFilesFromDirectory( + static std::vector getSourceFilesFromDirectory( // TODO: Replace this with getFileNamesFromDirectory. const std::string& path, const std::vector& extensions ); + + static std::vector getFileNamesFromDirectory( + const std::string& path, const std::vector& extensions + ); + static bool exists(const std::string& path); static std::string fileName(const std::string& path);