mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-11 15:40:51 +00:00
dialog fixes for multithreading (#2913)
* add appicon to msg_dialogs * give every msg_dialog its own taskprogress * weird little m*f* algorithm
This commit is contained in:
parent
8d0e7adb62
commit
cfbfdd7b8a
@ -1,10 +1,18 @@
|
|||||||
|
|
||||||
#include "msg_dialog_frame.h"
|
#include "msg_dialog_frame.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
inline QString qstr(const std::string& _in) { return QString::fromUtf8(_in.data(), _in.size()); }
|
inline QString qstr(const std::string& _in) { return QString::fromUtf8(_in.data(), _in.size()); }
|
||||||
|
|
||||||
void msg_dialog_frame::Create(const std::string& msg)
|
void msg_dialog_frame::Create(const std::string& msg)
|
||||||
{
|
{
|
||||||
|
static int dialog_nr;
|
||||||
|
static int dialog_count;
|
||||||
|
++dialog_count;
|
||||||
|
|
||||||
if (m_dialog)
|
if (m_dialog)
|
||||||
{
|
{
|
||||||
m_dialog->close();
|
m_dialog->close();
|
||||||
@ -51,7 +59,6 @@ void msg_dialog_frame::Create(const std::string& msg)
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_tb_button = new QWinTaskbarButton();
|
m_tb_button = new QWinTaskbarButton();
|
||||||
m_tb_button->setWindow(m_taskbarTarget);
|
|
||||||
m_tb_progress = m_tb_button->progress();
|
m_tb_progress = m_tb_button->progress();
|
||||||
m_tb_progress->setRange(0, m_gauge_max);
|
m_tb_progress->setRange(0, m_gauge_max);
|
||||||
m_tb_progress->setVisible(true);
|
m_tb_progress->setVisible(true);
|
||||||
@ -110,10 +117,82 @@ void msg_dialog_frame::Create(const std::string& msg)
|
|||||||
m_dialog->setLayout(layout);
|
m_dialog->setLayout(layout);
|
||||||
|
|
||||||
connect(m_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }});
|
connect(m_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }});
|
||||||
|
connect(m_dialog, &QDialog::destroyed, [=] {if (--dialog_count <= 0) dialog_nr = 0;});
|
||||||
|
|
||||||
//Fix size
|
//Fix size
|
||||||
m_dialog->setFixedSize(m_dialog->sizeHint());
|
m_dialog->setFixedSize(m_dialog->sizeHint());
|
||||||
|
|
||||||
|
// order compile-dialogs on screen
|
||||||
|
if (qstr(msg).contains("Compiling PPU module"))
|
||||||
|
{
|
||||||
|
const QSize screensize = QApplication::primaryScreen()->geometry().size();
|
||||||
|
const double ratio = (double)screensize.width() / (double)screensize.height();
|
||||||
|
const int thread_count = QThread::idealThreadCount();
|
||||||
|
const int min_x = screensize.width() / 10;
|
||||||
|
const int max_x = screensize.width() - min_x;
|
||||||
|
const int min_y = screensize.height() / 10;
|
||||||
|
const int max_y = screensize.height() - min_y;
|
||||||
|
const int s_width = 30 + m_dialog->frameSize().width();
|
||||||
|
const int s_height = 60 + m_dialog->frameSize().height();
|
||||||
|
const int max_dialogs_x = std::max(1, (max_x - min_x) / s_width);
|
||||||
|
const int max_dialogs_y = std::max(1, (max_y - min_y) / s_height);
|
||||||
|
int dialogs_x = std::min(max_dialogs_x, thread_count);
|
||||||
|
int dialogs_y = std::min(max_dialogs_y, (int)((double)thread_count / (double)max_dialogs_x + 0.5));
|
||||||
|
const int dialogs = std::min(dialogs_x * dialogs_y, thread_count);
|
||||||
|
|
||||||
|
// resize to better aspect ratio
|
||||||
|
while ((double)dialogs_x / (double)dialogs_y > ratio)
|
||||||
|
{
|
||||||
|
--dialogs_x;
|
||||||
|
while (dialogs_x * dialogs_y < dialogs)
|
||||||
|
{
|
||||||
|
++dialogs_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int origin_x = (screensize.width() - dialogs_x * s_width) / 2;
|
||||||
|
const int origin_y = (screensize.height() - dialogs_y * s_height) / 2;
|
||||||
|
|
||||||
|
// create positions
|
||||||
|
QList<QPoint> location;
|
||||||
|
for (int y = 0; y < dialogs_y; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < dialogs_x; x++)
|
||||||
|
{
|
||||||
|
location.append(QPoint(origin_x + x * s_width, origin_y + y * s_height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create offset positions for moar threads than your window can handle
|
||||||
|
if (dialogs_x * dialogs_y < thread_count)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < dialogs_y; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < dialogs_x; x++)
|
||||||
|
{
|
||||||
|
location.append(QPoint(origin_x + s_width / 2 + x * s_width, origin_y + s_height / 2 + y * s_height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// move to position
|
||||||
|
m_dialog->move(location.at(dialog_nr));
|
||||||
|
|
||||||
|
// reset dialog_nr if needed
|
||||||
|
if (++dialog_nr >= location.count()) dialog_nr = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we assume compilation is over, so reset dialog_nr
|
||||||
|
dialog_nr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m_dialog->show();
|
m_dialog->show();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// if we do this before, the QWinTaskbarProgress won't show
|
||||||
|
if (m_tb_button) m_tb_button->setWindow(m_dialog->windowHandle());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void msg_dialog_frame::CreateOsk(const std::string& msg, char16_t* osk_text)
|
void msg_dialog_frame::CreateOsk(const std::string& msg, char16_t* osk_text)
|
||||||
|
@ -71,6 +71,8 @@ public:
|
|||||||
explicit custom_dialog(bool disableCancel, QWidget* parent = 0)
|
explicit custom_dialog(bool disableCancel, QWidget* parent = 0)
|
||||||
: QDialog(parent), m_disable_cancel(disableCancel)
|
: QDialog(parent), m_disable_cancel(disableCancel)
|
||||||
{
|
{
|
||||||
|
setWindowIcon(QIcon(":/rpcs3.ico"));
|
||||||
|
|
||||||
if (m_disable_cancel)
|
if (m_disable_cancel)
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowCloseButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowCloseButtonHint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user