diff --git a/include/eepp/ui/abstract/uiabstracttableview.hpp b/include/eepp/ui/abstract/uiabstracttableview.hpp index 24976124e..899fe016d 100644 --- a/include/eepp/ui/abstract/uiabstracttableview.hpp +++ b/include/eepp/ui/abstract/uiabstracttableview.hpp @@ -113,6 +113,9 @@ class EE_API UIAbstractTableView : public UIAbstractView { void setFitAllColumnsToWidget( bool fitAllColumnsToWidget ); void recalculateColumnsWidth(); + + UITableCell* getCellFromIndex( const ModelIndex& index ) const; + protected: friend class EE::UI::UITableHeaderColumn; diff --git a/src/eepp/ui/abstract/uiabstracttableview.cpp b/src/eepp/ui/abstract/uiabstracttableview.cpp index adcd3fd80..ebb2a6308 100644 --- a/src/eepp/ui/abstract/uiabstracttableview.cpp +++ b/src/eepp/ui/abstract/uiabstracttableview.cpp @@ -830,4 +830,16 @@ void UIAbstractTableView::recalculateColumnsWidth() { createOrUpdateColumns( false ); } +UITableCell* UIAbstractTableView::getCellFromIndex( const ModelIndex& index ) const { + for ( const auto& row : mWidgets ) { + for ( const auto& widget : row ) { + if ( widget.second->isType( UI_TYPE_TABLECELL ) && + widget.second->asType()->getCurIndex() == index ) { + return widget.second->asType(); + } + } + } + return nullptr; +} + }}} // namespace EE::UI::Abstract diff --git a/src/eepp/ui/uitableview.cpp b/src/eepp/ui/uitableview.cpp index e8b9c62bd..663839fae 100644 --- a/src/eepp/ui/uitableview.cpp +++ b/src/eepp/ui/uitableview.cpp @@ -271,7 +271,8 @@ Uint32 UITableView::onKeyDown( const KeyEvent& event ) { onOpenModelIndex( curIndex, &event ); return 1; } - case KEY_MENU: { + case KEY_MENU: + case KEY_APPLICATION: { if ( curIndex.isValid() ) onOpenMenuModelIndex( curIndex, &event ); return 1; diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index eddb62beb..771f3ea5f 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -701,7 +701,8 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { } return 1; } - case KEY_MENU: { + case KEY_MENU: + case KEY_APPLICATION: { if ( curIndex.isValid() ) onOpenMenuModelIndex( curIndex, &event ); return 1; diff --git a/src/tools/ecode/statusbuildoutputcontroller.cpp b/src/tools/ecode/statusbuildoutputcontroller.cpp index 254e6d7a8..7b7ece4e9 100644 --- a/src/tools/ecode/statusbuildoutputcontroller.cpp +++ b/src/tools/ecode/statusbuildoutputcontroller.cpp @@ -491,29 +491,66 @@ void StatusBuildOutputController::createContainer() { mTableIssues->on( Event::OnModelEvent, [this]( const Event* event ) { auto modelEvent = static_cast( event ); auto idx = modelEvent->getModelIndex(); - if ( modelEvent->getModel() && modelEvent->getModelEventType() == ModelEventType::Open && - idx.isValid() ) { + if ( modelEvent->getModel() && idx.isValid() ) { auto model = modelEvent->getModel(); - Variant vPath( model->data( idx, ModelRole::Custom ) ); - if ( vPath.isValid() && vPath.is( Variant::Type::cstr ) ) { - std::string path( vPath.asCStr() ); - UITab* tab = mSplitter->isDocumentOpen( path ); - Variant lineNum( model->data( model->index( modelEvent->getModelIndex().row(), 1 ), - ModelRole::Custom ) ); - Variant colNum( model->data( model->index( modelEvent->getModelIndex().row(), 2 ), - ModelRole::Custom ) ); - if ( !tab ) { - FileInfo fileInfo( path ); - if ( fileInfo.exists() && fileInfo.isRegularFile() ) - mApp->loadFileFromPath( - path, true, nullptr, - [&, lineNum, colNum]( UICodeEditor*, const std::string& ) { - onLoadDone( lineNum, colNum ); - } ); - } else { - tab->getTabWidget()->setTabSelected( tab ); - onLoadDone( lineNum, colNum ); + if ( modelEvent->getModelEventType() == ModelEventType::Open ) { + Variant vPath( model->data( idx, ModelRole::Custom ) ); + if ( vPath.isValid() && vPath.is( Variant::Type::cstr ) ) { + std::string path( vPath.asCStr() ); + UITab* tab = mSplitter->isDocumentOpen( path ); + Variant lineNum( model->data( + model->index( modelEvent->getModelIndex().row(), 1 ), ModelRole::Custom ) ); + Variant colNum( model->data( + model->index( modelEvent->getModelIndex().row(), 2 ), ModelRole::Custom ) ); + if ( !tab ) { + FileInfo fileInfo( path ); + if ( fileInfo.exists() && fileInfo.isRegularFile() ) + mApp->loadFileFromPath( + path, true, nullptr, + [&, lineNum, colNum]( UICodeEditor*, const std::string& ) { + onLoadDone( lineNum, colNum ); + } ); + } else { + tab->getTabWidget()->setTabSelected( tab ); + onLoadDone( lineNum, colNum ); + } } + } else if ( modelEvent->getModelEventType() == ModelEventType::OpenMenu ) { + UIPopUpMenu* menu = UIPopUpMenu::New(); + menu->add( mApp->i18n( "copy_error_message", "Copy Error Message" ), + mApp->findIcon( "copy" ) ) + ->setId( "copy-error-message" ); + menu->add( mApp->i18n( "copy_file_path", "Copy File Path" ), + mApp->findIcon( "copy" ) ) + ->setId( "copy-file-path" ); + menu->on( + Event::OnItemClicked, [this, model, modelEvent, idx]( const Event* event ) { + UIMenuItem* item = event->getNode()->asType(); + std::string id( item->getId() ); + if ( id == "copy-error-message" ) { + Variant msg( + model->data( model->index( modelEvent->getModelIndex().row(), 0 ), + ModelRole::Display ) ); + mApp->getWindow()->getClipboard()->setText( msg.toString() ); + } else if ( id == "copy-file-path" ) { + Variant msg( model->data( idx, ModelRole::Custom ) ); + mApp->getWindow()->getClipboard()->setText( msg.toString() ); + } + } ); + UITableCell* cell = mTableIssues->getCellFromIndex( idx ); + if ( modelEvent->getTriggerEvent()->getType() == Event::MouseClick || + cell == nullptr ) { + Vector2f pos( mApp->getWindow()->getInput()->getMousePosf() ); + menu->nodeToWorldTranslation( pos ); + UIMenu::findBestMenuPos( pos, menu ); + menu->setPixelsPosition( pos ); + } else { + Vector2f pos( 0, cell->getPixelsSize().getHeight() ); + cell->nodeToWorldTranslation( pos ); + UIMenu::findBestMenuPos( pos, menu ); + menu->setPixelsPosition( pos ); + } + menu->show(); } } } );