26#include <QDialogButtonBox>
34#include "moc_qgsprocessinghistorywidget.cpp"
36using namespace Qt::StringLiterals;
42 QVBoxLayout *vl =
new QVBoxLayout();
43 vl->setContentsMargins( 0, 0, 0, 0 );
44 vl->addWidget( mHistoryWidget );
50 if ( QMessageBox::question(
this, tr(
"Clear History" ), tr(
"Are you sure you want to clear the Processing history?" ), QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes )
63 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save File" ), QDir::homePath(), tr(
"Log files (*.log *.LOG)" ) );
68 if ( fileName.isEmpty() )
75 const QString logSeparator = u
"|~|"_s;
76 QFile logFile( fileName );
77 if ( logFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
79 QTextStream logOut( &logFile );
82 logOut << u
"ALGORITHM%1%2%3%4\n"_s.arg( logSeparator, entry.timestamp.toString(
"yyyy-MM-dd HH:mm:ss" ), logSeparator, entry.entry.value( u
"python_command"_s ).toString() );
95 setObjectName( u
"QgsProcessingHistoryDialog"_s );
98 setWindowTitle( tr(
"Processing History" ) );
100 QVBoxLayout *vl =
new QVBoxLayout();
103 vl->addWidget( mMessageBar );
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, [
this]() { close(); } );
125 vl->addWidget( mButtonBox );
@ Warning
Warning message.
@ 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.
A bar for displaying non-blocking messages to the user.
QgsProcessingHistoryDialog(QWidget *parent=nullptr)
Constructor for QgsProcessingHistoryDialog.
void showMessage(const QString &message)
Emitted when the provider needs to display a message.
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.