[StdCmdSendToPythonConsole] make python console visible if not already visible and set keyboard focus to it when invoking the send to python console command
This commit is contained in:
@@ -22,12 +22,17 @@
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QDockWidget>
|
||||
#endif
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "CommandT.h"
|
||||
#include "DockWindowManager.h"
|
||||
#include "Document.h"
|
||||
#include "PythonConsole.h"
|
||||
#include "Selection.h"
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProviderDocumentObject.h"
|
||||
@@ -161,6 +166,24 @@ void StdCmdSendToPythonConsole::activated(int iMsg)
|
||||
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
|
||||
}
|
||||
}
|
||||
//show the python console if it's not already visible, and set the keyboard focus to it
|
||||
QWidget* pc = DockWindowManager::instance()->getDockWindow("Python console");
|
||||
PythonConsole *pcPython = qobject_cast<PythonConsole*>(pc);
|
||||
if (pcPython){
|
||||
QDockWidget* dw = nullptr;
|
||||
QWidget* par = pcPython->parentWidget();
|
||||
while (par){
|
||||
dw = qobject_cast<QDockWidget*>(par);
|
||||
if (dw){
|
||||
break;
|
||||
}
|
||||
par = par->parentWidget();
|
||||
}
|
||||
if (dw && !dw->toggleViewAction()->isChecked()){
|
||||
dw->toggleViewAction()->activate(QAction::Trigger);
|
||||
}
|
||||
pcPython->setFocus();
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
e.ReportException();
|
||||
|
||||
Reference in New Issue
Block a user