QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
QString aFamily;
for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
+ {
+ aFamily = *it;
+ if ( famdb.contains(aFamily) )
{
- aFamily = *it;
- if ( famdb.contains(aFamily) )
- {
- f.setFamily( aFamily );
- aResMgr->setValue( "PyConsole", "font", f );
- break;
- }
+ f.setFamily( aFamily );
+ aResMgr->setValue( "PyConsole", "font", f );
+ break;
}
+ }
}
/*!Destructor.
dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
dock->setObjectName( QString( "window_%1" ).arg( id ) );
dock->setWidget( wid );
+
+ QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
+ if ( !accel.isEmpty() )
+ dock->toggleViewAction()->setShortcut( accel );
+
dock->show();
}
void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
{
QDockWidget* dock = windowDock( dockWindow( id ) );
- if ( dock && desktop() )
+ if ( dock && desktop() ) {
desktop()->addDockWidget( place, dock );
+ QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
+ if ( a ) a->update();
+ }
}
/*!
ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
-
+ ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
wid = ob;
-
ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyCons = new PyConsole_Console( desktop(),new LightApp_PyInterp());
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
+ pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
+ pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
+
wid = pyCons;
pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
{
LogWindow* logWin = new LogWindow( desktop() );
logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
+ logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
wid = logWin;
logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
+ pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
}
#ifndef DISABLE_PYCONSOLE
- if( sec=="PyConsole" )
+ if( sec=="PyConsole" && pythonConsole() )
{
- if( param=="font" )
- if( pythonConsole() )
- pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
+ if ( param=="font" ) {
+ pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
+ }
+ else if ( param=="show_banner" ) {
+ pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
+ }
}
#endif
</section>
<section name="PyConsole">
<!-- Python console preferences -->
+ <parameter name="show_banner" value="true" />
<parameter name="font" value="Helvetic,12" />
<parameter name="additional_families" value="Helvetic;Helvetica;Helvetica[Adobe];Times;Times[Adobe];Sans Serif;Serif;Monospace;Lucida"/>
</section>
<source>PREF_GROUP_PY_CONSOLE</source>
<translation>Python console properties</translation>
</message>
+ <message>
+ <source>PREF_SHOW_BANNER</source>
+ <translation>Show banner</translation>
+ </message>
<message>
<source>PREF_GROUP_STYLE</source>
<translation>Salome style</translation>
myEditor->setIsSuppressOutput(on);
}
+/*!
+ \brief Get 'show banner' flag value.
+
+ \sa setIsShowBanner()
+ \return \c true if python console shows banner
+*/
+bool PyConsole_Console::isShowBanner() const
+{
+ return myEditor->isShowBanner();
+}
+
+/*!
+ \brief Set 'show banner' flag value.
+
+ The banner is shown in the top of the python console window.
+
+ \sa isShowBanner()
+ \param on 'show banner' flag
+*/
+void PyConsole_Console::setIsShowBanner( const bool on )
+{
+ myEditor->setIsShowBanner( on );
+}
+
/*!
\brief Change the python console's font.
\param f new font
bool isSuppressOutput() const;
void setIsSuppressOutput( const bool );
+ bool isShowBanner() const;
+ void setIsShowBanner( const bool );
void exec( const QString& );
void execAndWait( const QString& );
void staticCallback( void* data, char* c )
{
- if(!((PyConsole_Editor*)data)->isSuppressOutput())
- QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c ) );
+ if(!((PyConsole_Editor*)data)->isSuppressOutput())
+ QApplication::postEvent( (PyConsole_Editor*)data, new PrintEvent( c ) );
}
/*!
myInterp( 0 ),
myCmdInHistory( -1 ),
myEventLoop( 0 ),
+ myShowBanner( true ),
myIsSync( false ),
- myIsSuppressOutput(false)
+ myIsSuppressOutput( false )
{
QString fntSet( "" );
QFont aFont = SUIT_Tools::stringToFont( fntSet );
\brief Get suppress output flag value.
\sa setIsSuppressOutput()
- \return True if python console output is suppressed.
+ \return \c true if python console output is suppressed.
*/
bool PyConsole_Editor::isSuppressOutput() const
{
myIsSuppressOutput = on;
}
+/*!
+ \brief Get 'show banner' flag value.
+
+ \sa setIsShowBanner()
+ \return \c true if python console shows banner
+*/
+bool PyConsole_Editor::isShowBanner() const
+{
+ return myShowBanner;
+}
+
+/*!
+ \brief Set 'show banner' flag value.
+
+ The banner is shown in the top of the python console window.
+
+ \sa isShowBanner()
+ \param on 'show banner' flag
+*/
+void PyConsole_Editor::setIsShowBanner( const bool on )
+{
+ if ( myShowBanner != on ) {
+ myShowBanner = on;
+ clear();
+ }
+}
+
+/*!
+ \brief Get size hint for the Python console window
+ \return size hint value
+*/
+QSize PyConsole_Editor::sizeHint() const
+{
+ QFontMetrics fm( font() );
+ int nbLines = ( isShowBanner() ? myBanner.split("\n").count() : 0 ) + 1;
+ QSize s(100, fm.lineSpacing()*nbLines);
+ return s;
+}
+
/*!
\brief Put the string \a str to the python editor.
\param str string to be put in the command line of the editor
if ( myInterp ) {
// print banner
myBanner = myInterp->getbanner().c_str();
- addText( myBanner );
+ if ( isShowBanner() )
+ addText( myBanner );
// clear command buffer
myCommandBuffer.truncate(0);
// unset read-only state
void PyConsole_Editor::clear()
{
QTextEdit::clear();
- addText( myBanner );
+ if ( isShowBanner() )
+ addText( myBanner );
myPrompt = READY_PROMPT;
addText( myPrompt );
}
bool isSuppressOutput() const;
void setIsSuppressOutput(const bool);
+ bool isShowBanner() const;
+ void setIsShowBanner( const bool );
+
+ virtual QSize sizeHint() const;
+
protected:
virtual void dropEvent( QDropEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event );
QStringList myHistory; //!< commands history buffer
QEventLoop* myEventLoop; //!< internal event loop
QString myBanner; //!< current banner
+ bool myShowBanner; //!< 'show banner' flag
QStringList myQueue; //!< python commands queue
bool myIsSync; //!< synchronous mode flag
bool myIsSuppressOutput; //!< suppress output flag
}
}
+/*!
+ \brief Update associated menu
+*/
+void QtxDockAction::update()
+{
+ updateMenu();
+}
+
/*!
\brief Get parent main window.
\return main window pointer.
QtxDockAction( const QString&, const QIcon&, const QString&, QMainWindow* );
virtual ~QtxDockAction();
+ void update();
+
int dockType() const;
void setDockType( const int );
ob->setAutoSizeFirstColumn(autoSizeFirst);
ob->setAutoSizeColumns(autoSize);
ob->setResizeOnExpandItem(resizeOnExpandItem);
+ ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
// temporary commented
/*
PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new SalomeApp_PyInterp() );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
+ pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
+ pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
wid = pyCons;
- pyCons->resize( pyCons->width(), desktop()->height()/4 );
+ //pyCons->resize( pyCons->width(), desktop()->height()/4 );
pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
return wid;
</section>
<section name="PyConsole">
<!-- Python console preferences -->
+ <parameter name="show_banner" value="true" />
<parameter name="font" value="Helvetic,12" />
<parameter name="additional_families" value="Helvetic;Helvetica;Helvetica[Adobe];Times;Times[Adobe];Sans Serif;Serif;Monospace;Lucida"/>
</section>