| 36 | #include "ui/widgets/PageContainer.h" |
| 37 | |
| 38 | ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel>& mods, QWidget* parent, BaseInstance* instance) |
| 39 | : QDialog(parent), mods(mods), m_verticalLayout(new QVBoxLayout(this)), m_instance(instance) |
| 40 | { |
| 41 | setObjectName(QStringLiteral("ModDownloadDialog")); |
| 42 | m_verticalLayout->setObjectName(QStringLiteral("verticalLayout")); |
| 43 | |
| 44 | resize(std::max(0.5 * parent->width(), 400.0), std::max(0.75 * parent->height(), 400.0)); |
| 45 | |
| 46 | setWindowIcon(APPLICATION->getThemedIcon("new")); |
| 47 | // NOTE: m_buttons must be initialized before PageContainer, because it indirectly accesses m_buttons through setSuggestedPack! Do not |
| 48 | // move this below. |
| 49 | m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 50 | |
| 51 | m_container = new PageContainer(this); |
| 52 | m_container->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Expanding); |
| 53 | m_container->layout()->setContentsMargins(0, 0, 0, 0); |
| 54 | m_verticalLayout->addWidget(m_container); |
| 55 | |
| 56 | m_container->addButtons(m_buttons); |
| 57 | |
| 58 | connect(m_container, &PageContainer::selectedPageChanged, this, &ModDownloadDialog::selectedPageChanged); |
| 59 | |
| 60 | // Bonk Qt over its stupid head and make sure it understands which button is the default one... |
| 61 | // See: https://stackoverflow.com/questions/24556831/qbuttonbox-set-default-button |
| 62 | auto OkButton = m_buttons->button(QDialogButtonBox::Ok); |
| 63 | OkButton->setEnabled(false); |
| 64 | OkButton->setDefault(true); |
| 65 | OkButton->setAutoDefault(true); |
| 66 | OkButton->setText(tr("Review and confirm")); |
| 67 | OkButton->setShortcut(tr("Ctrl+Return")); |
| 68 | OkButton->setToolTip(tr("Opens a new popup to review your selected mods and confirm your selection. Shortcut: Ctrl+Return")); |
| 69 | connect(OkButton, &QPushButton::clicked, this, &ModDownloadDialog::confirm); |
| 70 | |
| 71 | auto CancelButton = m_buttons->button(QDialogButtonBox::Cancel); |
| 72 | CancelButton->setDefault(false); |
| 73 | CancelButton->setAutoDefault(false); |
| 74 | connect(CancelButton, &QPushButton::clicked, this, &ModDownloadDialog::reject); |
| 75 | |
| 76 | auto HelpButton = m_buttons->button(QDialogButtonBox::Help); |
| 77 | HelpButton->setDefault(false); |
| 78 | HelpButton->setAutoDefault(false); |
| 79 | connect(HelpButton, &QPushButton::clicked, m_container, &PageContainer::help); |
| 80 | |
| 81 | QMetaObject::connectSlotsByName(this); |
| 82 | setWindowModality(Qt::WindowModal); |
| 83 | setWindowTitle(dialogTitle()); |
| 84 | |
| 85 | restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("ModDownloadGeometry").toByteArray())); |
| 86 | |
| 87 | m_container->selectPage(APPLICATION->settings()->get("DefaultModPlatform").toString().toLower()); |
| 88 | } |
| 89 | |
| 90 | QString ModDownloadDialog::dialogTitle() |
| 91 | { |
nothing calls this directly
no test coverage detected