From daf54c0c4b19782e6223e2ad88193b72fba30d3d Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Mon, 9 Apr 2007 00:25:21 +0000 Subject: [PATCH] dhb move functions that were not slots from the slots part of mainwin.h Add code to set the color of undocked treeWidgetItems in the page selector window to blue if undocked. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4527 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/mainwin.cpp | 22 ++++++++++++++++++++-- bacula/src/qt-console/mainwin.h | 6 +++--- bacula/src/qt-console/pages.cpp | 6 ++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 4f1300095c..3fd51f1b31 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -45,7 +45,6 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) treeWidget->clear(); treeWidget->setColumnCount(1); treeWidget->setHeaderLabel("Select Page"); -// treeWidget->addAction(actionUndock); treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); m_pages = 0; @@ -281,7 +280,6 @@ void MainWin::treeItemDoubleClicked(QTreeWidgetItem * /*item*/, int /*column*/) /* * Called with a change of the highlighed tree widget item in the page selector. */ - void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem) { int treeindex; @@ -459,6 +457,26 @@ void MainWin::setContextMenuDockText( Pages* page, QTreeWidgetItem* item ) docktext += item->text(0) += " Window"; actionToggleDock->setText(docktext); + setTreeWidgetItemDockColor(page, item); +} + +/* + * Function to set the color of the tree widget item based on whether it is + * docked or not. + */ +void MainWin::setTreeWidgetItemDockColor( Pages* page, QTreeWidgetItem* item ) +{ + if( item->text(0) != "Console" ){ + if( page->isDocked() ){ + /* Set the brush to blue if undocked */ + QBrush blackBrush(Qt::black); + item->setForeground(0, blackBrush); + } else { + /* Set the brush back to black if docked */ + QBrush blueBrush(Qt::blue); + item->setForeground(0, blueBrush); + } + } } void MainWin::stackItemChanged(int) diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 87af42f73a..21f6cfa956 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -60,7 +60,9 @@ public: void writeSettings(); void readSettings(); void resetFocus() { lineEdit->setFocus(); }; - + void setContextMenuDockText(); + void setContextMenuDockText(Pages *, QTreeWidgetItem *); + void setTreeWidgetItemDockColor(Pages *, QTreeWidgetItem *); public slots: void input_line(); @@ -74,8 +76,6 @@ public slots: void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *); void stackItemChanged(int); void toggleDockContextWindow(); - void setContextMenuDockText(); - void setContextMenuDockText(Pages *, QTreeWidgetItem *); protected: void closeEvent(QCloseEvent *event); diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index a3b076fb1c..19d225f4da 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -32,6 +32,7 @@ */ #include "pages.h" +#include "bat.h" /* * dockPage @@ -108,6 +109,11 @@ void Pages::closeEvent(QCloseEvent* /*event*/) { /* A Widget was closed, lets toggle it back into the window, and set it in front. */ dockPage(); + mainWin->setContextMenuDockText(); +// setTreeWidgetItemDockColor(page, item); +// foreach(Pages *page, m_pagehash){ +// if +// } #ifdef xxx /* FIXME Really having problems getting it to the front, -- 2.39.5