From 17aaa234ddf4984709d188645c63f3baf1c78444 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 1 Mar 2005 09:45:16 +0000 Subject: [PATCH] PAL8321 (add 'Close' button for Registry tool window) --- src/RegistryDisplay/RegWidget.cxx | 116 ++++++++++++++++++++++++++++++ src/RegistryDisplay/RegWidget.hxx | 4 ++ 2 files changed, 120 insertions(+) diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx index a2cb69e3b..192da7bbc 100644 --- a/src/RegistryDisplay/RegWidget.cxx +++ b/src/RegistryDisplay/RegWidget.cxx @@ -57,6 +57,80 @@ QString findFile( QString filename ); #define BOLD( text ) ( QString( "" ) + QString( text ) + QString( "" ) ) +static const char* const time_data[] = { +"16 16 6 1", +". c None", +"b c None", +"# c #000000", +"a c #4c4c4c", +"d c #878787", +"c c #ffffff", +".....#####ab....", +"...##cc#dc##ab..", +"..#ccc###dcc#ab.", +".#ccccc#dcccc#a.", +".#ccccc#dcccc#ab", +"#cccccc#dccccc#a", +"#cccccc#dccc#c#a", +"#c##ccc########a", +"#ccddcccdddd#d#a", +"#cccccccccccdc#a", +".#ccccccccccc#aa", +".#ccccc#ccccc#a.", +"..#cccc#dccc#aa.", +"...##cccdc##aa..", +".....#####aaa...", +"......aaaaa....."}; + +static const char* const close_data[] = { +"16 16 6 1", +"d c None", +". c None", +"# c #000000", +"a c #4c4c4c", +"c c #5b5b5b", +"b c #ffffff", +".....#####a.....", +"...##bbbbb##a...", +"..#bbbbbbbbb#a..", +".#b#cbbbbbb#d#a.", +".#bc#cbbbb#cb#a.", +"#bbbc#cbb#cbbb#a", +"#bbbbc#c#cbbbb#a", +"#bbbbbc#cbbbbb#a", +"#bbbbc#c#cbbbb#a", +"#bbb#ccbb##bbb#a", +".#b#c#bbbbc#b#aa", +".#bc#bbbbbb#c#a.", +"..#bbbbbbbbb#aa.", +"...##bbbbb##aa..", +".....#####aaa...", +"......aaaaa....."}; + +static const char* const refresh_data[] = { +"16 16 5 1", +". c None", +"# c #000000", +"a c #4c4c4c", +"c c #878787", +"b c #ffffff", +".....#####a.....", +"...##bb#bb##a...", +"..#bbbbc#bbb#a..", +".#bbbb####cbb#a.", +".#bbb#cc#cbbb#a.", +"#bbb#cb#cbbbbb#a", +"#bb#cbbbbbb#bb#a", +"#bb#cbbbbbb#cb#a", +"#bb#cbbbbbb#cb#a", +"#bbbbbb#bb#cbb#a", +".#bbbb#cb#cbb#aa", +".#bbb####cbbb#a.", +"..#bbb#cbbbb#aa.", +"...##bb#cb##aa..", +".....#####aaa...", +"......aaaaa....."}; + /*! Creates components list */ @@ -125,12 +199,19 @@ RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) if ( !pm.isNull() ) setIcon( pm ); + // pixmap for buttons + QPixmap image_refresh ( ( const char** ) refresh_data ); + QPixmap image_interval( ( const char** ) time_data ); + QPixmap image_close ( ( const char** ) close_data ); + // Buttons definition QToolBar* topbar = new QToolBar( tr("Toolbar"), this ); setDockEnabled( topbar, DockTornOff, false ); setDockMenuEnabled( false ); _refresh = new QPushButton( tr( "Refresh" ), topbar ); + _refresh->setIconSet( image_refresh ); + _refresh->setFocusPolicy( NoFocus ); connect( _refresh, SIGNAL( clicked() ), this, SLOT( slotListeSelect() ) ); QToolTip::add( _refresh, "", toolTipGroup(), tr("Immediately updates list of components") ); @@ -141,9 +222,18 @@ RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) */ _interval = new QPushButton( tr( "Interval" ), topbar ); + _interval->setIconSet( image_interval ); + _interval->setFocusPolicy( NoFocus ); connect( _interval, SIGNAL( clicked() ), this, SLOT( slotSelectRefresh() ) ); QToolTip::add( _interval, "", toolTipGroup(), tr("Changes refresh interval") ); + topbar->addSeparator(); + _close = new QPushButton( tr("Close"), topbar ); + _close->setIconSet( image_close ); + _close->setFocusPolicy( NoFocus ); + connect( _close, SIGNAL( clicked() ), this, SLOT( close() ) ); + QToolTip::add( _close, "", toolTipGroup(), tr("Closes Registry window") ); + // Display area and associated slots definition _tabWidget = new QTabWidget( this ); _clients = new QListView( _tabWidget ); @@ -198,6 +288,18 @@ bool RegWidget::eventFilter( QObject* object, QEvent* event ) else if ( object == myIntervalWindow && event->type() == QEvent::Close ) { myIntervalWindow = 0; } + else if ( object == _clients && event->type() == QEvent::KeyPress ) { + QKeyEvent* ke = (QKeyEvent*)event; + if ( ke->key() == Key_Enter || ke->key() == Key_Return ) { + slotClientChanged( _clients->currentItem() ); + } + } + else if ( object == _history && event->type() == QEvent::KeyPress ) { + QKeyEvent* ke = (QKeyEvent*)event; + if ( ke->key() == Key_Enter || ke->key() == Key_Return ) { + slotHistoryChanged( _history->currentItem() ); + } + } } return QMainWindow::eventFilter( object, event ); } @@ -317,6 +419,8 @@ void RegWidget::closeEvent( QCloseEvent *e) void RegWidget::SetListe() { BEGIN_OF("SetListe"); + _clients->installEventFilter( this ); + _clients->setAllColumnsShowFocus( true ); _clients->addColumn( tr( "Component" ), -1); _clients->addColumn( tr( "PID" ), -1 ); _clients->addColumn( tr( "User Name" ), -1 ); @@ -333,6 +437,8 @@ void RegWidget::SetListe() void RegWidget::SetListeHistory() { BEGIN_OF("SetListeHistory") + _history->installEventFilter( this ); + _history->setAllColumnsShowFocus( true ); _history->addColumn( tr( "Component" ), -1); _history->addColumn( tr( "PID" ), -1 ); _history->addColumn( tr( "User Name" ), -1 ); @@ -582,6 +688,16 @@ void InfoWindow::setText( const QString& text ) myTextView->setText( text ); } +/*! + Key press event +*/ +void InfoWindow::keyPressEvent( QKeyEvent * e ) +{ + QMainWindow::keyPressEvent( e ); + if ( e->key() == Key_Escape ) + close(); +} + static const char* SEPARATOR = ":"; QString findFile( QString filename ) diff --git a/src/RegistryDisplay/RegWidget.hxx b/src/RegistryDisplay/RegWidget.hxx index 556d26727..697c12a4f 100644 --- a/src/RegistryDisplay/RegWidget.hxx +++ b/src/RegistryDisplay/RegWidget.hxx @@ -85,6 +85,7 @@ protected : QTabWidget* _tabWidget; QPushButton* _refresh; QPushButton* _interval; + QPushButton* _close; QTimer* _counter; Registry::AllInfos* _serverhistory; Registry::AllInfos* _serverclients; @@ -105,6 +106,9 @@ public: void setText( const QString& text ); QTextView* textView() const { return myTextView; } +protected: + void keyPressEvent( QKeyEvent * e ); + private: QTextView* myTextView; -- 2.39.2