mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-22 03:40:30 +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;
|
QMenu menu;
|
||||||
QAction* clear = new QAction(tr("&Clear"));
|
QAction* clear = new QAction(tr("&Clear"));
|
||||||
QAction* open = new QAction(tr("&Open log file"));
|
QAction* open = new QAction(tr("&Open log file"));
|
||||||
|
QAction* save = new QAction(tr("&Save filtered log"));
|
||||||
QAction* filter = new QAction(tr("&Filter log"));
|
QAction* filter = new QAction(tr("&Filter log"));
|
||||||
|
|
||||||
QAction* timestamps = new QAction(tr("&Show Timestamps"));
|
QAction* timestamps = new QAction(tr("&Show Timestamps"));
|
||||||
@ -112,6 +113,8 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
|||||||
|
|
||||||
menu.addAction(open);
|
menu.addAction(open);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.addAction(save);
|
||||||
|
menu.addSeparator();
|
||||||
menu.addAction(filter);
|
menu.addAction(filter);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
menu.addAction(timestamps);
|
menu.addAction(timestamps);
|
||||||
@ -132,13 +135,31 @@ void log_viewer::show_context_menu(const QPoint& pos)
|
|||||||
|
|
||||||
connect(open, &QAction::triggered, this, [this]()
|
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())
|
if (file_path.isEmpty())
|
||||||
return;
|
return;
|
||||||
m_path_last = file_path;
|
m_path_last = file_path;
|
||||||
show_log();
|
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]()
|
connect(filter, &QAction::triggered, this, [this]()
|
||||||
{
|
{
|
||||||
m_filter_term = QInputDialog::getText(this, tr("Filter log"), tr("Enter text"), QLineEdit::EchoMode::Normal, m_filter_term);
|
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