From f9da20f097ccebed845c9f487db2303a0764f2d1 Mon Sep 17 00:00:00 2001 From: jriegel Date: Thu, 20 Dec 2012 19:10:29 +0100 Subject: [PATCH] fix of #917 --- src/Gui/TaskView/TaskWatcher.cpp | 25 +++++++++++++++++++++++++ src/Gui/TaskView/TaskWatcher.h | 17 +++++++++++++++++ src/Mod/PartDesign/Gui/Workbench.cpp | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Gui/TaskView/TaskWatcher.cpp b/src/Gui/TaskView/TaskWatcher.cpp index d32809ed2..e3143ddfe 100644 --- a/src/Gui/TaskView/TaskWatcher.cpp +++ b/src/Gui/TaskView/TaskWatcher.cpp @@ -143,5 +143,30 @@ bool TaskWatcherCommandsEmptyDoc::shouldShow() return doc && doc->countObjects() == 0; } +//************************************************************************** +//************************************************************************** +// TaskWatcherCommandsEmptySelection +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +TaskWatcherCommandsEmptySelection::TaskWatcherCommandsEmptySelection(const char* commands[], + const char* name, + const char* pixmap ) + : TaskWatcherCommands(0,commands,name,pixmap) +{ +} + +TaskWatcherCommandsEmptySelection::~TaskWatcherCommandsEmptySelection() +{ +} + +//==== implementer =========================================================================== + + +//==== calls from the TaskView =============================================================== + +bool TaskWatcherCommandsEmptySelection::shouldShow() +{ + return (App::GetApplication().getActiveDocument() && Gui::Selection().size() == 0); +} #include "moc_TaskWatcher.cpp" diff --git a/src/Gui/TaskView/TaskWatcher.h b/src/Gui/TaskView/TaskWatcher.h index c5e1cdd16..df7bdbf7f 100644 --- a/src/Gui/TaskView/TaskWatcher.h +++ b/src/Gui/TaskView/TaskWatcher.h @@ -97,6 +97,23 @@ public: }; +// -------------------------------------------------------------------------- + +/// Special watcher class for showing commands when there is nothing selected +class GuiExport TaskWatcherCommandsEmptySelection : public TaskWatcherCommands +{ + Q_OBJECT + +public: + TaskWatcherCommandsEmptySelection(const char* commands[], const char* name, const char* pixmap); + ~TaskWatcherCommandsEmptySelection(); + +public: + /// is called wenn the document or the Selection changes. + virtual bool shouldShow(void); + +}; + } //namespace TaskView diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 5a11069c1..1cdb6c3ca 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -140,7 +140,7 @@ void Workbench::activated() "Part_Box", "Part_Cylinder", 0}; - Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptyDoc( + Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptySelection( Empty, "Create Geometry", "Part_Box"