+ // Create central widget.
+ myEditor = new PyEditor_Widget( this );
+ setCentralWidget( myEditor );
+
+ // Create actions.
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ QtxAction* action;
+
+ // . New
+ action = new QtxAction( tr( "TTP_NEW" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_NEW" ) ),
+ tr( "ACT_NEW" ), 0, this );
+ action->setStatusTip( tr( "DSC_NEW" ) );
+ action->setShortcut( QKeySequence::New );
+ connect( action, SIGNAL( triggered( bool ) ), this, SLOT( onNew() ) );
+ toolMgr()->registerAction( action, NewId );
+
+ // . Open
+ action = new QtxAction( tr( "TTP_OPEN" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_OPEN" ) ),
+ tr( "ACT_OPEN" ), 0, this );
+ action->setStatusTip( tr( "DSC_OPEN" ) );
+ action->setShortcut( QKeySequence::Open );
+ connect( action, SIGNAL( triggered( bool ) ), this, SLOT( onOpen() ) );
+ toolMgr()->registerAction( action, OpenId );
+
+ // . Save
+ action = new QtxAction( tr( "TTP_SAVE" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_SAVE" ) ),
+ tr( "ACT_SAVE" ), 0, this );
+ action->setStatusTip( tr( "DSC_SAVE" ) );
+ action->setShortcut( QKeySequence::Save );
+ connect( action, SIGNAL( triggered( bool ) ), this, SLOT( onSave() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( modificationChanged( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, SaveId );
+
+ // . SaveAs
+ action = new QtxAction( tr( "TTP_SAVEAS" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_SAVEAS" ) ),
+ tr( "ACT_SAVEAS" ), 0, this );
+ action->setStatusTip( tr( "DSC_SAVEAS" ) );
+ action->setShortcut( QKeySequence::SaveAs );
+ connect( action, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAs() ) );
+ toolMgr()->registerAction( action, SaveAsId );
+
+ // . Undo
+ action = new QtxAction( tr( "TTP_UNDO" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_UNDO" ) ),
+ tr( "ACT_UNDO" ), 0, this );
+ action->setStatusTip( tr( "DSC_UNDO" ) );
+ action->setShortcut( QKeySequence::Undo );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( undo() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( undoAvailable( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, UndoId );
+
+ // . Redo
+ action = new QtxAction( tr( "TTP_REDO" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_REDO" ) ),
+ tr( "ACT_REDO" ), 0, this );
+ action->setStatusTip( tr( "DSC_REDO" ) );
+ action->setShortcut( QKeySequence::Redo );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( redo() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( redoAvailable( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, RedoId );
+
+ // . Cut
+ action = new QtxAction( tr( "TTP_CUT" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_CUT" ) ),
+ tr( "ACT_CUT" ), 0, this );
+ action->setStatusTip( tr( "DSC_CUT" ) );
+ action->setShortcut( QKeySequence::Cut );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( cut() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( copyAvailable( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, CutId );
+
+ // . Copy
+ action = new QtxAction( tr( "TTP_COPY" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_COPY" ) ),
+ tr( "ACT_COPY" ), 0, this );
+ action->setStatusTip( tr( "DSC_COPY" ) );
+ action->setShortcut( QKeySequence::Copy );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( copy() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( copyAvailable( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, CopyId );
+
+ // . Paste
+ action = new QtxAction( tr( "TTP_PASTE" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_PASTE" ) ),
+ tr( "ACT_PASTE" ), 0, this );
+ action->setStatusTip( tr( "DSC_PASTE" ) );
+ action->setShortcut( QKeySequence::Paste );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( paste() ) );
+ toolMgr()->registerAction( action, PasteId );
+
+ // . Delete
+ action = new QtxAction( tr( "TTP_DELETE" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_DELETE" ) ),
+ tr( "ACT_DELETE" ), 0, this );
+ action->setStatusTip( tr( "DSC_DELETE" ) );
+ action->setShortcut( QKeySequence::Delete );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( deleteSelected() ) );
+ action->setEnabled( false );
+ connect( myEditor, SIGNAL( copyAvailable( bool ) ),
+ action, SLOT( setEnabled( bool ) ) );
+ toolMgr()->registerAction( action, DeleteId );
+
+ // . SelectAll
+ action = new QtxAction( tr( "TTP_SELECT_ALL" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_SELECT_ALL" ) ),
+ tr( "ACT_SELECT_ALL" ), 0, this );
+ action->setStatusTip( tr( "DSC_SELECT_ALL" ) );
+ action->setShortcut( QKeySequence::SelectAll );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( selectAll() ) );
+ toolMgr()->registerAction( action, SelectAllId );
+
+ // . Find
+ action = new QtxAction( tr( "TTP_FIND" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_FIND" ) ),
+ tr( "ACT_FIND" ), 0, this );
+ action->setStatusTip( tr( "DSC_FIND" ) );
+ action->setShortcut( QKeySequence::Find );
+ action->setShortcutContext( Qt::WidgetShortcut );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( find() ) );
+ toolMgr()->registerAction( action, FindId );
+
+ // . Replace
+ action = new QtxAction( tr( "TTP_REPLACE" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_REPLACE" ) ),
+ tr( "ACT_REPLACE" ), 0, this );
+ action->setStatusTip( tr( "DSC_REPLACE" ) );
+ action->setShortcuts( QList<QKeySequence>() << QKeySequence( "Ctrl+H" ) << QKeySequence( QKeySequence::Replace ) );
+ action->setShortcutContext( Qt::WidgetShortcut );
+ connect( action, SIGNAL( triggered( bool ) ), myEditor, SLOT( replace() ) );
+ toolMgr()->registerAction( action, ReplaceId );
+
+ // . Preferences
+ action = new QtxAction( tr( "TTP_PREFERENCES" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_PREFERENCES" ) ),
+ tr( "ACT_PREFERENCES" ), 0, this );
+ action->setStatusTip( tr( "DSC_PREFERENCES" ) );
+ connect( action, SIGNAL( triggered( bool ) ), this, SLOT( onPreferences() ) );
+ toolMgr()->registerAction( action, PreferencesId );
+
+ // . Help
+ action = new QtxAction( tr( "TTP_HELP" ),
+ resMgr->loadPixmap( "PyViewer", tr( "ICON_HELP" ) ),
+ tr( "ACT_HELP" ), 0, this );
+ action->setStatusTip( tr( "DSC_HELP" ) );
+ connect( action, SIGNAL( triggered() ), this, SLOT( onHelp() ) );
+ toolMgr()->registerAction( action, HelpId );
+
+ // Create toolbar.
+ int idTB = toolMgr()->createToolBar( tr("TOOLBAR_LABEL"), QString( "PythonEditor" ), false );
+ toolMgr()->append( NewId, idTB );
+ toolMgr()->append( OpenId, idTB );
+ toolMgr()->append( SaveId, idTB );
+ toolMgr()->append( SaveAsId, idTB );
+ toolMgr()->append( toolMgr()->separator(), idTB );
+ toolMgr()->append( UndoId, idTB );
+ toolMgr()->append( RedoId, idTB );
+ toolMgr()->append( toolMgr()->separator(), idTB );
+ toolMgr()->append( CutId, idTB );
+ toolMgr()->append( CopyId, idTB );
+ toolMgr()->append( PasteId, idTB );
+ toolMgr()->append( DeleteId, idTB );
+ toolMgr()->append( SelectAllId, idTB );
+ toolMgr()->append( toolMgr()->separator(), idTB );
+ toolMgr()->append( FindId, idTB );
+ toolMgr()->append( ReplaceId, idTB );
+ toolMgr()->append( toolMgr()->separator(), idTB );
+ toolMgr()->append( PreferencesId, idTB );
+ toolMgr()->append( toolMgr()->separator(), idTB );
+ toolMgr()->append( HelpId, idTB );
+
+ // Set current file.