105#include <QApplication>
106#include <QFontDatabase>
111#include <QFileDialog>
112#include <QtPrintSupport/QPrinter>
113#include <QtPrintSupport/QPrintDialog>
114#include <QColorDialog>
116#include <QMessageBox>
118#include <QTextCursor>
120#include <QTextDocumentFragment>
123#include <QFileSystemWatcher>
124#include <QDesktopServices>
126#include <QRegularExpression>
127#include <QElapsedTimer>
157 : QMainWindow( parent )
160 fAdmin = std::make_unique<PAdmin>();
182 QMessageBox::information(
this,
"ERROR",
"Couldn't invoke QFileSystemWatcher!");
199 fTabWidget = std::make_unique<QTabWidget>(
this );
206 QString iconName(
"");
208 iconName = QString(
":/icons/musrfit-dark.svg");
210 iconName = QString(
":/icons/musrfit-plain.svg");
211 setWindowIcon( QIcon( iconName ) );
214 if ( qApp->arguments().size() != 1 ) {
215 for (
int i = 1; i < qApp->arguments().size(); ++i )
216 load( qApp->arguments()[ i ] );
279 QToolBar *tb =
new QToolBar(
this );
280 tb->setWindowTitle(
"File Actions" );
283 QMenu *menu =
new QMenu( tr(
"F&ile" ),
this );
284 menuBar()->addMenu( menu );
287 QString iconName(
"");
291 iconName = QString(
":/icons/document-new-dark.svg");
293 iconName = QString(
":/icons/document-new-plain.svg");
294 a =
new QAction( QIcon( iconName ), tr(
"&New..." ),
this );
295 a->setShortcut( tr(
"Ctrl+N") );
296 a->setStatusTip( tr(
"Create a new msr-file") );
297 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileNew() ) );
302 iconName = QString(
":/icons/document-new-plain.svg");
303 a =
new QAction( QIcon( iconName ), tr(
"&New..." ),
this );
304 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileNew() ) );
311 iconName = QString(
":/icons/document-open-dark.svg");
313 iconName = QString(
":/icons/document-open-plain.svg");
314 a =
new QAction( QIcon( iconName ), tr(
"&Open..." ),
this );
315 a->setShortcut( tr(
"Ctrl+O") );
316 a->setStatusTip( tr(
"Opens a msr-file") );
317 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileOpen() ) );
322 iconName = QString(
":/icons/document-open-plain.svg");
323 a =
new QAction( QIcon( iconName ), tr(
"&Open..." ),
this );
324 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileOpen() ) );
341 iconName = QString(
":/icons/view-refresh-dark.svg");
343 iconName = QString(
":/icons/view-refresh-plain.svg");
344 a =
new QAction( QIcon( iconName ), tr(
"Reload..." ),
this );
345 a->setShortcut( tr(
"F5") );
346 a->setStatusTip( tr(
"Reload msr-file") );
347 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileReload() ) );
352 iconName = QString(
":/icons/view-refresh-plain.svg");
353 a =
new QAction( QIcon( iconName ), tr(
"Reload..." ),
this );
354 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileReload() ) );
359 a =
new QAction( tr(
"Open Prefs..." ),
this);
360 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileOpenPrefs() ) );
363 menu->addSeparator();
367 iconName = QString(
":/icons/document-save-dark.svg");
369 iconName = QString(
":/icons/document-save-plain.svg");
370 a =
new QAction( QIcon( iconName ), tr(
"&Save..." ),
this );
371 a->setShortcut( tr(
"Ctrl+S") );
372 a->setStatusTip( tr(
"Save msr-file") );
373 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileSave() ) );
378 iconName = QString(
":/icons/document-save-plain.svg");
379 a =
new QAction( QIcon( iconName ), tr(
"&Save..." ),
this );
380 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileSave() ) );
386 a =
new QAction( tr(
"Save &As..." ),
this );
387 a->setStatusTip( tr(
"Save msr-file As") );
388 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileSaveAs() ) );
392 a =
new QAction( tr(
"Save Prefs..." ),
this );
393 a->setStatusTip( tr(
"Save the preferences") );
394 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileSavePrefs() ) );
397 menu->addSeparator();
401 iconName = QString(
":/icons/document-print-dark.svg");
403 iconName = QString(
":/icons/document-print-plain.svg");
404 a =
new QAction( QIcon( iconName ), tr(
"&Print..." ),
this );
405 a->setShortcut( tr(
"Ctrl+P") );
406 a->setStatusTip( tr(
"Print msr-file") );
407 connect( a, SIGNAL( triggered() ),
this, SLOT(
filePrint() ) );
412 iconName = QString(
":/icons/document-print-plain.svg");
413 a =
new QAction( QIcon( iconName ), tr(
"&Print..." ),
this );
414 connect( a, SIGNAL( triggered() ),
this, SLOT(
filePrint() ) );
419 menu->addSeparator();
422 a =
new QAction( tr(
"&Close" ),
this );
423 a->setShortcut( tr(
"Ctrl+W") );
424 a->setStatusTip( tr(
"Close msr-file") );
425 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileClose() ) );
429 a =
new QAction( tr(
"Close &All" ),
this );
430 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileCloseAll() ) );
434 a =
new QAction( tr(
"Clo&se All Others" ),
this );
435 a->setShortcut( tr(
"Ctrl+Shift+W") );
436 a->setStatusTip( tr(
"Close All Other Tabs") );
440 menu->addSeparator();
443 a =
new QAction( tr(
"E&xit" ),
this );
444 a->setShortcut( tr(
"Ctrl+Q") );
445 a->setStatusTip( tr(
"Exit Program") );
446 connect( a, SIGNAL( triggered() ),
this, SLOT(
fileExit() ) );
461 QToolBar *tb =
new QToolBar(
this );
462 tb->setWindowTitle(
"Edit Actions" );
465 QMenu *menu =
new QMenu( tr(
"&Edit" ),
this );
466 menuBar()->addMenu( menu );
469 QString iconName(
"");
473 iconName = QString(
":/icons/edit-undo-dark.svg");
475 iconName = QString(
":/icons/edit-undo-plain.svg");
476 a =
new QAction( QIcon( iconName ), tr(
"&Undo" ),
this );
477 a->setShortcut( tr(
"Ctrl+Z") );
478 a->setStatusTip( tr(
"Edit Undo") );
479 connect( a, SIGNAL( triggered() ),
this, SLOT(
editUndo() ) );
484 iconName = QString(
":/icons/edit-undo-plain.svg");
485 a =
new QAction( QIcon( iconName ), tr(
"&Undo" ),
this );
486 connect( a, SIGNAL( triggered() ),
this, SLOT(
editUndo() ) );
493 iconName = QString(
":/icons/edit-redo-dark.svg");
495 iconName = QString(
":/icons/edit-redo-plain.svg");
496 a =
new QAction( QIcon( iconName ), tr(
"&Redo" ),
this );
497 a->setShortcut( tr(
"Ctrl+Y") );
498 a->setStatusTip( tr(
"Edit Redo") );
499 connect( a, SIGNAL( triggered() ),
this, SLOT(
editRedo() ) );
504 iconName = QString(
":/icons/edit-redo-plain.svg");
505 a =
new QAction( QIcon( iconName ), tr(
"&Redo" ),
this );
506 connect( a, SIGNAL( triggered() ),
this, SLOT(
editRedo() ) );
511 menu->addSeparator();
514 a =
new QAction( tr(
"Select &All" ),
this );
515 a->setShortcut( tr(
"Ctrl+A") );
516 a->setStatusTip( tr(
"Edit Select All") );
517 connect( a, SIGNAL( triggered() ),
this, SLOT(
editSelectAll() ) );
520 menu->addSeparator();
525 iconName = QString(
":/icons/edit-copy-dark.svg");
527 iconName = QString(
":/icons/edit-copy-plain.svg");
528 a =
new QAction( QIcon( iconName ), tr(
"&Copy" ),
this );
529 a->setShortcut( tr(
"Ctrl+C") );
530 a->setStatusTip( tr(
"Edit Copy") );
531 connect( a, SIGNAL( triggered() ),
this, SLOT(
editCopy() ) );
536 iconName = QString(
":/icons/edit-copy-plain.svg");
537 a =
new QAction( QIcon( iconName ), tr(
"&Copy" ),
this );
538 connect( a, SIGNAL( triggered() ),
this, SLOT(
editCopy() ) );
545 iconName = QString(
":/icons/edit-cut-dark.svg");
547 iconName = QString(
":/icons/edit-cut-plain.svg");
548 a =
new QAction( QIcon( iconName ), tr(
"Cu&t" ),
this );
549 a->setShortcut( tr(
"Ctrl+X") );
550 a->setStatusTip( tr(
"Edit Cut") );
551 connect( a, SIGNAL( triggered() ),
this, SLOT(
editCut() ) );
556 iconName = QString(
":/icons/edit-cut-plain.svg");
557 a =
new QAction( QIcon( iconName ), tr(
"Cu&t" ),
this );
558 connect( a, SIGNAL( triggered() ),
this, SLOT(
editCut() ) );
565 iconName = QString(
":/icons/edit-paste-dark.svg");
567 iconName = QString(
":/icons/edit-paste-plain.svg");
568 a =
new QAction( QIcon( iconName ), tr(
"&Paste" ),
this );
569 a->setShortcut( tr(
"Ctrl+V") );
570 a->setStatusTip( tr(
"Edit Paste") );
571 connect( a, SIGNAL( triggered() ),
this, SLOT(
editPaste() ) );
576 iconName = QString(
":/icons/edit-paste-plain.svg");
577 a =
new QAction( QIcon( iconName ), tr(
"&Paste" ),
this );
578 connect( a, SIGNAL( triggered() ),
this, SLOT(
editPaste() ) );
583 menu->addSeparator();
588 iconName = QString(
":/icons/edit-find-dark.svg");
590 iconName = QString(
":/icons/edit-find-plain.svg");
591 a =
new QAction( QIcon( iconName ), tr(
"&Find" ),
this );
592 a->setShortcut( tr(
"Ctrl+F") );
593 a->setStatusTip( tr(
"Edit Find") );
594 connect( a, SIGNAL( triggered() ),
this, SLOT(
editFind() ) );
599 iconName = QString(
":/icons/edit-find-plain.svg");
600 a =
new QAction( QIcon( iconName ), tr(
"&Find" ),
this );
601 connect( a, SIGNAL( triggered() ),
this, SLOT(
editFind() ) );
608 iconName = QString(
":/icons/go-next-use-dark.svg");
610 iconName = QString(
":/icons/go-next-use-plain.svg");
611 a =
new QAction( QIcon( iconName ), tr(
"Find &Next" ),
this );
612 a->setShortcut( tr(
"F3") );
613 a->setStatusTip( tr(
"Edit Find Next") );
614 connect( a, SIGNAL( triggered() ),
this, SLOT(
editFindNext() ) );
619 iconName = QString(
":/icons/go-next-use-plain.svg");
620 a =
new QAction( QIcon( iconName ), tr(
"Find &Next" ),
this );
621 connect( a, SIGNAL( triggered() ),
this, SLOT(
editFindNext() ) );
628 iconName = QString(
":/icons/go-previous-use-dark.svg");
630 iconName = QString(
":/icons/go-previous-use-plain.svg");
631 a =
new QAction( QIcon( iconName ) , tr(
"Find Pre&vious" ),
this );
632 a->setShortcut( tr(
"Shift+F4") );
633 a->setStatusTip( tr(
"Edit Find Previous") );
639 iconName = QString(
":/icons/go-previous-use-plain.svg");
640 a =
new QAction( QIcon( iconName ), tr(
"Find Pre&vious" ),
this );
647 a =
new QAction( tr(
"Replace..." ),
this );
648 a->setShortcut( tr(
"Ctrl+R") );
649 a->setStatusTip( tr(
"Edit Replace") );
652 menu->addSeparator();
654 QMenu *addSubMenu =
new QMenu( tr (
"Add Block"),
this);
656 a =
new QAction( tr(
"Title Block"),
this );
657 a->setStatusTip( tr(
"Invokes MSR Title Block Dialog") );
658 connect( a, SIGNAL( triggered() ),
this, SLOT(
insertTitle() ));
659 addSubMenu->addAction(a);
661 a =
new QAction( tr(
"Parameter Block"),
this );
662 a->setStatusTip( tr(
"Invokes MSR Parameter Block Dialog") );
664 addSubMenu->addAction(a);
666 a =
new QAction( tr(
"Theory Block"),
this );
667 a->setStatusTip( tr(
"Invokes MSR Theory Block Dialog") );
669 addSubMenu->addAction(a);
671 a =
new QAction( tr(
"Function Block"),
this );
672 a->setStatusTip( tr(
"Invokes MSR Function Block Dialog") );
674 addSubMenu->addAction(a);
677 QMenu *theoryFunctions =
new QMenu( tr(
"Add Theory Function"),
this );
678 for (
unsigned int i=0; i<
fAdmin->getTheoryCounts(); i++) {
680 a =
new QAction( theoryItem->
label,
this);
681 theoryFunctions->addAction(a);
683 connect( theoryFunctions, SIGNAL( triggered(QAction*)),
this, SLOT(
insertTheoryFunction(QAction*) ) );
685 a =
new QAction( tr(
"Asymmetry Run Block"),
this );
686 a->setStatusTip( tr(
"Invokes MSR Asymmetry Run Block Dialog") );
688 addSubMenu->addAction(a);
690 a =
new QAction( tr(
"Single Histo Run Block"),
this );
691 a->setStatusTip( tr(
"Invokes MSR Single Histo Run Block Dialog") );
693 addSubMenu->addAction(a);
695 a =
new QAction( tr(
"NonMuSR Run Block"),
this );
696 a->setStatusTip( tr(
"Invokes MSR NonMuSR Run Block Dialog") );
698 addSubMenu->addAction(a);
700 a =
new QAction( tr(
"Command Block"),
this );
701 a->setStatusTip( tr(
"Invokes MSR Command Block Dialog") );
703 addSubMenu->addAction(a);
705 a =
new QAction( tr(
"Fourier Block"),
this );
706 a->setStatusTip( tr(
"Invokes MSR Fourier Block Dialog") );
708 addSubMenu->addAction(a);
710 a =
new QAction( tr(
"Plot Block"),
this );
711 a->setStatusTip( tr(
"Invokes MSR Plot Block Dialog") );
713 addSubMenu->addAction(a);
715 a =
new QAction( tr(
"Statistic Block"),
this );
716 a->setStatusTip( tr(
"Invokes MSR Statistic Block Dialog") );
718 addSubMenu->addAction(a);
720 menu->addMenu(addSubMenu);
721 menu->addMenu(theoryFunctions);
722 menu->addSeparator();
724 a =
new QAction( tr(
"Co&mment" ),
this );
725 a->setShortcut( tr(
"Ctrl+M") );
726 a->setStatusTip( tr(
"Edit Comment Selected Lines") );
727 connect( a, SIGNAL( triggered() ),
this, SLOT(
editComment() ) );
730 a =
new QAction( tr(
"Unco&mment" ),
this );
731 a->setShortcut( tr(
"Ctrl+Shift+M") );
732 a->setStatusTip( tr(
"Edit Uncomment Selected Lines") );
733 connect( a, SIGNAL( triggered() ),
this, SLOT(
editUncomment() ) );
747 QToolBar *tb =
new QToolBar(
this );
748 tb->setWindowTitle(
"Format Actions" );
753 fComboFont->addItems( QFontDatabase::families() );
754 connect(
fComboFont.get(), SIGNAL( currentTextChanged(
const QString & ) ),
755 this, SLOT(
textFamily(
const QString & ) ) );
757 if (edit ==
nullptr) {
760 edit->setText(
fAdmin->getFontName() );
763 fComboSize = std::make_unique<QComboBox>( tb );
765 QList<int> sizes = QFontDatabase::standardSizes();
766 QList<int>::Iterator it = sizes.begin();
767 for ( ; it != sizes.end(); ++it )
768 fComboSize->addItem( QString::number( *it ) );
769 connect(
fComboSize.get(), SIGNAL( currentTextChanged(
const QString & ) ),
770 this, SLOT(
textSize(
const QString & ) ) );
772 if (edit ==
nullptr) {
775 edit->setText( QString(
"%1").arg(
fAdmin->getFontSize()) );
794 QToolBar *tb =
new QToolBar(
this );
795 tb->setWindowTitle(
"Musr Actions" );
798 QMenu *menu =
new QMenu( tr(
"&MusrFit" ),
this );
799 menuBar()->addMenu( menu );
802 QString iconName(
"");
806 iconName = QString(
":/icons/musrWiz-32x32-dark.svg");
808 iconName = QString(
":/icons/musrWiz-32x32.svg");
809 a =
new QAction( QIcon( iconName ), tr(
"musr&Wiz" ),
this );
810 a->setShortcut( tr(
"Alt+W") );
811 a->setStatusTip( tr(
"Call musrWiz which helps to create msr-files - currently still very limited") );
812 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrWiz() ) );
817 iconName = QString(
":/icons/musrWiz-32x32.svg");
818 a =
new QAction( QIcon( iconName ), tr(
"musr&Wiz" ),
this );
819 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrWiz() ) );
824 menu->addSeparator();
829 iconName = QString(
":/icons/musrchisq-dark.svg");
831 iconName = QString(
":/icons/musrchisq-plain.svg");
832 a =
new QAction( QIcon( iconName ), tr(
"Calculate &Chisq" ),
this );
833 a->setShortcut( tr(
"Alt+C") );
834 a->setStatusTip( tr(
"Calculate Chi Square (Log Max Likelihood)") );
835 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrCalcChisq() ) );
840 iconName = QString(
":/icons/musrchisq-plain.svg");
841 a =
new QAction( QIcon( iconName ), tr(
"Calculate &Chisq" ),
this );
842 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrCalcChisq() ) );
849 iconName = QString(
":/icons/musrfit-dark.svg");
851 iconName = QString(
":/icons/musrfit-plain.svg");
852 a =
new QAction( QIcon( iconName ), tr(
"&Fit" ),
this );
853 a->setShortcut( tr(
"Alt+F") );
854 a->setStatusTip( tr(
"Fit") );
855 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrFit() ) );
860 iconName = QString(
":/icons/musrfit-plain.svg");
861 a =
new QAction( QIcon( iconName ), tr(
"&Fit" ),
this );
862 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrFit() ) );
869 iconName = QString(
":/icons/musrswap-dark.svg");
871 iconName = QString(
":/icons/musrswap-plain.svg");
872 a =
new QAction( QIcon( iconName ), tr(
"&Swap Msr <-> Mlog" ),
this );
873 a->setShortcut( tr(
"Alt+S") );
874 a->setStatusTip( tr(
"Swap msr-file <-> mlog-file") );
880 iconName = QString(
":/icons/musrswap-plain.svg");
881 a =
new QAction( QIcon( iconName ), tr(
"&Swap Msr <-> Mlog" ),
this );
889 iconName = QString(
":/icons/musrStep-32x32-dark.svg");
891 iconName = QString(
":/icons/musrStep-32x32.svg");
892 a =
new QAction( QIcon( iconName ), tr(
"Set Ste&ps" ),
this );
893 a->setShortcut( tr(
"Alt+P") );
894 a->setStatusTip( tr(
"Set Steps") );
895 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrSetSteps() ) );
900 iconName = QString(
":/icons/musrStep-32x32.svg");
901 a =
new QAction( QIcon( iconName ), tr(
"Set Ste&ps" ),
this );
902 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrSetSteps() ) );
909 iconName = QString(
":/icons/msr2data-dark.svg");
911 iconName = QString(
":/icons/msr2data-plain.svg");
912 a =
new QAction( QIcon( iconName ), tr(
"Msr&2Data" ),
this );
913 a->setShortcut( tr(
"Alt+2") );
914 a->setStatusTip( tr(
"Start msr2data interface") );
915 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrMsr2Data() ) );
920 iconName = QString(
":/icons/msr2data-plain.svg");
921 a =
new QAction( QIcon( iconName ), tr(
"&Msr2Data" ),
this );
922 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrMsr2Data() ) );
929 iconName = QString(
":/icons/mupp-dark.svg");
931 iconName = QString(
":/icons/mupp-plain.svg");
932 a =
new QAction( QIcon( iconName ), tr(
"m&upp" ),
this );
933 a->setShortcut( tr(
"Alt+U") );
934 a->setStatusTip( tr(
"Start mupp, the muSR parameter plotter") );
935 connect( a, SIGNAL( triggered() ),
this, SLOT(
mupp() ) );
940 iconName = QString(
":/icons/mupp-plain.svg");
941 a =
new QAction( QIcon( iconName ), tr(
"m&upp" ),
this );
942 connect( a, SIGNAL( triggered() ),
this, SLOT(
mupp() ) );
949 iconName = QString(
":/icons/musrview2dat-dark.svg");
951 iconName = QString(
":/icons/musrview2dat-plain.svg");
952 a =
new QAction( QIcon( iconName ), tr(
"View2Dat" ),
this );
953 a->setStatusTip( tr(
"Export musrview data from a collection of msr-files.") );
954 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrView2Dat() ) );
959 iconName = QString(
":/icons/musrview2dat-plain.svg");
960 a =
new QAction( QIcon( iconName ), tr(
"View2Dat" ),
this );
961 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrView2Dat() ) );
966 menu->addSeparator();
971 iconName = QString(
":/icons/musrview-dark.svg");
973 iconName = QString(
":/icons/musrview-plain.svg");
974 a =
new QAction( QIcon( iconName ), tr(
"&View" ),
this );
975 a->setShortcut( tr(
"Alt+V") );
976 a->setStatusTip( tr(
"Start musrview") );
977 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrView() ) );
982 iconName = QString(
":/icons/musrview-plain.svg");
983 a =
new QAction( QIcon( iconName ), tr(
"&View" ),
this );
984 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrView() ) );
991 iconName = QString(
":/icons/musrt0-dark.svg");
993 iconName = QString(
":/icons/musrt0-plain.svg");
994 fMusrT0Action = std::make_unique<QAction>( QIcon( iconName ), tr(
"&T0" ),
this );
1000 iconName = QString(
":/icons/musrt0-plain.svg");
1001 a =
new QAction( QIcon( iconName ), tr(
"&T0" ),
this );
1002 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrT0() ) );
1010 iconName = QString(
":/icons/musrFT-dark.svg");
1012 iconName = QString(
":/icons/musrFT-plain.svg");
1013 a =
new QAction( QIcon( iconName ), tr(
"Raw Fourier" ),
this );
1014 a->setStatusTip( tr(
"Start musrFT") );
1015 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrFT() ) );
1020 iconName = QString(
":/icons/musrFT-plain.svg");
1021 a =
new QAction( QIcon( iconName ), tr(
"Raw Fourier" ),
this );
1022 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrFT() ) );
1029 iconName = QString(
":/icons/musrprefs-dark.svg");
1031 iconName = QString(
":/icons/musrprefs-plain.svg");
1032 a =
new QAction( QIcon( iconName ), tr(
"&Preferences" ),
this );
1033 a->setStatusTip( tr(
"Show Preferences") );
1034 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrPrefs() ) );
1039 iconName = QString(
":/icons/musrprefs-plain.svg");
1040 a =
new QAction( QIcon( iconName ), tr(
"&Preferences" ),
this );
1041 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrPrefs() ) );
1046 menu->addSeparator();
1051 iconName = QString(
":/icons/musrdump-dark.svg");
1053 iconName = QString(
":/icons/musrdump-plain.svg");
1054 a =
new QAction( QIcon( iconName), tr(
"&Dump Header"),
this);
1055 a->setStatusTip( tr(
"Dumps muSR File Header Information") );
1056 connect( a, SIGNAL(triggered()),
this, SLOT(
musrDump()));
1060 iconName = QString(
":/icons/musrdump-plain.svg");
1061 a =
new QAction( QIcon( iconName ), tr(
"&Dump Header" ),
this );
1062 connect( a, SIGNAL( triggered() ),
this, SLOT(
musrDump() ) );
1078 QMenu *menu =
new QMenu( tr(
"&Help" ),
this );
1079 menuBar()->addMenu( menu);
1082 a =
new QAction(tr(
"Contents ..." ),
this );
1083 a->setStatusTip( tr(
"Help Contents") );
1084 connect( a, SIGNAL( triggered() ),
this, SLOT(
helpContents() ));
1087 a =
new QAction(tr(
"Author(s) ..." ),
this );
1088 a->setStatusTip( tr(
"Help About") );
1089 connect( a, SIGNAL( triggered() ),
this, SLOT(
helpAbout() ));
1092 a =
new QAction(tr(
"About Qt..." ),
this );
1093 a->setStatusTip( tr(
"Help About Qt") );
1094 connect( a, SIGNAL( triggered() ),
this, SLOT(
helpAboutQt() ));
1104 QToolBar *tb =
new QToolBar(
this );
1105 tb->setWindowTitle(
"JumpToBlock Actions" );
1108 QStringList jumpToBlockStr = {
"FITPARAMETER",
"THEORY",
"FUNCTIONS",
"GLOBAL",
"RUN",
"COMMANDS",
"PLOT",
"FOURIER",
"STATISTIC"};
1117 QLabel *jstr =
new QLabel(
" Jump to block: ");
1119 tb->addWidget(jstr);
1133 if ( !QFile::exists( f ) )
1138 edit->setFont(QFont(
fAdmin->getFontName(),
fAdmin->getFontSize()));
1139 edit->setCenterOnScroll(
true);
1143 fTabWidget->addTab( edit, QFileInfo( f ).fileName() );
1145 fTabWidget->insertTab( index, edit, QFileInfo( f ).fileName() );
1147 if ( !file.open( QIODevice::ReadOnly ) )
1151 fAdmin->addRecentFile(QFileInfo(f).absoluteFilePath());
1158 QTextStream ts( &file );
1159 QString txt = ts.readAll();
1160 edit->setPlainText( txt );
1165 edit->viewport()->setFocus();
1182 if (
fTabWidget->currentWidget()->inherits(
"PSubTextEdit" )) {
1323 edit->setFont(QFont(
fAdmin->getFontName(),
fAdmin->getFontSize()));
1324 edit->setCenterOnScroll(
true);
1329 edit->viewport()->setFocus();
1340 QStringList flns = QFileDialog::getOpenFileNames(
this, tr(
"Open msr-/mlog-File"),
1342 tr(
"msr-Files (*.msr);;msr-Files (*.msr *.mlog);;All Files (*)" ));
1344 QStringList::Iterator it = flns.begin();
1346 bool alreadyOpen =
false;
1350 if (flns.size() > 0) {
1351 finfo1.setFile(flns.at(0));
1355 while( it != flns.end() ) {
1357 finfo1.setFile(*it);
1373 if (tabStr ==
"noname") {
1386 QAction *action = qobject_cast<QAction *>(sender());
1390 QFileInfo finfo1, finfo2;
1392 bool alreadyOpen =
false;
1393 QString fln = action->text();
1395 finfo1.setFile(fln);
1399 finfo2.setFile(tabFln);
1400 if (finfo1.absoluteFilePath() == finfo2.absoluteFilePath()) {
1409 if (!finfo1.exists()) {
1410 QMessageBox::critical(
this,
"ERROR", QString(
"File '%1' does not exist.\nWill not do anything.").arg(fln));
1421 if (fln ==
"noname") {
1436 QMessageBox::critical(
this,
"ERROR",
"Cannot reload a file not previously saved ;-)");
1454 msgBox.setText(
"Which Preferences do you want to open?");
1455 msgBox.addButton(
"Default", QMessageBox::AcceptRole);
1456 msgBox.addButton(
"Custom", QMessageBox::AcceptRole);
1457 msgBox.setStandardButtons(QMessageBox::Cancel);
1458 int result = msgBox.exec();
1459 if (result == QMessageBox::Cancel) {
1461 }
else if (result == 0) {
1462 fln =
fAdmin->getDefaultPrefPathName();
1463 msg = QString(
"Current Default Preferences Path-Name:\n") + fln;
1464 if (QMessageBox::information(
this,
"INFO", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
1466 }
else if (result == 1) {
1467 fln = QFileDialog::getOpenFileName(
this, tr(
"Open Prefs"),
1469 tr(
"xml-Files (*.xml);; All Files (*)" ));
1472 if (
fAdmin->loadPrefs(fln)) {
1473 msg = QString(
"Prefs from '") + fln + QString(
"' loaded.");
1474 QMessageBox::information(
nullptr,
"INFO", msg);
1509 if ( !file.open( QIODevice::WriteOnly ) ) {
1510 QMessageBox::critical(
this,
"ERROR",
"Couldn't save the file!\nDisk full?\nNo write access?");
1513 QTextStream ts( &file );
1536 QString fn = QFileDialog::getSaveFileName(
this,
1538 tr(
"msr-Files (*.msr *.mlog);;All Files (*)" ) );
1539 if ( !fn.isEmpty() ) {
1557 msgBox.setText(
"Which Preferences do you want to open?");
1558 QAbstractButton *def = msgBox.addButton(
"Default", QMessageBox::AcceptRole);
1559 QAbstractButton *cust = msgBox.addButton(
"Custom", QMessageBox::AcceptRole);
1560 msgBox.setStandardButtons(QMessageBox::Cancel);
1561 int result = msgBox.exec();
1562 if (result == QMessageBox::Cancel) {
1564 }
else if (msgBox.clickedButton() == def) {
1565 fln =
fAdmin->getDefaultPrefPathName();
1566 msg = QString(
"Current Default Preferences Path-Name:\n") + fln;
1567 if (QMessageBox::information(
this,
"INFO", msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
1569 }
else if (msgBox.clickedButton() == cust) {
1570 fln = QFileDialog::getSaveFileName(
this,
1571 tr(
"Save Prefs As" ),
"musredit_startup.xml",
1572 tr(
"xml-Files (*.xml);;All Files (*)" ) );
1575 if ( !fln.isEmpty() ) {
1577 msg = QString(
"Prefs to '") + fln + QString(
"' saved.");
1578 QMessageBox::information(
nullptr,
"INFO", msg);
1590#ifndef QT_NO_PRINTER
1591 QPrinter printer( QPrinter::HighResolution );
1592 printer.setFullPage(
true);
1593 QPrintDialog dialog(&printer,
this);
1594 if (dialog.exec()) {
1595 statusBar()->showMessage(
"Printing..." );
1597 QPainter p( &printer );
1603 font.setPointSize( 10 );
1607 QFontMetrics fm = p.fontMetrics();
1608 int dpiy = printer.logicalDpiY();
1609 int margin =
static_cast<int>( (2/2.54)*dpiy );
1613 QString header1(fln);
1614 QFileInfo flnInfo(fln);
1615 QString header2 = QString(
"last modified: ") + flnInfo.lastModified().toString(
"dd.MM.yyyy - hh:mm:ss");
1616 QString line(
"-------------------------------------");
1617 QStringList strList =
currentEditor()->toPlainText().split(
"\n");
1618 for (QStringList::Iterator it = strList.begin(); it != strList.end(); ++it) {
1620 if ( margin + yPos > printer.height() - margin ) {
1626 font.setPointSize( 8 );
1629 p.drawText(margin, margin+yPos, printer.width(), fm.lineSpacing(),
1630 Qt::TextExpandTabs | Qt::TextDontClip, header1);
1631 yPos += fm.lineSpacing();
1632 p.drawText(margin, margin+yPos, printer.width(), fm.lineSpacing(),
1633 Qt::TextExpandTabs | Qt::TextDontClip, header2);
1634 yPos += fm.lineSpacing();
1635 p.drawText(margin, margin+yPos, printer.width(), fm.lineSpacing(),
1636 Qt::TextExpandTabs | Qt::TextDontClip, line);
1637 yPos += 1.5*fm.lineSpacing();
1639 font.setPointSize( 10 );
1644 p.drawText(margin, margin+yPos, printer.width(), fm.lineSpacing(),
1645 Qt::TextExpandTabs | Qt::TextDontClip, *it);
1646 yPos += fm.lineSpacing();
1670 if ((
fTabWidget->tabText(idx).indexOf(
"*")>0) && check) {
1671 int result = QMessageBox::warning(
this,
"WARNING",
1672 "Do you really want to close this file.\nChanges will be lost",
1673 QMessageBox::Close, QMessageBox::Cancel);
1674 if (result == QMessageBox::Cancel)
1700 if (
fTabWidget->tabText(i).indexOf(
"*") > 0) {
1701 int result = QMessageBox::warning(
this,
"WARNING",
1702 "Do you really want to close all files.\nChanges of unsaved files will be lost",
1703 QMessageBox::Close, QMessageBox::Cancel);
1704 if (result == QMessageBox::Cancel)
1737 if (
fTabWidget->tabText(i).indexOf(
"*") > 0) {
1738 int result = QMessageBox::warning(
this,
"WARNING",
1739 "Do you really want to close all files.\nChanges of unsaved files will be lost",
1740 QMessageBox::Close, QMessageBox::Cancel);
1741 if (result == QMessageBox::Cancel)
1779 for (
int i=0; i <
fTabWidget->count(); i++) {
1780 if (
fTabWidget->tabText(i).indexOf(
"*") > 0) {
1781 int result = QMessageBox::warning(
this,
"WARNING",
1782 "Do you really want to exit from the applcation.\nChanges will be lost",
1783 QMessageBox::Close, QMessageBox::Cancel);
1784 if (result == QMessageBox::Cancel)
1790 fAdmin->saveRecentFiles();
1884 QMessageBox::critical(
this,
"ERROR",
"Couldn't invoke find data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
1889 if (dlg ==
nullptr) {
1890 QMessageBox::critical(
this,
"ERROR",
"Couldn't invoke find dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
1896 if (dlg->result() != QDialog::Accepted) {
1910 QTextDocument::FindFlags flags;
1912 flags |= QTextDocument::FindCaseSensitively;
1914 flags |= QTextDocument::FindBackward;
1916 flags |= QTextDocument::FindWholeWords;
1927 QTextDocument::FindFlags flags;
1929 flags |= QTextDocument::FindCaseSensitively;
1931 flags |= QTextDocument::FindWholeWords;
1942 QTextDocument::FindFlags flags;
1944 flags |= QTextDocument::FindCaseSensitively;
1946 flags |= QTextDocument::FindWholeWords;
1948 flags |= QTextDocument::FindBackward;
1976 QMessageBox::critical(
this,
"ERROR",
"Couldn't invoke find&replace data structure, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
1981 if (dlg ==
nullptr) {
1982 QMessageBox::critical(
this,
"ERROR",
"Couldn't invoke find&replace dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
1988 if (dlg->result() != QDialog::Accepted) {
2004 QObject::connect(confirmDlg.fReplace_pushButton, SIGNAL(clicked()),
this, SLOT(
replace()));
2005 QObject::connect(confirmDlg.fReplaceAndClose_pushButton, SIGNAL(clicked()),
this, SLOT(
replaceAndClose()));
2006 QObject::connect(confirmDlg.fReplaceAll_pushButton, SIGNAL(clicked()),
this, SLOT(
replaceAll()));
2007 QObject::connect(confirmDlg.fFindNext_pushButton, SIGNAL(clicked()),
this, SLOT(
editFindNext()));
2008 QObject::connect(
this, SIGNAL(
close()), &confirmDlg, SLOT(accept()));
2029 if (curs.hasComplexSelection()) {
2031 }
else if (curs.hasSelection()) {
2032 int pos = curs.position();
2033 int secStart = curs.selectionStart();
2034 int secEnd = curs.selectionEnd();
2035 curs.clearSelection();
2036 curs.setPosition(secStart);
2037 curs.movePosition(QTextCursor::StartOfBlock);
2039 curs.insertText(
"#");
2040 }
while (curs.movePosition(QTextCursor::NextBlock) && (curs.position() <= secEnd));
2041 curs.setPosition(pos+1);
2043 int pos = curs.position();
2044 curs.clearSelection();
2045 curs.movePosition(QTextCursor::StartOfLine);
2046 curs.insertText(
"#");
2047 curs.setPosition(pos+1);
2064 if (curs.hasComplexSelection()) {
2066 }
else if (curs.hasSelection()) {
2067 int pos = curs.position();
2068 int secStart = curs.selectionStart();
2069 int secEnd = curs.selectionEnd();
2070 curs.clearSelection();
2071 curs.setPosition(secStart);
2072 curs.movePosition(QTextCursor::StartOfBlock);
2073 while (curs.position() < secEnd) {
2074 QString line = curs.block().text();
2075 if (line.startsWith(
"#")) {
2077 curs.select(QTextCursor::BlockUnderCursor);
2078 curs.removeSelectedText();
2079 curs.insertText(
"\n"+line);
2082 curs.movePosition(QTextCursor::NextBlock);
2084 curs.setPosition(pos);
2087 int pos = curs.position();
2088 curs.clearSelection();
2089 curs.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, 1);
2090 QString line = curs.block().text();
2091 if (line.startsWith(
"#")) {
2093 curs.select(QTextCursor::BlockUnderCursor);
2094 curs.removeSelectedText();
2096 curs.insertText(line);
2098 curs.insertText(
"\n"+line);
2101 curs.setPosition(pos);
2131 fAdmin->setFontSize(p.toInt());
2146 QString cmd =
fAdmin->getExecPath() +
"/musrWiz";
2147#if defined(Q_OS_DARWIN)
2148 cmd = QString(
"/Applications/musrWiz.app/Contents/MacOS/musrWiz");
2150 QString workDir =
"./";
2154 QProcess *proc =
new QProcess(
this);
2155 if (proc ==
nullptr) {
2156 QMessageBox::critical(
nullptr,
"ERROR",
"Couldn't invoke QProcess!");
2161 connect(proc,
static_cast<void(QProcess::*)(
int, QProcess::ExitStatus)
>(&QProcess::finished),
2162 [=,
this](
int exitCode, QProcess::ExitStatus exitStatus){
exitStatusMusrWiz(exitCode, exitStatus); });
2165 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2166#if defined(Q_OS_DARWIN)
2167 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
2169 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
2171 proc->setProcessEnvironment(env);
2172 proc->setWorkingDirectory(workDir);
2173 proc->start(cmd, arg);
2174 if (!proc->waitForStarted()) {
2176 QString msg(tr(
"Could not execute the output command: ")+cmd[0]);
2177 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
2193 if (
fAdmin->getEstimateN0Flag() && ((fittype==0) || (fittype==4)))
2194 result = QMessageBox::question(
this,
"Estimate N0 active",
2195 "Do you wish a chisq/mlh evaluation with an automatic N0 estimate?");
2198 if (tabLabel ==
"noname") {
2199 QMessageBox::critical(
this,
"ERROR",
"For a fit a real msr-file is needed.");
2201 }
else if (tabLabel ==
"noname*") {
2203 }
else if (tabLabel.indexOf(
"*") > 0) {
2207 QVector<QString> cmd;
2209 str =
fAdmin->getExecPath() +
"/musrfit";
2213 cmd.append(
"--chisq-only");
2214 if (
fAdmin->getEstimateN0Flag() && (result == QMessageBox::Yes) && ((fittype==0) || (fittype==4)))
2215 cmd.append(
"--estimateN0");
2217 fitOutputHandler.setModal(
true);
2218 fitOutputHandler.exec();
2231 if (tabLabel ==
"noname") {
2232 QMessageBox::critical(
this,
"ERROR",
"For a fit a real msr-file is needed.");
2234 }
else if (tabLabel ==
"noname*") {
2236 }
else if (tabLabel.indexOf(
"*") > 0) {
2240 QVector<QString> cmd;
2242 str =
fAdmin->getExecPath() +
"/musrfit";
2248 if (
fAdmin->getKeepMinuit2OutputFlag())
2249 cmd.append(
"--keep-mn2-output");
2252 if (
fAdmin->getTitleFromDataFileFlag())
2253 cmd.append(
"--title-from-data-file");
2256 if (
fAdmin->getDumpAsciiFlag()) {
2257 cmd.append(
"--dump");
2258 cmd.append(
"ascii");
2260 if (
fAdmin->getDumpRootFlag()) {
2261 cmd.append(
"--dump");
2266 if (
fAdmin->getEstimateN0Flag()) {
2267 cmd.append(
"--estimateN0");
2271 if (
fAdmin->getYamlOutFlag()) {
2272 cmd.append(
"--yaml");
2276 cmd.append(
"--use-no-of-threads");
2277 QString noThreads = QString(
"%1").arg(
fAdmin->getNoOfThreadsToBeUsed());
2278 cmd.append(noThreads);
2281 if (
fAdmin->getChisqPerRunBlockFlag()) {
2282 cmd.append(
"--per-run-block-chisq");
2286 cmd.append(
"--timeout");
2288 numStr.setNum(
fAdmin->getTimeout());
2292 fitOutputHandler.setModal(
true);
2294 fitOutputHandler.exec();
2300 QString complementFileName;
2303 if ((idx = currentFileName.indexOf(
".msr")) > 0) {
2304 complementFileName = currentFileName;
2305 complementFileName.replace(idx, 5,
".mlog");
2306 }
else if ((idx = currentFileName.indexOf(
".mlog")) > 0) {
2307 complementFileName = currentFileName;
2308 complementFileName.replace(idx, 5,
".msr ");
2309 complementFileName = complementFileName.trimmed();
2311 QMessageBox::information(
this,
"musrFit",
2312 "This is neither a msr- nor a mlog-file, hence no idea what to be done.\n",
2321 load(currentFileName, currentIdx);
2326 if (
fTabWidget->tabText(i).indexOf(complementFileName) >= 0) {
2334 load(complementFileName, idx);
2361 if (dlg ==
nullptr) {
2362 QMessageBox::critical(
this,
"ERROR",
"Couldn't invoke msr2data dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
2366 if (dlg->exec() == QDialog::Accepted) {
2368 QString runListFileName;
2385 QMessageBox::critical(
this,
"ERROR",
2386 "No valid run list input found :-(\nCannot do anything.",
2387 QMessageBox::Ok, QMessageBox::NoButton);
2397 str = QString(
"Run List File '%1' doesn't exist.").arg(runListFileName);
2398 QMessageBox::critical(
this,
"ERROR",
2399 str, QMessageBox::Ok, QMessageBox::NoButton);
2404 QMessageBox::critical(
this,
"ERROR",
2405 "No idea how you could reach this point.\nPlease contact the developers.",
2406 QMessageBox::Ok, QMessageBox::NoButton);
2412 QVector<QString> cmd;
2414 str =
fAdmin->getExecPath() +
"/msr2data";
2421 while (!runList.section(
' ', end, end, QString::SectionSkipEmpty).isEmpty()) {
2426 str =
"[" + runList +
"]";
2429 str =
"[" + runList.section(
' ', 0, 0, QString::SectionSkipEmpty);
2432 for (i=1; i<end-1; i++) {
2433 cmd.append(runList.section(
' ', i, i, QString::SectionSkipEmpty));
2436 str = runList.section(
' ', end-1, end-1, QString::SectionSkipEmpty) +
"]";
2441 cmd.append(runListFileName);
2458 cmd.append(
"paramList");
2459 QStringList list =
fMsr2DataParam->paramList.split(QRegularExpression(
"[(\\s|,|;)]"), Qt::SkipEmptyParts);
2460 for (
int i=0; i<list.size(); i++)
2461 cmd.append(list[i]);
2466 cmd.append(
"noheader");
2470 cmd.append(
"nosummary");
2533 cmd.append(
"global");
2539 cmd.append(
"global+");
2541 cmd.append(
"global+!");
2551 QString workDir = QString(
"./");
2556 fitOutputHandler.setModal(
true);
2558 fitOutputHandler.exec();
2564 QTextStream *stream;
2566 bool alreadOpen=
false;
2575 for (
int i=0; i<list.size(); i++) {
2582 workDir = QString(
"./");
2586 finfo.setFile(workDir +
"/" + fln);
2589 load(workDir +
"/" + fln);
2598 if (!file->open(QIODevice::ReadOnly)) {
2599 str = QString(
"Couldn't open run list file %1, sorry.").arg(
fMsr2DataParam->runListFileName);
2600 QMessageBox::critical(
this,
"ERROR", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
2604 stream =
new QTextStream(file);
2605 while ( !stream->atEnd() ) {
2606 str = stream->readLine();
2607 str = str.trimmed();
2608 if (!str.isEmpty() && !str.startsWith(
"#") && !str.startsWith(
"run", Qt::CaseInsensitive)) {
2609 fln = str.section(
' ', 0, 0, QString::SectionSkipEmpty);
2615 workDir = QString(
"./");
2619 finfo.setFile(workDir +
"/" + fln);
2622 load(workDir +
"/" + fln);
2644 fln = runList.section(
" ", 0, 0, QString::SectionSkipEmpty) + QString(
"+global") +
fMsr2DataParam->msrFileExtension + QString(
".msr");
2648 if (!file->open(QIODevice::ReadOnly)) {
2649 str = QString(
"Couldn't open run list file %1, sorry.").arg(
fMsr2DataParam->runListFileName);
2650 QMessageBox::critical(
this,
"ERROR", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
2654 stream =
new QTextStream(file);
2655 while ( !stream->atEnd() ) {
2656 str = stream->readLine();
2657 str = str.trimmed();
2658 if (!str.isEmpty() && !str.startsWith(
"#") && !str.startsWith(
"run", Qt::CaseInsensitive)) {
2659 fln = str.section(
' ', 0, 0, QString::SectionSkipEmpty);
2666 fln += QString(
"+global") +
fMsr2DataParam->msrFileExtension + QString(
".msr");
2697 if (tabLabel ==
"noname") {
2698 QMessageBox::critical(
this,
"ERROR",
"For a view a real mlog/msr-file is needed.");
2700 }
else if (tabLabel ==
"noname*") {
2702 }
else if (tabLabel.indexOf(
"*") > 0) {
2706 QString cmd =
fAdmin->getExecPath() +
"/musrview";
2711 QString workDir = QFileInfo(fln).absolutePath();
2717 int pos = str.lastIndexOf(
"/");
2719 str.remove(0, pos+1);
2723 str.setNum(
fAdmin->getTimeout());
2724 arg <<
"--timeout" << str;
2727 if (
fAdmin->getMusrviewShowFourierFlag())
2731 if (
fAdmin->getMusrviewShowAvgFlag())
2735 if (
fAdmin->getMusrviewShowOneToOneFlag())
2743 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2744#if defined(Q_OS_DARWIN)
2745 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
2747 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
2749 proc.setProgram(cmd);
2750 proc.setProcessEnvironment(env);
2751 proc.setArguments(arg);
2752 proc.setWorkingDirectory(workDir);
2753 if (!proc.startDetached()) {
2754 QString msg = QString(
"musrview failed. Possible reasons:\n");
2755 msg += QString(
"* corrupted msr-file.\n");
2756 msg += QString(
"* cannot read data-file.\n");
2757 msg += QString(
"* many more things can go wrong.\n");
2758 msg += QString(
"Please check!");
2759 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close);
2769 QStringList flns = QFileDialog::getOpenFileNames(
this, tr(
"Open msr-/mlog-File"),
2771 tr(
"msr-Files (*.msr)" ));
2775 QString cmd =
fAdmin->getExecPath() +
"/musrview";
2780 QString workDir = QFileInfo(fln).absolutePath();
2783 for (
auto it : flns) {
2784 std::cout << it.toLatin1().data() << std::endl;
2789 if (
fAdmin->getMusrviewShowFourierFlag())
2793 if (
fAdmin->getMusrviewShowAvgFlag())
2797 if (
fAdmin->getMusrviewShowOneToOneFlag())
2804 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2805#if defined(Q_OS_DARWIN)
2806 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
2808 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
2810 proc.setProgram(cmd);
2811 proc.setProcessEnvironment(env);
2812 proc.setArguments(arg);
2813 proc.setWorkingDirectory(workDir);
2814 if (!proc.startDetached()) {
2815 QString msg = QString(
"musrview failed. Possible reasons:\n");
2816 msg += QString(
"* corrupted msr-file.\n");
2817 msg += QString(
"* cannot read data-file.\n");
2818 msg += QString(
"* many more things can go wrong.\n");
2819 msg += QString(
"Please check!");
2820 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close);
2824 QMessageBox::information(
this,
"INFO",
"<b>In the pipeline</b>.\nIt might take a couple of seconds to complete everything.");
2837 if (tabLabel ==
"noname") {
2838 QMessageBox::critical(
this,
"ERROR",
"For a view a real mlog/msr-file is needed.");
2840 }
else if (tabLabel ==
"noname*") {
2842 }
else if (tabLabel.indexOf(
"*") > 0) {
2846 QString cmd =
fAdmin->getExecPath() +
"/musrt0";
2853 int pos = str.lastIndexOf(
"/");
2855 str.remove(0, pos+1);
2859 str.setNum(
fAdmin->getTimeout());
2860 arg <<
"--timeout" << str;
2862 QProcess *proc =
new QProcess(
this);
2865 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2866#if defined(Q_OS_DARWIN)
2867 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
2869 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
2871 proc->setProcessEnvironment(env);
2872 proc->setWorkingDirectory(workDir);
2874 connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
2875 [=,
this](
int exitCode, QProcess::ExitStatus exitStatus){
fileReload(); });
2877 proc->start(cmd, arg);
2878 if (!proc->waitForStarted()) {
2880 QString msg(tr(
"Could not execute the output command: ")+cmd[0]);
2881 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
2899 if (dlg ==
nullptr) {
2900 QMessageBox::critical(
this,
"ERROR musrFT",
"Couldn't invoke musrFT Options Dialog.");
2904 if (dlg->exec() == QDialog::Accepted) {
2906 QProcess *proc =
new QProcess(
this);
2907 proc->setStandardOutputFile(
"musrFT.log");
2908 proc->setStandardErrorFile(
"musrFT.log");
2909 QString cmd =
fAdmin->getExecPath() +
"/musrFT";
2910 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2911#if defined(Q_OS_DARWIN)
2912 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
2914 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
2916 proc->setProcessEnvironment(env);
2918 if (!proc->waitForStarted()) {
2920 QString msg(tr(
"Could not execute the output command: ")+cmd[0]);
2921 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
2938 if (dlg ==
nullptr) {
2939 QMessageBox::critical(
this,
"ERROR musrPrefs",
"Couldn't invoke Preferences Dialog.");
2943 if (dlg->exec() == QDialog::Accepted) {
2955 fAdmin->setDumpAsciiFlag(
true);
2956 fAdmin->setDumpRootFlag(
false);
2957 }
else if (dlg->
getDump() == 2) {
2958 fAdmin->setDumpAsciiFlag(
false);
2959 fAdmin->setDumpRootFlag(
true);
2961 fAdmin->setDumpAsciiFlag(
false);
2962 fAdmin->setDumpRootFlag(
false);
2996 if (tabLabel ==
"noname") {
2997 QMessageBox::critical(
this,
"ERROR",
"For musrStep a real mlog/msr-file is needed.");
2999 }
else if (tabLabel ==
"noname*") {
3001 }
else if (tabLabel.indexOf(
"*") > 0) {
3006 QString cmd =
fAdmin->getExecPath() +
"/musrStep";
3007#if defined(Q_OS_DARWIN)
3008 cmd = QString(
"/Applications/musrStep.app/Contents/MacOS/musrStep");
3016 int pos = str.lastIndexOf(
"/");
3018 str.remove(0, pos+1);
3021 QProcess *proc =
new QProcess(
this);
3022 if (proc ==
nullptr) {
3023 QMessageBox::critical(
nullptr,
"ERROR",
"Couldn't invoke QProcess!");
3028 connect(proc,
static_cast<void(QProcess::*)(
int, QProcess::ExitStatus)
>(&QProcess::finished),
3029 [=,
this](
int exitCode, QProcess::ExitStatus exitStatus){
exitStatusMusrSetSteps(exitCode, exitStatus); });
3032 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3033#if defined(Q_OS_DARWIN)
3034 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
3036 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
3038 proc->setProcessEnvironment(env);
3039 proc->setWorkingDirectory(workDir);
3040 proc->start(cmd, arg);
3041 if (!proc->waitForStarted()) {
3043 QString msg(tr(
"Could not execute the output command: ")+cmd[0]);
3044 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
3060 QString swapFileName;
3061 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3062 QString tempFileName = QString(
"%1/.musrfit/__swap__.msr").arg(env.value(
"HOME"));
3066 if ((idx = currentFileName.indexOf(
".msr")) > 0) {
3067 swapFileName = currentFileName;
3068 swapFileName.replace(idx, 5,
".mlog");
3069 }
else if ((idx = currentFileName.indexOf(
".mlog")) > 0) {
3070 swapFileName = currentFileName;
3071 swapFileName.replace(idx, 5,
".msr ");
3072 swapFileName = swapFileName.trimmed();
3074 QMessageBox::information(
this,
"musrSwapMsrMlog",
3075 "This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n",
3081 if (!QFile::exists(swapFileName)) {
3082 QString msg =
"swap file '" + swapFileName +
"' doesn't exist.\nCannot swap anything.";
3083 QMessageBox::warning(
this,
"musrSwapMsrMlog",
3084 msg, QMessageBox::Ok, QMessageBox::NoButton );
3088 if (QMessageBox::information(
this,
"INFO",
3089 QString(
"Will now swap files: %1 <-> %2").arg(currentFileName).arg(swapFileName),
3090 QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Cancel)
3101 if (QFile::exists(tempFileName)) {
3102 if (!QFile::remove(tempFileName)) {
3103 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to remove %1").arg(tempFileName));
3107 if (!QFile::copy(currentFileName, tempFileName)) {
3108 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to copy %1 -> %2").arg(currentFileName).arg(tempFileName));
3112 if (!QFile::remove(currentFileName)) {
3113 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to remove %1").arg(currentFileName));
3116 if (!QFile::copy(swapFileName, currentFileName)) {
3117 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to copy %1 -> %2").arg(swapFileName).arg(currentFileName));
3121 if (!QFile::remove(swapFileName)) {
3122 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to remove %1").arg(swapFileName));
3125 if (!QFile::copy(tempFileName, swapFileName)) {
3126 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to copy %1 -> %2").arg(tempFileName).arg(swapFileName));
3130 if (!QFile::remove(tempFileName)) {
3131 QMessageBox::critical(
nullptr,
"ERROR", QString(
"failed to remove %1").arg(tempFileName));
3139 load(currentFileName);
3144 if (
fTabWidget->tabText(i).indexOf(swapFileName) >= 0) {
3164 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Select muSR Data File"),
"./", tr(
"muSR Data Files (*.root *.bin *.msr *.nxs)"));
3165 if (fileName.isEmpty())
3168 QVector<QString> cmd;
3169 QString str =
fAdmin->getExecPath() +
"/dump_header";
3172 cmd.append(fileName);
3176 dumpOutputHandler.setModal(
false);
3177 dumpOutputHandler.exec();
3188 cmd =
fAdmin->getExecPath() +
"/mupp";
3189#if defined(Q_OS_DARWIN)
3190 cmd = QString(
"/Applications/mupp.app/Contents/MacOS/mupp");
3195 QProcess *proc =
new QProcess(
this);
3201 QString workDir = QFileInfo(fln).absolutePath();
3204 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
3205#if defined(Q_OS_DARWIN)
3206 env.insert(
"DYLD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:/usr/local/lib:" + env.value(
"DYLD_LIBRARY_PATH"));
3208 env.insert(
"LD_LIBRARY_PATH", env.value(
"ROOTSYS") +
"/lib:" + env.value(
"LD_LIBRARY_PATH"));
3210 proc->setProcessEnvironment(env);
3211 proc->setWorkingDirectory(workDir);
3212 proc->start(cmd, arg);
3213 if (!proc->waitForStarted()) {
3215 QString msg(tr(
"Could not execute the output command: ")+cmd);
3216 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
3227 bool ok = QDesktopServices::openUrl(QUrl(
fAdmin->getHelpUrl(
"main"), QUrl::TolerantMode));
3229 QString msg = QString(
"<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(
fAdmin->getHelpUrl(
"main"));
3230 QMessageBox::critical(
nullptr, tr(
"FATAL ERROR"), msg, QMessageBox::Close );
3250 QMessageBox::aboutQt(
this);
3262 if (exitStatus == QProcess::CrashExit) {
3263 QMessageBox::critical(
nullptr,
"FATAL ERROR",
"musrWiz returned CrashExit.");
3272 QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
3273 QString pathName = procEnv.value(
"HOME",
"");
3274 pathName +=
"/.musrfit/musredit/musrWiz.log";
3276 std::ifstream fin(pathName.toLatin1().data(), std::ifstream::in);
3277 if (!fin.is_open()) {
3278 errMsg = QString(
"PTextEdit::exitStatusMusrWiz: couldn't read %1 file.").arg(pathName);
3279 QMessageBox::critical(
nullptr,
"ERROR", errMsg);
3283 bool musrT0tag =
false;
3284 QString str, pathFileName(
"");
3285 while (fin.good()) {
3286 fin.getline(line, 128);
3288 if (str.startsWith(
"path-file-name:")) {
3289 pathFileName = str.mid(16);
3290 }
else if (str.startsWith(
"musrt0-tag: yes")) {
3301 if (tabStr ==
"noname") {
3311 QFile logFile(pathName);
3312 if (!logFile.remove()) {
3313 errMsg = QString(
"PTextEdit::exitStatusMusrWiz: couldn't delete %1 file.").arg(pathName);
3314 QMessageBox::critical(
nullptr,
"ERROR", errMsg);
3326 if (exitStatus == QProcess::CrashExit) {
3327 QMessageBox::critical(
nullptr,
"FATAL ERROR",
"musrStep returned CrashExit.");
3352 fComboFont->lineEdit()->setText( f.family() );
3353 fComboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
3384 tabLabel.truncate(tabLabel.length()-1);
3411 str = QString(
"cursor pos: %1, %2").arg(line+1).arg(pos+1);
3412 statusBar()->showMessage(str);
3447 QTextDocument::FindFlags flags;
3449 flags |= QTextDocument::FindCaseSensitively;
3451 flags |= QTextDocument::FindBackward;
3453 flags |= QTextDocument::FindWholeWords;
3468 QFont font(
fAdmin->getFontName(),
fAdmin->getFontSize());
3485 QString str =
"File '" + fileName +
"' changed on the system.\nDo you want to reload it?";
3486 int result = QMessageBox::question(
this,
"INFO", str, QMessageBox::Yes, QMessageBox::No);
3487 if (result == QMessageBox::Yes) {
3491 if (
fTabWidget->tabText(i) == QFileInfo(fileName).fileName()) {
3508 load(fileName, idx);
3546 QTextDocument::FindFlags flags= QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords;
3563 if (
fAdmin->getIgnoreThemeAutoDetection())
3569 QString str = QIcon::themeName();
3571 if (str.isEmpty()) {
3572 str = QProcessEnvironment::systemEnvironment().value(
"HOME", QString(
"??"));
3573 str +=
"/.kde4/share/config/kdeglobals";
3575 if (QFile::exists(str)) {
3577 if (!fln.open(QIODevice::ReadOnly | QIODevice::Text))
3579 QTextStream fin(&fln);
3581 while (!fin.atEnd() && !done) {
3582 line = fin.readLine();
3583 if (line.contains(
"ColorScheme")) {
3584 if (line.contains(
"dark", Qt::CaseInsensitive)) {
3596 if (str.contains(
"dark", Qt::CaseInsensitive)) {
3598 if (str.contains(
"ubuntu", Qt::CaseInsensitive) ||
3599 str.contains(
"xfce", Qt::CaseInsensitive) ||
3600 str.contains(
"mx", Qt::CaseInsensitive)) {
3617 for (
int i=0; i<
fAdmin->getNumRecentFiles(); i++) {
3642 QStringList tok = runListStr.split(
' ', Qt::SkipEmptyParts);
3643 for (
int i=0; i<tok.size(); i++) {
3644 if (tok[i].contains(
'-')) {
3645 QStringList runListTok = tok[i].split(
'-', Qt::SkipEmptyParts);
3646 if (runListTok.size() != 2) {
3652 start = runListTok[0].toInt(&isInt);
3658 end = runListTok[1].toInt(&isInt);
3664 for (
int i=start; i<=end; i++) {
3665 str = QString(
"%1").arg(i);
3668 }
else if (tok[i].contains(
':')) {
3669 QStringList runListTok = tok[i].split(
':', Qt::SkipEmptyParts);
3670 int start{0}, end{0}, step{0};
3671 if (runListTok.size() != 3) {
3676 start = runListTok[0].toInt(&isInt);
3682 end = runListTok[1].toInt(&isInt);
3688 step = runListTok[2].toInt(&isInt);
3695 str = QString(
"%1").arg(start);
3698 }
while (start <= end);
3716 bool result =
false;
3722 finfo2.setFile(tabFln);
3723 if (finfo.absoluteFilePath() == finfo2.absoluteFilePath()) {
3739 if (
fAdmin->getDarkThemeIconsMenuFlag()) {
3740 fActions[
"New"]->setIcon(QIcon(
":/icons/document-new-dark.svg"));
3741 fActions[
"Open"]->setIcon(QIcon(
":/icons/document-open-dark.svg"));
3742 fActions[
"Reload"]->setIcon(QIcon(
":/icons/view-refresh-dark.svg"));
3743 fActions[
"Save"]->setIcon(QIcon(
":/icons/document-save-dark.svg"));
3744 fActions[
"Print"]->setIcon(QIcon(
":/icons/document-print-dark.svg"));
3745 fActions[
"Undo"]->setIcon(QIcon(
":/icons/edit-undo-dark.svg"));
3746 fActions[
"Redo"]->setIcon(QIcon(
":/icons/edit-redo-dark.svg"));
3747 fActions[
"Copy"]->setIcon(QIcon(
":/icons/edit-copy-dark.svg"));
3748 fActions[
"Cut"]->setIcon(QIcon(
":/icons/edit-cut-dark.svg"));
3749 fActions[
"Paste"]->setIcon(QIcon(
":/icons/edit-paste-dark.svg"));
3750 fActions[
"Find"]->setIcon(QIcon(
":/icons/edit-find-dark.svg"));
3751 fActions[
"Find Next"]->setIcon(QIcon(
":/icons/go-next-use-dark.svg"));
3752 fActions[
"Find Previous"]->setIcon(QIcon(
":/icons/go-previous-use-dark.svg"));
3753 fActions[
"musrWiz"]->setIcon(QIcon(
":/icons/musrWiz-32x32-dark.svg"));
3754 fActions[
"calcChisq"]->setIcon(QIcon(
":/icons/musrchisq-dark.svg"));
3755 fActions[
"musrfit"]->setIcon(QIcon(
":/icons/musrfit-dark.svg"));
3756 fActions[
"Swap Msr/Mlog"]->setIcon(QIcon(
":/icons/musrswap-dark.svg"));
3757 fActions[
"musrStep"]->setIcon(QIcon(
":/icons/musrStep-32x32-dark.svg"));
3758 fActions[
"msr2data"]->setIcon(QIcon(
":/icons/msr2data-dark.svg"));
3759 fActions[
"mupp"]->setIcon(QIcon(
":/icons/mupp-dark.svg"));
3760 fActions[
"musrview2dat"]->setIcon(QIcon(
":/icons/musrview2dat-dark.svg"));
3761 fActions[
"musrview"]->setIcon(QIcon(
":/icons/musrview-dark.svg"));
3762 fActions[
"musrt0"]->setIcon(QIcon(
":/icons/musrt0-dark.svg"));
3763 fActions[
"musrFT"]->setIcon(QIcon(
":/icons/musrFT-dark.svg"));
3764 fActions[
"musrprefs"]->setIcon(QIcon(
":/icons/musrprefs-dark.svg"));
3765 fActions[
"musrdump"]->setIcon(QIcon(
":/icons/musrdump-dark.svg"));
3767 fActions[
"New"]->setIcon(QIcon(
":/icons/document-new-plain.svg"));
3768 fActions[
"Open"]->setIcon(QIcon(
":/icons/document-open-plain.svg"));
3769 fActions[
"Reload"]->setIcon(QIcon(
":/icons/view-refresh-plain.svg"));
3770 fActions[
"Save"]->setIcon(QIcon(
":/icons/document-save-plain.svg"));
3771 fActions[
"Print"]->setIcon(QIcon(
":/icons/document-print-plain.svg"));
3772 fActions[
"Undo"]->setIcon(QIcon(
":/icons/edit-undo-plain.svg"));
3773 fActions[
"Redo"]->setIcon(QIcon(
":/icons/edit-redo-plain.svg"));
3774 fActions[
"Copy"]->setIcon(QIcon(
":/icons/edit-copy-plain.svg"));
3775 fActions[
"Cut"]->setIcon(QIcon(
":/icons/edit-cut-plain.svg"));
3776 fActions[
"Paste"]->setIcon(QIcon(
":/icons/edit-paste-plain.svg"));
3777 fActions[
"Find"]->setIcon(QIcon(
":/icons/edit-find-plain.svg"));
3778 fActions[
"Find Next"]->setIcon(QIcon(
":/icons/go-next-use-plain.svg"));
3779 fActions[
"Find Previous"]->setIcon(QIcon(
":/icons/go-previous-use-plain.svg"));
3780 fActions[
"musrWiz"]->setIcon(QIcon(
":/icons/musrWiz-32x32.svg"));
3781 fActions[
"calcChisq"]->setIcon(QIcon(
":/icons/musrchisq-plain.svg"));
3782 fActions[
"musrfit"]->setIcon(QIcon(
":/icons/musrfit-plain.svg"));
3783 fActions[
"Swap Msr/Mlog"]->setIcon(QIcon(
":/icons/musrswap-plain.svg"));
3784 fActions[
"musrStep"]->setIcon(QIcon(
":/icons/musrStep-32x32.svg"));
3785 fActions[
"msr2data"]->setIcon(QIcon(
":/icons/msr2data-plain.svg"));
3786 fActions[
"mupp"]->setIcon(QIcon(
":/icons/mupp-plain.svg"));
3787 fActions[
"musrview2dat"]->setIcon(QIcon(
":/icons/musrview2dat-plain.svg"));
3788 fActions[
"musrview"]->setIcon(QIcon(
":/icons/musrview-plain.svg"));
3789 fActions[
"musrt0"]->setIcon(QIcon(
":/icons/musrt0-plain.svg"));
3790 fActions[
"musrFT"]->setIcon(QIcon(
":/icons/musrFT-plain.svg"));
3791 fActions[
"musrprefs"]->setIcon(QIcon(
":/icons/musrprefs-plain.svg"));
3792 fActions[
"musrdump"]->setIcon(QIcon(
":/icons/musrdump-plain.svg"));
3802 if (
fAdmin->getDarkThemeIconsToolbarFlag()) {
3803 fActions[
"New-tb"]->setIcon(QIcon(
":/icons/document-new-dark.svg"));
3804 fActions[
"Open-tb"]->setIcon(QIcon(
":/icons/document-open-dark.svg"));
3805 fActions[
"Reload-tb"]->setIcon(QIcon(
":/icons/view-refresh-dark.svg"));
3806 fActions[
"Save-tb"]->setIcon(QIcon(
":/icons/document-save-dark.svg"));
3807 fActions[
"Print-tb"]->setIcon(QIcon(
":/icons/document-print-dark.svg"));
3808 fActions[
"Undo-tb"]->setIcon(QIcon(
":/icons/edit-undo-dark.svg"));
3809 fActions[
"Redo-tb"]->setIcon(QIcon(
":/icons/edit-redo-dark.svg"));
3810 fActions[
"Copy-tb"]->setIcon(QIcon(
":/icons/edit-copy-dark.svg"));
3811 fActions[
"Cut-tb"]->setIcon(QIcon(
":/icons/edit-cut-dark.svg"));
3812 fActions[
"Paste-tb"]->setIcon(QIcon(
":/icons/edit-paste-dark.svg"));
3813 fActions[
"Find-tb"]->setIcon(QIcon(
":/icons/edit-find-dark.svg"));
3814 fActions[
"Find Next-tb"]->setIcon(QIcon(
":/icons/go-next-use-dark.svg"));
3815 fActions[
"Find Previous-tb"]->setIcon(QIcon(
":/icons/go-previous-use-dark.svg"));
3816 fActions[
"musrWiz-tb"]->setIcon(QIcon(
":/icons/musrWiz-32x32-dark.svg"));
3817 fActions[
"calcChisq-tb"]->setIcon(QIcon(
":/icons/musrchisq-dark.svg"));
3818 fActions[
"musrfit-tb"]->setIcon(QIcon(
":/icons/musrfit-dark.svg"));
3819 fActions[
"Swap Msr/Mlog-tb"]->setIcon(QIcon(
":/icons/musrswap-dark.svg"));
3820 fActions[
"musrStep-tb"]->setIcon(QIcon(
":/icons/musrStep-32x32-dark.svg"));
3821 fActions[
"msr2data-tb"]->setIcon(QIcon(
":/icons/msr2data-dark.svg"));
3822 fActions[
"mupp-tb"]->setIcon(QIcon(
":/icons/mupp-dark.svg"));
3823 fActions[
"musrview2dat-tb"]->setIcon(QIcon(
":/icons/musrview2dat-dark.svg"));
3824 fActions[
"musrview-tb"]->setIcon(QIcon(
":/icons/musrview-dark.svg"));
3825 fActions[
"musrt0-tb"]->setIcon(QIcon(
":/icons/musrt0-dark.svg"));
3826 fActions[
"musrFT-tb"]->setIcon(QIcon(
":/icons/musrFT-dark.svg"));
3827 fActions[
"musrprefs-tb"]->setIcon(QIcon(
":/icons/musrprefs-dark.svg"));
3828 fActions[
"musrdump-tb"]->setIcon(QIcon(
":/icons/musrdump-dark.svg"));
3830 fActions[
"New-tb"]->setIcon(QIcon(
":/icons/document-new-plain.svg"));
3831 fActions[
"Open-tb"]->setIcon(QIcon(
":/icons/document-open-plain.svg"));
3832 fActions[
"Reload-tb"]->setIcon(QIcon(
":/icons/view-refresh-plain.svg"));
3833 fActions[
"Save-tb"]->setIcon(QIcon(
":/icons/document-save-plain.svg"));
3834 fActions[
"Print-tb"]->setIcon(QIcon(
":/icons/document-print-plain.svg"));
3835 fActions[
"Undo-tb"]->setIcon(QIcon(
":/icons/edit-undo-plain.svg"));
3836 fActions[
"Redo-tb"]->setIcon(QIcon(
":/icons/edit-redo-plain.svg"));
3837 fActions[
"Copy-tb"]->setIcon(QIcon(
":/icons/edit-copy-plain.svg"));
3838 fActions[
"Cut-tb"]->setIcon(QIcon(
":/icons/edit-cut-plain.svg"));
3839 fActions[
"Paste-tb"]->setIcon(QIcon(
":/icons/edit-paste-plain.svg"));
3840 fActions[
"Find-tb"]->setIcon(QIcon(
":/icons/edit-find-plain.svg"));
3841 fActions[
"Find Next-tb"]->setIcon(QIcon(
":/icons/go-next-use-plain.svg"));
3842 fActions[
"Find Previous-tb"]->setIcon(QIcon(
":/icons/go-previous-use-plain.svg"));
3843 fActions[
"musrWiz-tb"]->setIcon(QIcon(
":/icons/musrWiz-32x32.svg"));
3844 fActions[
"calcChisq-tb"]->setIcon(QIcon(
":/icons/musrchisq-plain.svg"));
3845 fActions[
"musrfit-tb"]->setIcon(QIcon(
":/icons/musrfit-plain.svg"));
3846 fActions[
"Swap Msr/Mlog-tb"]->setIcon(QIcon(
":/icons/musrswap-plain.svg"));
3847 fActions[
"musrStep-tb"]->setIcon(QIcon(
":/icons/musrStep-32x32.svg"));
3848 fActions[
"msr2data-tb"]->setIcon(QIcon(
":/icons/msr2data-plain.svg"));
3849 fActions[
"mupp-tb"]->setIcon(QIcon(
":/icons/mupp-plain.svg"));
3850 fActions[
"musrview2dat-tb"]->setIcon(QIcon(
":/icons/musrview2dat-plain.svg"));
3851 fActions[
"musrview-tb"]->setIcon(QIcon(
":/icons/musrview-plain.svg"));
3852 fActions[
"musrt0-tb"]->setIcon(QIcon(
":/icons/musrt0-plain.svg"));
3853 fActions[
"musrFT-tb"]->setIcon(QIcon(
":/icons/musrFT-plain.svg"));
3854 fActions[
"musrprefs-tb"]->setIcon(QIcon(
":/icons/musrprefs-plain.svg"));
3855 fActions[
"musrdump-tb"]->setIcon(QIcon(
":/icons/musrdump-plain.svg"));
Administration and configuration management for musredit.
Dialog for displaying dump_header command output.
Find dialog for text searching in musredit.
Dialog for displaying musrfit fitting process output.
Dialog for configuring musrFT command-line options.
Dialog interface for the msr2data batch processing tool.
About dialog for the musredit application.
Preferences dialog for musredit application settings.
Confirmation dialog for find-and-replace operations in musredit.
Find and replace dialog for the musredit text editor.
Enhanced text editor widget for editing msr files in musredit.
Main window class for the musredit application.
Dialog for executing and displaying dump_header command output.
Dialog for searching text in the editor.
virtual PFindReplaceData * getData()
Retrieves the search parameters from the dialog.
Dialog for executing and monitoring musrfit fitting processes.
Dialog for configuring musrFT Fourier transform tool options.
QStringList getMusrFTOptions()
Builds and returns the musrFT command-line options.
Dialog for configuring msr2data batch processing parameters.
virtual int getRunTag()
Returns the run input method tag.
virtual PMsr2DataParam * getMsr2DataParam()
Retrieves all msr2data parameters from the dialog.
About dialog displaying version and build information.
Preferences dialog for configuring musredit and musrfit settings.
int getTimeout()
Returns the fitting timeout preference.
bool getEstimateN0Flag()
Returns the N0 estimation preference.
bool getMusrviewShowFourierFlag()
Returns the musrview Fourier display preference.
bool getMusrviewShowAvgFlag()
Returns the musrview average display preference.
int getDump()
Returns the dump format preference.
bool getTitleFromDataFileFlag()
Returns the title-from-data-file preference.
bool getMusrviewShowOneToOneFlag()
Returns the musrview one-to-one plotting preference.
bool getEnableMusrT0Flag()
Returns the musrT0 enablement preference.
bool getYamlOutFlag()
Returns the YAML output preference.
bool getDarkThemeIconsToolbarFlag()
Returns the dark theme toolbar icons preference.
bool getDarkThemeIconsMenuFlag()
Returns the dark theme menu icons preference.
bool getIgnoreThemeAutoDetection()
Returns the theme auto-detection override preference.
bool getKeepRunPerBlockChisqFlag()
Returns the per-run chi-square preference.
bool getKeepMinuit2OutputFlag()
Returns the MINUIT2 output preservation preference.
Confirmation dialog for interactive find-and-replace operations.
Find and replace dialog for text editing operations.
virtual PFindReplaceData * getData()
Retrieves updated find/replace parameters from the dialog.
Enhanced text editor for msr file editing with block insertion support.
void insertTheoryBlock()
Slot: Inserts a THEORY block via dialog.
void insertPlotBlock()
Slot: Inserts a PLOT block via dialog.
void insertFourierBlock()
Slot: Inserts a FOURIER block via dialog.
void insertFunctionBlock()
Slot: Inserts a FUNCTIONS block via dialog.
void insertTitle()
Slot: Inserts a title block via dialog.
void insertParameterBlock()
Slot: Inserts a FITPARAMETER block via dialog.
void insertNonMusrRunBlock()
Slot: Inserts a non-µSR RUN block via dialog.
void insertStatisticBlock()
Slot: Inserts a default STATISTIC block.
void insertTheoryFunction(QString name)
Slot: Inserts a specific theory function.
void insertCommandBlock()
Slot: Inserts a default COMMANDS block.
int getFitType()
Retrieves the fit type from the current msr file content.
void insertSingleHistRunBlock()
Slot: Inserts a single histogram RUN block via dialog.
void insertAsymRunBlock()
Slot: Inserts an asymmetry RUN block via dialog.
void exitStatusMusrWiz(int exitCode, QProcess::ExitStatus exitStatus)
Slot: Handles exit status of musrWiz process.
void insertTheoryBlock()
Slot: Inserts a THEORY block into the current editor.
void replaceAll()
Slot: Replaces all occurrences without prompting.
QMap< QString, QAction * > fActions
QString fLastDirInUse
string holding the path from where the last file was loaded.
void setupFileActions()
Initializes File menu and toolbar actions.
std::unique_ptr< QComboBox > fComboSize
combo box for the font size
void musrView()
Slot: Launches musrView for viewing fit results.
PMsr2DataParam * fMsr2DataParam
structure holding the necessary input information for msr2data
QStringList getRunList(QString runListStr, bool &ok)
Parses a run list string into individual run numbers.
QTimer fFileSystemWatcherTimeout
timer used to re-enable file system watcher. Needed to delay the re-enabling
bool fileAlreadyOpen(QFileInfo &finfo, int &idx)
Checks if a file is already open in a tab.
void editUndo()
Slot: Undo last edit operation.
void fileCloseAll()
Slot: Closes all open tabs.
void editComment()
Slot: Comments out selected lines.
std::unique_ptr< QComboBox > fComboFont
combo box for the font selector
void musrDump()
Slot: Dumps raw histogram data from run files.
void applyFontSettings(int)
Slot: Applies font settings when tab changes.
void fileSystemWatcherActivation()
Manages file system watcher activation state.
void musrWiz()
Slot: Launches musrWiz (msr file creation wizard).
bool fFileSystemWatcherActive
flag to enable/disable the file system watcher
void fileSaveAs()
Slot: Saves the current file with a new name.
void close()
Signal: Emitted when the main window is closing.
void load(const QString &f, const int index=-1)
Loads a file into the editor.
void editCut()
Slot: Cut selected text to clipboard.
void fontChanged(const QFont &f)
Slot: Responds to font changes in editor.
PTextEdit(QWidget *parent=nullptr)
Constructs the main musredit window.
void setupHelpActions()
Initializes Help menu actions.
bool fFontChanging
flag needed to prevent some textChanged feature to occure when only the font changed
void aboutToQuit()
Slot: Cleanup handler called before application quits.
void fileSavePrefs()
Slot: Saves the preferences file.
PFindReplaceData * fFindReplaceData
structure holding the ncessary input for find/replace
void musrCalcChisq()
Slot: Calculates chi-square for current msr file.
void insertFunctionBlock()
Slot: Inserts a FUNCTIONS block into the current editor.
QMap< PSubTextEdit *, QString > fFilenames
mapper between tab widget object and filename
void fillRecentFiles()
Populates the Recent Files menu.
bool getTheme()
Detects the current system theme.
void textChanged(const bool forced=false)
Slot: Responds to text changes in editor.
void musrSetSteps()
Slot: Launches musrStep for setting fit step sizes.
std::unique_ptr< QFileSystemWatcher > fFileSystemWatcher
checks if msr-files are changing on the disk while being open in musredit.
void fileSave()
Slot: Saves the current file.
void musrFit()
Slot: Executes fit with current msr file.
void helpContents()
Slot: Opens online documentation.
void helpAboutQt()
Slot: Displays Qt About dialog.
QAction * fRecentFilesAction[MAX_RECENT_FILES]
array of the recent file actions
bool fDarkToolBarIcon
flag indicating if a dark or plain icon shall be used in the toolbar
QStringList fMusrFTPrevCmd
void fileOpenPrefs()
Slot: Opens the preferences file in a new tab.
void fileCloseAllOthers()
Slot: Closes all tabs except the current one.
void setupMusrActions()
Initializes Musr menu and toolbar actions.
void setupTextActions()
Initializes Text menu and toolbar actions.
void editUncomment()
Slot: Uncomments selected lines.
void insertTheoryFunction(QAction *a)
Slot: Inserts a specific theory function into the current editor.
void switchToolbarIcons()
Switches toolbar icons between dark and plain variants.
void editRedo()
Slot: Redo previously undone edit operation.
void insertParameterBlock()
Slot: Inserts a FITPARAMETER block into the current editor.
void insertCommandBlock()
Slot: Inserts a COMMANDS block into the current editor.
void fileChanged(const QString &fileName)
Slot: Handles file system watcher notifications.
std::unique_ptr< PAdmin > fAdmin
pointer to the xml-startup file informations. Needed for different purposes like default working- and...
void insertTitle()
Slot: Inserts a title block into the current editor.
void helpAbout()
Slot: Displays musredit About dialog.
void editSelectAll()
Slot: Select all text in current editor.
void fileExit()
Slot: Exits the application.
void editFindAndReplace()
Slot: Opens find and replace dialog.
void musrSwapMsrMlog()
Slot: Swaps between .msr and .mlog files.
void setFileSystemWatcherActive()
Slot: Re-enables file system watcher after delay.
PSubTextEdit * currentEditor() const
Gets the currently active editor widget.
void insertPlotBlock()
Slot: Inserts a PLOT block into the current editor.
void insertNonMusrRunBlock()
Slot: Inserts a non-µSR RUN block into the current editor.
std::unique_ptr< QComboBox > fJumpToBlock
combo box used to jump to the msr-file blocks
void editFindNext()
Slot: Finds next occurrence of search text.
void musrView2Dat()
Slot: Launches musrView in 2-data file mode.
void replace()
Slot: Replaces current match and finds next occurrence.
void mupp()
Slot: Launches mupp (muon parameter plot).
void textFamily(const QString &f)
Slot: Changes font family for current editor.
void setupEditActions()
Initializes Edit menu and toolbar actions.
void editFind()
Slot: Opens find dialog.
std::unique_ptr< QAction > fMusrT0Action
void currentCursorPosition()
Slot: Updates status bar with current cursor position.
void setupJumpToBlock()
Initializes the Jump to Block combo box.
void musrFT()
Slot: Opens Fourier transform dialog.
void fileReload()
Slot: Reloads the current file from disk.
void filePrint()
Slot: Prints the current file.
void editFindPrevious()
Slot: Finds previous occurrence of search text.
void editCopy()
Slot: Copy selected text to clipboard.
void musrPrefs()
Slot: Opens preferences dialog.
void insertAsymRunBlock()
Slot: Inserts an asymmetry RUN block into the current editor.
void fileOpen()
Slot: Opens a file dialog to load an msr file.
void insertSingleHistRunBlock()
Slot: Inserts a single histogram RUN block into the current editor.
void insertStatisticBlock()
Slot: Inserts a STATISTIC block into the current editor.
void switchMenuIcons()
Switches menu icons between dark and plain variants.
void insertFourierBlock()
Slot: Inserts a FOURIER block into the current editor.
void fileOpenRecent()
Slot: Opens a recently used file.
void textSize(const QString &p)
Slot: Changes font size for current editor.
void exitStatusMusrSetSteps(int exitCode, QProcess::ExitStatus exitStatus)
Slot: Handles exit status of musrSetSteps process.
void jumpToBlock(int idx)
Slot: Jumps cursor to selected msr file block.
void musrT0()
Slot: Opens musrT0 dialog for determining t0 timing parameter.
bool fDarkMenuIcon
flag indicating if a dark or plain icon shall be used in the menu pull-downs
void musrMsr2Data()
Slot: Opens msr2data conversion dialog.
std::unique_ptr< QTabWidget > fTabWidget
tab widget in which the text editor(s) are placed
void editPaste()
Slot: Paste text from clipboard at cursor position.
void doConnections(PSubTextEdit *e)
Establishes signal-slot connections for an editor.
void fileClose(const bool check=true)
Slot: Closes the current tab.
QMenu * fRecentFilesMenu
recent file menu
void fileNew()
Slot: Creates a new empty msr file in a new tab.
void replaceAndClose()
Slot: Replaces current match and closes replace dialog.
#define MAX_RECENT_FILES
Maximum number of recently opened files to track.
Configuration structure for find and replace operations.
Parameter structure for msr2data tool integration.
Structure holding information about a musrfit theory function.
QString label
Short label for GUI menus and buttons.