mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-23 16:39:43 +00:00
DolphinQt: Center dialogs on top-level parent window.
The `QtUtils::AdjustSizeWithinScreen()` function now centers the widget on their parent window after the widget's size is adjusted. This is required in some desktop environments (generally on Linux systems) to ensure that the just-resized widget remains aligned with its parent window. The creation of the **Cheats Manager** dialog is now deferred to first show, as creating it within the main window's constructor prevents the dialog from knowing the real position of its parent window, which is only properly calculated on first show. For the same reasons, the analytics prompt is now shown only when the application is ready (i.e. when the main window has been shown). | Before | After | | ------ | ----- | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced analytics prompt" title="[Dolphin Emulator] Misplaced analytics prompt" src="https://github.com/user-attachments/assets/c3e43b3b-cf79-4398-b531-7de6068c583e" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered analytics prompt" title="[Dolphin Emulator] Centered analytics prompt" src="https://github.com/user-attachments/assets/a10d06d9-7438-4032-b96c-dfcb48826349" /> | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced Settings dialog" title="[Dolphin Emulator] Misplaced Settings dialog" src="https://github.com/user-attachments/assets/f35b10ee-4f07-48d4-86f9-2537ad5ca7ca" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered Settings dialog" title="[Dolphin Emulator] Centered Settings dialog" src="https://github.com/user-attachments/assets/33e37237-77a4-44f6-a0e2-b709f65b672b" /> | | <img width="1920" height="1080" alt="[Dolphin Emulator] Misplaced Cheats Manager dialog" title="[Dolphin Emulator] Misplaced Cheats Manager dialog" src="https://github.com/user-attachments/assets/1fbd3836-5639-4d5a-b57e-e2e21f21c9db" /> | <img width="1920" height="1080" alt="[Dolphin Emulator] Centered Cheats Manager dialog" title="[Dolphin Emulator] Centered Cheats Manager dialog" src="https://github.com/user-attachments/assets/3f2b1b50-de16-49b7-bac4-c444c6cab0bc" /> |
This commit is contained in:
parent
11b9e40275
commit
8a639bd13d
5 changed files with 78 additions and 29 deletions
|
@ -265,30 +265,44 @@ int main(int argc, char* argv[])
|
|||
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
||||
if (!Config::Get(Config::MAIN_ANALYTICS_PERMISSION_ASKED))
|
||||
{
|
||||
ModalMessageBox analytics_prompt(&win);
|
||||
// To ensure that the analytics prompt appears aligned with the center of the main window,
|
||||
// the dialog is only shown after the application is ready, as only then it is guaranteed that
|
||||
// the main window has been placed in its final position.
|
||||
auto* const connection_context = new QObject(&win);
|
||||
QObject::connect(
|
||||
qApp, &QGuiApplication::applicationStateChanged, connection_context,
|
||||
[connection_context, &win](const Qt::ApplicationState state) {
|
||||
if (state != Qt::ApplicationState::ApplicationActive)
|
||||
return;
|
||||
|
||||
analytics_prompt.setIcon(QMessageBox::Question);
|
||||
analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting"));
|
||||
analytics_prompt.setText(
|
||||
QObject::tr("Do you authorize Dolphin to report information to Dolphin's developers?"));
|
||||
analytics_prompt.setInformativeText(
|
||||
QObject::tr("If authorized, Dolphin can collect data on its performance, "
|
||||
"feature usage, and configuration, as well as data on your system's "
|
||||
"hardware and operating system.\n\n"
|
||||
"No private data is ever collected. This data helps us understand "
|
||||
"how people and emulated games use Dolphin and prioritize our "
|
||||
"efforts. It also helps us identify rare configurations that are "
|
||||
"causing bugs, performance and stability issues.\n"
|
||||
"This authorization can be revoked at any time through Dolphin's "
|
||||
"settings."));
|
||||
// Severe the connection after the first run.
|
||||
delete connection_context;
|
||||
|
||||
const int answer = analytics_prompt.exec();
|
||||
ModalMessageBox analytics_prompt(&win);
|
||||
|
||||
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
|
||||
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
|
||||
analytics_prompt.setIcon(QMessageBox::Question);
|
||||
analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting"));
|
||||
analytics_prompt.setText(QObject::tr(
|
||||
"Do you authorize Dolphin to report information to Dolphin's developers?"));
|
||||
analytics_prompt.setInformativeText(
|
||||
QObject::tr("If authorized, Dolphin can collect data on its performance, "
|
||||
"feature usage, and configuration, as well as data on your system's "
|
||||
"hardware and operating system.\n\n"
|
||||
"No private data is ever collected. This data helps us understand "
|
||||
"how people and emulated games use Dolphin and prioritize our "
|
||||
"efforts. It also helps us identify rare configurations that are "
|
||||
"causing bugs, performance and stability issues.\n"
|
||||
"This authorization can be revoked at any time through Dolphin's "
|
||||
"settings."));
|
||||
|
||||
DolphinAnalytics::Instance().ReloadConfig();
|
||||
const int answer = analytics_prompt.exec();
|
||||
|
||||
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
|
||||
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
|
||||
|
||||
DolphinAnalytics::Instance().ReloadConfig();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue