28#include <QDialogButtonBox>
35 QVBoxLayout *vl =
new QVBoxLayout();
36 vl->setContentsMargins( 0, 0, 0, 0 );
37 vl->addWidget( mHistoryWidget );
43 if ( QMessageBox::question(
this,
44 tr(
"Clear History" ),
45 tr(
"Are you sure you want to clear the Processing history?" ),
46 QMessageBox::Yes | QMessageBox::No,
48 ) == QMessageBox::Yes )
61 QString fileName = QFileDialog::getSaveFileName(
this,
64 tr(
"Log files (*.log *.LOG)" ) );
69 if ( fileName.isEmpty() )
76 const QString logSeparator = QStringLiteral(
"|~|" );
77 QFile logFile( fileName );
78 if ( logFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
80 QTextStream logOut( &logFile );
83 logOut << QStringLiteral(
"ALGORITHM%1%2%3%4\n" ).arg( logSeparator,
84 entry.timestamp.toString(
"yyyy-MM-dd HH:mm:ss" ),
86 entry.entry.value( QStringLiteral(
"python_command" ) ).toString() );
99 setObjectName( QStringLiteral(
"QgsProcessingHistoryDialog" ) );
102 setWindowTitle( tr(
"Processing History" ) );
104 QVBoxLayout *vl =
new QVBoxLayout();
106 vl->addWidget( mWidget, 1 );
108 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Close | QDialogButtonBox::Help );
110 QPushButton *clearButton =
new QPushButton( tr(
"Clear" ) );
111 clearButton->setToolTip( tr(
"Clear history" ) );
112 mButtonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
114 QPushButton *saveButton =
new QPushButton( tr(
"Save As…" ) );
115 saveButton->setToolTip( tr(
"Save history" ) );
116 mButtonBox->addButton( saveButton, QDialogButtonBox::ActionRole );
121 connect( mButtonBox->button( QDialogButtonBox::Close ), &QPushButton::clicked, mWidget, [ = ]() { close(); } );
123 vl->addWidget( mButtonBox );
@ LocalProfile
Local profile.
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
static QgsGui * instance()
Returns a pointer to the singleton instance.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static QgsHistoryProviderRegistry * historyProviderRegistry()
Returns the global history provider registry, used for tracking history providers.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Encapsulates a history entry.
bool clearHistory(Qgis::HistoryProviderBackend backend, const QString &providerId=QString())
Clears the history for the specified backend.
QList< QgsHistoryEntry > queryEntries(const QDateTime &start=QDateTime(), const QDateTime &end=QDateTime(), const QString &providerId=QString(), Qgis::HistoryProviderBackends backends=Qgis::HistoryProviderBackend::LocalProfile) const
Queries history entries which occurred between the specified start and end times.
A widget showing entries from a QgsHistoryProviderRegistry.
QgsProcessingHistoryDialog(QWidget *parent=nullptr)
Constructor for QgsProcessingHistoryDialog.
A widget for showing Processing algorithm execution history.
void saveLog()
Interactively allows users to save the history log.
QgsProcessingHistoryWidget(QWidget *parent=nullptr)
Constructor for QgsProcessingHistoryWidget, with the specified parent widget.
void clearHistory()
Clears the Processing history (after user confirmation).
void openHelp()
Opens helps for the widget.