From: Dirk H Bartley Date: Sun, 8 Apr 2007 17:17:33 +0000 (+0000) Subject: dhb use the stack widget signal currentChanged to trigger function X-Git-Tag: Release-7.0.0~6603 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ad7f765d6b31462fd154223359b6d16a57aa4a63;p=bacula%2Fbacula dhb use the stack widget signal currentChanged to trigger function stackItemChanged to call pages virtual function currentStackItem. This prevents a window becoming the top visible window without getting the chance to populate it's screen. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4525 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 51cf958ed2..01a0b00311 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -196,6 +196,8 @@ void MainWin::createConnections() connect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + connect(stackedWidget, SIGNAL(currentChanged(int)), + this, SLOT(stackItemChanged(int))); connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); connect(actionConnect, SIGNAL(triggered()), m_console, SLOT(connect())); @@ -307,8 +309,6 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre /* put this page on the top of the stack */ stackedWidget->setCurrentIndex(stackindex); } - /* run the virtual function in case this class overrides it */ - page->PgSeltreeWidgetCurrentItem(); setContextMenuDockText(page, currentitem); treeWidget->addAction(actionToggleDock); @@ -411,6 +411,9 @@ void MainWin::toggleDockContextWindow() if( m_pagehash.value(treeindex) ){ Pages* page = m_pagehash.value(treeindex); page->togglePageDocking(); + if ( page->isDocked() ){ + stackedWidget->setCurrentWidget(page); + } /* Toggle the menu item. The window's dock status has been toggled */ setContextMenuDockText(page, currentitem); } @@ -453,3 +456,10 @@ void MainWin::setContextMenuDockText( Pages* page, QTreeWidgetItem* item ) actionToggleDock->setText(docktext); } + +void MainWin::stackItemChanged(int) +{ + Pages* page = (Pages*)stackedWidget->currentWidget(); + /* run the virtual function in case this class overrides it */ + page->currentStackItem(); +} diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index a563e627dd..87af42f73a 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -72,6 +72,7 @@ public slots: void restoreDialogClicked(); void undockWindowButton(); void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); + void stackItemChanged(int); void toggleDockContextWindow(); void setContextMenuDockText(); void setContextMenuDockText(Pages *, QTreeWidgetItem *); diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index f21b68b074..13c14d0fef 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -232,9 +232,9 @@ void MediaList::createContextMenu() } /* - * Virtual function which is called when this page is selected in the page selector tree + * Virtual function which is called when this page is visible on the stack */ -void MediaList::PgSeltreeWidgetCurrentItem() +void MediaList::currentStackItem() { if(!m_populated) { populateTree(); diff --git a/bacula/src/qt-console/medialist/medialist.h b/bacula/src/qt-console/medialist/medialist.h index 3ab3eb32f4..875da89d7b 100644 --- a/bacula/src/qt-console/medialist/medialist.h +++ b/bacula/src/qt-console/medialist/medialist.h @@ -47,7 +47,7 @@ public: ~MediaList(); virtual void PgSeltreeWidgetClicked(); virtual void PgSeltreeWidgetDoubleClicked(); - virtual void PgSeltreeWidgetCurrentItem(); + virtual void currentStackItem(); public slots: void treeItemClicked(QTreeWidgetItem *item, int column); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index fb262a8b5b..a3b076fb1c 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -65,7 +65,7 @@ void Pages::undockPage() /* Change from a stacked widget to a normal window */ m_parent->removeWidget(this); setWindowFlags(Qt::Window); - showNormal(); + show(); /* Clear docked flag */ m_docked = false; } @@ -99,7 +99,7 @@ bool Pages::isDocked() /* * When a window is closed, this slot is called. The idea is to put it back in the * stack here, and it works. I wanted to get it to the top of the stack so that the - * user immediately sees where his window went. Also, if he floats the window, then + * user immediately sees where his window went. Also, if he undocks the window, then * closes it with the tree item highlighted, it may be confusing that the highlighted * treewidgetitem is not the stack item in the front. */ @@ -117,21 +117,25 @@ printf("In Pages closeEvent a\n"); if( stackindex >= 0 ){ printf("In Pages closeEvent b\n"); m_parent->setCurrentIndex(0); - //m_parent->setCurrentIndex(stackindex); m_parent->setCurrentWidget(this); - m_parent->update(); + show(); + //m_parent->setCurrentIndex(stackindex); +// m_parent->setCurrentWidget(this); +/* m_parent->update(); update(); setUpdatesEnabled(true); + setVisible(true); m_parent->show(); show(); - m_parent->repaint(); + m_parent->repaint();*/ repaint(); + raise(); } #endif } /* - * The next two are virtual functions. The idea here is that each subclass will have the + * The next three are virtual functions. The idea here is that each subclass will have the * built in virtual function to override if the programmer wants to populate the window * when it it is first clicked. */ @@ -143,12 +147,15 @@ void Pages::PgSeltreeWidgetDoubleClicked() { } -void Pages::PgSeltreeWidgetCurrentItem() +/* + * * Virtual function which is called when this page is visible on the stack + */ +void Pages::currentStackItem() { } /* - * This function exists because I wanted to have an easy way for new programmers to understand + * This function exists because to have an easy way for programmers adding new features to understand * exactly what values needed to be set in order to behave correctly in the interface. It can * be called from the constructor, like with medialist or after being constructed, like with * Console. diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index 5840ce0929..8ed8920875 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -63,7 +63,7 @@ public: void SetPassedValues(QStackedWidget*, QTreeWidgetItem*, int ); virtual void PgSeltreeWidgetClicked(); virtual void PgSeltreeWidgetDoubleClicked(); - virtual void PgSeltreeWidgetCurrentItem(); + virtual void currentStackItem(); public slots: /* closeEvent is a virtual function inherited from QWidget */