A bunch of upstream patches:
* fix loading icons in some examples
* allow pasting multiple lines
* remember the last dir to open/save macro files
* do not throw errors during menu creation when using '/control/verbose 0'
--- source/interfaces/basic/include/G4UIQt.hh.orig
+++ source/interfaces/basic/include/G4UIQt.hh
@@ -215,6 +215,8 @@ private:
QToolBar *fToolbarApp;
QToolBar *fToolbarUser;
+ G4String fLastErrMessage;
+ QString fLastOpenPath;
bool fMoveSelected;
bool fRotateSelected;
@@ -226,6 +228,7 @@ private Q_SLOTS :
void ExitSession();
void ClearButtonCallback();
void CommandEnteredCallback();
+ void CommandEditedCallback(const QString &);
void ButtonCallback(const QString&);
void HelpTreeClicCallback();
void HelpTreeDoubleClicCallback();
--- source/interfaces/basic/src/G4UIQt.cc.orig
+++ source/interfaces/basic/src/G4UIQt.cc
@@ -131,6 +131,7 @@ G4UIQt::G4UIQt (
,fPickSelected(false)
,fZoomInSelected(false)
,fZoomOutSelected(false)
+,fLastOpenPath("")
{
G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
@@ -270,6 +271,7 @@ G4UIQt::G4UIQt (
// Connect signal
connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
+ connect(fCommandArea, SIGNAL(textEdited(const QString &)), SLOT(CommandEditedCallback(const QString &)));
connect(fUITabWidget, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
@@ -720,10 +722,10 @@ G4int G4UIQt::ReceiveG4cout (
QStringList result = newStr.filter(fCoutFilter->text());
- if (result.join("\n").isEmpty()) {
+ if (result.join("").isEmpty()) {
return 0;
}
- fCoutTBTextArea->append(result.join("\n"));
+ fCoutTBTextArea->append(result.join(""));
fCoutTBTextArea->repaint();
fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
@@ -753,7 +755,11 @@ G4int G4UIQt::ReceiveG4cerr (
// Suppress space, \n,\t,\r...
if (QString(aString.data()).trimmed() != "") {
- QMessageBox::critical(fMainWindow, "Error",aString.data());
+ if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
+ (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit )) {
+ // In case of Abort or Quit, the useful error message should be in the last error message !
+ QMessageBox::critical(fMainWindow, "Error",QString(fLastErrMessage.data())+"\n"+aString.data());
+ }
}
QColor previousColor = fCoutTBTextArea->textColor();
fCoutTBTextArea->setTextColor(Qt::red);
@@ -761,6 +767,10 @@ G4int G4UIQt::ReceiveG4cerr (
fCoutTBTextArea->setTextColor(previousColor);
fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
fCoutTBTextArea->repaint();
+
+ if (QString(aString.data()).trimmed() != "") {
+ fLastErrMessage = aString;
+ }
return 0;
}
@@ -805,9 +815,14 @@ void G4UIQt::AddButton (
QMenu *parentTmp = (QMenu*)GetInteractor(aMenu);
if(parentTmp==NULL) {
- G4cout << "Menu name " << aMenu<< " does not exist, please define it before using it."<< G4endl;
+ G4UImanager* UImanager = G4UImanager::GetUIpointer();
+ G4int verbose = UImanager->GetVerboseLevel();
+
+ if (verbose >= 2) {
+ G4cout << "Menu name " << aMenu<< " does not exist, please define it before using it."<< G4endl;
+ }
}