mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-21 00:39:53 +00:00
Qt: Add save filtered log to menu of log viewer
This commit is contained in:
parent
958d77ba52
commit
b2d84dcebd
@ -65,6 +65,7 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||
QMenu menu;
|
||||
QAction* clear = new QAction(tr("&Clear"));
|
||||
QAction* open = new QAction(tr("&Open log file"));
|
||||
QAction* save = new QAction(tr("&Save filtered log"));
|
||||
QAction* filter = new QAction(tr("&Filter log"));
|
||||
|
||||
QAction* timestamps = new QAction(tr("&Show Timestamps"));
|
||||
@ -112,6 +113,8 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||
|
||||
menu.addAction(open);
|
||||
menu.addSeparator();
|
||||
menu.addAction(save);
|
||||
menu.addSeparator();
|
||||
menu.addAction(filter);
|
||||
menu.addSeparator();
|
||||
menu.addAction(timestamps);
|
||||
@ -132,13 +135,31 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
||||
|
||||
connect(open, &QAction::triggered, this, [this]()
|
||||
{
|
||||
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select log file"), m_path_last, tr("Log files (*.log);;"));
|
||||
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select log file"), m_path_last, tr("Log files (*.log);;All files (*.*)"));
|
||||
if (file_path.isEmpty())
|
||||
return;
|
||||
m_path_last = file_path;
|
||||
show_log();
|
||||
});
|
||||
|
||||
connect(save, &QAction::triggered, this, [this]()
|
||||
{
|
||||
const QString file_path = QFileDialog::getSaveFileName(this, tr("Save to file"), m_path_last, tr("Log files (*.log);;All files (*.*)"));
|
||||
if (file_path.isEmpty())
|
||||
return;
|
||||
|
||||
if (QFile log_file(file_path); log_file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
log_file.write(m_log_text->toPlainText().toUtf8());
|
||||
log_file.close();
|
||||
gui_log.success("Exported filtered log to file '%s'", sstr(file_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_log.error("Failed to export filtered log to file '%s'", sstr(file_path));
|
||||
}
|
||||
});
|
||||
|
||||
connect(filter, &QAction::triggered, this, [this]()
|
||||
{
|
||||
m_filter_term = QInputDialog::getText(this, tr("Filter log"), tr("Enter text"), QLineEdit::EchoMode::Normal, m_filter_term);
|
||||
|
Loading…
x
Reference in New Issue
Block a user