X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=tools%2FPyEditor%2Fsrc%2FPyEditor_FindTool.cxx;h=b749ef942dc7010828123b71fcc0dcbe216a2732;hb=b6e35aa42d3c67a529d7f9339718dfaed6891323;hp=de6be82e5bf5f4d76922c82d1c089bb6a11650c8;hpb=b975b2713ca3a0679420c1bb0041ee9bc69c5048;p=modules%2Fgui.git diff --git a/tools/PyEditor/src/PyEditor_FindTool.cxx b/tools/PyEditor/src/PyEditor_FindTool.cxx index de6be82e5..b749ef942 100644 --- a/tools/PyEditor/src/PyEditor_FindTool.cxx +++ b/tools/PyEditor/src/PyEditor_FindTool.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 OPEN CASCADE +// Copyright (C) 2015-2024 OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -110,10 +110,10 @@ PyEditor_FindTool::PyEditor_FindTool( PyEditor_Editor* editor, QWidget* parent ) addAction( new QAction( tr( "CASE_SENSITIVE_CHECK" ), this ) ); addAction( new QAction( tr( "WHOLE_WORDS_CHECK" ), this ) ); addAction( new QAction( tr( "REGEX_CHECK" ), this ) ); - addAction( new QAction( tr( "Find" ), this ) ); + addAction( new QAction( QIcon( ":/images/py_find.png" ), tr( "Find" ), this ) ); addAction( new QAction( tr( "FindPrevious" ), this ) ); addAction( new QAction( tr( "FindNext" ), this ) ); - addAction( new QAction( tr( "Replace" ), this ) ); + addAction( new QAction( QIcon( ":/images/py_replace.png" ), tr( "Replace" ), this ) ); foreach ( QAction* action, actions().mid( CaseSensitive, RegExp+1 ) ) { @@ -135,6 +135,7 @@ PyEditor_FindTool::PyEditor_FindTool( PyEditor_Editor* editor, QWidget* parent ) } myEditor->installEventFilter( this ); + connect( myEditor, SIGNAL( customizeMenu( QMenu* ) ), this, SLOT( customizeMenu( QMenu* ) ) ); hide(); } @@ -157,7 +158,7 @@ bool PyEditor_FindTool::event( QEvent* e ) { case Qt::Key_Escape: hide(); - break; + return true; default: break; } @@ -221,7 +222,10 @@ bool PyEditor_FindTool::eventFilter( QObject* o, QEvent* e ) { case Qt::Key_Escape: if ( isVisible() ) + { hide(); + return true; + } break; default: break; @@ -239,6 +243,16 @@ void PyEditor_FindTool::activateFind() activate( Find ); } +/*! + \brief Customize menu for editor. +*/ +void PyEditor_FindTool::customizeMenu( QMenu* menu ) +{ + menu->addSeparator(); + menu->addAction( actions()[Find] ); + menu->addAction( actions()[Replace] ); +} + /*! \brief Slot: activate 'Replace' dialog. */ @@ -406,8 +420,8 @@ QList PyEditor_FindTool::shortcuts( int action ) const bindings << QKeySequence( QKeySequence::FindNext ); break; case Replace: - bindings << QKeySequence( QKeySequence::Replace ); bindings << QKeySequence( "Ctrl+H" ); + bindings << QKeySequence( QKeySequence::Replace ); break; default: break; @@ -604,7 +618,7 @@ void PyEditor_FindTool::addCompletion( const QString& text, bool replace ) QStringListModel& model = replace ? myReplaceCompletion : myFindCompletion; QStringList completions = model.stringList(); - if ( !text.isEmpty() and !completions.contains( text ) ) + if ( !text.isEmpty() && !completions.contains( text ) ) { completions.prepend( text ); model.setStringList( completions );