* @brief Constructs the Downloader widget. * * Initializes the UI, network manager, and default settings. The download * directory defaults to the user's home Downloads folder. * * @param parent Optional parent widget. */
| 53 | * @param parent Optional parent widget. |
| 54 | */ |
| 55 | Downloader::Downloader(QWidget* parent) |
| 56 | : QWidget(parent) |
| 57 | , m_startTime(0) |
| 58 | , m_ui(new Ui::Downloader) |
| 59 | , m_reply(nullptr) |
| 60 | , m_useCustomProcedures(false) |
| 61 | , m_mandatoryUpdate(false) |
| 62 | , m_manager(new QNetworkAccessManager()) |
| 63 | { |
| 64 | // Register the static-library resource so :/icons/update.png resolves |
| 65 | Q_INIT_RESOURCE(qsimpleupdater); |
| 66 | |
| 67 | m_ui->setupUi(this); |
| 68 | |
| 69 | // Render the icon at 48x48 logical px (sharp from the 96px source at 2x) |
| 70 | m_ui->updater_icon->setFixedSize(48, 48); |
| 71 | m_ui->updater_icon->setScaledContents(true); |
| 72 | |
| 73 | // Add breathing room between the icon and the progress column |
| 74 | if (auto* row = qobject_cast<QHBoxLayout*>(m_ui->widget->layout())) |
| 75 | row->setSpacing(16); |
| 76 | |
| 77 | // Set download directory |
| 78 | m_downloadDir.setPath(QDir::homePath() + "/Downloads/"); |
| 79 | |
| 80 | // Make the window look like a modal dialog |
| 81 | setWindowIcon(QIcon()); |
| 82 | setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); |
| 83 | |
| 84 | // Configure the appearance and behavior of the buttons |
| 85 | m_ui->openButton->setEnabled(false); |
| 86 | m_ui->openButton->setVisible(false); |
| 87 | connect(m_ui->stopButton, &QPushButton::clicked, this, &Downloader::cancelDownload); |
| 88 | connect(m_ui->openButton, &QPushButton::clicked, this, &Downloader::installUpdate); |
| 89 | connect( |
| 90 | m_manager, &QNetworkAccessManager::authenticationRequired, this, &Downloader::authenticate); |
| 91 | |
| 92 | // Resize to fit (activate the layout first so the hint is valid) |
| 93 | if (layout()) |
| 94 | layout()->activate(); |
| 95 | setFixedSize(minimumSizeHint()); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @brief Destroys the Downloader and frees owned resources. |
nothing calls this directly
no test coverage detected