mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-28 01:04:41 +08:00
(GUI) Removed Reload button
This commit is contained in:
parent
5e4193cb13
commit
fd259d3948
@ -166,19 +166,17 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("localhost"), m_lastP
|
|||||||
toolbar->setObjectName("ProfilerGUI_FileToolbar");
|
toolbar->setObjectName("ProfilerGUI_FileToolbar");
|
||||||
toolbar->setContentsMargins(1, 0, 1, 0);
|
toolbar->setContentsMargins(1, 0, 1, 0);
|
||||||
|
|
||||||
toolbar->addAction(QIcon(":/Open"), tr("Open"), this, SLOT(onOpenFileClicked(bool)));
|
|
||||||
|
|
||||||
m_loadActionMenu = new QMenu(this);
|
m_loadActionMenu = new QMenu(this);
|
||||||
auto action = m_loadActionMenu->menuAction();
|
auto action = m_loadActionMenu->menuAction();
|
||||||
action->setText("Reload last file");
|
action->setText("Open file");
|
||||||
action->setIcon(QIcon(":/Reopen"));
|
action->setIcon(QIcon(":/Open"));
|
||||||
connect(action, &QAction::triggered, this, &This::onReloadFileClicked);
|
connect(action, &QAction::triggered, this, &This::onOpenFileClicked);
|
||||||
toolbar->addAction(action);
|
toolbar->addAction(action);
|
||||||
|
|
||||||
for (const auto& f : m_lastFiles)
|
for (const auto& f : m_lastFiles)
|
||||||
{
|
{
|
||||||
action = new QAction(f, this);
|
action = new QAction(f, this);
|
||||||
connect(action, &QAction::triggered, this, &This::onReloadFileClicked);
|
connect(action, &QAction::triggered, this, &This::onOpenFileClicked);
|
||||||
m_loadActionMenu->addAction(action);
|
m_loadActionMenu->addAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,9 +560,20 @@ void EasyMainWindow::dropEvent(QDropEvent* drop_event)
|
|||||||
|
|
||||||
void EasyMainWindow::onOpenFileClicked(bool)
|
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 (*.*)");
|
auto action = qobject_cast<QAction*>(sender());
|
||||||
if (!filename.isEmpty())
|
if (action == nullptr)
|
||||||
loadFile(filename);
|
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);
|
m_lastFiles.push_front(filename);
|
||||||
|
|
||||||
auto action = new QAction(filename, this);
|
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();
|
auto fileActions = m_loadActionMenu->actions();
|
||||||
if (fileActions.empty())
|
if (fileActions.empty())
|
||||||
m_loadActionMenu->addAction(action);
|
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)
|
void EasyMainWindow::onSaveFileClicked(bool)
|
||||||
{
|
{
|
||||||
if (m_serializedBlocks.empty())
|
if (m_serializedBlocks.empty())
|
||||||
|
@ -230,7 +230,6 @@ public:
|
|||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
void onOpenFileClicked(bool);
|
void onOpenFileClicked(bool);
|
||||||
void onReloadFileClicked(bool);
|
|
||||||
void onSaveFileClicked(bool);
|
void onSaveFileClicked(bool);
|
||||||
void onDeleteClicked(bool);
|
void onDeleteClicked(bool);
|
||||||
void onExitClicked(bool);
|
void onExitClicked(bool);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user