-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#endif
#ifndef DISABLE_PYCONSOLE
- #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
- #include <PyConsole_Console.h>
+ #include "PyConsole_Interp.h"
+ #include "LightApp_PyEditor.h"
+ #include "PyConsole_Console.h"
#endif
#include "LightApp_Application.h"
#include <SUIT_ViewWindow.h>
#include <Qtx.h>
+#include <QtxFontEdit.h>
#include <QtxToolBar.h>
#include <QtxTreeView.h>
#include <QtxMRUAction.h>
//since the 'toolbar marker' is not unique, find index of first occurrence of the
//'toolbar marker' in the array and check that next string is name of the toolbar
-int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
- int aResult = -1,tmp = 0;
- int inputLen = input.length();
- QDataStream anInputData(&input, QIODevice::ReadOnly);
- while(tmp < inputLen) {
- tmp = input.indexOf(QToolBarMarker, tmp + 1);
- if(tmp < 0 )
+namespace
+{
+ int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
+ int aResult = -1,tmp = 0;
+ int inputLen = input.length();
+ QDataStream anInputData( &input, QIODevice::ReadOnly );
+ while ( tmp < inputLen ) {
+ tmp = input.indexOf( QToolBarMarker, tmp + 1 );
+ if ( tmp < 0 )
break;
- anInputData.device()->seek(tmp);
+ anInputData.device()->seek( tmp );
uchar mark;
- anInputData>>mark;
+ anInputData >> mark;
int lines;
anInputData >> lines;
- if(lines == 0 && anInputData.atEnd()){
+ if ( lines == 0 && anInputData.atEnd() ) {
//Case then array doesn't contain information about toolbars,
aResult = tmp;
break;
int cnt;
anInputData >> cnt;
QString str;
- anInputData>>str;
- if(aFlags.contains(str)) {
+ anInputData >> str;
+ if ( aFlags.contains( str ) ) {
aResult = tmp;
break;
}
}
- return aResult;
+ return aResult;
+ }
+
+ QString langToName( const QString& lang )
+ {
+ // special processing for English language to avoid such result as "American English"
+ // as Qt cannot just say "English"
+ QString result;
+ if ( lang == "en" )
+ result = "English";
+ else
+ result = QLocale( lang ).nativeLanguageName();
+ return result;
+ }
}
/*!
*/
LightApp_Application::~LightApp_Application()
{
+ savePreferences();
delete mySelMgr;
delete myScreenHelper;
}
/*!Closeapplication.*/
void LightApp_Application::closeApplication()
{
+#ifndef DISABLE_QTXWEBBROWSER
QProcess::startDetached( "HelpBrowser",
QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
-
+#endif
CAM_Application::closeApplication();
}
*/
void LightApp_Application::onSelection()
{
+ //MESSAGE("onSelection")
onSelectionChanged();
if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
anApp.append( quote );
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
-
+#endif
+
if( useExtBrowser ) {
if ( !anApp.isEmpty() ) {
RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
anApp.append( quote );
#endif
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+#endif
if(useExtBrowser) {
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
{
SUIT_ViewManager* aVM = viewManager( vmType );
SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
-
+ MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
if ( anActiveVM && anActiveVM->getType() == vmType )
- aVM = anActiveVM;
+ {
+ MESSAGE("aVM = anActiveVM");
+ aVM = anActiveVM;
+ }
if ( aVM && create )
{
if ( !aVM->getActiveView() )
- aVM->createView();
+ {
+ MESSAGE("aVM->createView()");
+ aVM->createView();
+ }
else
- desktop()->setActiveWindow( aVM->getActiveView() );
+ {
+ MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
+ desktop()->setActiveWindow( aVM->getActiveView() );
+ }
}
else if ( create )
- aVM = createViewManager( vmType );
+ {
+ MESSAGE("aVM = createViewManager( vmType )");
+ aVM = createViewManager( vmType );
+ }
return aVM;
}
}
/*!Gets file filter.
- *\retval QString "(*.bin)"
+ *\retval QString "(*.hdf)"
*/
-QString LightApp_Application::getFileFilter() const
+QString LightApp_Application::getFileFilter( bool /*open*/) const
{
- //return "(*.bin)";
- // HDF persistence
return "(*.hdf)";
}
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
- PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
+ PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
pyCons->setObjectName( "pythonConsole" );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
- pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
- pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
+ pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
+ pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
+ pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
-
wid = pyCons;
- pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
#endif
else if ( flag == WT_LogWindow )
LightApp_Preferences::Selector, "language", "language" );
QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
QList<QVariant> aIcons;
+ QList<QVariant> aNumbers;
+ QStringList aTitles;
foreach ( QString aLang, aLangs ) {
aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
+ aNumbers << aLang;
+ aTitles << langToName( aLang );
}
- pref->setItemProperty( "strings", aLangs, curLang );
+ pref->setItemProperty( "strings", aTitles, curLang );
+ pref->setItemProperty( "ids", aNumbers, curLang );
pref->setItemProperty( "icons", aIcons, curLang );
pref->setItemProperty( "restart", true, curLang );
// .... -> ascii save mode
pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
// .... -> store windows geometry
+ pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
// ... "Study properties" group <<end>>
// ... "Help browser" group <<start>>
+#ifndef DISABLE_QTXWEBBROWSER
int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
+#else
+ int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
+#endif
+
#ifdef WIN32
QString platform = "winapplication";
#else
// ... "Python console properties" group <<start>>
int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
+ pref->setItemProperty( "columns", 2, pythonConsoleGroup );
// .... -> font
pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
// .... -> show banner
pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
+ // .... -> auto-completion
+ pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
// ... "Python console properties" group <<end>>
// ... "MRU" preferences group <<start>>
int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
// ... "Font settings" group <<start>>
int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
- pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
- LightApp_Preferences::Font, "PyEditor", "Font" );
+ int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
+ LightApp_Preferences::Font, "PyEditor", "Font" );
+ pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
// ... "Font settings" group <<end>>
// ... "Display settings" group <<start>>
int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
else if ( param=="show_banner" ) {
pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
}
+ else if ( param=="auto_completion" ) {
+ pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
+ }
}
#endif
}
}
#endif
-
-#ifndef DISABLE_PYVIEWER
- if ( sec == QString( "PyViewer" ) && ( param == QString( "HighlightCurrentLine" ) ||
- param == QString( "LineNumberArea" ) ||
- param == QString( "TextWrapping" ) ||
- param == QString( "CenterCursorOnScroll" ) ||
- param == QString( "TabSpaceVisible" ) ||
- param == QString( "TabSize" ) ||
- param == QString( "VerticalEdge" ) ||
- param == QString( "NumberColumns" ) ||
- param == QString( "Font" ) ) )
- {
- QList<SUIT_ViewManager*> lst;
- viewManagers( PyViewer_Viewer::Type(), lst );
- QListIterator<SUIT_ViewManager*> itPy( lst );
- while ( itPy.hasNext() )
- {
- SUIT_ViewManager* viewMgr = itPy.next();
- SUIT_ViewModel* vm = viewMgr->getViewModel();
- if ( !vm || !vm->inherits( "PyViewer_Viewer" ) )
- continue;
-
- PyViewer_Viewer* pyEditVM = dynamic_cast<PyViewer_Viewer*>( vm );
-
- viewMgr->setViewModel( vm );
- PyViewer_ViewWindow* pyView = dynamic_cast<PyViewer_ViewWindow*>( viewMgr->getActiveView() );
- if( pyView )
- {
- pyView->setPreferences();
- }
- }
- }
-#endif
}
/*!
}
if(dwMap) {
- QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
+ QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
{
QDockWidget* dw = *dit;
bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
QStringList paths;
-#ifdef WIN32
+#if defined(WIN32)
paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
+#elif defined(__APPLE__)
+ paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
#else
paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
#endif
PyConsole_Interp* LightApp_Application::getPyInterp()
{
static PyConsole_Interp* myInterp = 0;
- if ( !myInterp )
+ if ( !myInterp ) {
myInterp = createPyInterp();
+ myInterp->initialize();
+ }
return myInterp;
}
PyConsole_Interp* LightApp_Application::createPyInterp()
{
- return new LightApp_PyInterp();
+ return new PyConsole_Interp();
}
#endif // DISABLE_PYCONSOLE