1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 12:42:41 +01:00

Emu: msg_dialog_frame fixes

This commit is contained in:
Megamouse 2019-01-06 23:00:48 +01:00
parent 8a4778ba8c
commit b0a24665e5
4 changed files with 20 additions and 9 deletions

View File

@ -100,6 +100,7 @@ public:
virtual ~MsgDialogBase();
virtual void Create(const std::string& msg, const std::string& title = "") = 0;
virtual void Close() = 0;
virtual void SetMsg(const std::string& msg) = 0;
virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) = 0;
virtual void ProgressBarReset(u32 progressBarIndex) = 0;

View File

@ -340,8 +340,6 @@ void Emulator::Init()
{
while (true)
{
std::shared_ptr<MsgDialogBase> dlg;
// Wait for the start condition
while (!g_progr_ftotal && !g_progr_ptotal)
{
@ -349,7 +347,7 @@ void Emulator::Init()
}
// Initialize message dialog
dlg = Emu.GetCallbacks().get_msg_dialog();
std::shared_ptr<MsgDialogBase> dlg = Emu.GetCallbacks().get_msg_dialog();
dlg->type.se_normal = true;
dlg->type.bg_invisible = true;
dlg->type.progress_bar_count = 1;
@ -384,7 +382,9 @@ void Emulator::Init()
pdone = g_progr_pdone;
// Compute new progress in percents
const u32 new_value = ((ptotal ? pdone * 1. / ptotal : 0.) + fdone) * 100. / (ftotal ? ftotal : 1);
const u32 total = ftotal + ptotal;
const u32 done = fdone + pdone;
const u32 new_value = double(done) * 100. / double(total ? total : 1);
// Compute the difference
const u32 delta = new_value > value ? new_value - value : 0;
@ -421,6 +421,11 @@ void Emulator::Init()
g_progr_fdone -= fdone;
g_progr_ptotal -= pdone;
g_progr_pdone -= pdone;
Emu.CallAfter([=]
{
dlg->Close();
});
}
});

View File

@ -13,11 +13,7 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title)
static const auto& barWidth = [](){return QLabel("This is the very length of the progressbar due to hidpi reasons.").sizeHint().width();};
if (m_dialog)
{
m_dialog->close();
delete m_dialog;
}
Close();
m_dialog = new custom_dialog(type.disable_cancel);
m_dialog->setWindowTitle(title.empty() ? (type.se_normal ? "Normal dialog" : "Error dialog") : qstr(title));
@ -152,6 +148,14 @@ void msg_dialog_frame::Create(const std::string& msg, const std::string& title)
#endif
}
void msg_dialog_frame::Close()
{
if (m_dialog)
{
m_dialog->close();
}
}
msg_dialog_frame::msg_dialog_frame(QWindow* taskbarTarget) : m_taskbarTarget(taskbarTarget) {}
msg_dialog_frame::~msg_dialog_frame()

View File

@ -53,6 +53,7 @@ public:
msg_dialog_frame(QWindow* taskbarTarget);
~msg_dialog_frame();
virtual void Create(const std::string& msg, const std::string& title = "") override;
virtual void Close() override;
virtual void SetMsg(const std::string& msg) override;
virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) override;
virtual void ProgressBarReset(u32 progressBarIndex) override;