#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
- if (!anApp.isEmpty()) {
+ if ( !anApp.isEmpty() )
+ {
RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
rs->start();
}
- else {
- if( SUIT_MessageBox::question(desktop(), tr("WRN_WARNING"),
- tr("DEFINE_EXTERNAL_BROWSER"),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- onPreferences();
+ else
+ {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
}
}
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
- if (!anApp.isEmpty()) {
+ if ( !anApp.isEmpty() )
+ {
RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, theContext );
rs->start();
}
- else {
- if( SUIT_MessageBox::question(desktop(), tr("WRN_WARNING"),
- tr("DEFINE_EXTERNAL_BROWSER"),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
- onPreferences();
+ else
+ {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+ showPreferences( tr( "PREF_APP" ) );
}
}
/*!Private SLOT. On preferences.*/
void LightApp_Application::onPreferences()
+{
+ showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
+}
+
+/*!Private SLOT. On preferences.*/
+void LightApp_Application::showPreferences( const QString& itemText )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
if ( !prefDlg )
return;
- preferences()->activateModule( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
+ preferences()->activateItem( itemText );
- if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() ) {
+ if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
+ {
if ( desktop() )
resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
resourceMgr()->save();
pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
LightApp_Preferences::Color, "VTKViewer", "background" );
pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
- pref->addPreference( tr( "PREF_USE_ADVANCED_SELECTION_ALGORITHM" ), vtkGroup,
+ pref->addPreference( tr( "PREF_USE_ADVANCED_SELECTION_ALGORITHM" ), vtkGroup,
LightApp_Preferences::Bool, "VTKViewer", "use_advanced_selection_algorithm" );
pref->setItemProperty( "min", 1.0E-06, vtkTS );
SUIT_ViewWindow* wnd;
foreach( wnd, wndList )
{
- if ( wnd )
+ if ( wnd )
wnd->close();
}
}
enum { MenuWindowId = 6 };
- enum { RenameId = CAM_Application::UserID,
+ enum { RenameId = CAM_Application::UserID,
CloseId, CloseAllId, GroupAllId,
PreferencesId, MRUId, ModulesListId,
NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId, UserID };
virtual int openChoice( const QString& );
virtual bool openAction( const int, const QString& );
+ void showPreferences( const QString& = QString() );
+
protected:
typedef QPointer<QWidget> WinPtr;
typedef QMap<int, WinPtr> WinMap;
return res;
}
-void LightApp_Preferences::activateModule( const QString& mod ) const
+void LightApp_Preferences::activateItem( const QString& mod ) const
{
QtxPreferenceItem* item = findItem( mod, true );
- if ( item && item->depth() < 3 )
- item->ensureVisible();
+ if ( !item )
+ return;
+
+ item->ensureVisible();
+ item->activate();
}
/*!Do nothing.*/
bool hasModule( const QString& ) const;
- void activateModule( const QString& ) const;
+ void activateItem( const QString& ) const;
protected:
void changedResources( const ResourceMap& );
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionGroup.cxx
+// Author: Sergey TELKOV
+
+#include "QtxActionGroup.h"
+
+#include "QtxComboBox.h"
+
+#include <QApplication>
+
+/*!
+ \class QtxActionGroup
+ \brief An action class which is represented in the menu bar (or toolbar) as
+ a group of actions or combo box and support exclusive triggerd action behaviour.
+*/
+
+/*!
+ \brief Constructor.
+ \param parent parent object
+*/
+QtxActionGroup::QtxActionGroup( QObject* parent )
+: QtxActionSet( parent ),
+ myExclusive( false ),
+ myDropDown( false )
+{
+ connect( this, SIGNAL( triggered( QAction* ) ), this, SLOT( onTriggered( QAction* ) ) );
+}
+
+/*!
+ \brief Destructor.
+*/
+QtxActionGroup::~QtxActionGroup()
+{
+}
+
+/*!
+ \brief Returns true if the action group is exclusive.
+*/
+bool QtxActionGroup::isExclusive() const
+{
+ return myExclusive;
+}
+
+/*!
+ \brief Set the action group is exclusive.
+ \param on if true group should be exclusive otherwise not.
+*/
+void QtxActionGroup::setExclusive( const bool on )
+{
+ if ( myExclusive == on )
+ return;
+
+ bool e = isEmptyAction();
+
+ myExclusive = on;
+
+ if ( e != isEmptyAction() )
+ updateType();
+}
+
+/*!
+ \brief Returns .
+ \param on if true group should be exclusive otherwise not.
+*/
+bool QtxActionGroup::usesDropDown() const
+{
+ return myDropDown;
+}
+
+/*!
+ \brief Sets whether the group's actions are displayed in a subwidget of the widgets the action group is added to.
+*/
+void QtxActionGroup::setUsesDropDown( const bool on )
+{
+ if ( myDropDown == on )
+ return;
+
+ bool e = isEmptyAction();
+
+ myDropDown = on;
+
+ if ( e != isEmptyAction() )
+ updateType();
+}
+
+/*!
+ \brief Append the specified action into group.
+*/
+void QtxActionGroup::add( QAction* a )
+{
+ insertAction( a );
+}
+
+/*!
+ \brief Called when some action is activated by the user.
+ \param a toggled action
+*/
+void QtxActionGroup::onTriggered( QAction* a )
+{
+ if ( !isExclusive() )
+ return;
+
+ if ( !a->isCheckable() || !a->isChecked() )
+ return;
+
+ QList<QAction*> aList = actions();
+ for ( QList<QAction*>::const_iterator it = aList.begin(); it != aList.end(); ++it )
+ {
+ QAction* cur = *it;
+ if ( cur->isCheckable() )
+ cur->setChecked( cur == a );
+ }
+
+ emit selected( a );
+}
+
+void QtxActionGroup::onActivated( int id )
+{
+ const QObject* s = sender();
+
+ QAction* a = action( id );
+ if ( !a )
+ return;
+
+ if ( a->isChecked() )
+ return;
+
+ a->setChecked( true );
+
+ QList<QWidget*> lst = createdWidgets();
+ for ( QList<QWidget*>::iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ QtxComboBox* cb = ::qobject_cast<QtxComboBox*>( *it );
+ if ( cb && cb != s )
+ cb->setCurrentId( id );
+ }
+}
+
+/*!
+ \brief Update action set for the specified widget.
+ \param w a widget this action is added to
+*/
+void QtxActionGroup::updateAction( QWidget* w )
+{
+ QtxComboBox* cb = createdWidget( w );
+ if ( !cb )
+ QtxActionSet::updateAction( w );
+ else
+ {
+ updateAction( cb );
+
+ QList<QAction*> lst = actions();
+ for ( QList<QAction*>::iterator it = lst.begin(); it != lst.end(); ++it )
+ w->removeAction( *it );
+ }
+}
+
+void QtxActionGroup::updateAction( QtxComboBox* cb )
+{
+ if ( !cb )
+ return;
+
+ cb->clear();
+ cb->setCleared( false );
+
+ QAction* cur = 0;
+ QList<QAction*> lst = actions();
+ for ( QList<QAction*>::iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ QAction* a = *it;
+ cb->addItem( a->icon(), a->text() );
+ cb->setId( cb->count() - 1, actionId( a ) );
+ if ( a->isChecked() )
+ cur = a;
+ }
+
+ if ( cur )
+ cb->setCurrentId( actionId( cur ) );
+ else
+ cb->setCleared( true );
+}
+
+QWidget* QtxActionGroup::createWidget( QWidget* p )
+{
+ QtxComboBox* cb = !isEmptyAction() ? new QtxComboBox( p ) : 0;
+ if ( cb )
+ connect( cb, SIGNAL( activatedId( int ) ), this, SLOT( onActivated( int ) ) );
+ return cb;
+}
+
+/*!
+ \brief Check if the action itself should be invisible
+ (only child action are shown)
+ \return \c true if the action itself should be visible
+*/
+bool QtxActionGroup::isEmptyAction() const
+{
+ return !isExclusive() || !usesDropDown();
+}
+
+
+void QtxActionGroup::updateType()
+{
+ QList<QWidget*> lst = associatedWidgets();
+ for ( QList<QWidget*>::iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ QWidget* w = *it;
+ QList<QAction*> lst = w->actions();
+
+ int i = lst.indexOf( this );
+ w->removeAction( this );
+
+ lst = w->actions();
+ w->insertAction( i < lst.count() ? lst.at( i ) : 0, this );
+ }
+}
+
+QtxComboBox* QtxActionGroup::createdWidget( QWidget* p )
+{
+ QtxComboBox* cb = 0;
+ QList<QWidget*> lst = createdWidgets();
+ for ( QList<QWidget*>::iterator it = lst.begin(); it != lst.end() && !cb; ++it )
+ {
+ if ( (*it)->parent() == p )
+ cb = ::qobject_cast<QtxComboBox*>( *it );
+ }
+ return cb;
+}
+
+
+
+
+
+/*!
+ \fn void QtxActionGroup::selected( QAction* a );
+ \brief Emitted when some child action is checked by the user.
+ \param a action being checked
+*/
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionGroup.h
+// Author: Sergey TELKOV
+
+#ifndef QTXACTIONGROUP_H
+#define QTXACTIONGROUP_H
+
+#include "QtxActionSet.h"
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class QtxComboBox;
+
+class QTX_EXPORT QtxActionGroup : public QtxActionSet
+{
+ Q_OBJECT
+
+public:
+ QtxActionGroup( QObject* = 0 );
+ QtxActionGroup( QObject*, const bool );
+ virtual ~QtxActionGroup();
+
+ bool isExclusive() const;
+ void setExclusive( const bool );
+
+ bool usesDropDown() const;
+ void setUsesDropDown( const bool );
+
+ void add( QAction* );
+
+signals:
+ void selected( QAction* );
+
+private slots:
+ void onActivated( int );
+ void onTriggered( QAction* );
+
+protected:
+ virtual void updateAction( QWidget* );
+ virtual void updateAction( QtxComboBox* );
+
+ virtual QWidget* createWidget( QWidget* );
+
+ virtual bool isEmptyAction() const;
+
+private:
+ void updateType();
+ QtxComboBox* createdWidget( QWidget* );
+
+private:
+ bool myDropDown;
+ bool myExclusive;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
/*!
\brief Called when action is changed.
-
+
Update action state.
*/
void QtxActionSet::onChanged()
for ( ActionList::iterator it = mySet.begin(); it != mySet.end(); ++it )
w->removeAction( *it );
+ if ( !w->actions().contains( this ) )
+ return;
+
QAction* first = 0;
for ( int i = 0; i < mySet.count(); i++ )
{
delete myListener;
}
+void QtxPagePrefItem::activate()
+{
+ QtxPreferenceItem::activate();
+
+ if ( widget() )
+ widget()->setFocus();
+}
+
/*!
\brief Get preference item editor widget.
\return editor widget
{
// QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
// if ( !aGroup )
- widget()->layout()->addWidget( myControl );
+ widget()->layout()->addWidget( myControl );
+ widget()->setFocusProxy( myControl );
// else myControl->setParent( aGroup->gridBox() );
}
}
QWidget* widget() const;
+ virtual void activate();
+
protected:
void setWidget( QWidget* );
return item;
}
+void QtxPreferenceItem::activate()
+{
+}
+
void QtxPreferenceItem::ensureVisible()
{
if ( parentItem() )
virtual QtxResourceMgr* resourceMgr() const;
virtual QtxPreferenceMgr* preferenceMgr() const;
+ virtual void activate();
void ensureVisible();
static int RTTI();