Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/perf/cpudetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void CpuDetailWidget::onContextMenuRequested(const QPoint &globalPos)
menu.addSeparator();

// ── Copy ─────────────────────────────────────────────────────────────────
UIHelper::AddCopyWidgetAction(&menu, this->m_graphArea, tr("Copy graph"));
UIHelper::AddGraphContextMenuItems(&menu, this->m_graphArea);

menu.exec(globalPos);
}
4 changes: 2 additions & 2 deletions src/perf/diskdetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ DiskDetailWidget::DiskDetailWidget(QWidget *parent) : QWidget(parent), ui(new Ui
this->ui->transferGraphWidget->SetGridRows(4);
this->ui->transferGraphWidget->SetSeriesNames(tr("Read"), tr("Write"));
this->ui->transferGraphWidget->SetValueFormat(GraphWidget::ValueFormat::BytesPerSec);
UIHelper::EnableCopyWidgetContextMenu(this->ui->activeGraphWidget);
UIHelper::EnableCopyWidgetContextMenu(this->ui->transferGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->activeGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->transferGraphWidget);
this->ui->activeGraphMaxLabel->setText(tr("100%"));
UIHelper::EnableCopyLabelContextMenu(this->ui->activeValueLabel);
UIHelper::EnableCopyLabelContextMenu(this->ui->capacityValueLabel);
Expand Down
8 changes: 4 additions & 4 deletions src/perf/gpudetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ GpuDetailWidget::GpuDetailWidget(QWidget *parent) : QWidget(parent), ui(new Ui::
auto *graph = new GraphWidget(this);
configureGraph(graph);
graph->setMinimumHeight(120);
UIHelper::EnableCopyWidgetContextMenu(graph);
UIHelper::EnableGraphContextMenu(graph);

this->m_engineSelectors.append(selector);
this->m_engineValueLabels.append(value);
Expand All @@ -103,17 +103,17 @@ GpuDetailWidget::GpuDetailWidget(QWidget *parent) : QWidget(parent), ui(new Ui::

configureGraph(this->ui->dedicatedMemGraphWidget);
this->ui->dedicatedMemGraphWidget->SetSeriesNames(tr("Dedicated memory usage"));
UIHelper::EnableCopyWidgetContextMenu(this->ui->dedicatedMemGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->dedicatedMemGraphWidget);

configureGraph(this->ui->sharedMemGraphWidget);
this->ui->sharedMemGraphWidget->SetSeriesNames(tr("Shared memory usage"));
UIHelper::EnableCopyWidgetContextMenu(this->ui->sharedMemGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->sharedMemGraphWidget);

configureGraph(this->ui->copyBwGraphWidget);
this->ui->copyBwGraphWidget->SetSeriesNames(tr("TX"), tr("RX"));
this->ui->copyBwGraphWidget->SetValueFormat(GraphWidget::ValueFormat::BytesPerSec);
this->ui->copyBwGraphWidget->setToolTip(tr("Copy bandwidth: light trace = TX, dark trace = RX"));
UIHelper::EnableCopyWidgetContextMenu(this->ui->copyBwGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->copyBwGraphWidget);

UIHelper::EnableCopyLabelContextMenu(this->ui->utilValueLabel);
UIHelper::EnableCopyLabelContextMenu(this->ui->tempValueLabel);
Expand Down
2 changes: 1 addition & 1 deletion src/perf/memorydetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ MemoryDetailWidget::MemoryDetailWidget(QWidget *parent) : QWidget(parent), ui(ne
this->ui->graphWidget->SetGridRows(4);
this->ui->graphWidget->SetSeriesNames(tr("Used memory"));
this->ui->graphWidget->SetValueFormat(GraphWidget::ValueFormat::Percent);
UIHelper::EnableCopyWidgetContextMenu(this->ui->graphWidget);
UIHelper::EnableGraphContextMenu(this->ui->graphWidget);
UIHelper::EnableCopyLabelContextMenu(this->ui->statInUseValue);
UIHelper::EnableCopyLabelContextMenu(this->ui->statAvailValue);
UIHelper::EnableCopyLabelContextMenu(this->ui->statCompressedValue);
Expand Down
2 changes: 1 addition & 1 deletion src/perf/networkdetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void NetworkDetailWidget::onGraphContextMenuRequested(const QPoint &pos)
connect(bytesAction, &QAction::triggered, this, &NetworkDetailWidget::onShowBytesTriggered);

menu.addSeparator();
UIHelper::AddCopyWidgetAction(&menu, this->ui->throughputGraphWidget, tr("Copy graph"));
UIHelper::AddGraphContextMenuItems(&menu, this->ui->throughputGraphWidget);

menu.exec(this->ui->throughputGraphWidget->mapToGlobal(pos));
}
Expand Down
4 changes: 2 additions & 2 deletions src/perf/swapdetailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ SwapDetailWidget::SwapDetailWidget(QWidget *parent) : QWidget(parent), ui(new Ui
this->ui->activityGraphWidget->setToolTip(
tr("Swap in: disk -> RAM (pages read back into memory)\n"
"Swap out: RAM -> disk (pages written to swap storage)"));
UIHelper::EnableCopyWidgetContextMenu(this->ui->activityGraphWidget);
UIHelper::EnableGraphContextMenu(this->ui->activityGraphWidget);

UIHelper::EnableCopyLabelContextMenu(this->ui->usageValueLabel);
UIHelper::EnableCopyLabelContextMenu(this->ui->inUseValueLabel);
Expand Down Expand Up @@ -221,7 +221,7 @@ void SwapDetailWidget::onContextMenuRequested(const QPoint &globalPos)

menu.addSeparator();

UIHelper::AddCopyWidgetAction(&menu, this->ui->usageGraphArea, tr("Copy graph"));
UIHelper::AddGraphContextMenuItems(&menu, this->ui->usageGraphArea);

menu.exec(globalPos);
}
Expand Down
38 changes: 8 additions & 30 deletions src/performancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ namespace
// Construction
////////////////////////////////////////////////////////////////////////////////////////////////////

PerformanceWidget *PerformanceWidget::s_instance = nullptr;

PerformanceWidget::PerformanceWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PerformanceWidget)
{
s_instance = this;

// Ensure the metrics are initialized before we start enumerating devices
Metrics::Get();

Expand Down Expand Up @@ -122,6 +126,7 @@ PerformanceWidget::PerformanceWidget(QWidget *parent) : QWidget(parent), ui(new

PerformanceWidget::~PerformanceWidget()
{
s_instance = nullptr;
delete this->ui;
}

Expand Down Expand Up @@ -377,9 +382,6 @@ void PerformanceWidget::SetActive(bool active)
void PerformanceWidget::onSidePanelContextMenu(Perf::SidePanelItem * /*item*/, const QPoint &globalPos)
{
QMenu menu(this);
QHash<QAction *, int> graphWindowActions;
QHash<QAction *, int> refreshIntervalActions;
QAction *pausedRefreshAction = nullptr;

QAction *cpu = menu.addAction(tr("CPU"));
cpu->setCheckable(true);
Expand Down Expand Up @@ -414,40 +416,16 @@ void PerformanceWidget::onSidePanelContextMenu(Perf::SidePanelItem * /*item*/, c
showGrid->setChecked(CFG->SidePanelGridEnabled);

menu.addSeparator();
QMenu *timeMenu = menu.addMenu(tr("Graph time"));
QVector<int> intervals = CFG->DataWindowAvailableIntervals;
if (intervals.isEmpty())
intervals.append(CFG->PerfGraphWindowSec);

for (int sec : intervals)
{
QAction *a = timeMenu->addAction(Misc::SimplifyTime(sec));
a->setCheckable(true);
a->setChecked(CFG->PerfGraphWindowSec == sec);
graphWindowActions.insert(a, sec);
}
UIHelper::AddRefreshIntervalContextMenu(&menu, nullptr, this->m_active);
UIHelper::AddGraphWindowContextMenu(&menu);

QMenu *refreshMenu = menu.addMenu(tr("Refresh interval"));
UIHelper::PopulateRefreshIntervalMenu(refreshMenu, refreshIntervalActions, pausedRefreshAction);
menu.addSeparator();
UIHelper::AddGlobalContextMenuItems(&menu, this);

QAction *picked = menu.exec(globalPos);
if (!picked)
return;

if (graphWindowActions.contains(picked))
{
const int requestedWindow = graphWindowActions.value(picked);
CFG->PerfGraphWindowSec = requestedWindow;
this->applyGraphWindowSeconds();
if (this->m_active)
this->onProviderUpdated();
return;
}

if (UIHelper::ApplyRefreshIntervalAction(picked, refreshIntervalActions, pausedRefreshAction))
return;

if (picked == customizeOrder)
{
SidePanelOrderDialog dialog(sanitizeSidePanelGroupOrder(CFG->PerfSidePanelGroupOrder), this);
Expand Down
11 changes: 7 additions & 4 deletions src/performancewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ QT_END_NAMESPACE
class PerformanceWidget : public QWidget
{
Q_OBJECT

public:
explicit PerformanceWidget(QWidget *parent = nullptr);
~PerformanceWidget();
void SetActive(bool active);
bool IsActive() const { return this->m_active; }
void ApplyColorScheme();

private slots:
static PerformanceWidget *Get() { return s_instance; };
void onProviderUpdated();
void applyGraphWindowSeconds();

private slots:
void onSidePanelContextMenu(Perf::SidePanelItem *item, const QPoint &globalPos);

private:
static PerformanceWidget *s_instance;

Ui::PerformanceWidget *ui;
Perf::SidePanel *m_sidePanel;
QStackedWidget *m_stack;
Expand Down Expand Up @@ -81,7 +85,6 @@ class PerformanceWidget : public QWidget
void setupGpuPanels();
void applySidePanelOrder();
void tagTimeAxisLabels();
void applyGraphWindowSeconds();
void applyPanelVisibility();
void applySidePanelGridEnabled();
void updateSamplingPolicy();
Expand Down
16 changes: 4 additions & 12 deletions src/processeswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@ void ProcessesWidget::onTableContextMenu(const QPoint &pos)
{
// Pause refresh during context menu so we don't loose the selection
this->m_tableContextMenuOpen = true;
QHash<QAction *, int> refreshIntervalActions;
QAction *pausedRefreshAction = nullptr;

const QModelIndex clickedIndex = this->ui->tableView->indexAt(pos);
const QModelIndex targetIndex = clickedIndex.isValid() ? clickedIndex : this->ui->tableView->currentIndex();
Expand Down Expand Up @@ -681,12 +679,10 @@ void ProcessesWidget::onTableContextMenu(const QPoint &pos)
connect(reniceAction, &QAction::triggered, this, &ProcessesWidget::reniceSelected);

menu.addSeparator();
QMenu *refreshMenu = menu.addMenu(tr("Refresh interval"));
UIHelper::PopulateRefreshIntervalMenu(refreshMenu, refreshIntervalActions, pausedRefreshAction);
UIHelper::AddRefreshIntervalContextMenu(&menu, this->m_refreshTimer, this->m_active);
UIHelper::AddGlobalContextMenuItems(&menu, this);

QAction *picked = menu.exec(this->ui->tableView->viewport()->mapToGlobal(pos));
UIHelper::ApplyRefreshIntervalAction(picked, refreshIntervalActions, pausedRefreshAction, this->m_refreshTimer, this->m_active);
menu.exec(this->ui->tableView->viewport()->mapToGlobal(pos));

this->m_contextMenuTargetIndex = QModelIndex();
this->m_tableContextMenuOpen = false;
Expand All @@ -698,8 +694,6 @@ void ProcessesWidget::onTreeContextMenu(const QPoint &pos)
{
this->m_tableContextMenuOpen = true;
QMenu menu(this);
QHash<QAction *, int> refreshIntervalActions;
QAction *pausedRefreshAction = nullptr;

QMenu *viewMenu = menu.addMenu(tr("View"));
QAction *kernelAct = viewMenu->addAction(tr("Kernel tasks"));
Expand Down Expand Up @@ -740,12 +734,10 @@ void ProcessesWidget::onTreeContextMenu(const QPoint &pos)
connect(reniceAction, &QAction::triggered, this, &ProcessesWidget::reniceSelected);

menu.addSeparator();
QMenu *refreshMenu = menu.addMenu(tr("Refresh interval"));
UIHelper::PopulateRefreshIntervalMenu(refreshMenu, refreshIntervalActions, pausedRefreshAction);
UIHelper::AddRefreshIntervalContextMenu(&menu, this->m_refreshTimer, this->m_active);
UIHelper::AddGlobalContextMenuItems(&menu, this);

QAction *picked = menu.exec(this->m_treeView->viewport()->mapToGlobal(pos));
UIHelper::ApplyRefreshIntervalAction(picked, refreshIntervalActions, pausedRefreshAction, this->m_refreshTimer, this->m_active);
menu.exec(this->m_treeView->viewport()->mapToGlobal(pos));

this->m_tableContextMenuOpen = false;
if (this->m_active && this->m_refreshPending && !CFG->RefreshPaused)
Expand Down
8 changes: 2 additions & 6 deletions src/serviceswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ void ServicesWidget::onHeaderContextMenu(const QPoint &pos)
void ServicesWidget::onTableContextMenu(const QPoint &pos)
{
this->m_tableContextMenuOpen = true;
QHash<QAction *, int> refreshIntervalActions;
QAction *pausedRefreshAction = nullptr;

const QModelIndex clickedIndex = this->ui->tableView->indexAt(pos);
const QModelIndex targetIndex = clickedIndex.isValid() ? clickedIndex : this->ui->tableView->currentIndex();
Expand Down Expand Up @@ -320,12 +318,10 @@ void ServicesWidget::onTableContextMenu(const QPoint &pos)
});

menu.addSeparator();
QMenu *refreshMenu = menu.addMenu(tr("Refresh interval"));
UIHelper::PopulateRefreshIntervalMenu(refreshMenu, refreshIntervalActions, pausedRefreshAction);
UIHelper::AddRefreshIntervalContextMenu(&menu, this->m_refreshTimer, this->m_active);
UIHelper::AddGlobalContextMenuItems(&menu, this);

QAction *picked = menu.exec(this->ui->tableView->viewport()->mapToGlobal(pos));
UIHelper::ApplyRefreshIntervalAction(picked, refreshIntervalActions, pausedRefreshAction, this->m_refreshTimer, this->m_active);
menu.exec(this->ui->tableView->viewport()->mapToGlobal(pos));

this->m_tableContextMenuOpen = false;
}
Expand Down
Loading
Loading