Raw -> Smart Pointers for musredit qt5.
This commit is contained in:
parent
afbe8a8ee6
commit
4d516d659d
@ -36,7 +36,7 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#include <musredit.h>
|
#include "musredit.h"
|
||||||
|
|
||||||
class PAdmin;
|
class PAdmin;
|
||||||
|
|
||||||
@ -208,8 +208,8 @@ class PAdmin : public QObject
|
|||||||
bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
|
bool fEnableMusrT0; ///< flag indicating if musrT0 shall be enabled at startup from within musredit (default: yes).
|
||||||
bool fDarkThemeIconsMenu; ///< flag indicating if dark theme icons shall be used in the menu (default: no)
|
bool fDarkThemeIconsMenu; ///< flag indicating if dark theme icons shall be used in the menu (default: no)
|
||||||
bool fDarkThemeIconsToolbar; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no)
|
bool fDarkThemeIconsToolbar; ///< flag indicating if dark theme icons shall be used in the toolbar (default: no)
|
||||||
int fEditWidth; ///< startup edit width
|
int fEditWidth{900}; ///< startup edit width
|
||||||
int fEditHeight; ///< startup edit height
|
int fEditHeight{800}; ///< startup edit height
|
||||||
|
|
||||||
QString fBeamline; ///< name of the beamline. Used to generate default run header lines.
|
QString fBeamline; ///< name of the beamline. Used to generate default run header lines.
|
||||||
QString fInstitute; ///< name of the institute. Used to generate default run header lines.
|
QString fInstitute; ///< name of the institute. Used to generate default run header lines.
|
||||||
|
@ -92,7 +92,7 @@ bool PDefaultPathsXMLParser::parse(QIODevice *device)
|
|||||||
if (fXml.hasError()) {
|
if (fXml.hasError()) {
|
||||||
QString msg;
|
QString msg;
|
||||||
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
|
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
|
||||||
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
QMessageBox::critical(nullptr, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ PDefaultPaths::PDefaultPaths() : QObject()
|
|||||||
PDefaultPathsXMLParser handler(fPrefPathName, this);
|
PDefaultPathsXMLParser handler(fPrefPathName, this);
|
||||||
if (!handler.isValid()) {
|
if (!handler.isValid()) {
|
||||||
fValid = false;
|
fValid = false;
|
||||||
QMessageBox::critical(0, "ERROR",
|
QMessageBox::critical(nullptr, "ERROR",
|
||||||
"Error parsing musrfit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
|
"Error parsing musrfit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
|
||||||
QMessageBox::Ok, QMessageBox::NoButton);
|
QMessageBox::Ok, QMessageBox::NoButton);
|
||||||
return;
|
return;
|
||||||
@ -219,8 +219,7 @@ PDefaultPaths::PDefaultPaths() : QObject()
|
|||||||
*/
|
*/
|
||||||
PChangeDefaultPathsDialog::PChangeDefaultPathsDialog()
|
PChangeDefaultPathsDialog::PChangeDefaultPathsDialog()
|
||||||
{
|
{
|
||||||
fDefaultPath = 0;
|
fDefaultPath = std::make_unique<PDefaultPaths>();
|
||||||
fDefaultPath = new PDefaultPaths();
|
|
||||||
if (!fDefaultPath->isValid())
|
if (!fDefaultPath->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#ifndef _PCHANGEDEFAULTPATHSDIALOG_H_
|
#ifndef _PCHANGEDEFAULTPATHSDIALOG_H_
|
||||||
#define _PCHANGEDEFAULTPATHSDIALOG_H_
|
#define _PCHANGEDEFAULTPATHSDIALOG_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
@ -98,7 +100,7 @@ class PChangeDefaultPathsDialog : public QDialog, private Ui::PChangeDefaultPath
|
|||||||
void saveDefaultPathList();
|
void saveDefaultPathList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PDefaultPaths *fDefaultPath;
|
std::unique_ptr<PDefaultPaths> fDefaultPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PCHANGEDEFAULTPATHSDIALOG_H_
|
#endif // _PCHANGEDEFAULTPATHSDIALOG_H_
|
||||||
|
@ -45,20 +45,20 @@ PDumpOutputHandler::PDumpOutputHandler(QVector<QString> &cmd)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
fVbox = new QVBoxLayout( this );
|
fVbox = std::make_unique<QVBoxLayout>( this );
|
||||||
fOutput = new QTextEdit();
|
fOutput = std::make_unique<QTextEdit>();
|
||||||
fVbox->addWidget(fOutput);
|
fVbox->addWidget(fOutput.get());
|
||||||
fOutput->setMinimumSize(600, 755);
|
fOutput->setMinimumSize(600, 755);
|
||||||
fOutput->setReadOnly(true);
|
fOutput->setReadOnly(true);
|
||||||
connect( fOutput, SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
|
connect( fOutput.get(), SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
|
||||||
fQuitButton = new QPushButton( tr("Quit") );
|
fQuitButton = std::make_unique<QPushButton>( tr("Quit") );
|
||||||
fVbox->addWidget(fQuitButton);
|
fVbox->addWidget(fQuitButton.get());
|
||||||
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
|
connect( fQuitButton.get(), SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
|
||||||
resize( 600, 800 );
|
resize( 600, 800 );
|
||||||
fQuitButton->setFocus();
|
fQuitButton->setFocus();
|
||||||
|
|
||||||
// QProcess related code
|
// QProcess related code
|
||||||
fProc = new QProcess( this );
|
fProc = std::make_unique<QProcess>( this );
|
||||||
|
|
||||||
// make sure that the system environment variables are properly set
|
// make sure that the system environment variables are properly set
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
@ -75,15 +75,15 @@ PDumpOutputHandler::PDumpOutputHandler(QVector<QString> &cmd)
|
|||||||
for (int i=1; i<cmd.size(); i++)
|
for (int i=1; i<cmd.size(); i++)
|
||||||
arguments << cmd[i];
|
arguments << cmd[i];
|
||||||
|
|
||||||
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
|
connect( fProc.get(), SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
|
||||||
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
|
connect( fProc.get(), SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
|
||||||
|
|
||||||
|
|
||||||
fProc->start(program, arguments);
|
fProc->start(program, arguments);
|
||||||
if ( !fProc->waitForStarted() ) {
|
if ( !fProc->waitForStarted() ) {
|
||||||
// error handling
|
// error handling
|
||||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
||||||
QMessageBox::critical( 0,
|
QMessageBox::critical( nullptr,
|
||||||
tr("Fatal error"),
|
tr("Fatal error"),
|
||||||
msg,
|
msg,
|
||||||
tr("Quit") );
|
tr("Quit") );
|
||||||
@ -132,10 +132,6 @@ PDumpOutputHandler::~PDumpOutputHandler()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fProc) {
|
|
||||||
delete fProc;
|
|
||||||
fProc = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#ifndef _PDUMPOUTPUTHANDLER_H_
|
#ifndef _PDUMPOUTPUTHANDLER_H_
|
||||||
#define _PDUMPOUTPUTHANDLER_H_
|
#define _PDUMPOUTPUTHANDLER_H_
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@ -39,8 +42,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
|
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
|
||||||
@ -62,11 +63,11 @@ class PDumpOutputHandler : public QDialog
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PID fProcPID; ///< keeps the process PID
|
Q_PID fProcPID; ///< keeps the process PID
|
||||||
QProcess *fProc; ///< pointer to the dump_header process
|
std::unique_ptr<QProcess> fProc; ///< pointer to the dump_header process
|
||||||
|
|
||||||
QVBoxLayout *fVbox; ///< pointer to the dialog layout manager
|
std::unique_ptr<QVBoxLayout> fVbox; ///< pointer to the dialog layout manager
|
||||||
QTextEdit *fOutput; ///< the captured dump_header output is written (read only) into this text edit object.
|
std::unique_ptr<QTextEdit> fOutput; ///< the captured dump_header output is written (read only) into this text edit object.
|
||||||
QPushButton *fQuitButton; ///< quit button
|
std::unique_ptr<QPushButton> fQuitButton; ///< quit button
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PDUMPOUTPUTHANDLER_H_
|
#endif // _PDUMPOUTPUTHANDLER_H_
|
||||||
|
@ -46,22 +46,21 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QVector<QString>
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
fVbox = new QVBoxLayout( this );
|
fVbox = std::make_unique<QVBoxLayout>( this );
|
||||||
//Qt.3x fVbox->resize(800, 500);
|
fOutput = std::make_unique<QPlainTextEdit>();
|
||||||
fOutput = new QPlainTextEdit();
|
|
||||||
fOutput->setMaximumBlockCount(1000);
|
fOutput->setMaximumBlockCount(1000);
|
||||||
fVbox->addWidget(fOutput);
|
fVbox->addWidget(fOutput.get());
|
||||||
fOutput->setMinimumSize(800, 455);
|
fOutput->setMinimumSize(800, 455);
|
||||||
fOutput->setReadOnly(true);
|
fOutput->setReadOnly(true);
|
||||||
connect( fOutput, SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
|
connect( fOutput.get(), SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
|
||||||
fQuitButton = new QPushButton( tr("Fitting...") );
|
fQuitButton = std::make_unique<QPushButton>( tr("Fitting...") );
|
||||||
fVbox->addWidget(fQuitButton);
|
fVbox->addWidget(fQuitButton.get());
|
||||||
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
|
connect( fQuitButton.get(), SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
|
||||||
resize( 800, 500 );
|
resize( 800, 500 );
|
||||||
fQuitButton->setFocus();
|
fQuitButton->setFocus();
|
||||||
|
|
||||||
// QProcess related code
|
// QProcess related code
|
||||||
fProc = new QProcess( this );
|
fProc = std::make_unique<QProcess>( this );
|
||||||
|
|
||||||
// make sure that the system environment variables are properly set
|
// make sure that the system environment variables are properly set
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
@ -83,9 +82,9 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QVector<QString>
|
|||||||
for (int i=1; i<cmd.size(); i++)
|
for (int i=1; i<cmd.size(); i++)
|
||||||
arguments << cmd[i];
|
arguments << cmd[i];
|
||||||
|
|
||||||
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
|
connect( fProc.get(), SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
|
||||||
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
|
connect( fProc.get(), SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
|
||||||
connect( fProc, SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
|
connect( fProc.get(), SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
|
||||||
|
|
||||||
fProc->start(program, arguments);
|
fProc->start(program, arguments);
|
||||||
if ( !fProc->waitForStarted() ) {
|
if ( !fProc->waitForStarted() ) {
|
||||||
@ -138,10 +137,6 @@ PFitOutputHandler::~PFitOutputHandler()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fProc) {
|
|
||||||
delete fProc;
|
|
||||||
fProc = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#ifndef _PFITOUTPUTHANDLER_H_
|
#ifndef _PFITOUTPUTHANDLER_H_
|
||||||
#define _PFITOUTPUTHANDLER_H_
|
#define _PFITOUTPUTHANDLER_H_
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@ -39,8 +42,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
|
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
|
||||||
@ -63,11 +64,11 @@ class PFitOutputHandler : public QDialog
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PID fProcPID; ///< keeps the process PID
|
Q_PID fProcPID; ///< keeps the process PID
|
||||||
QProcess *fProc; ///< pointer to the musrfit process
|
std::unique_ptr<QProcess> fProc; ///< pointer to the musrfit process
|
||||||
|
|
||||||
QVBoxLayout *fVbox; ///< pointer to the dialog layout manager
|
std::unique_ptr<QVBoxLayout> fVbox; ///< pointer to the dialog layout manager
|
||||||
QPlainTextEdit *fOutput; ///< the captured musrfit output is written (read only) into this text edit object.
|
std::unique_ptr<QPlainTextEdit> fOutput; ///< the captured musrfit output is written (read only) into this text edit object.
|
||||||
QPushButton *fQuitButton; ///< quit button, either to interrupt the fit or to close the dialog at the end of the fit.
|
std::unique_ptr<QPushButton> fQuitButton; ///< quit button, either to interrupt the fit or to close the dialog at the end of the fit.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PFITOUTPUTHANDLER_H_
|
#endif // _PFITOUTPUTHANDLER_H_
|
||||||
|
@ -91,7 +91,7 @@ PTextEdit::PTextEdit( QWidget *parent )
|
|||||||
bool gotTheme = getTheme();
|
bool gotTheme = getTheme();
|
||||||
|
|
||||||
// reads and manages the conents of the xml-startup (musredit_startup.xml) file
|
// reads and manages the conents of the xml-startup (musredit_startup.xml) file
|
||||||
fAdmin = new PAdmin();
|
fAdmin = std::make_unique<PAdmin>();
|
||||||
|
|
||||||
// set default setting of the fDarkMenuIconIcons only if a theme has been recognized, otherwise take the
|
// set default setting of the fDarkMenuIconIcons only if a theme has been recognized, otherwise take the
|
||||||
// one from the xml startup file.
|
// one from the xml startup file.
|
||||||
@ -109,16 +109,14 @@ PTextEdit::PTextEdit( QWidget *parent )
|
|||||||
|
|
||||||
// enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime
|
// enable file system watcher. Needed to get notification if the msr-file is changed outside of musrfit at runtime
|
||||||
fFileSystemWatcherActive = true;
|
fFileSystemWatcherActive = true;
|
||||||
fFileSystemWatcher = new QFileSystemWatcher();
|
fFileSystemWatcher = std::make_unique<QFileSystemWatcher>();
|
||||||
if (fFileSystemWatcher == nullptr) {
|
if (fFileSystemWatcher == nullptr) {
|
||||||
QMessageBox::information(this, "**ERROR**", "Couldn't invoke QFileSystemWatcher!");
|
QMessageBox::information(this, "**ERROR**", "Couldn't invoke QFileSystemWatcher!");
|
||||||
} else {
|
} else {
|
||||||
connect( fFileSystemWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&)));
|
connect( fFileSystemWatcher.get(), SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(const QString&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize stuff
|
// initialize stuff
|
||||||
fMusrT0Action = nullptr;
|
|
||||||
|
|
||||||
fMsr2DataParam = nullptr;
|
fMsr2DataParam = nullptr;
|
||||||
fFindReplaceData = nullptr;
|
fFindReplaceData = nullptr;
|
||||||
|
|
||||||
@ -129,9 +127,9 @@ PTextEdit::PTextEdit( QWidget *parent )
|
|||||||
setupMusrActions();
|
setupMusrActions();
|
||||||
setupHelpActions();
|
setupHelpActions();
|
||||||
|
|
||||||
fTabWidget = new QTabWidget( this );
|
fTabWidget = std::make_unique<QTabWidget>( this );
|
||||||
fTabWidget->setMovable(true); // allows to shuffle around tabs
|
fTabWidget->setMovable(true); // allows to shuffle around tabs
|
||||||
setCentralWidget( fTabWidget );
|
setCentralWidget( fTabWidget.get() );
|
||||||
|
|
||||||
textFamily(fAdmin->getFontName());
|
textFamily(fAdmin->getFontName());
|
||||||
textSize(QString("%1").arg(fAdmin->getFontSize()));
|
textSize(QString("%1").arg(fAdmin->getFontSize()));
|
||||||
@ -152,7 +150,7 @@ PTextEdit::PTextEdit( QWidget *parent )
|
|||||||
fileNew();
|
fileNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( fTabWidget, SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
|
connect( fTabWidget.get(), SIGNAL( currentChanged(int) ), this, SLOT( applyFontSettings(int) ));
|
||||||
|
|
||||||
fLastDirInUse = fAdmin->getDefaultSavePath();
|
fLastDirInUse = fAdmin->getDefaultSavePath();
|
||||||
}
|
}
|
||||||
@ -164,14 +162,6 @@ PTextEdit::PTextEdit( QWidget *parent )
|
|||||||
*/
|
*/
|
||||||
void PTextEdit::aboutToQuit()
|
void PTextEdit::aboutToQuit()
|
||||||
{
|
{
|
||||||
if (fAdmin) {
|
|
||||||
delete fAdmin;
|
|
||||||
fAdmin = nullptr;
|
|
||||||
}
|
|
||||||
if (fMusrT0Action) {
|
|
||||||
delete fMusrT0Action;
|
|
||||||
fMusrT0Action = nullptr;
|
|
||||||
}
|
|
||||||
if (fMsr2DataParam) {
|
if (fMsr2DataParam) {
|
||||||
delete fMsr2DataParam;
|
delete fMsr2DataParam;
|
||||||
fMsr2DataParam = nullptr;
|
fMsr2DataParam = nullptr;
|
||||||
@ -650,33 +640,33 @@ void PTextEdit::setupTextActions()
|
|||||||
tb->setWindowTitle( "Format Actions" );
|
tb->setWindowTitle( "Format Actions" );
|
||||||
addToolBar( tb );
|
addToolBar( tb );
|
||||||
|
|
||||||
fComboFont = new QComboBox();
|
fComboFont = std::make_unique<QComboBox>();
|
||||||
fComboFont->setEditable(true);
|
fComboFont->setEditable(true);
|
||||||
QFontDatabase db;
|
QFontDatabase db;
|
||||||
fComboFont->addItems( db.families() );
|
fComboFont->addItems( db.families() );
|
||||||
connect( fComboFont, SIGNAL( activated( const QString & ) ),
|
connect( fComboFont.get(), SIGNAL( activated( const QString & ) ),
|
||||||
this, SLOT( textFamily( const QString & ) ) );
|
this, SLOT( textFamily( const QString & ) ) );
|
||||||
QLineEdit *edit = fComboFont->lineEdit();
|
QLineEdit *edit = fComboFont->lineEdit();
|
||||||
if (edit == nullptr) {
|
if (edit == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
edit->setText( fAdmin->getFontName() );
|
edit->setText( fAdmin->getFontName() );
|
||||||
tb->addWidget(fComboFont);
|
tb->addWidget(fComboFont.get());
|
||||||
|
|
||||||
fComboSize = new QComboBox( tb );
|
fComboSize = std::make_unique<QComboBox>( tb );
|
||||||
fComboSize->setEditable(true);
|
fComboSize->setEditable(true);
|
||||||
QList<int> sizes = db.standardSizes();
|
QList<int> sizes = db.standardSizes();
|
||||||
QList<int>::Iterator it = sizes.begin();
|
QList<int>::Iterator it = sizes.begin();
|
||||||
for ( ; it != sizes.end(); ++it )
|
for ( ; it != sizes.end(); ++it )
|
||||||
fComboSize->addItem( QString::number( *it ) );
|
fComboSize->addItem( QString::number( *it ) );
|
||||||
connect( fComboSize, SIGNAL( activated( const QString & ) ),
|
connect( fComboSize.get(), SIGNAL( activated( const QString & ) ),
|
||||||
this, SLOT( textSize( const QString & ) ) );
|
this, SLOT( textSize( const QString & ) ) );
|
||||||
edit = fComboSize->lineEdit();
|
edit = fComboSize->lineEdit();
|
||||||
if (edit == nullptr) {
|
if (edit == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
edit->setText( QString("%1").arg(fAdmin->getFontSize()) );
|
edit->setText( QString("%1").arg(fAdmin->getFontSize()) );
|
||||||
tb->addWidget(fComboSize);
|
tb->addWidget(fComboSize.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -868,19 +858,19 @@ void PTextEdit::setupMusrActions()
|
|||||||
iconName = QString(":/icons/musrt0-dark.svg");
|
iconName = QString(":/icons/musrt0-dark.svg");
|
||||||
else
|
else
|
||||||
iconName = QString(":/icons/musrt0-plain.svg");
|
iconName = QString(":/icons/musrt0-plain.svg");
|
||||||
fMusrT0Action = new QAction( QIcon( QPixmap(iconName) ), tr( "&T0" ), this );
|
fMusrT0Action = std::make_unique<QAction>( QIcon( QPixmap(iconName) ), tr( "&T0" ), this );
|
||||||
fMusrT0Action->setStatusTip( tr("Start musrt0") );
|
fMusrT0Action->setStatusTip( tr("Start musrt0") );
|
||||||
connect( fMusrT0Action, SIGNAL( triggered() ), this, SLOT( musrT0() ) );
|
connect( fMusrT0Action.get(), SIGNAL( triggered() ), this, SLOT( musrT0() ) );
|
||||||
menu->addAction(fMusrT0Action);
|
menu->addAction(fMusrT0Action.get());
|
||||||
fActions["musrt0"] = fMusrT0Action;
|
fActions["musrt0"] = fMusrT0Action.get();
|
||||||
if (!fDarkToolBarIcon) { // tool bar icon is not dark, even though the theme is (ubuntu)
|
if (!fDarkToolBarIcon) { // tool bar icon is not dark, even though the theme is (ubuntu)
|
||||||
iconName = QString(":/icons/musrt0-plain.svg");
|
iconName = QString(":/icons/musrt0-plain.svg");
|
||||||
a = new QAction( QIcon( QPixmap(iconName) ), tr( "&T0" ), this );
|
a = new QAction( QIcon( QPixmap(iconName) ), tr( "&T0" ), this );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( musrT0() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( musrT0() ) );
|
||||||
}
|
}
|
||||||
tb->addAction(fMusrT0Action);
|
tb->addAction(fMusrT0Action.get());
|
||||||
fMusrT0Action->setEnabled(fAdmin->getEnableMusrT0Flag());
|
fMusrT0Action->setEnabled(fAdmin->getEnableMusrT0Flag());
|
||||||
fActions["musrt0-tb"] = fMusrT0Action;
|
fActions["musrt0-tb"] = fMusrT0Action.get();
|
||||||
|
|
||||||
// musrFT
|
// musrFT
|
||||||
if (fDarkMenuIcon)
|
if (fDarkMenuIcon)
|
||||||
@ -982,7 +972,7 @@ void PTextEdit::load( const QString &f, const int index )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// create a new text edit object
|
// create a new text edit object
|
||||||
PSubTextEdit *edit = new PSubTextEdit( fAdmin );
|
PSubTextEdit *edit = new PSubTextEdit( fAdmin.get() );
|
||||||
edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize()));
|
edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize()));
|
||||||
|
|
||||||
// place the text edit object at the appropriate tab position
|
// place the text edit object at the appropriate tab position
|
||||||
@ -1022,6 +1012,9 @@ void PTextEdit::load( const QString &f, const int index )
|
|||||||
*/
|
*/
|
||||||
PSubTextEdit *PTextEdit::currentEditor() const
|
PSubTextEdit *PTextEdit::currentEditor() const
|
||||||
{
|
{
|
||||||
|
if (fTabWidget == nullptr)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if ( fTabWidget->currentWidget() ) {
|
if ( fTabWidget->currentWidget() ) {
|
||||||
if (fTabWidget->currentWidget()->inherits( "PSubTextEdit" )) {
|
if (fTabWidget->currentWidget()->inherits( "PSubTextEdit" )) {
|
||||||
return dynamic_cast<PSubTextEdit*>(fTabWidget->currentWidget());
|
return dynamic_cast<PSubTextEdit*>(fTabWidget->currentWidget());
|
||||||
@ -1163,7 +1156,7 @@ void PTextEdit::insertStatisticBlock()
|
|||||||
*/
|
*/
|
||||||
void PTextEdit::fileNew()
|
void PTextEdit::fileNew()
|
||||||
{
|
{
|
||||||
PSubTextEdit *edit = new PSubTextEdit( fAdmin );
|
PSubTextEdit *edit = new PSubTextEdit( fAdmin.get() );
|
||||||
edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize()));
|
edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize()));
|
||||||
doConnections( edit );
|
doConnections( edit );
|
||||||
fTabWidget->addTab( edit, tr( "noname" ) );
|
fTabWidget->addTab( edit, tr( "noname" ) );
|
||||||
@ -2727,7 +2720,7 @@ void PTextEdit::musrFT()
|
|||||||
*/
|
*/
|
||||||
void PTextEdit::musrPrefs()
|
void PTextEdit::musrPrefs()
|
||||||
{
|
{
|
||||||
PPrefsDialog *dlg = new PPrefsDialog(fAdmin);
|
PPrefsDialog *dlg = new PPrefsDialog(fAdmin.get());
|
||||||
|
|
||||||
if (dlg == nullptr) {
|
if (dlg == nullptr) {
|
||||||
QMessageBox::critical(this, "**ERROR** musrPrefs", "Couldn't invoke Preferences Dialog.");
|
QMessageBox::critical(this, "**ERROR** musrPrefs", "Couldn't invoke Preferences Dialog.");
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#ifndef _PTEXTEDIT_H_
|
#ifndef _PTEXTEDIT_H_
|
||||||
#define _PTEXTEDIT_H_
|
#define _PTEXTEDIT_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -40,10 +43,12 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "PAdmin.h"
|
||||||
#include "musredit.h"
|
#include "musredit.h"
|
||||||
|
|
||||||
class PSubTextEdit;
|
class PSubTextEdit;
|
||||||
@ -65,7 +70,6 @@ class PTextEdit : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
PTextEdit( QWidget *parent = nullptr );
|
PTextEdit( QWidget *parent = nullptr );
|
||||||
virtual ~PTextEdit() {}
|
|
||||||
|
|
||||||
int getEditW() { return fEditW; }
|
int getEditW() { return fEditW; }
|
||||||
int getEditH() { return fEditH; }
|
int getEditH() { return fEditH; }
|
||||||
@ -167,8 +171,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
bool fDarkMenuIcon; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs
|
bool fDarkMenuIcon; ///< flag indicating if a dark or plain icon shall be used in the menu pull-downs
|
||||||
bool fDarkToolBarIcon; ///< flag indicating if a dark or plain icon shall be used in the toolbar
|
bool fDarkToolBarIcon; ///< flag indicating if a dark or plain icon shall be used in the toolbar
|
||||||
PAdmin *fAdmin; ///< pointer to the xml-startup file informations. Needed for different purposes like default working- and executable directories etc.
|
std::unique_ptr<PAdmin> fAdmin; ///< pointer to the xml-startup file informations. Needed for different purposes like default working- and executable directories etc.
|
||||||
QFileSystemWatcher *fFileSystemWatcher; ///< checks if msr-files are changing on the disk while being open in musredit.
|
std::unique_ptr<QFileSystemWatcher> fFileSystemWatcher; ///< checks if msr-files are changing on the disk while being open in musredit.
|
||||||
bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher
|
bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher
|
||||||
QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling
|
QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling
|
||||||
QString fLastDirInUse; ///< string holding the path from where the last file was loaded.
|
QString fLastDirInUse; ///< string holding the path from where the last file was loaded.
|
||||||
@ -176,16 +180,16 @@ private:
|
|||||||
int fEditW, fEditH;
|
int fEditW, fEditH;
|
||||||
|
|
||||||
QMap<QString, QAction*> fActions;
|
QMap<QString, QAction*> fActions;
|
||||||
QAction *fMusrT0Action;
|
std::unique_ptr<QAction> fMusrT0Action;
|
||||||
|
|
||||||
PMsr2DataParam *fMsr2DataParam; ///< structure holding the necessary input information for msr2data
|
PMsr2DataParam *fMsr2DataParam; ///< structure holding the necessary input information for msr2data
|
||||||
PFindReplaceData *fFindReplaceData; ///< structure holding the ncessary input for find/replace
|
PFindReplaceData *fFindReplaceData; ///< structure holding the ncessary input for find/replace
|
||||||
|
|
||||||
QComboBox *fComboFont; ///< combo box for the font selector
|
std::unique_ptr<QComboBox> fComboFont; ///< combo box for the font selector
|
||||||
QComboBox *fComboSize; ///< combo box for the font size
|
std::unique_ptr<QComboBox> fComboSize; ///< combo box for the font size
|
||||||
bool fFontChanging; ///< flag needed to prevent some textChanged feature to occure when only the font changed
|
bool fFontChanging; ///< flag needed to prevent some textChanged feature to occure when only the font changed
|
||||||
|
|
||||||
QTabWidget *fTabWidget; ///< tab widget in which the text editor(s) are placed
|
std::unique_ptr<QTabWidget> fTabWidget; ///< tab widget in which the text editor(s) are placed
|
||||||
QMap<PSubTextEdit*, QString> fFilenames; ///< mapper between tab widget object and filename
|
QMap<PSubTextEdit*, QString> fFilenames; ///< mapper between tab widget object and filename
|
||||||
|
|
||||||
QMenu *fRecentFilesMenu; ///< recent file menu
|
QMenu *fRecentFilesMenu; ///< recent file menu
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
@ -67,12 +68,12 @@ int main( int argc, char ** argv )
|
|||||||
|
|
||||||
QApplication a( argc, argv );
|
QApplication a( argc, argv );
|
||||||
|
|
||||||
PTextEdit *mw = new PTextEdit();
|
std::unique_ptr<PTextEdit> mw = std::make_unique<PTextEdit>();
|
||||||
mw->setWindowTitle( "MusrFit Editor" );
|
mw->setWindowTitle( "MusrFit Editor" );
|
||||||
mw->resize( mw->getEditW(), mw->getEditH() );
|
mw->resize( mw->getEditW(), mw->getEditH() );
|
||||||
mw->show();
|
mw->show();
|
||||||
|
|
||||||
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
|
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
|
||||||
a.connect( &a, SIGNAL( aboutToQuit() ), mw, SLOT( aboutToQuit() ) );
|
a.connect( &a, SIGNAL( aboutToQuit() ), mw.get(), SLOT( aboutToQuit() ) );
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user