Skip to content

Commit

Permalink
perfdata added to file open list
Browse files Browse the repository at this point in the history
along with a group that includes it and moving out to a separate function again
  • Loading branch information
GitMensch committed Dec 3, 2022
1 parent 9db22ee commit e506636
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ MainWindow::MainWindow(QWidget* parent)
auto openNewWindow = new QAction(QIcon::fromTheme(QStringLiteral("document-open")), tr("Open in new window"), this);
openNewWindow->setShortcut(Qt::Key_O | Qt::ControlModifier | Qt::ShiftModifier);
connect(openNewWindow, &QAction::triggered, this, [this] {
const auto fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(),
tr("Data Files (perf*.data perf.data.*);;All Files (*)"));
const auto fileName = getOpenDataFileName();
if (!fileName.isEmpty())
openInNewWindow(fileName);
});
Expand Down Expand Up @@ -279,10 +278,17 @@ void MainWindow::closeEvent(QCloseEvent* event)
QMainWindow::closeEvent(event);
}

QString MainWindow::getOpenDataFileName()
{
const QString filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser);;"
"Linux Perf Files (perf*.data perf.data.*);;"
"Perfparser Files (*.perfparser);;All Files (*)");
return QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), filter);
}

void MainWindow::onOpenFileButtonClicked()
{
const auto fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(),
tr("Data Files (perf*.data perf.data.*);;All Files (*)"));
const auto fileName = getOpenDataFileName();
if (fileName.isEmpty()) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public slots:
void openFile(const QString& path, bool isReload);
void closeEvent(QCloseEvent* event) override;
void setupCodeNavigationMenu();
QString getOpenDataFileName();

QScopedPointer<Ui::MainWindow> ui;
PerfParser* m_parser;
Expand Down

0 comments on commit e506636

Please sign in to comment.