Skip to content

Commit b5f4944

Browse files
committed
move profile info to its own dialog
1 parent 6f561ab commit b5f4944

File tree

8 files changed

+143
-7
lines changed

8 files changed

+143
-7
lines changed

Source/ui_qt/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ set(QT_SOURCES
119119
memorycardmanagerdialog.cpp
120120
memorycardmanagerdialog.h
121121
PreferenceDefs.h
122+
profiledialog.cpp
123+
profiledialog.h
122124
QStringUtils.cpp
123125
QStringUtils.h
124126
vfsmanagerdialog.cpp
@@ -199,6 +201,7 @@ set(QT_MOC_HEADERS
199201
openglwindow.h
200202
outputwindow.h
201203
memorycardmanagerdialog.h
204+
profiledialog.h
202205
S3FileBrowser.h
203206
vfsmanagerdialog.h
204207
vfsmodel.h
@@ -213,6 +216,8 @@ set(QT_UIS
213216
Qt_ui/inputeventselectiondialog.ui
214217
Qt_ui/mainwindow.ui
215218
Qt_ui/memorycardmanager.ui
219+
Qt_ui/profiledialog.ui
220+
Qt_ui/profilemenu.ui
216221
Qt_ui/s3filebrowser.ui
217222
Qt_ui/settingsdialog.ui
218223
Qt_ui/vfsmanagerdialog.ui

Source/ui_qt/Qt_ui/mainwindow.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@
209209
<string>Ctrl+L</string>
210210
</property>
211211
</action>
212+
<action name="actionShow_Profile_Dialog">
213+
<property name="text">
214+
<string>Show Profile Dialog</string>
215+
</property>
216+
</action>
217+
<action name="actionProfileReset">
218+
<property name="text">
219+
<string>Reset</string>
220+
</property>
221+
</action>
212222
</widget>
213223
<layoutdefault spacing="6" margin="11"/>
214224
<resources>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ProfileDialog</class>
4+
<widget class="QDialog" name="ProfileDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>504</width>
10+
<height>248</height>
11+
</rect>
12+
</property>
13+
<property name="sizeIncrement">
14+
<size>
15+
<width>810</width>
16+
<height>0</height>
17+
</size>
18+
</property>
19+
<property name="windowTitle">
20+
<string>Profile Dialog</string>
21+
</property>
22+
<layout class="QVBoxLayout">
23+
<item>
24+
<widget class="QTextEdit" name="profileStatsLabel">
25+
<property name="font">
26+
<font>
27+
<family>Courier</family>
28+
</font>
29+
</property>
30+
</widget>
31+
</item>
32+
</layout>
33+
</widget>
34+
<resources/>
35+
<connections/>
36+
</ui>

Source/ui_qt/Qt_ui/profilemenu.ui

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ProfileMenu</class>
4+
<widget class="QMenu" name="ProfileMenu">
5+
<property name="title">
6+
<string>Profile</string>
7+
</property>
8+
<action name="actionShowProfile">
9+
<property name="text">
10+
<string>Show</string>
11+
</property>
12+
</action>
13+
<action name="actionResetProfile">
14+
<property name="text">
15+
<string>Reset</string>
16+
</property>
17+
</action>
18+
<addaction name="actionShowProfile"/>
19+
<addaction name="actionResetProfile"/>
20+
</widget>
21+
<resources/>
22+
<connections/>
23+
</ui>

Source/ui_qt/mainwindow.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
#else
3838
#include "tools/PsfPlayer/Source/SH_OpenAL.h"
3939
#endif
40+
41+
#ifdef PROFILE
42+
#include "profiledialog.h"
43+
#include "ui_profilemenu.h"
44+
#endif
45+
4046
#include "input/PH_GenericInput.h"
4147
#include "DiskUtils.h"
4248
#include "PathUtils.h"
@@ -75,11 +81,13 @@ MainWindow::MainWindow(QWidget* parent)
7581

7682
#ifdef PROFILE
7783
{
78-
m_profileStatsLabel = new QLabel(this);
79-
QFont courierFont("Courier");
80-
m_profileStatsLabel->setFont(courierFont);
81-
m_profileStatsLabel->setAlignment(Qt::AlignTop);
82-
ui->gridLayout->addWidget(m_profileStatsLabel, 0, 1);
84+
m_profileDialog = new ProfileDialog(this);
85+
auto profileMenu = new QMenu(this);
86+
profileMenuUi = new Ui::ProfileMenu();
87+
profileMenuUi->setupUi(profileMenu);
88+
ui->menuBar->insertMenu(ui->menuHelp->menuAction(), profileMenu);
89+
connect(profileMenuUi->actionShowProfile, &QAction::triggered, m_profileDialog, &QWidget::show);
90+
connect(profileMenuUi->actionResetProfile, &QAction::triggered, []() { CStatsManager::GetInstance().ResetStats(); });
8391
}
8492
#endif
8593

@@ -475,7 +483,10 @@ void MainWindow::updateStats()
475483
uint32 drawCalls = CStatsManager::GetInstance().GetDrawCalls();
476484
uint32 dcpf = (frames != 0) ? (drawCalls / frames) : 0;
477485
#ifdef PROFILE
478-
m_profileStatsLabel->setText(QString::fromStdString(CStatsManager::GetInstance().GetProfilingInfo()));
486+
if(m_profileDialog->isVisible())
487+
{
488+
m_profileDialog->updateStats(CStatsManager::GetInstance().GetProfilingInfo());
489+
}
479490
#endif
480491
m_fpsLabel->setText(QString("%1 f/s, %2 dc/f").arg(frames).arg(dcpf));
481492
CStatsManager::GetInstance().ClearStats();

Source/ui_qt/mainwindow.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#include "InputProviderQtKey.h"
1616
#include "ScreenShotUtils.h"
1717

18+
#ifdef PROFILE
19+
class ProfileDialog;
20+
namespace Ui
21+
{
22+
class ProfileMenu;
23+
}
24+
#endif
25+
1826
namespace Ui
1927
{
2028
class MainWindow;
@@ -97,7 +105,8 @@ class MainWindow : public QMainWindow
97105
QLabel* m_fpsLabel = nullptr;
98106
QLabel* m_gsLabel = nullptr;
99107
#ifdef PROFILE
100-
QLabel* m_profileStatsLabel = nullptr;
108+
Ui::ProfileMenu* profileMenuUi = nullptr;
109+
ProfileDialog* m_profileDialog;
101110
CPS2VM::ProfileFrameDoneSignal::Connection m_profileFrameDoneConnection;
102111
#endif
103112
ElidedLabel* m_msgLabel = nullptr;

Source/ui_qt/profiledialog.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "profiledialog.h"
2+
#include "ui_profiledialog.h"
3+
4+
ProfileDialog::ProfileDialog(QWidget* parent)
5+
: QDialog(parent)
6+
, ui(new Ui::ProfileDialog)
7+
{
8+
ui->setupUi(this);
9+
}
10+
11+
ProfileDialog::~ProfileDialog()
12+
{
13+
delete ui;
14+
}
15+
16+
void ProfileDialog::updateStats(std::string msg)
17+
{
18+
ui->profileStatsLabel->setText(msg.c_str());
19+
}

Source/ui_qt/profiledialog.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <QDialog>
4+
5+
namespace Ui
6+
{
7+
class ProfileDialog;
8+
}
9+
10+
class
11+
ProfileDialog : public QDialog
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
explicit ProfileDialog(QWidget* parent = 0);
17+
~ProfileDialog();
18+
19+
void updateStats(std::string);
20+
21+
private:
22+
Ui::ProfileDialog* ui;
23+
};

0 commit comments

Comments
 (0)