#include <SUPERVGraph_ViewFrame.h>
#include <SUPERVGraph_ViewManager.h>
+#include <QtxWorkstack.h>
+
#include <qdir.h>
#include <qimage.h>
#include <qstring.h>
createMenu( a, newWinMenu, -1 );
}
+ STD_TabDesktop* tab_desk = dynamic_cast<STD_TabDesktop*>( desk );
+ if( tab_desk )
+ {
+ QAction* a = createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ),
+ 0, desk, false, tab_desk->workstack(), SLOT( onRenameActive() ) );
+ createMenu( a, windowMenu, -1 );
+ }
+
connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
enum { NewGLViewId = STD_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId,
- PreferencesId, MRUId, UserID };
+ PreferencesId, MRUId, RenameId, UserID };
public:
LightApp_Application();
virtual ~LightApp_Application();
msgid "LightApp_Application::ACTIVATING_MODULE"
msgstr "Trying to activate module \"%1\""
+msgid "LightApp_Application::TOT_RENAME"
+msgstr "Rename"
+
+msgid "LightApp_Application::MEN_RENAME"
+msgstr "Rename"
+
+msgid "LightApp_Application::PRP_RENAME"
+msgstr "Rename active window"
+
msgid "LightApp_Application::TOT_DESK_PREFERENCES"
msgstr "Preferences"
QtxWorkstack.h \
QtxResourceEdit.h \
QtxListView.h \
- QtxDirListEditor.h
+ QtxDirListEditor.h \
+ QtxNameDlg.h
# .po files to transform in .qm
QtxResourceEdit.cxx \
QtxWorkstack.cxx \
QtxListView.cxx \
- QtxDirListEditor.cxx
+ QtxDirListEditor.cxx \
+ QtxNameDlg.cxx
LIB_MOC = \
QtxAction.h \
QtxWorkstack.h \
QtxListView.h \
QtxListResourceEdit.h \
- QtxDirListEditor.h
+ QtxDirListEditor.h \
+ QtxNameDlg.h
RESOURCES_FILES = \
--- /dev/null
+// File : QtxNameDlg.cxx\r
+// Author : Vadim SANDLER\r
+// $Header$\r
+\r
+#include "QtxNameDlg.h"\r
+\r
+#include <qlayout.h>\r
+#include <qgroupbox.h>\r
+#include <qlabel.h>\r
+#include <qlineedit.h>\r
+#include <qpushbutton.h>\r
+\r
+#ifndef WIN32\r
+using namespace std;\r
+#endif\r
+\r
+/*!\r
+ Constructor\r
+*/\r
+QtxNameDlg::QtxNameDlg( QWidget* parent )\r
+: QtxDialog( parent ? parent : NULL,//application()->desktop(), \r
+ "QtxNameDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
+{\r
+ setCaption( tr("TLT_RENAME") );\r
+ setSizeGripEnabled( TRUE );\r
+\r
+ clearButtonFlags( Help );\r
+ setButtonFlags( OKCancel );\r
+\r
+ QHBoxLayout* topLayout = new QHBoxLayout( mainFrame(), 0, 5 );\r
+\r
+ /***************************************************************/\r
+ QLabel* TextLabel = new QLabel( mainFrame(), "TextLabel1" );\r
+ TextLabel->setText( tr( "NAME_LBL" ) );\r
+ topLayout->addWidget( TextLabel );\r
+ \r
+ myLineEdit = new QLineEdit( mainFrame(), "LineEdit1" );\r
+ myLineEdit->setMinimumSize( 250, 0 );\r
+ topLayout->addWidget( myLineEdit );\r
+ \r
+ /* Move widget on the botton right corner of main widget */\r
+ setAlignment( Qt::AlignCenter );\r
+\r
+ QPushButton* btn = dynamic_cast<QPushButton*>( button( OK ) );\r
+ if( btn )\r
+ btn->setAutoDefault( true );\r
+\r
+ setFocusProxy( myLineEdit );\r
+}\r
+\r
+/*!\r
+ Destructor\r
+*/\r
+QtxNameDlg::~QtxNameDlg()\r
+{\r
+}\r
+\r
+/*!\r
+ Sets name\r
+*/\r
+void QtxNameDlg::setName( const QString& name )\r
+{\r
+ myLineEdit->setText( name );\r
+ myLineEdit->end(false);\r
+ myLineEdit->home(true);\r
+}\r
+\r
+/*!\r
+ Returns name entered by user\r
+*/\r
+QString QtxNameDlg::name()\r
+{\r
+ return myLineEdit->text();\r
+}\r
+\r
+void QtxNameDlg::accept()\r
+{\r
+ if ( name().stripWhiteSpace().isEmpty() )\r
+ return;\r
+ QDialog::accept();\r
+}\r
+\r
+/*!\r
+ Creates modal <Rename> dialog and returns name entered [ static ]\r
+*/\r
+QString QtxNameDlg::getName( QWidget* parent, const QString& oldName )\r
+{\r
+ QString n;\r
+ QtxNameDlg* dlg = new QtxNameDlg( parent );\r
+ if ( !oldName.isNull() )\r
+ dlg->setName( oldName );\r
+ if ( dlg->exec() == QDialog::Accepted ) \r
+ n = dlg->name();\r
+ delete dlg;\r
+ return n;\r
+}\r
--- /dev/null
+// SALOME SalomeApp : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : QtxNameDlg.h
+// Author : Vadim SANDLER
+// Module : SALOME
+// $Header$
+
+#ifndef QTX_NAMEDLG_H
+#define QTX_NAMEDLG_H
+
+#include "Qtx.h"
+#include "QtxDialog.h"
+
+class QLineEdit;
+class QPushButton;
+
+//=================================================================================
+// class : QtxNameDlg
+/*! purpose : Common <Rename> dialog box class*/
+//=================================================================================
+class QTX_EXPORT QtxNameDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ QtxNameDlg( QWidget* parent = 0 );
+ ~QtxNameDlg();
+
+ void setName( const QString& name );
+ QString name();
+
+ static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
+
+protected slots:
+ void accept();
+
+private:
+ QPushButton* myButtonOk;
+ QPushButton* myButtonCancel;
+ QLineEdit* myLineEdit;
+};
+
+#endif // QTX_NAMEDLG_H
// Author: Sergey TELKOV
#include "QtxWorkstack.h"
+#include "QtxNameDlg.h"
#include <qstyle.h>
#include <qimage.h>
QtxWorkstack::QtxWorkstack( QWidget* parent )
: QWidget( parent ),
myWin( 0 ),
-myArea( 0 )
+myArea( 0 ),
+myWinForAction( 0 )
{
myActionsMap.insert( SplitVertical, new QAction( tr( "Split vertically" ), 0, this ));
myActionsMap.insert( SplitHorizontal, new QAction( tr( "Split horizontally" ), 0, this ));
- myActionsMap.insert( Close, new QAction( tr( "Close" ), 0, this ));
+ myActionsMap.insert( Close, new QAction( tr( "Close" ), 0, this ));
+ myActionsMap.insert( Rename, new QAction( tr( "Rename" ), 0, this ));
connect( myActionsMap[SplitVertical], SIGNAL( activated() ), this, SLOT( splitVertical() ) );
connect( myActionsMap[SplitHorizontal], SIGNAL( activated() ), this, SLOT( splitHorizontal() ) );
connect( myActionsMap[Close], SIGNAL( activated() ), this, SLOT( onCloseWindow() ) );
+ connect( myActionsMap[Rename], SIGNAL( activated() ), this, SLOT( onRename() ) );
QVBoxLayout* base = new QVBoxLayout( this );
mySplit = new QSplitter( this );
split( Qt::Vertical );
}
+void QtxWorkstack::renameWindow( QWidget* w )
+{
+ if( !w )
+ return;
+
+ QString new_name = QtxNameDlg::getName( ( QWidget* )parent(), w->caption() );
+ if( !new_name.isEmpty() )
+ w->setCaption( new_name );
+}
+
+void QtxWorkstack::onRenameActive()
+{
+ renameWindow( activeWindow() );
+}
+
+void QtxWorkstack::onRename()
+{
+ renameWindow( myWinForAction );
+}
+
QSplitter* QtxWorkstack::wrapSplitter( QtxWorkstackArea* area )
{
if ( !area )
*/
void QtxWorkstack::onCloseWindow()
{
- if ( activeWindow() )
- activeWindow()->close();
+ //if ( activeWindow() )
+ //activeWindow()->close();
+ if( myWinForAction )
+ myWinForAction->close();
}
void QtxWorkstack::onDestroyed( QObject* obj )
QApplication::postEvent( this, new QCustomEvent( QEvent::User ) );
}
-void QtxWorkstack::onContextMenuRequested( QPoint p )
+void QtxWorkstack::onContextMenuRequested( QWidget* w, QPoint p )
{
+ myWinForAction = 0;
if ( !activeArea() )
return;
if ( lst.isEmpty() )
return;
+ myWinForAction = w;
QPopupMenu* pm = new QPopupMenu();
if ( lst.count() > 1 )
myActionsMap[SplitHorizontal]->addTo( pm );
pm->insertSeparator();
}
+
myActionsMap[Close]->addTo( pm );
+ myActionsMap[Rename]->addTo( pm );
pm->exec( p );
connect( area, SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) );
connect( area, SIGNAL( activated( QWidget* ) ), this, SLOT( onWindowActivated( QWidget* ) ) );
- connect( area, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( onContextMenuRequested( QPoint ) ) );
+ connect( area, SIGNAL( contextMenuRequested( QWidget*, QPoint ) ),
+ this, SLOT( onContextMenuRequested( QWidget*, QPoint ) ) );
connect( area, SIGNAL( deactivated( QtxWorkstackArea* ) ), this, SLOT( onDeactivated( QtxWorkstackArea* ) ) );
return area;
connect( myClose, SIGNAL( clicked() ), this, SLOT( onClose() ) );
connect( myBar, SIGNAL( selected( int ) ), this, SLOT( onSelected( int ) ) );
connect( myBar, SIGNAL( dragActiveTab() ), this, SLOT( onDragActiveTab() ) );
- connect( myBar, SIGNAL( contextMenuRequested( QPoint ) ), this, SIGNAL( contextMenuRequested( QPoint ) ) );
+ connect( myBar, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( onBarRequestContextMenu( QPoint ) ) );
updateState();
setWidgetActive( wid );
}
+void QtxWorkstackArea::onBarRequestContextMenu( QPoint p )
+{
+ const QtxWorkstackTabBar* bar = dynamic_cast<const QtxWorkstackTabBar*>( sender() );
+ if( bar )
+ emit contextMenuRequested( widget( myBar->tabAt( tabAt( p ) )->identifier() ), p );
+}
+
void QtxWorkstackArea::onWidgetDestroyed()
{
if( sender() )
Q_OBJECT
public:
- enum { SplitVertical, SplitHorizontal, Close };
+ enum { SplitVertical, SplitHorizontal, Close, Rename };
enum SplitType {
SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one
public slots:
void splitVertical();
void splitHorizontal();
+ void onRenameActive();
private slots:
+ void onRename();
void onCloseWindow();
void onDestroyed( QObject* );
void onWindowActivated( QWidget* );
- void onContextMenuRequested( QPoint );
+ void onContextMenuRequested( QWidget*, QPoint );
void onDeactivated( QtxWorkstackArea* );
protected:
QSplitter* wrapSplitter( QtxWorkstackArea* );
void insertWidget( QWidget*, QWidget*, QWidget* );
+ void renameWindow( QWidget* );
QtxWorkstackArea* areaAt( const QPoint& ) const;
const int need_pos, const int splitter_pos );
private:
- QWidget* myWin;
+ QWidget* myWin, *myWinForAction;
QtxWorkstackArea* myArea;
QSplitter* mySplit;
signals:
void activated( QWidget* );
- void contextMenuRequested( QPoint );
+ void contextMenuRequested( QWidget*, QPoint );
void deactivated( QtxWorkstackArea* );
public slots:
void onChildHided( QtxWorkstackChild* );
void onChildActivated( QtxWorkstackChild* );
void onChildCaptionChanged( QtxWorkstackChild* );
+ void onBarRequestContextMenu( QPoint );
protected:
virtual void customEvent( QCustomEvent* );