From c89ef0ffae597ac8c1063732e1d9a2d84703a80c Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 26 Nov 2009 22:44:00 +0000 Subject: Allow the XmlConsole to be closed, and there to be only one. Resolves: #261 Resolve: #262 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: Swift/Controllers/UIInterfaces/XMLConsoleWidget.h # modified: Swift/Controllers/XMLConsoleController.cpp # modified: Swift/QtUI/QtXMLConsoleWidget.cpp # modified: Swift/QtUI/QtXMLConsoleWidget.h # # Untracked files: # (use "git add ..." to include in what will be committed) # # src/ diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h index 69628df..efde1a2 100644 --- a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h @@ -2,6 +2,7 @@ namespace Swift { class XMLConsoleWidget { - + public: + virtual void show() = 0; }; } diff --git a/Swift/Controllers/XMLConsoleController.cpp b/Swift/Controllers/XMLConsoleController.cpp index 8bd79ed..810e8a6 100644 --- a/Swift/Controllers/XMLConsoleController.cpp +++ b/Swift/Controllers/XMLConsoleController.cpp @@ -9,12 +9,16 @@ XMLConsoleController::XMLConsoleController(UIEventStream* uiEventStream, XMLCons uiEventStream_ = uiEventStream; xmlConsoleWidgetFactory_ = xmlConsoleWidgetFactory; uiEventStream_->onUIEvent.connect(boost::bind(&XMLConsoleController::handleUIEvent, this, _1)); + xmlConsoleWidget_ = NULL; } void XMLConsoleController::handleUIEvent(boost::shared_ptr rawEvent) { boost::shared_ptr event = boost::dynamic_pointer_cast(rawEvent); if (event != NULL) { - xmlConsoleWidget_ = xmlConsoleWidgetFactory_->createXMLConsoleWidget(); + if (xmlConsoleWidget_ == NULL) { + xmlConsoleWidget_ = xmlConsoleWidgetFactory_->createXMLConsoleWidget(); + } + xmlConsoleWidget_->show(); } } diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp index d2ebb06..7553d06 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.cpp +++ b/Swift/QtUI/QtXMLConsoleWidget.cpp @@ -1,7 +1,29 @@ #include "QtXMLConsoleWidget.h" +#include + namespace Swift { QtXMLConsoleWidget::QtXMLConsoleWidget() { } + +void QtXMLConsoleWidget::showEvent(QShowEvent* event) { + emit windowOpening(); + QWidget::showEvent(event); +} + +void QtXMLConsoleWidget::show() { + QWidget::show(); + emit windowOpening(); +} + +void QtXMLConsoleWidget::activate() { + emit wantsToActivate(); +} + +void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) { + emit windowClosing(); + event->accept(); +} + } diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h index f545e18..50b53f2 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.h +++ b/Swift/QtUI/QtXMLConsoleWidget.h @@ -8,5 +8,11 @@ namespace Swift { Q_OBJECT public: QtXMLConsoleWidget(); + void show(); + void activate(); + protected slots: + void closeEvent(QCloseEvent* event); + protected: + void showEvent(QShowEvent* event); }; } -- cgit v0.10.2-6-g49f6