0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

(GUI) Removed Reload button

This commit is contained in:
Victor Zarubkin 2016-12-11 03:43:21 +03:00
parent 5e4193cb13
commit fd259d3948
2 changed files with 19 additions and 40 deletions

View File

@ -166,19 +166,17 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("localhost"), m_lastP
toolbar->setObjectName("ProfilerGUI_FileToolbar");
toolbar->setContentsMargins(1, 0, 1, 0);
toolbar->addAction(QIcon(":/Open"), tr("Open"), this, SLOT(onOpenFileClicked(bool)));
m_loadActionMenu = new QMenu(this);
auto action = m_loadActionMenu->menuAction();
action->setText("Reload last file");
action->setIcon(QIcon(":/Reopen"));
connect(action, &QAction::triggered, this, &This::onReloadFileClicked);
action->setText("Open file");
action->setIcon(QIcon(":/Open"));
connect(action, &QAction::triggered, this, &This::onOpenFileClicked);
toolbar->addAction(action);
for (const auto& f : m_lastFiles)
{
action = new QAction(f, this);
connect(action, &QAction::triggered, this, &This::onReloadFileClicked);
connect(action, &QAction::triggered, this, &This::onOpenFileClicked);
m_loadActionMenu->addAction(action);
}
@ -562,9 +560,20 @@ void EasyMainWindow::dropEvent(QDropEvent* drop_event)
void EasyMainWindow::onOpenFileClicked(bool)
{
auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFiles.empty() ? QString() : m_lastFiles.front(), "Profiler Log File (*.prof);;All Files (*.*)");
if (!filename.isEmpty())
loadFile(filename);
auto action = qobject_cast<QAction*>(sender());
if (action == nullptr)
return;
if (action == m_loadActionMenu->menuAction())
{
auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFiles.empty() ? QString() : m_lastFiles.front(), "Profiler Log File (*.prof);;All Files (*.*)");
if (!filename.isEmpty())
loadFile(filename);
}
else
{
loadFile(action->text());
}
}
//////////////////////////////////////////////////////////////////////////
@ -574,7 +583,7 @@ void EasyMainWindow::addFileToList(const QString& filename)
m_lastFiles.push_front(filename);
auto action = new QAction(filename, this);
connect(action, &QAction::triggered, this, &This::onReloadFileClicked);
connect(action, &QAction::triggered, this, &This::onOpenFileClicked);
auto fileActions = m_loadActionMenu->actions();
if (fileActions.empty())
m_loadActionMenu->addAction(action);
@ -614,35 +623,6 @@ void EasyMainWindow::readStream(::std::stringstream& data)
//////////////////////////////////////////////////////////////////////////
void EasyMainWindow::onReloadFileClicked(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action == nullptr)
return;
if (action == m_loadActionMenu->menuAction())
{
if (m_lastFiles.empty())
return;
for (auto it = m_lastFiles.begin(); it != m_lastFiles.end(); ++it)
{
const auto& f = *it;
if (!f.isEmpty())
{
loadFile(f);
break;
}
}
}
else
{
loadFile(action->text());
}
}
//////////////////////////////////////////////////////////////////////////
void EasyMainWindow::onSaveFileClicked(bool)
{
if (m_serializedBlocks.empty())

View File

@ -230,7 +230,6 @@ public:
protected slots:
void onOpenFileClicked(bool);
void onReloadFileClicked(bool);
void onSaveFileClicked(bool);
void onDeleteClicked(bool);
void onExitClicked(bool);