From c510345ff6600229b9b7c9d993376fbe577d5848 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 7 Sep 2019 15:48:16 +0200 Subject: [PATCH] move Save history action to the correct position in the context-menu, do some minor optimizations --- src/Gui/PythonConsole.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index c2eebbbe6d..aa1c95c957 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -1235,6 +1235,9 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) QAction *a; bool mayPasteHere = cursorBeyond( this->textCursor(), this->inputBegin() ); + ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General"); + a = menu.addAction(tr("&Copy"), this, SLOT(copy()), Qt::CTRL+Qt::Key_C); a->setEnabled(textCursor().hasSelection()); @@ -1247,6 +1250,11 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) a = menu.addAction( tr("Save history as..."), this, SLOT(onSaveHistoryAs())); a->setEnabled(!d->history.isEmpty()); + QAction* saveh = menu.addAction(tr("Save history")); + saveh->setToolTip(tr("Saves Python history across %1 sessions").arg(qApp->applicationName())); + saveh->setCheckable(true); + saveh->setChecked(hGrp->GetBool("SavePythonHistory", false)); + menu.addSeparator(); a = menu.addAction(tr("&Paste"), this, SLOT(paste()), Qt::CTRL+Qt::Key_V); @@ -1266,8 +1274,6 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) QAction* wrap = menu.addAction(tr("Word wrap")); wrap->setCheckable(true); - ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("General"); if (hGrp->GetBool("PythonWordWrap", true)) { wrap->setChecked(true); this->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@ -1276,16 +1282,6 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) this->setWordWrapMode(QTextOption::NoWrap); } - QAction* saveh = menu.addAction(tr("Save history")); - saveh->setToolTip(tr("Saves python history across FreeCAD sessions")); - saveh->setCheckable(true); - - if (hGrp->GetBool("SavePythonHistory", false)) { - saveh->setChecked(true); - } else { - saveh->setChecked(false); - } - QAction* exec = menu.exec(e->globalPos()); if (exec == wrap) { if (wrap->isChecked()) { @@ -1296,13 +1292,8 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) hGrp->SetBool("PythonWordWrap", false); } } else if (exec == saveh) { - if (saveh->isChecked()) { - hGrp->SetBool("SavePythonHistory", true); - } else { - hGrp->SetBool("SavePythonHistory", false); - } + hGrp->SetBool("SavePythonHistory", saveh->isChecked()); } - } void PythonConsole::onClearConsole()