Skip to content

Commit

Permalink
Remove console window and pipe everything to results log. Refs #6202
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Apr 15, 2013
1 parent d34793f commit d294b5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 76 deletions.
70 changes: 2 additions & 68 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args)
explorerSplitter->setSizes( splitterSizes << 45 << 45);
explorerWindow->hide();


consoleWindow = new QDockWidget(this);
consoleWindow->setObjectName("consoleWindow"); // this is needed for QMainWindow::restoreState()
consoleWindow->setWindowTitle(tr("Scripting Console"));
addDockWidget( Qt::TopDockWidgetArea, consoleWindow );
console = new QTextEdit(consoleWindow);
console->setReadOnly(true);
console->setContextMenuPolicy(Qt::CustomContextMenu);
connect(console, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(showScriptConsoleContextMenu(const QPoint &)));
consoleWindow->setWidget(console);
consoleWindow->hide();
// Interpreter
m_interpreterDock = new QDockWidget(this);
m_interpreterDock->setObjectName("interpreterDock"); // this is needed for QMainWindow::restoreState()
m_interpreterDock->setWindowTitle("Script Interpreter");
Expand Down Expand Up @@ -571,14 +560,6 @@ bool ApplicationWindow::hasParaviewPath() const
return config.hasProperty("paraview.path");
}

void ApplicationWindow::showScriptConsoleContextMenu(const QPoint &p)
{
(void)p;
QMenu *menu = console->createStandardContextMenu();
menu->addAction(actionClearConsole);
menu->popup(QCursor::pos());
}

void ApplicationWindow::initWindow()
{
switch(d_init_window_type){
Expand Down Expand Up @@ -1041,7 +1022,6 @@ void ApplicationWindow::insertTranslatedStrings()
explorerWindow->setWindowTitle(tr("Project Explorer"));
logWindow->setWindowTitle(tr("Results Log"));
undoStackWindow->setWindowTitle(tr("Undo Stack"));
consoleWindow->setWindowTitle(tr("Scripting Console"));
displayBar->setWindowTitle(tr("Data Display"));
plotTools->setWindowTitle(tr("Plot"));
standardTools->setWindowTitle(tr("Standard Tools"));
Expand Down Expand Up @@ -1081,11 +1061,8 @@ void ApplicationWindow::initMainMenu()

view->setCheckable(true);

//view->addAction(actionShowPlotWizard);
view->addAction(actionShowExplorer);
view->addAction(actionShowLog);
//view->addAction(actionShowUndoStack);
view->addAction(actionShowConsole);

view->insertSeparator();
view->addAction(actionShowScriptWindow);//Mantid
Expand Down Expand Up @@ -4692,40 +4669,6 @@ ApplicationWindow* ApplicationWindow::openProject(const QString& fn, bool factor
return app;
}

void ApplicationWindow::scriptPrint(const QString &msg, bool error, bool timestamp)
{
if( error || msg.contains("error",Qt::CaseInsensitive) )
{
console->setTextColor(Qt::red);
consoleWindow->show();
}
else
{
console->setTextColor(Qt::black);
}
QString msg_to_print = msg;

if( error || timestamp )
{
if( timestamp )
{
QString separator(100, '-');
msg_to_print = separator + "\n" + QDateTime::currentDateTime().toString()
+ ": " + msg.trimmed() + "\n" + separator + '\n';
}

// Check for last character being a new line character unless we are at the start of the
// scroll area
if( !console->text().endsWith('\n') && console->textCursor().position() != 0 )
{
console->textCursor().insertText("\n");
}
}

console->textCursor().insertText(msg_to_print);
console->moveCursor(QTextCursor::End);
}

bool ApplicationWindow::setScriptingLanguage(const QString &lang)
{
if ( lang.isEmpty() ) return false;
Expand Down Expand Up @@ -12587,8 +12530,6 @@ void ApplicationWindow::createActions()

actionShowUndoStack = undoStackWindow->toggleViewAction();

actionShowConsole = consoleWindow->toggleViewAction();

actionAddLayer = new QAction(QIcon(getQPixmap("newLayer_xpm")), tr("Add La&yer"), this);
actionAddLayer->setShortcut( tr("Alt+L") );
connect(actionAddLayer, SIGNAL(activated()), this, SLOT(addLayer()));
Expand Down Expand Up @@ -12626,9 +12567,6 @@ void ApplicationWindow::createActions()
actionCloseAllWindows->setShortcut( tr("Ctrl+Q") );
connect(actionCloseAllWindows, SIGNAL(activated()), qApp, SLOT(closeAllWindows()));

actionClearConsole = new QAction(tr("Clear &Console"), this);
connect(actionClearConsole, SIGNAL(activated()), console, SLOT(clear()));

actionDeleteFitTables = new QAction(QIcon(getQPixmap("close_xpm")), tr("Delete &Fit Tables"), this);
connect(actionDeleteFitTables, SIGNAL(activated()), this, SLOT(deleteFitTables()));

Expand Down Expand Up @@ -13446,9 +13384,6 @@ void ApplicationWindow::translateActionsStrings()
actionShowUndoStack->setMenuText(tr("&Undo/Redo Stack"));
actionShowUndoStack->setToolTip(tr("Show available undo/redo commands"));

actionShowConsole->setMenuText(tr("&Console"));
actionShowConsole->setToolTip(tr("Show Scripting console"));

#ifdef SCRIPTING_PYTHON
actionShowScriptWindow->setMenuText(tr("&Script Window"));
actionShowScriptWindow->setToolTip(tr("Script Window"));
Expand Down Expand Up @@ -13489,7 +13424,6 @@ void ApplicationWindow::translateActionsStrings()
actionCloseAllWindows->setMenuText(tr("&Quit"));
actionCloseAllWindows->setShortcut(tr("Ctrl+Q"));

actionClearConsole->setMenuText(tr("Clear &Console"));
actionDeleteFitTables->setMenuText(tr("Delete &Fit Tables"));

actionToolBars->setMenuText(tr("&Toolbars..."));
Expand Down Expand Up @@ -16364,7 +16298,7 @@ void ApplicationWindow::executeScriptFile(const QString & filename, const Script
* @param code :: An arbitrary string of python code
* @param async :: If true the code will be run asynchronously but only if it is called from the GUI thread
* @param quiet :: If true then no output is produced concerning script start/finished
* @param redirect :: If true redirect stdout/stderr to script console
* @param redirect :: If true redirect stdout/stderr to results log
*/
bool ApplicationWindow::runPythonScript(const QString & code, bool async,
bool quiet, bool redirect)
Expand Down
9 changes: 1 addition & 8 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,6 @@ public slots:
//@{
//! show scripting language selection dialog
void showScriptingLangDialog();
//! print to scripting console (if available) or to stdout
void scriptPrint(const QString &text,bool error = false, bool timestamp = false);
//! switches to the given scripting language;
bool setScriptingLanguage(const QString &lang);

Expand Down Expand Up @@ -1161,8 +1159,6 @@ public slots:
void tileMdiWindows();
void shakeViewport();

/// context menu for scripting console
void showScriptConsoleContextMenu(const QPoint &p);
///
void showMantidConcepts();

Expand Down Expand Up @@ -1396,8 +1392,6 @@ public slots:
QTranslator *appTranslator, *qtTranslator;
QDockWidget *explorerWindow, *undoStackWindow;
MantidQt::API::MessageDisplay *resultsLog;
QDockWidget *consoleWindow;
QTextEdit *console;
QDockWidget *m_interpreterDock;
CommandLineInterpreter *m_scriptInterpreter;
QMdiArea *d_workspace;
Expand All @@ -1423,11 +1417,10 @@ public slots:
QAction *actionCutSelection, *actionCopySelection, *actionPasteSelection, *actionClearSelection;
QAction *actionShowExplorer, *actionShowLog, *actionAddLayer, *actionShowLayerDialog, *actionAutomaticLayout,*actionclearAllMemory, *actionreleaseFreeMemory;
QAction *actionICatLogin,*actionICatSearch,*actionMydataSearch,*actionICatLogout,*actionAdvancedSearch;
QAction *actionShowConsole;
QAction *actionSwapColumns, *actionMoveColRight, *actionMoveColLeft, *actionMoveColFirst, *actionMoveColLast;
QAction *actionExportGraph, *actionExportAllGraphs, *actionPrint, *actionPrintAllPlots, *actionShowExportASCIIDialog;
QAction *actionExportPDF, *actionReadOnlyCol, *actionStemPlot;
QAction *actionCloseAllWindows, *actionClearConsole, *actionShowPlotWizard, *actionShowConfigureDialog;
QAction *actionCloseAllWindows, *actionShowPlotWizard, *actionShowConfigureDialog;
QAction *actionShowCurvesDialog, *actionAddErrorBars, *actionRemoveErrorBars, *actionAddFunctionCurve, *actionUnzoom, *actionNewLegend, *actionAddImage;
QAction *actionPlotL, *actionPlotP, *actionPlotLP, *actionPlotVerticalDropLines, *actionPlotSpline;
QAction *actionPlotVertSteps, *actionPlotHorSteps, *actionPlotVerticalBars;
Expand Down

0 comments on commit d294b5f

Please sign in to comment.