diff --git a/bin/app/data/gui/code_view/code_view.css b/bin/app/data/gui/code_view/code_view.css index c9e978cc..199f07f4 100644 --- a/bin/app/data/gui/code_view/code_view.css +++ b/bin/app/data/gui/code_view/code_view.css @@ -6,6 +6,14 @@ padding: 4px 12px; } +#code_file #title_label:hover { + background: #D2D2D2; +} + +#code_file #title_label:disabled { + color: black; +} + #code_snippet { font-family: "Source Code Pro"; font-size: 14px; @@ -29,3 +37,9 @@ #code_snippet #maximize_button:enabled { border-image: url(data/gui/code_view/images/button_maximize.png); } + +QToolTip { + background-color: rgb(204, 204, 204); + border: 1px solid rgb(0, 0, 0); + color: rgb(0, 0, 0); +} diff --git a/src/app/qt/element/QtCodeFile.cpp b/src/app/qt/element/QtCodeFile.cpp index 9193dd73..76d7930a 100644 --- a/src/app/qt/element/QtCodeFile.cpp +++ b/src/app/qt/element/QtCodeFile.cpp @@ -1,13 +1,14 @@ #include "qt/element/QtCodeFile.h" -#include +#include #include +#include "utility/messaging/type/MessageShowFile.h" + #include "qt/element/QtCodeFileList.h" #include "qt/element/QtCodeSnippet.h" -#include "utility/file/FileSystem.h" -QtCodeFile::QtCodeFile(const std::string& filePath, QtCodeFileList* parent) +QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent) : QWidget(parent) , m_parent(parent) , m_filePath(filePath) @@ -20,26 +21,32 @@ QtCodeFile::QtCodeFile(const std::string& filePath, QtCodeFileList* parent) layout->setAlignment(Qt::AlignTop); setLayout(layout); - QLabel* label = new QLabel(FileSystem::fileName(filePath).c_str(), this); - label->setObjectName("title_label"); - label->minimumSizeHint(); // force font loading - label->setFixedWidth(label->fontMetrics().width(FileSystem::fileName(filePath).c_str()) + 32); - label->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); - layout->addWidget(label); + m_title = new QPushButton(filePath.fileName().c_str(), this); + m_title->setObjectName("title_label"); + m_title->minimumSizeHint(); // force font loading + m_title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + m_title->setToolTip(QString::fromStdString(filePath.str())); + m_title->setFixedWidth(m_title->fontMetrics().width(filePath.fileName().c_str()) + 32); + m_title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); + layout->addWidget(m_title); + + connect(m_title, SIGNAL(clicked()), this, SLOT(clickedTitle())); + + update(); } QtCodeFile::~QtCodeFile() { } -const std::string& QtCodeFile::getFilePath() const +const FilePath& QtCodeFile::getFilePath() const { return m_filePath; } std::string QtCodeFile::getFileName() const { - return FileSystem::fileName(m_filePath); + return m_filePath.fileName(); } const std::vector& QtCodeFile::getActiveTokenIds() const @@ -86,4 +93,11 @@ void QtCodeFile::update() { snippet->update(); } + + m_title->setEnabled(m_parent->getShowMaximizeButton()); +} + +void QtCodeFile::clickedTitle() +{ + MessageShowFile(m_filePath.absoluteStr(), 0, 0).dispatch(); } diff --git a/src/app/qt/element/QtCodeFile.h b/src/app/qt/element/QtCodeFile.h index 6efe1e22..95e4b3f2 100644 --- a/src/app/qt/element/QtCodeFile.h +++ b/src/app/qt/element/QtCodeFile.h @@ -7,19 +7,24 @@ #include +#include "utility/file/FilePath.h" #include "utility/types.h" +class QPushButton; class QtCodeFileList; class QtCodeSnippet; class TokenLocationFile; -class QtCodeFile : public QWidget +class QtCodeFile + : public QWidget { + Q_OBJECT + public: - QtCodeFile(const std::string& filePath, QtCodeFileList* parent); + QtCodeFile(const FilePath& filePath, QtCodeFileList* parent); virtual ~QtCodeFile(); - const std::string& getFilePath() const; + const FilePath& getFilePath() const; std::string getFileName() const; const std::vector& getActiveTokenIds() const; const std::vector& getErrorMessages() const; @@ -32,11 +37,16 @@ public: void update(); +private slots: + void clickedTitle(); + private: QtCodeFileList* m_parent; + QPushButton* m_title; + std::vector> m_snippets; - const std::string m_filePath; + const FilePath m_filePath; }; #endif // QT_CODE_FILE_H diff --git a/src/app/qt/element/QtCodeFileList.cpp b/src/app/qt/element/QtCodeFileList.cpp index 415b9a1b..bd3825b9 100644 --- a/src/app/qt/element/QtCodeFileList.cpp +++ b/src/app/qt/element/QtCodeFileList.cpp @@ -39,12 +39,12 @@ void QtCodeFileList::addCodeSnippet( const std::string& code, const TokenLocationFile& locationFile ){ - std::string fileName = locationFile.getFilePath().fileName(); + FilePath filePath = locationFile.getFilePath(); QtCodeFile* file = nullptr; for (std::shared_ptr filePtr : m_files) { - if (filePtr->getFileName() == fileName) + if (filePtr->getFilePath() == filePath) { file = filePtr.get(); break; @@ -53,7 +53,7 @@ void QtCodeFileList::addCodeSnippet( if (!file) { - std::shared_ptr filePtr = std::make_shared(locationFile.getFilePath().absoluteStr(), this); + std::shared_ptr filePtr = std::make_shared(locationFile.getFilePath(), this); m_files.push_back(filePtr); file = filePtr.get(); diff --git a/src/app/qt/element/QtCodeSnippet.cpp b/src/app/qt/element/QtCodeSnippet.cpp index 100fae08..86f8088d 100644 --- a/src/app/qt/element/QtCodeSnippet.cpp +++ b/src/app/qt/element/QtCodeSnippet.cpp @@ -272,7 +272,7 @@ void QtCodeSnippet::updateLineNumberArea(const QRect &rect, int dy) void QtCodeSnippet::clickedMaximizeButton() { - MessageShowFile(m_parent->getFilePath(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch(); + MessageShowFile(m_parent->getFilePath().absoluteStr(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch(); } void QtCodeSnippet::clearSelection() diff --git a/src/app/qt/element/QtSearchBar.cpp b/src/app/qt/element/QtSearchBar.cpp index 1006ea06..9be2f111 100644 --- a/src/app/qt/element/QtSearchBar.cpp +++ b/src/app/qt/element/QtSearchBar.cpp @@ -36,6 +36,7 @@ QtSearchBar::QtSearchBar() m_searchButton = new QPushButton(this); m_searchButton->setObjectName("search_button"); + m_searchButton->setToolTip("search"); m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_searchButton->setIcon(QIcon("data/gui/search_view/images/search.png")); layout->addWidget(m_searchButton); diff --git a/src/app/qt/element/QtStatusBar.cpp b/src/app/qt/element/QtStatusBar.cpp index 48067d93..309da332 100644 --- a/src/app/qt/element/QtStatusBar.cpp +++ b/src/app/qt/element/QtStatusBar.cpp @@ -29,7 +29,7 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader { if (isError) { - m_text.setStyleSheet("QLabel { color: red }"); + m_text.setStyleSheet("QLabel { color: #E00000 }"); } else { diff --git a/src/app/qt/element/QtUndoRedo.cpp b/src/app/qt/element/QtUndoRedo.cpp index 6e6b3700..ee1259f7 100644 --- a/src/app/qt/element/QtUndoRedo.cpp +++ b/src/app/qt/element/QtUndoRedo.cpp @@ -13,12 +13,14 @@ QtUndoRedo::QtUndoRedo() m_undoButton = new QPushButton(this); m_undoButton->setObjectName("undo_button"); + m_undoButton->setToolTip("undo"); m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_undoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_left.png")); m_undoButton->setEnabled(false); m_redoButton = new QPushButton(this); m_redoButton->setObjectName("redo_button"); + m_redoButton->setToolTip("redo"); m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac m_redoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_right.png")); m_redoButton->setEnabled(false); diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 99badb5a..4655afbc 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -33,6 +33,7 @@ std::shared_ptr Application::create(ViewFactory* viewFactory) } else { + MessageStatus("StartupProject was not defined in the ApplicationSettings", true).dispatch(); LOG_WARNING("No StartupProject defined in ApplicationSettings"); }