diff --git a/bin/app/data/gui/code_view/images/edit.png b/bin/app/data/gui/code_view/images/edit.png new file mode 100644 index 00000000..e4a2562b Binary files /dev/null and b/bin/app/data/gui/code_view/images/edit.png differ diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2c2d0afb..14662659 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -243,6 +243,7 @@ add_files( utility/messaging/type/MessageInterruptTasks.h utility/messaging/type/MessageLoadProject.h utility/messaging/type/MessageMoveIDECursor.h + utility/messaging/type/MessageProjectEdit.h utility/messaging/type/MessageProjectNew.h utility/messaging/type/MessageRedo.h utility/messaging/type/MessageRefresh.h diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index f88947fa..8e740b3e 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -42,13 +42,12 @@ void CodeController::handleMessage(MessageActivateAll* message) statsSnippet.locationFile = std::make_shared(FilePath()); statsSnippet.locationFile->isWholeCopy = true; + statsSnippet.title = ProjectSettings::getInstance()->getFilePath().withoutExtension().fileName(); + std::vector description = getProjectDescription(statsSnippet.locationFile.get()); std::stringstream ss; - ss << "\n"; - ss << "\tProject: " + ProjectSettings::getInstance()->getFilePath().withoutExtension().fileName() + "\n"; - if (description.size()) { ss << "\n"; diff --git a/src/lib/utility/messaging/type/MessageProjectEdit.h b/src/lib/utility/messaging/type/MessageProjectEdit.h new file mode 100644 index 00000000..580da57c --- /dev/null +++ b/src/lib/utility/messaging/type/MessageProjectEdit.h @@ -0,0 +1,20 @@ +#ifndef MESSAGE_PROJECT_EDIT_H +#define MESSAGE_PROJECT_EDIT_H + +#include "utility/messaging/Message.h" + +class MessageProjectEdit + : public Message +{ +public: + MessageProjectEdit() + { + } + + static const std::string getStaticType() + { + return "MessageProjectEdit"; + } +}; + +#endif // MESSAGE_PROJECT_EDIT_H diff --git a/src/lib_gui/qt/element/QtCodeFile.cpp b/src/lib_gui/qt/element/QtCodeFile.cpp index edcf265e..3d2ca581 100644 --- a/src/lib_gui/qt/element/QtCodeFile.cpp +++ b/src/lib_gui/qt/element/QtCodeFile.cpp @@ -9,6 +9,7 @@ #include "utility/logging/logging.h" #include "utility/messaging/type/MessageActivateFile.h" #include "utility/messaging/type/MessageChangeFileView.h" +#include "utility/messaging/type/MessageProjectEdit.h" #include "data/location/TokenLocation.h" #include "data/location/TokenLocationFile.h" @@ -157,6 +158,31 @@ void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params) if (params.reduced) { m_title->hide(); + + QPushButton* title = new QPushButton(params.title.c_str(), this); + title->setObjectName("title_label"); + title->minimumSizeHint(); // force font loading + title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac + title->setFixedHeight(std::max(title->fontMetrics().height() * 1.2, 28.0)); + title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); + + if (isTrial()) + { + title->setEnabled(false); + } + else + { + std::string text = ResourcePaths::getGuiPath() + "code_view/images/edit.png"; + + title->setIcon(utility::colorizePixmap( + QPixmap(text.c_str()), + ColorScheme::getInstance()->getColor("code/file/title/icon").c_str() + )); + + connect(title, SIGNAL(clicked()), this, SLOT(editProject())); + } + + dynamic_cast(m_titleBar->layout())->insertWidget(1, title); } m_snippetLayout->addWidget(snippet.get()); @@ -379,6 +405,11 @@ void QtCodeFile::clickedTitle() MessageActivateFile(m_filePath).dispatch(); } +void QtCodeFile::editProject() +{ + MessageProjectEdit().dispatch(); +} + void QtCodeFile::clickedMinimizeButton() const { MessageChangeFileView( diff --git a/src/lib_gui/qt/element/QtCodeFile.h b/src/lib_gui/qt/element/QtCodeFile.h index c90d950d..8915f868 100644 --- a/src/lib_gui/qt/element/QtCodeFile.h +++ b/src/lib_gui/qt/element/QtCodeFile.h @@ -73,6 +73,7 @@ public slots: private slots: void clickedTitleBar(); void clickedTitle(); + void editProject(); private: virtual void handleMessage(MessageWindowFocus* message); diff --git a/src/lib_gui/qt/element/QtCodeSnippet.cpp b/src/lib_gui/qt/element/QtCodeSnippet.cpp index e9f221a5..dc2f878c 100644 --- a/src/lib_gui/qt/element/QtCodeSnippet.cpp +++ b/src/lib_gui/qt/element/QtCodeSnippet.cpp @@ -74,7 +74,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeFile* file) layout->setAlignment(Qt::AlignTop); setLayout(layout); - if (m_titleString.size()) + if (m_titleString.size() && !params.reduced) { m_title = createScopeLine(layout); if (m_titleId == 0) // title is a file path diff --git a/src/lib_gui/qt/view/QtMainView.cpp b/src/lib_gui/qt/view/QtMainView.cpp index 69200a02..39c24088 100644 --- a/src/lib_gui/qt/view/QtMainView.cpp +++ b/src/lib_gui/qt/view/QtMainView.cpp @@ -10,7 +10,8 @@ #include "qt/window/QtMainWindow.h" QtMainView::QtMainView() - : m_createNewProjectFromSolutionFunctor(std::bind(&QtMainView::doCreateNewProjectFromSolution, this, std::placeholders::_1, std::placeholders::_2)) + : m_editProjectFunctor(std::bind(&QtMainView::doEditProject, this)) + , m_createNewProjectFromSolutionFunctor(std::bind(&QtMainView::doCreateNewProjectFromSolution, this, std::placeholders::_1, std::placeholders::_2)) , m_showStartScreenFunctor(std::bind(&QtMainView::doShowStartScreen, this)) , m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this)) , m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1)) @@ -124,6 +125,11 @@ void QtMainView::handleMessage(MessageForceEnterLicense* message) m_forceLicenseScreenFunctor(message->licenseExpired); } +void QtMainView::handleMessage(MessageProjectEdit* message) +{ + m_editProjectFunctor(); +} + void QtMainView::handleMessage(MessageProjectNew* message) { if (message->ideId.size() != 0 && message->solutionPath.size() != 0) @@ -137,6 +143,11 @@ void QtMainView::handleMessage(MessageShowStartScreen* message) m_showStartScreenFunctor(); } +void QtMainView::doEditProject() +{ + m_window->editProject(); +} + void QtMainView::doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath) { m_window->newProjectFromSolution(ideId, solutionPath); diff --git a/src/lib_gui/qt/view/QtMainView.h b/src/lib_gui/qt/view/QtMainView.h index 9fbd813a..f4019b63 100644 --- a/src/lib_gui/qt/view/QtMainView.h +++ b/src/lib_gui/qt/view/QtMainView.h @@ -11,6 +11,7 @@ #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageForceEnterLicense.h" +#include "utility/messaging/type/MessageProjectEdit.h" #include "utility/messaging/type/MessageProjectNew.h" #include "utility/messaging/type/MessageShowStartScreen.h" @@ -20,6 +21,7 @@ class View; class QtMainView : public MainView , public MessageListener + , public MessageListener , public MessageListener , public MessageListener { @@ -50,9 +52,11 @@ public: private: void handleMessage(MessageForceEnterLicense* message); + void handleMessage(MessageProjectEdit* message); void handleMessage(MessageProjectNew* message); void handleMessage(MessageShowStartScreen* message); + void doEditProject(); void doCreateNewProjectFromSolution(const std::string& ideId, const std::string& solutionPath); void doShowStartScreen(); void doHideStartScreen(); @@ -66,6 +70,7 @@ private: std::shared_ptr m_window; std::vector m_views; + QtThreadedFunctor<> m_editProjectFunctor; QtThreadedFunctor m_createNewProjectFromSolutionFunctor; QtThreadedFunctor<> m_showStartScreenFunctor; QtThreadedFunctor<> m_hideStartScreenFunctor;