From d90d7aa257f74cc7a84b495045bd9fd19b760b6d Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 28 Nov 2005 09:20:47 +0000 Subject: [PATCH] It is recommended to use standard Qt QInputDialog instead QtxNameDlg --- src/LightApp/LightApp_Application.cxx | 27 ++++++-- src/LightApp/LightApp_Application.h | 3 +- src/Qtx/Makefile.in | 9 +-- src/Qtx/QtxNameDlg.cxx | 96 --------------------------- src/Qtx/QtxNameDlg.h | 47 ------------- src/Qtx/QtxWorkstack.cxx | 20 ++---- src/Qtx/QtxWorkstack.h | 2 - 7 files changed, 30 insertions(+), 174 deletions(-) delete mode 100644 src/Qtx/QtxNameDlg.cxx delete mode 100644 src/Qtx/QtxNameDlg.h diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index e21e2027b..930a698a4 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -73,6 +73,7 @@ #include #include #include +#include #define OBJECT_BROWSER_WIDTH 300 #define OBJECT_COLUMN_WIDTH 150 @@ -457,13 +458,9 @@ void LightApp_Application::createActions() createMenu( a, newWinMenu, -1 ); } - STD_TabDesktop* tab_desk = dynamic_cast( 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 ); - } + createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ), + 0, desk, false, this, SLOT( onRenameWindow() ) ); + createMenu( RenameId, windowMenu, -1 ); connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) ); @@ -1877,3 +1874,19 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm ) STD_Application::removeViewManager( vm ); delete vm; } + +/*! rename active window of desktop */ +void LightApp_Application::onRenameWindow() +{ + if( !desktop() ) + return; + + QWidget* w = desktop()->activeWindow(); + if( !w ) + return; + + bool ok; + QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w ); + if( ok && !name.isEmpty() ) + w->setCaption( name ); +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index c6f3e8eda..14d2e4c23 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -44,7 +44,7 @@ class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application public: typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes; - enum { NewGLViewId = STD_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId, + enum { NewGLViewId = CAM_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId, PreferencesId, MRUId, RenameId, UserID }; public: LightApp_Application(); @@ -150,6 +150,7 @@ private slots: void onPreferences(); void onMRUActivated( QString ); void onPreferenceChanged( QString&, QString&, QString& ); + void onRenameWindow(); protected: void updateWindows(); diff --git a/src/Qtx/Makefile.in b/src/Qtx/Makefile.in index 04f2941ec..0a92974f9 100755 --- a/src/Qtx/Makefile.in +++ b/src/Qtx/Makefile.in @@ -48,8 +48,7 @@ EXPORT_HEADERS= Qtx.h \ QtxWorkstack.h \ QtxResourceEdit.h \ QtxListView.h \ - QtxDirListEditor.h \ - QtxNameDlg.h + QtxDirListEditor.h # .po files to transform in .qm @@ -96,8 +95,7 @@ LIB_SRC= \ QtxResourceEdit.cxx \ QtxWorkstack.cxx \ QtxListView.cxx \ - QtxDirListEditor.cxx \ - QtxNameDlg.cxx + QtxDirListEditor.cxx LIB_MOC = \ QtxAction.h \ @@ -129,8 +127,7 @@ LIB_MOC = \ QtxWorkstack.h \ QtxListView.h \ QtxListResourceEdit.h \ - QtxDirListEditor.h \ - QtxNameDlg.h + QtxDirListEditor.h RESOURCES_FILES = \ diff --git a/src/Qtx/QtxNameDlg.cxx b/src/Qtx/QtxNameDlg.cxx deleted file mode 100644 index 28e4fcb04..000000000 --- a/src/Qtx/QtxNameDlg.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// File : QtxNameDlg.cxx -// Author : Vadim SANDLER -// $Header$ - -#include "QtxNameDlg.h" - -#include -#include -#include -#include -#include - -#ifndef WIN32 -using namespace std; -#endif - -/*! - Constructor -*/ -QtxNameDlg::QtxNameDlg( QWidget* parent ) -: QtxDialog( parent ? parent : NULL,//application()->desktop(), - "QtxNameDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - setCaption( tr("TLT_RENAME") ); - setSizeGripEnabled( TRUE ); - - clearButtonFlags( Help ); - setButtonFlags( OKCancel ); - - QHBoxLayout* topLayout = new QHBoxLayout( mainFrame(), 0, 5 ); - - /***************************************************************/ - QLabel* TextLabel = new QLabel( mainFrame(), "TextLabel1" ); - TextLabel->setText( tr( "NAME_LBL" ) ); - topLayout->addWidget( TextLabel ); - - myLineEdit = new QLineEdit( mainFrame(), "LineEdit1" ); - myLineEdit->setMinimumSize( 250, 0 ); - topLayout->addWidget( myLineEdit ); - - /* Move widget on the botton right corner of main widget */ - setAlignment( Qt::AlignCenter ); - - QPushButton* btn = dynamic_cast( button( OK ) ); - if( btn ) - btn->setAutoDefault( true ); - - setFocusProxy( myLineEdit ); -} - -/*! - Destructor -*/ -QtxNameDlg::~QtxNameDlg() -{ -} - -/*! - Sets name -*/ -void QtxNameDlg::setName( const QString& name ) -{ - myLineEdit->setText( name ); - myLineEdit->end(false); - myLineEdit->home(true); -} - -/*! - Returns name entered by user -*/ -QString QtxNameDlg::name() -{ - return myLineEdit->text(); -} - -void QtxNameDlg::accept() -{ - if ( name().stripWhiteSpace().isEmpty() ) - return; - QDialog::accept(); -} - -/*! - Creates modal dialog and returns name entered [ static ] -*/ -QString QtxNameDlg::getName( QWidget* parent, const QString& oldName ) -{ - QString n; - QtxNameDlg* dlg = new QtxNameDlg( parent ); - if ( !oldName.isNull() ) - dlg->setName( oldName ); - if ( dlg->exec() == QDialog::Accepted ) - n = dlg->name(); - delete dlg; - return n; -} diff --git a/src/Qtx/QtxNameDlg.h b/src/Qtx/QtxNameDlg.h deleted file mode 100644 index a6a81938b..000000000 --- a/src/Qtx/QtxNameDlg.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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 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 diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 20cbd0515..5d57ad6e0 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -709,26 +709,16 @@ void QtxWorkstack::splitHorizontal() split( Qt::Vertical ); } -void QtxWorkstack::renameWindow( QWidget* w ) +void QtxWorkstack::onRename() { - if ( !w ) + if ( !myWorkWin ) return; bool ok = false; QString newName = QInputDialog::getText( tr( "Rename" ), tr( "Enter new name:" ), QLineEdit::Normal, - w->caption(), &ok, topLevelWidget() ); - if ( ok ) - w->setCaption( newName ); -} - -void QtxWorkstack::onRenameActive() -{ - renameWindow( activeWindow() ); -} - -void QtxWorkstack::onRename() -{ - renameWindow( myWorkWin ); + myWorkWin->caption(), &ok, topLevelWidget() ); + if ( ok && !newName.isEmpty() ) + myWorkWin->setCaption( newName ); } QSplitter* QtxWorkstack::wrapSplitter( QtxWorkstackArea* area ) diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 14f18e417..dfc7dac57 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -69,7 +69,6 @@ signals: public slots: void splitVertical(); void splitHorizontal(); - void onRenameActive(); private slots: void onRename(); @@ -90,7 +89,6 @@ private: QSplitter* wrapSplitter( QtxWorkstackArea* ); void insertWidget( QWidget*, QWidget*, QWidget* ); - void renameWindow( QWidget* ); QtxWorkstackArea* areaAt( const QPoint& ) const; -- 2.39.2