--- /dev/null
+/*!
+
+\page python_viewer_page Python viewer
+
+The functionalities of Python viewer are available via its Viewer
+Toolbar.
+
+\image html pythonviewer_toolbar.png
+<hr>
+
+\image html python_new.png
+
+<b>New</b> - clears viewer in order to create a new script. If viewer was modified, you will be asked to close it before removing.
+<hr>
+
+\image html python_open.png
+<b>Open</b> - allows to open an existing script by browsing for it in a standard Open File dialog box, choosing the required .py file and clicking Open button. If there is already opened script, you will be asked to close it before opening new one.
+<hr>
+
+\image html python_save.png
+
+<b>Save</b> - saves the current script.
+
+\note If the script hasn't been previously saved, Save will call the standard Save File dialog box where you can enter the name for your script and save it.
+
+<hr>
+
+\image html python_saveas.png
+
+<b>Save As...</b> - allows to save the current script with a new name. Input a new name for the script in the standard Save file as dialog box and click Save button.
+<hr>
+
+\image html python_undo.png
+
+<b>Undo</b> - undo the last user's action in Python viewer.
+<hr>
+
+\image html python_redo.png
+
+<b>Redo</b> - redo the previously user's action in Python viewer.
+<hr>
+
+\image html python_cut.png
+
+<b>Cut</b> - save the selected text into clipboard and remove it from the viewer.
+<hr>
+
+\image html python_copy.png
+
+<b>Copy</b> - save the selected text into clipboard.
+<hr>
+
+\image html python_paste.png
+
+<b>Paste</b> - restore the saved text from clipboard.
+<hr>
+
+\image html python_delete.png
+
+<b>Delete</b> - remove the selected text.
+<hr>
+
+\image html python_selectall.png
+
+<b>Select All</b> - select whole the text.
+<hr>
+
+\image html python_preferences.png
+
+<b>Preferences</b> - provides an access to the preferences dialog box, that allows to specify advanced parameters for the Python Viewer.
+
+\anchor custom_python_preferences
+\image html python_view_preferences.png
+
+The following options are available:
+
+- <b>Font settings</b> allows setting font variant and it's size.
+
+- <b>Display settings</b> specifies the script representation in the viewer:
+
+ - <b>Enable current line highlight</b> switches on a background coloring of current line.
+ - <b>Enable text wrapping</b> allows lines wrapping at the view border of the editor.
+
+ - <b>Center cursor on scroll</b> scrolls the script vertically to make the cursor visible at the center of the viewer.
+
+ - <b>Display line numbers area</b> will make a panel displaying the line numbers of the script visible in the left border of the editor.
+
+- <b>Tab settings</b> allows to display tab indentation as a set of desirable number of white spaces.
+
+- <b>Vertical edge settings</b> manages drawing of vertical line at the specified column of the viewer.
+
+- <b>Save settings as default</b> will store the applied Python viewer settings in the SALOME preferences .xml file and restore it in the current and next SALOME sessions.
+
+*/
#include "PyEditor_Settings.h"
#include <QCheckBox>
-#include <QComboBox>
-#include <QDialogButtonBox>
-#include <QFontComboBox>
#include <QGroupBox>
#include <QLabel>
+#include <QPushButton>
#include <QSpinBox>
#include <QVBoxLayout>
-
+#include <QtxFontEdit.h>
/*!
\class PyEditor_SettingsDlg
// . Font settings <start>
QGroupBox* aFontSetBox = new QGroupBox( tr( "GR_FONT_SET" ) );
QHBoxLayout* aFontSetLayout = new QHBoxLayout( aFontSetBox );
- QLabel* aFontFamilyLabel = new QLabel( tr( "LBL_FONT_FAM" ) );
- w_FontFamily = new QFontComboBox;
- w_FontFamily->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
- QLabel* aFontSizeLabel = new QLabel( tr( "LBL_FONT_SIZE" ) );
- w_FontSize = new QComboBox;
- w_FontSize->setInsertPolicy( QComboBox::NoInsert );
- w_FontSize->setValidator( new QIntValidator( 1, 250, w_FontSize ) );
- w_FontSize->setEditable( true );
- w_FontSize->setMinimumContentsLength( 3 );
- aFontSetLayout->addWidget( aFontFamilyLabel );
- aFontSetLayout->addWidget( w_FontFamily );
- aFontSetLayout->addWidget( aFontSizeLabel );
- aFontSetLayout->addWidget( w_FontSize );
- /*connect( w_FontFamily, SIGNAL( currentFontChanged( const QFont& ) ),
- this, SLOT( onFontChanged( const QFont& ) ) );*/
+ w_FontWidget = new QtxFontEdit( QtxFontEdit::Family|QtxFontEdit::Size|QtxFontEdit::UserSize, this );
+ aFontSetLayout->addWidget( w_FontWidget );
// . Font settings <end>
// . Display settings <start>
aMainLayout->addWidget( w_DefaultCheck );
aMainLayout->addStretch( 1 );
+ myOkBtn = new QPushButton( tr( "BUT_OK" ), this );
+ myOkBtn->setAutoDefault( TRUE );
+ myOkBtn->setDefault( TRUE );
+ myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
+ myCancelBtn->setAutoDefault( TRUE );
+ myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
+ myHelpBtn->setAutoDefault( TRUE );
QHBoxLayout* aButtonLayout = new QHBoxLayout;
- w_ButtonBox = new QDialogButtonBox( Qt::Horizontal );
- w_ButtonBox->setStandardButtons( QDialogButtonBox::Ok
- | QDialogButtonBox::Cancel
- | QDialogButtonBox::Apply );
- aButtonLayout->addWidget( w_ButtonBox, 1, Qt::AlignRight );
+ aButtonLayout->addWidget( myOkBtn );
+ aButtonLayout->addStretch();
+ aButtonLayout->addWidget( myCancelBtn );
+ aButtonLayout->addWidget( myHelpBtn );
aMainLayout->addLayout( aButtonLayout );
- connect( w_ButtonBox, SIGNAL( clicked( QAbstractButton* ) ),
- this, SLOT( onClick( QAbstractButton* ) ) );
-
- settingsToGui();
-
- onFontChanged( currentFont() );
-}
-
-/*!
- \brief Set currently selected font.
- \param fnt current font
- \sa currentFont()
-*/
-void PyEditor_SettingsDlg::setCurrentFont( const QFont& fnt )
-{
- w_FontFamily->blockSignals( true );
- w_FontSize->blockSignals( true );
+ connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( onOk() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
- setFontFamily( fnt.family() );
- setFontSize( fnt.pointSize() );
-
- w_FontFamily->blockSignals( false );
- w_FontSize->blockSignals( false );
-}
-
-/*!
- \brief Get currently selected font.
- \return current font
- \sa setCurrentFont()
-*/
-QFont PyEditor_SettingsDlg::currentFont() const
-{
- return QFont( fontFamily(), fontSize() );
-}
-
-/*!
- \brief Set font size.
- \param s size value
- \sa fontSize()
-*/
-void PyEditor_SettingsDlg::setFontSize( const int s )
-{
- if ( s <= 0 )
- return;
-
- int idx = w_FontSize->findText( QString::number( s ) );
- if ( idx != -1 )
- w_FontSize->setCurrentIndex( idx );
- else if ( w_FontSize->isEditable() )
- w_FontSize->setEditText( QString::number( s ) );
-}
-
-/*!
- \brief Get font size.
- \return size value
- \sa setFontSize()
-*/
-int PyEditor_SettingsDlg::fontSize() const
-{
- bool ok;
- int pSize = w_FontSize->currentText().toInt( &ok );
- return ok ? pSize : 0;
-}
-
-/*!
- \brief Set font family name.
- \param theFamily new font family name
- \sa fontFamily()
-*/
-void PyEditor_SettingsDlg::setFontFamily( const QString& theFamily )
-{
- w_FontFamily->setCurrentFont( QFont( theFamily ) );
- onFontChanged( w_FontFamily->currentFont() );
-}
-
-/*!
- \brief Get font family name.
- \return font family name
- \sa setFontFamily()
-*/
-QString PyEditor_SettingsDlg::fontFamily() const
-{
- return w_FontFamily->currentFont().family();
+ settingsToGui();
}
/*!
return w_DefaultCheck->isChecked();
}
-/*!
- SLOT: Perform dialog actions
- \param theButton button
-*/
-void PyEditor_SettingsDlg::onClick( QAbstractButton* theButton )
-{
- QDialogButtonBox::ButtonRole aButtonRole = w_ButtonBox->buttonRole( theButton );
- if ( aButtonRole == QDialogButtonBox::AcceptRole )
- {
- settingsFromGui();
- setSettings();
- accept();
- }
- else if ( aButtonRole == QDialogButtonBox::ApplyRole )
- {
- settingsFromGui();
- setSettings();
- }
- else if ( aButtonRole == QDialogButtonBox::RejectRole )
- {
- reject();
- }
-}
-
/*!
SLOT: Changes the widget visibility depending on the set theState flag.
\param theState flag of visibility
w_NumberColumns->setEnabled( theState );
}
-/*!
- \brief Called when current font is changed.
- \param theFont (not used)
-*/
-void PyEditor_SettingsDlg::onFontChanged( const QFont& /*theFont*/ )
-{
- bool blocked = w_FontSize->signalsBlocked();
- w_FontSize->blockSignals( true );
-
- int s = fontSize();
- w_FontSize->clear();
-
- QList<int> szList = QFontDatabase().pointSizes( fontFamily() );
- QStringList sizes;
- for ( QList<int>::const_iterator it = szList.begin(); it != szList.end(); ++it )
- sizes.append( QString::number( *it ) );
- w_FontSize->addItems( sizes );
-
- setFontSize( s );
-
- w_FontSize->blockSignals( blocked );
-}
-
/*!
\brief Sets settings from preferences dialog.
*/
my_Editor->settings()->p_TabSize = w_TabSize->value();
my_Editor->settings()->p_VerticalEdge = w_VerticalEdge->isChecked();
my_Editor->settings()->p_NumberColumns = w_NumberColumns->value();
- my_Editor->settings()->p_Font = currentFont();
+ my_Editor->settings()->p_Font = w_FontWidget->currentFont();
}
/*!
w_TabSize->setValue( my_Editor->settings()->p_TabSize );
w_VerticalEdge->setChecked( my_Editor->settings()->p_VerticalEdge );
w_NumberColumns->setValue( my_Editor->settings()->p_NumberColumns );
- setCurrentFont( my_Editor->settings()->p_Font );
+ w_FontWidget->setCurrentFont( my_Editor->settings()->p_Font );
+ w_FontWidget->setSizes();
onVerticalEdgeChecked( my_Editor->settings()->p_VerticalEdge );
}
my_Editor->updateStatement();
}
+
+/*!
+ Slot, called when user clicks "OK" button
+*/
+void PyEditor_SettingsDlg::onOk()
+{
+ settingsFromGui();
+ setSettings();
+ accept();
+}
+
+/*!
+ Slot, called when user clicks "Help" button.
+*/
+void PyEditor_SettingsDlg::onHelp()
+{
+ emit onHelpClicked();
+}